SkyNetWalker commited on
Commit
4facf91
·
verified ·
1 Parent(s): fc98e77

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -10
app.py CHANGED
@@ -23,7 +23,7 @@ def respond(
23
  max_tokens,
24
  temperature,
25
  top_p,
26
- model_name, # Added a parameter for model selection
27
  ):
28
  print(f"Received message: {message}")
29
  print(f"History: {history}")
@@ -47,7 +47,7 @@ def respond(
47
  print("Sending request to OpenAI API.")
48
 
49
  for message in client.chat.completions.create(
50
- model=model_name, # Use the selected model here
51
  max_tokens=max_tokens,
52
  stream=True,
53
  temperature=temperature,
@@ -65,20 +65,15 @@ chatbot = gr.Chatbot(height=600)
65
 
66
  print("Chatbot interface created.")
67
 
68
- # Define a list of models for the dropdown
69
- model_options = [
70
- "microsoft/phi-4",
71
  "PowerInfer/SmallThinker-3B-Preview",
 
72
  ]
73
 
74
  demo = gr.ChatInterface(
75
  respond,
76
  additional_inputs=[
77
- gr.Dropdown(
78
- choices=model_options,
79
- value="microsoft/phi-4",
80
- label="Select Model",
81
- ),
82
  gr.Textbox(value="", label="System message"),
83
  gr.Slider(minimum=1, maximum=4096, value=1024, step=1, label="Max new tokens"),
84
  gr.Slider(minimum=0.1, maximum=1.0, value=0.3, step=0.1, label="Temperature"),
@@ -89,6 +84,7 @@ demo = gr.ChatInterface(
89
  step=0.05,
90
  label="Top-P",
91
  ),
 
92
  ],
93
  fill_height=True,
94
  chatbot=chatbot,
 
23
  max_tokens,
24
  temperature,
25
  top_p,
26
+ model_name, # New parameter for model selection
27
  ):
28
  print(f"Received message: {message}")
29
  print(f"History: {history}")
 
47
  print("Sending request to OpenAI API.")
48
 
49
  for message in client.chat.completions.create(
50
+ model=model_name, # Use the selected model
51
  max_tokens=max_tokens,
52
  stream=True,
53
  temperature=temperature,
 
65
 
66
  print("Chatbot interface created.")
67
 
68
+ # Define the list of models
69
+ models = [
 
70
  "PowerInfer/SmallThinker-3B-Preview",
71
+ "microsoft/phi-4",
72
  ]
73
 
74
  demo = gr.ChatInterface(
75
  respond,
76
  additional_inputs=[
 
 
 
 
 
77
  gr.Textbox(value="", label="System message"),
78
  gr.Slider(minimum=1, maximum=4096, value=1024, step=1, label="Max new tokens"),
79
  gr.Slider(minimum=0.1, maximum=1.0, value=0.3, step=0.1, label="Temperature"),
 
84
  step=0.05,
85
  label="Top-P",
86
  ),
87
+ gr.Dropdown(choices=models, value=models[0], label="Model"), # Dropdown for model selection
88
  ],
89
  fill_height=True,
90
  chatbot=chatbot,