update allen ai tab
Browse files1 unmodified line234567567891011121314151112131415161718192021222324192021222325262728293031323334353637383940252627282941421 unmodified lineimport spacesimport transformers_gradio
# Load modelsllama_demo = gr.load(name="allenai/Llama-3.1-Tulu-3-8B", src=transformers_gradio.registry)llama_demo.fn = spaces.GPU()(llama_demo.fn)# Load Llama modeldemo = gr.load(name="akhaliq/allen-test", src="spaces")
# Load OLMo modelolmo_demo = gr.load(name="akhaliq/olmo-anychat", src="spaces")
# Create the interfacewith 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",# Disable API names for both demosfor fn in demo.fns.values(): fn.api_name = Falsefor fn in olmo_demo.fns.values(): fn.api_name = False
# Create a dropdown to select the modelwith gr.Blocks() as combined_demo: model_choice = gr.Dropdown( choices=["Llama", "OLMo"], value="Llama", 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) with gr.Tab("Model Interface"): # Create placeholder for the selected model's interface placeholder = gr.HTML() def update_interface(choice): if choice == "Llama": return demo else: return olmo_demo model_choice.change( fn=update_interface, inputs=[model_choice], outputs=[placeholder] )
chatinterface = gr.ChatInterface(chat, additional_inputs=[model_dropdown])
# Disable API namesfor fn in demo.fns.values(): fn.api_name = False
app_allenai.py+29-18