AIRider commited on
Commit
c35470f
1 Parent(s): 3a4c978

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -17
app.py CHANGED
@@ -27,23 +27,23 @@ def respond(
27
  system_message,
28
  ):
29
  try:
30
- stream = client.chat_completion(
31
- messages,
32
- max_tokens=max_tokens,
33
- temperature=temperature,
34
- top_p=top_p,
35
- stream=True,
36
- )
37
- partial_message = ""
38
- for response in stream:
39
- if response.choices[0].delta.content is not None:
40
- partial_message += response.choices[0].delta.content
41
- chat_history = chat_history[:-1] + [(message, partial_message)]
42
- yield chat_history
43
- except Exception as e:
44
- error_message = f"An error occurred: {str(e)}"
45
- chat_history.append((message, error_message))
46
- yield chat_history
47
 
48
  def clear_conversation():
49
  return []
 
27
  system_message,
28
  ):
29
  try:
30
+ stream = client.chat_completion(
31
+ messages,
32
+ max_tokens=max_tokens,
33
+ temperature=temperature,
34
+ top_p=top_p,
35
+ stream=True,
36
+ )
37
+ partial_message = ""
38
+ for response in stream:
39
+ if response.choices[0].delta.content is not None:
40
+ partial_message += response.choices[0].delta.content
41
+ chat_history = chat_history[:-1] + [(message, partial_message)]
42
+ yield chat_history
43
+ except Exception as e:
44
+ error_message = f"An error occurred: {str(e)}"
45
+ chat_history.append((message, error_message))
46
+ yield chat_history
47
 
48
  def clear_conversation():
49
  return []