Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -15,6 +15,7 @@ openai.api_key = os.getenv('OPENAI_API_KEY')
|
|
15 |
assistant_id=os.getenv('ASSISTANT_ID')
|
16 |
client = openai.OpenAI(api_key=openai.api_key)
|
17 |
|
|
|
18 |
def ask_openai(question):
|
19 |
try:
|
20 |
thread = client.beta.threads.create()
|
@@ -47,6 +48,12 @@ def ask_openai(question):
|
|
47 |
if not response_received:
|
48 |
return "Response timed out."
|
49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
response_text = "No response."
|
51 |
if steps.data:
|
52 |
last_step = steps.data[-1]
|
|
|
15 |
assistant_id=os.getenv('ASSISTANT_ID')
|
16 |
client = openai.OpenAI(api_key=openai.api_key)
|
17 |
|
18 |
+
|
19 |
def ask_openai(question):
|
20 |
try:
|
21 |
thread = client.beta.threads.create()
|
|
|
48 |
if not response_received:
|
49 |
return "Response timed out."
|
50 |
|
51 |
+
# Ensure steps is defined here
|
52 |
+
steps = client.beta.threads.runs.steps.list(
|
53 |
+
thread_id=thread.id,
|
54 |
+
run_id=run.id
|
55 |
+
)
|
56 |
+
|
57 |
response_text = "No response."
|
58 |
if steps.data:
|
59 |
last_step = steps.data[-1]
|