Spaces:
Running
Running
adjusted session management
Browse files
app.py
CHANGED
@@ -76,7 +76,7 @@ async def retrieve_food_data(query):
|
|
76 |
async def stream_completion(message_history):
|
77 |
msg = cl.Message(content="")
|
78 |
await msg.send()
|
79 |
-
|
80 |
try:
|
81 |
stream = await client.chat.completions.create(
|
82 |
messages=message_history,
|
@@ -85,14 +85,11 @@ async def stream_completion(message_history):
|
|
85 |
temperature=0
|
86 |
)
|
87 |
|
88 |
-
response_content = ""
|
89 |
async for part in stream:
|
90 |
token = part.choices[0].delta.content or ""
|
91 |
await msg.stream_token(token)
|
92 |
-
response_content += token
|
93 |
|
94 |
-
|
95 |
-
await msg.update()
|
96 |
except Exception as e:
|
97 |
logging.error(f"Error during stream completion: {e}")
|
98 |
|
|
|
76 |
async def stream_completion(message_history):
|
77 |
msg = cl.Message(content="")
|
78 |
await msg.send()
|
79 |
+
|
80 |
try:
|
81 |
stream = await client.chat.completions.create(
|
82 |
messages=message_history,
|
|
|
85 |
temperature=0
|
86 |
)
|
87 |
|
|
|
88 |
async for part in stream:
|
89 |
token = part.choices[0].delta.content or ""
|
90 |
await msg.stream_token(token)
|
|
|
91 |
|
92 |
+
await msg.send()
|
|
|
93 |
except Exception as e:
|
94 |
logging.error(f"Error during stream completion: {e}")
|
95 |
|