youngtsai commited on
Commit
0af21e4
·
1 Parent(s): 8ed3ff4

if content:

Browse files

history[-1][1] += content
history = history[-MAX_HISTORY_LENGTH:]
yield history

Files changed (1) hide show
  1. app.py +1 -10
app.py CHANGED
@@ -61,17 +61,8 @@ def openai_stream(history, openai_key, chat_model, use_key):
61
  ):
62
  content = chunk["choices"][0].get("delta", {}).get("content")
63
  if content:
64
- # Assuming the format of history is [(message1, response1), (message2, response2), ...]
65
- if history:
66
- history[-1][1] += content # Update the last response with the new content.
67
- else:
68
- # Handle the case where you might need to add a new message-response pair.
69
- # This is just a generic example. You might need a different approach based on your exact requirements.
70
- history.append((messages[-1]["content"], content))
71
-
72
- # Ensure history keeps only the last 10 message-response pairs.
73
  history = history[-MAX_HISTORY_LENGTH:]
74
-
75
  yield history
76
 
77
 
 
61
  ):
62
  content = chunk["choices"][0].get("delta", {}).get("content")
63
  if content:
64
+ history[-1][1] += content
 
 
 
 
 
 
 
 
65
  history = history[-MAX_HISTORY_LENGTH:]
 
66
  yield history
67
 
68