Spaces:
Runtime error
Runtime error
update allen ai tab
Browse files- 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
|
6 |
-
|
7 |
-
llama_demo.fn = spaces.GPU()(llama_demo.fn)
|
8 |
|
|
|
9 |
olmo_demo = gr.load(name="akhaliq/olmo-anychat", src="spaces")
|
10 |
|
11 |
-
#
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
label="Select Model"
|
17 |
)
|
18 |
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
|