Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
File size: 861 Bytes
5ea344f 5aeaad2 48a8102 5ea344f 963672f bb2a7e9 5aeaad2 bb2a7e9 48a8102 2201358 48a8102 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
import gradio as gr
import spaces
import transformers_gradio
# Load models
llama_demo = gr.load(name="allenai/Llama-3.1-Tulu-3-8B", src=transformers_gradio.registry)
llama_demo.fn = spaces.GPU()(llama_demo.fn)
olmo_demo = gr.load(name="akhaliq/olmo-anychat", src="spaces")
# Create the interface
with gr.Blocks() as demo:
model_dropdown = gr.Dropdown(
choices=["allenai/Llama-3.1-Tulu-3-8B", "akhaliq/olmo-anychat"],
value="allenai/Llama-3.1-Tulu-3-8B",
label="Select Model"
)
def chat(message, model_name):
if model_name == "allenai/Llama-3.1-Tulu-3-8B":
return llama_demo.fn(message)
else:
return olmo_demo.fn(message)
chatinterface = gr.ChatInterface(chat, additional_inputs=[model_dropdown])
# Disable API names
for fn in demo.fns.values():
fn.api_name = False
|