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

update interface beta test2

Browse files
Files changed (1) hide show
  1. app.py +12 -15
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-r-plus-08_2024', # Ensure the correct model ID is used
29
  query=f"{prompt} '{message_content}'",
30
  temperature=0.3,
31
  k=0,
@@ -37,26 +37,23 @@ def respond(message, chat_history):
37
 
38
  # Update chat history
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()
 
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,
 
37
 
38
  # Update chat history
39
  chat_history.append((message, response))
40
+ return chat_history
41
  except Exception as e:
42
  chat_history.append((message, f"Error: {str(e)}"))
43
+ return chat_history
44
 
45
  # Create Gradio interface
46
+ demo = gr.ChatInterface(
47
+ fn=respond,
48
+ type="messages",
49
+ flagging_mode="manual",
50
+ flagging_options=["Like", "Spam", "Inappropriate", "Other"],
51
+ save_history=True,
52
+ )
53
 
54
+ if __name__ == "__main__":
 
 
 
55
  demo.launch(
56
  share=True,
57
  server_name="0.0.0.0",
58
  allowed_paths=["*"]
59
+ )