Spaces:
Build error

TrancheVest commited on
Commit
09c93db
·
1 Parent(s): 322716d

Fix Chatbot issues: add type parameter and fix dictionary access

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -71,24 +71,24 @@ def run_chat(crypto, data_span):
71
  # --- QUESTION ---
72
  question = get_question(previous_qa)
73
  # append as a right-only message
74
- chat_history.append(("", question.content))
75
  yield chat_history, [] # show question
76
  time.sleep(1)
77
 
78
  # --- ANSWER ---
79
- answer = get_answer(question.content, previous_qa, crypto_data)
80
  # append as a left-only message
81
- chat_history.append((answer.content, ""))
82
  yield chat_history, [] # show answer
83
 
84
  # track for final evaluation
85
- qa_history.append({"question": question.content, "answer": answer.content})
86
- previous_qa += f"\nQ: {question.content}\nA: {answer.content}\n"
87
  time.sleep(1)
88
 
89
  # --- FINAL EVALUATION ---
90
  evaluation = evaluate_expertise(qa_history)
91
- chat_history.append(("📊 Evaluation:", evaluation.content))
92
  yield chat_history, chat_history
93
 
94
 
@@ -104,7 +104,7 @@ with gr.Blocks() as demo:
104
  )
105
  start_btn = gr.Button("Start Chat")
106
 
107
- chatbot = gr.Chatbot(height=600)
108
  state = gr.State([])
109
 
110
  start_btn.click(
 
71
  # --- QUESTION ---
72
  question = get_question(previous_qa)
73
  # append as a right-only message
74
+ chat_history.append(("", question["content"]))
75
  yield chat_history, [] # show question
76
  time.sleep(1)
77
 
78
  # --- ANSWER ---
79
+ answer = get_answer(question["content"], previous_qa, crypto_data)
80
  # append as a left-only message
81
+ chat_history.append((answer["content"], ""))
82
  yield chat_history, [] # show answer
83
 
84
  # track for final evaluation
85
+ qa_history.append({"question": question["content"], "answer": answer["content"]})
86
+ previous_qa += f"\nQ: {question['content']}\nA: {answer['content']}\n"
87
  time.sleep(1)
88
 
89
  # --- FINAL EVALUATION ---
90
  evaluation = evaluate_expertise(qa_history)
91
+ chat_history.append(("📊 Evaluation:", evaluation["content"]))
92
  yield chat_history, chat_history
93
 
94
 
 
104
  )
105
  start_btn = gr.Button("Start Chat")
106
 
107
+ chatbot = gr.Chatbot(height=600, type='messages')
108
  state = gr.State([])
109
 
110
  start_btn.click(