Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -55,22 +55,19 @@ def read_input_file(file):
|
|
| 55 |
return df
|
| 56 |
|
| 57 |
def query_openai_api(prompt):
|
| 58 |
-
import os
|
| 59 |
-
st.write(f"OPENAI_API_KEY: {os.getenv('OPENAI_API_KEY')}")
|
| 60 |
-
time.sleep(3)
|
| 61 |
-
|
| 62 |
try:
|
| 63 |
-
response =
|
| 64 |
model="gpt-4o",
|
| 65 |
-
messages=[
|
| 66 |
-
|
|
|
|
|
|
|
| 67 |
max_tokens=2500,
|
| 68 |
temperature=0.1
|
| 69 |
)
|
| 70 |
-
|
| 71 |
-
return responses
|
| 72 |
except Exception as e:
|
| 73 |
-
|
| 74 |
return []
|
| 75 |
|
| 76 |
def process_data(df):
|
|
|
|
| 55 |
return df
|
| 56 |
|
| 57 |
def query_openai_api(prompt):
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
try:
|
| 59 |
+
response = client.chat.completions.create(
|
| 60 |
model="gpt-4o",
|
| 61 |
+
messages=[
|
| 62 |
+
{"role": "system", "content": "You are a helpful assistant."},
|
| 63 |
+
{"role": "user", "content": prompt}
|
| 64 |
+
],
|
| 65 |
max_tokens=2500,
|
| 66 |
temperature=0.1
|
| 67 |
)
|
| 68 |
+
return [response.choices[0].message.content.strip()]
|
|
|
|
| 69 |
except Exception as e:
|
| 70 |
+
st.error(f"Error querying OpenAI API: {e}")
|
| 71 |
return []
|
| 72 |
|
| 73 |
def process_data(df):
|