ambrosfitz commited on
Commit
23c61db
1 Parent(s): c7c660e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -22,13 +22,14 @@ def runpod_chat(question, history=None):
22
  stream=True,
23
  )
24
 
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
 
32
 
33
  return full_response, history # Return full response and updated history to maintain state
34
 
 
22
  stream=True,
23
  )
24
 
25
+ # Stream the response and accumulate full response before displaying
26
+ full_response = "RunPod: "
27
  for message in response_stream:
28
+ part = message.choices[0].delta.content if message.choices[0].delta.content is not None else ""
29
+ full_response += part
30
+
31
+ # Append the full response to history once complete
32
+ history.append({"role": "assistant", "content": full_response})
33
 
34
  return full_response, history # Return full response and updated history to maintain state
35