Avo-k commited on
Commit
a422880
β€’
1 Parent(s): d730458

only str in messages content

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -53,10 +53,11 @@ def chat(query: str, history: list = [system_template], report_type="All availab
53
  complete_response = ""
54
 
55
  for chunk in response:
56
- complete_response += chunk["choices"][0]["delta"].get("content", "")
57
- messages[-1] = {"role": "assistant", "content": complete_response}
58
- gradio_format = make_pairs([a["content"] for a in messages[1:]])
59
- yield gradio_format, messages, sources
 
60
 
61
 
62
  def test(feed: str):
@@ -85,7 +86,7 @@ with gr.Blocks(title="🌍 ClimateGPT Ekimetrics", css=css_code) as demo:
85
  )
86
  with gr.Row():
87
  with gr.Column(scale=2):
88
- chatbot = gr.Chatbot()
89
  state = gr.State([system_template])
90
 
91
  with gr.Row():
 
53
  complete_response = ""
54
 
55
  for chunk in response:
56
+ if chunk_message := chunk["choices"][0]["delta"].get("content", None):
57
+ complete_response += chunk_message
58
+ messages[-1] = {"role": "assistant", "content": complete_response}
59
+ gradio_format = make_pairs([a["content"] for a in messages[1:]])
60
+ yield gradio_format, messages, sources
61
 
62
 
63
  def test(feed: str):
 
86
  )
87
  with gr.Row():
88
  with gr.Column(scale=2):
89
+ chatbot = gr.Chatbot(elem_id="chatbot")
90
  state = gr.State([system_template])
91
 
92
  with gr.Row():