Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -8,6 +8,7 @@ import mistune
|
|
8 |
import pytz
|
9 |
import math
|
10 |
import requests
|
|
|
11 |
|
12 |
from datetime import datetime
|
13 |
from openai import ChatCompletion
|
@@ -48,6 +49,12 @@ def create_file(filename, prompt, response):
|
|
48 |
elif filename.endswith(".md"):
|
49 |
with open(filename, 'w') as file:
|
50 |
file.write(f"# Prompt:\n{prompt}\n# Response:\n{response}")
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
|
52 |
# Updated to auto process transcript to chatgpt in AI pipeline from Whisper to ChatGPT
|
53 |
def transcribe_audio(openai_key, file_path, model):
|
@@ -141,6 +148,12 @@ def read_file_content(file,max_length):
|
|
141 |
return content
|
142 |
elif file.type == "text/plain":
|
143 |
return file.getvalue().decode()
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
else:
|
145 |
return ""
|
146 |
|
|
|
8 |
import pytz
|
9 |
import math
|
10 |
import requests
|
11 |
+
import pandas as pd
|
12 |
|
13 |
from datetime import datetime
|
14 |
from openai import ChatCompletion
|
|
|
49 |
elif filename.endswith(".md"):
|
50 |
with open(filename, 'w') as file:
|
51 |
file.write(f"# Prompt:\n{prompt}\n# Response:\n{response}")
|
52 |
+
elif filename.endswith(".csv"):
|
53 |
+
response_df = pd.DataFrame({"Prompt": [prompt], "Response": [response]})
|
54 |
+
response_df.to_csv(filename, index=False)
|
55 |
+
elif filename.endswith(".xlsx"):
|
56 |
+
response_df = pd.DataFrame({"Prompt": [prompt], "Response": [response]})
|
57 |
+
response_df.to_excel(filename, index=False)
|
58 |
|
59 |
# Updated to auto process transcript to chatgpt in AI pipeline from Whisper to ChatGPT
|
60 |
def transcribe_audio(openai_key, file_path, model):
|
|
|
148 |
return content
|
149 |
elif file.type == "text/plain":
|
150 |
return file.getvalue().decode()
|
151 |
+
elif file.type == "text/csv":
|
152 |
+
df = pd.read_csv(file)
|
153 |
+
return df.to_string(index=False)
|
154 |
+
elif file.type == "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":
|
155 |
+
df = pd.read_excel(file)
|
156 |
+
return df.to_string(index=False)
|
157 |
else:
|
158 |
return ""
|
159 |
|