akhaliq HF staff commited on
Commit
390672f
·
verified ·
1 Parent(s): 458403e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -13
app.py CHANGED
@@ -16,23 +16,35 @@ with gr.Blocks() as demo:
16
  label="Select Model"
17
  )
18
 
19
- def chat(message, history, model_name):
20
- if model_name == "allenai/Llama-3.1-Tulu-3-8B":
21
- response = llama_demo.fn(message)
22
- response = next(response)
23
- else:
24
- response = olmo_demo.fn(message)
25
- response = next(response)
26
- return str(response)
27
-
28
- chatinterface = gr.ChatInterface(chat, additional_inputs=[model_dropdown])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
 
30
  # Disable API names
31
  for fn in demo.fns.values():
32
  fn.api_name = False
33
 
34
 
35
-
36
-
37
-
38
  demo.launch()
 
16
  label="Select Model"
17
  )
18
 
19
+ # Create columns for each model
20
+ with gr.Column(visible=True) as llama_column:
21
+ llama_chat = gr.ChatInterface(
22
+ lambda message, history: str(next(llama_demo.fn(message)))
23
+ )
24
+
25
+ with gr.Column(visible=False) as olmo_column:
26
+ olmo_chat = gr.ChatInterface(
27
+ lambda message, history: str(next(olmo_demo.fn(message)))
28
+ )
29
+
30
+ # Update visibility when model changes
31
+ def update_model(new_model):
32
+ return [
33
+ gr.Column(visible=new_model == "allenai/Llama-3.1-Tulu-3-8B"),
34
+ gr.Column(visible=new_model == "akhaliq/olmo-anychat")
35
+ ]
36
+
37
+ model_dropdown.change(
38
+ fn=update_model,
39
+ inputs=model_dropdown,
40
+ outputs=[llama_column, olmo_column],
41
+ api_name=False,
42
+ queue=False,
43
+ )
44
 
45
  # Disable API names
46
  for fn in demo.fns.values():
47
  fn.api_name = False
48
 
49
 
 
 
 
50
  demo.launch()