GabrielSchultz commited on
Commit
14a13ab
·
verified ·
1 Parent(s): b254b47

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -4
app.py CHANGED
@@ -6,7 +6,7 @@ import os
6
  api_key = os.getenv("apichatbotacess")
7
 
8
  # Define the API calling function
9
- def api_call(prompt, thread_id):
10
  url = "https://multimodalcompany-dev--talent-chatbot-beta-dev-dev.modal.run"
11
  headers = {
12
  "key": api_key,
@@ -15,6 +15,7 @@ def api_call(prompt, thread_id):
15
  data = {
16
  "prompt": prompt,
17
  "thread_id": thread_id,
 
18
  "max_new_tokens": 4096,
19
  "top_p": 0.95,
20
  "temperature": 0.7,
@@ -31,15 +32,16 @@ def api_call(prompt, thread_id):
31
  return response.json()["message"]
32
 
33
  with gr.Blocks() as demo:
 
34
  thread_id_input = gr.Textbox(label="Enter Thread ID", placeholder="Thread ID", lines=1)
35
  chatbot = gr.Chatbot()
36
  msg = gr.Textbox(label="Your Message")
37
 
38
- def respond(message, thread_id, chat_history):
39
- bot_message = api_call(message, thread_id)
40
  chat_history.append((message, bot_message))
41
  return "", chat_history
42
 
43
- msg.submit(respond, [msg, thread_id_input, chatbot], [msg, chatbot])
44
 
45
  demo.launch(share=True)
 
6
  api_key = os.getenv("apichatbotacess")
7
 
8
  # Define the API calling function
9
+ def api_call(prompt, thread_id, model_name):
10
  url = "https://multimodalcompany-dev--talent-chatbot-beta-dev-dev.modal.run"
11
  headers = {
12
  "key": api_key,
 
15
  data = {
16
  "prompt": prompt,
17
  "thread_id": thread_id,
18
+ "model_name": model_name, # Add model_name to the data
19
  "max_new_tokens": 4096,
20
  "top_p": 0.95,
21
  "temperature": 0.7,
 
32
  return response.json()["message"]
33
 
34
  with gr.Blocks() as demo:
35
+ model_name = gr.Dropdown(choices=["OpenAI", "Claude"], label="Select Model")
36
  thread_id_input = gr.Textbox(label="Enter Thread ID", placeholder="Thread ID", lines=1)
37
  chatbot = gr.Chatbot()
38
  msg = gr.Textbox(label="Your Message")
39
 
40
+ def respond(message, thread_id, chat_history, model_name):
41
+ bot_message = api_call(message, thread_id, model_name)
42
  chat_history.append((message, bot_message))
43
  return "", chat_history
44
 
45
+ msg.submit(respond, [msg, thread_id_input, chatbot, model_name], [msg, chatbot])
46
 
47
  demo.launch(share=True)