akhaliq HF staff commited on
Commit
8b60cb4
1 Parent(s): 59c8947

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -0
app.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ 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(history, message, model_name):
20
+ if model_name == "allenai/Llama-3.1-Tulu-3-8B":
21
+ response = llama_demo.fn(message)
22
+ else:
23
+ response = olmo_demo.fn(message)
24
+ return response
25
+
26
+ chatinterface = gr.ChatInterface(chat, additional_inputs=[model_dropdown])
27
+
28
+ # Disable API names
29
+ for fn in demo.fns.values():
30
+ fn.api_name = False
31
+
32
+ demo.launch()