Tim Seufert commited on
Commit
4b1eda6
·
1 Parent(s): bdb8997

update interface beta test2

Browse files
Files changed (1) hide show
  1. app.py +15 -11
app.py CHANGED
@@ -25,7 +25,7 @@ def respond(message, chat_history):
25
  try:
26
  # Generate response using Cohere chat API
27
  response = co.chat(
28
- model='command-xlarge-nightly', # Ensure the correct model ID is used
29
  query=f"{prompt} '{message_content}'",
30
  temperature=0.3,
31
  k=0,
@@ -39,20 +39,24 @@ def respond(message, chat_history):
39
  chat_history.append((message, response))
40
  return chat_history, chat_history
41
  except Exception as e:
42
- return str(e), chat_history
 
43
 
44
  # Create Gradio interface
45
- demo = gr.ChatInterface(
46
- respond,
47
- type="messages",
48
- flagging_mode="manual",
49
- flagging_options=["Like", "Spam", "Inappropriate", "Other"],
50
- save_history=True,
51
- )
52
 
53
- if __name__ == "__main__":
 
 
 
54
  demo.launch(
55
  share=True,
56
  server_name="0.0.0.0",
57
  allowed_paths=["*"]
58
- )
 
 
 
 
25
  try:
26
  # Generate response using Cohere chat API
27
  response = co.chat(
28
+ model='command-r-plus-08_2024', # Ensure the correct model ID is used
29
  query=f"{prompt} '{message_content}'",
30
  temperature=0.3,
31
  k=0,
 
39
  chat_history.append((message, response))
40
  return chat_history, chat_history
41
  except Exception as e:
42
+ chat_history.append((message, f"Error: {str(e)}"))
43
+ return chat_history, chat_history
44
 
45
  # Create Gradio interface
46
+ with gr.Blocks() as demo:
47
+ chatbot = gr.Chatbot()
48
+ msg = gr.Textbox()
49
+ clear = gr.ClearButton([msg, chatbot])
 
 
 
50
 
51
+ # Set up message submission
52
+ msg.submit(respond, [msg, chatbot], [msg, chatbot])
53
+
54
+ # Launch the demo
55
  demo.launch(
56
  share=True,
57
  server_name="0.0.0.0",
58
  allowed_paths=["*"]
59
+ )
60
+
61
+ if __name__ == "__main__":
62
+ demo.launch()