akhaliq HF staff commited on
Commit
07eef74
1 Parent(s): c4974f0

update allen ai tab

Browse files
Files changed (1) hide show
  1. app_allenai.py +29 -18
app_allenai.py CHANGED
@@ -2,30 +2,41 @@ import gradio as gr
2
  import spaces
3
  import transformers_gradio
4
 
5
- # Load models
6
- llama_demo = gr.load(name="allenai/Llama-3.1-Tulu-3-8B", src=transformers_gradio.registry)
7
- llama_demo.fn = spaces.GPU()(llama_demo.fn)
8
 
 
9
  olmo_demo = gr.load(name="akhaliq/olmo-anychat", src="spaces")
10
 
11
- # Create the interface
12
- with gr.Blocks() as demo:
13
- model_dropdown = gr.Dropdown(
14
- choices=["allenai/Llama-3.1-Tulu-3-8B", "akhaliq/olmo-anychat"],
15
- value="allenai/Llama-3.1-Tulu-3-8B",
 
 
 
 
 
 
16
  label="Select Model"
17
  )
18
 
19
- def chat(message, model_name):
20
- if model_name == "allenai/Llama-3.1-Tulu-3-8B":
21
- return llama_demo.fn(message)
22
- else:
23
- return olmo_demo.fn(message)
 
 
 
 
 
 
 
 
 
 
24
 
25
- chatinterface = gr.ChatInterface(chat, additional_inputs=[model_dropdown])
26
-
27
- # Disable API names
28
- for fn in demo.fns.values():
29
- fn.api_name = False
30
 
31
 
 
2
  import spaces
3
  import transformers_gradio
4
 
5
+ # Load Llama model
6
+ demo = gr.load(name="akhaliq/allen-test", src="spaces")
 
7
 
8
+ # Load OLMo model
9
  olmo_demo = gr.load(name="akhaliq/olmo-anychat", src="spaces")
10
 
11
+ # Disable API names for both demos
12
+ for fn in demo.fns.values():
13
+ fn.api_name = False
14
+ for fn in olmo_demo.fns.values():
15
+ fn.api_name = False
16
+
17
+ # Create a dropdown to select the model
18
+ with gr.Blocks() as combined_demo:
19
+ model_choice = gr.Dropdown(
20
+ choices=["Llama", "OLMo"],
21
+ value="Llama",
22
  label="Select Model"
23
  )
24
 
25
+ with gr.Tab("Model Interface"):
26
+ # Create placeholder for the selected model's interface
27
+ placeholder = gr.HTML()
28
+
29
+ def update_interface(choice):
30
+ if choice == "Llama":
31
+ return demo
32
+ else:
33
+ return olmo_demo
34
+
35
+ model_choice.change(
36
+ fn=update_interface,
37
+ inputs=[model_choice],
38
+ outputs=[placeholder]
39
+ )
40
 
 
 
 
 
 
41
 
42