Threatthriver commited on
Commit
beaf568
·
verified ·
1 Parent(s): 01990d8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -7
app.py CHANGED
@@ -61,6 +61,7 @@ def gradio_ui():
61
  with gr.Column(scale=2):
62
  compute_time = gr.Textbox(label="Compute Time", interactive=False)
63
  chain_of_thought_display = gr.Textbox(label="Chain of Thought", interactive=False, lines=10)
 
64
 
65
  user_input = gr.Textbox(label="Type your message", placeholder="Ask me anything...", lines=2)
66
 
@@ -70,20 +71,22 @@ def gradio_ui():
70
 
71
  def handle_chat(chat_history, user_input):
72
  if not user_input.strip():
73
- return chat_history, "", "Please enter a valid message."
74
  ai_response, chain_of_thought, compute_info = chat_with_cerebras(user_input)
 
 
75
  chat_history.append((user_input, ai_response))
76
- return chat_history, chain_of_thought, compute_info
77
 
78
  def clear_chat():
79
- return [], "", ""
80
 
81
- send_button.click(handle_chat, inputs=[chat_history, user_input], outputs=[chat_history, chain_of_thought_display, compute_time])
82
- clear_button.click(clear_chat, outputs=[chat_history, chain_of_thought_display, compute_time])
83
 
84
- user_input.submit(handle_chat, inputs=[chat_history, user_input], outputs=[chat_history, chain_of_thought_display, compute_time])
85
 
86
- gr.Markdown("""---\n### 🌟 Features:\n- **Advanced Reasoning**: Chain-of-thought explanations for complex queries.\n- **Real-Time Performance Metrics**: Measure response compute time instantly.\n- **Insightful Chain of Thought**: See the reasoning process behind AI decisions.\n- **User-Friendly Design**: Intuitive chatbot interface with powerful features.\n- **Powered by IntellijMind**: Setting new standards for AI interaction.\n""")
87
 
88
  return demo
89
 
 
61
  with gr.Column(scale=2):
62
  compute_time = gr.Textbox(label="Compute Time", interactive=False)
63
  chain_of_thought_display = gr.Textbox(label="Chain of Thought", interactive=False, lines=10)
64
+ token_usage_display = gr.Textbox(label="Token Usage", interactive=False)
65
 
66
  user_input = gr.Textbox(label="Type your message", placeholder="Ask me anything...", lines=2)
67
 
 
71
 
72
  def handle_chat(chat_history, user_input):
73
  if not user_input.strip():
74
+ return chat_history, "", "", "Please enter a valid message."
75
  ai_response, chain_of_thought, compute_info = chat_with_cerebras(user_input)
76
+ # Placeholder for token usage (to be replaced with actual logic if token count available)
77
+ token_usage = "Tokens used: Not available in this version"
78
  chat_history.append((user_input, ai_response))
79
+ return chat_history, chain_of_thought, compute_info, token_usage
80
 
81
  def clear_chat():
82
+ return [], "", "", ""
83
 
84
+ send_button.click(handle_chat, inputs=[chat_history, user_input], outputs=[chat_history, chain_of_thought_display, compute_time, token_usage_display])
85
+ clear_button.click(clear_chat, outputs=[chat_history, chain_of_thought_display, compute_time, token_usage_display])
86
 
87
+ user_input.submit(handle_chat, inputs=[chat_history, user_input], outputs=[chat_history, chain_of_thought_display, compute_time, token_usage_display])
88
 
89
+ gr.Markdown("""---\n### 🌟 Features:\n- **Advanced Reasoning**: Chain-of-thought explanations for complex queries.\n- **Real-Time Performance Metrics**: Measure response compute time instantly.\n- **Token Usage Tracking**: (Future-ready) Display token usage per response.\n- **User-Friendly Design**: Intuitive chatbot interface with powerful features.\n- **Insightful Chain of Thought**: See the reasoning process behind AI decisions.\n- **Powered by IntellijMind**: Setting new standards for AI interaction.\n- **Submit on Enter**: Seamless interaction with keyboard support.\n""")
90
 
91
  return demo
92