Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -10,7 +10,6 @@ client = OpenAI(
|
|
10 |
)
|
11 |
|
12 |
def runpod_chat(question, history=None):
|
13 |
-
# Explicitly initialize history if it's None
|
14 |
if history is None:
|
15 |
history = [] # Ensure history starts as an empty list if none is provided
|
16 |
history.append({"role": "user", "content": question})
|
@@ -26,7 +25,7 @@ def runpod_chat(question, history=None):
|
|
26 |
# Stream the response and add to history
|
27 |
full_response = ""
|
28 |
for message in response_stream:
|
29 |
-
response = message.choices[0].delta.content
|
30 |
full_response += "RunPod: " + response + "\n"
|
31 |
history.append({"role": "assistant", "content": response})
|
32 |
time.sleep(0.3) # Simulate typing delay
|
|
|
10 |
)
|
11 |
|
12 |
def runpod_chat(question, history=None):
|
|
|
13 |
if history is None:
|
14 |
history = [] # Ensure history starts as an empty list if none is provided
|
15 |
history.append({"role": "user", "content": question})
|
|
|
25 |
# Stream the response and add to history
|
26 |
full_response = ""
|
27 |
for message in response_stream:
|
28 |
+
response = message.choices[0].delta.content if message.choices[0].delta.content is not None else "No response."
|
29 |
full_response += "RunPod: " + response + "\n"
|
30 |
history.append({"role": "assistant", "content": response})
|
31 |
time.sleep(0.3) # Simulate typing delay
|