update code snippet
Browse files65 unmodified lines6667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813965 unmodified lines "Perplexity": demo_perplexity,}
# Create code snippets for each providerdef get_code_snippet(provider): if "OpenAI" in provider: return """import gradio as grimport ai_gradio
gr.load( name='openai:gpt-4-turbo', src=ai_gradio.registry, title='AI Chat', description='Chat with an AI model').launch()""" elif "Gemini" in provider: return """import gradio as grimport ai_gradio
gr.load( name='gemini:gemini-1.5-flash', src=ai_gradio.registry, title='AI Chat', description='Chat with an AI model').launch()""" elif "Groq" in provider: return """import gradio as grimport ai_gradio
gr.load( name='groq:llama-3.2-70b-chat', src=ai_gradio.registry, title='AI Chat', description='Chat with an AI model').launch()""" return ""
import gradio as gr
# Modified get_app to include code snippetsdef get_app(models, default_model, src, dropdown_label): with gr.Blocks() as demo: # Add code snippet display code_component = gr.Code( label="Code Snippet", language="python", value=get_code_snippet(default_model) ) # Add dropdown and get the demo interface model = gr.Dropdown( choices=models, value=default_model, label=dropdown_label ) # Update code snippet when model changes def update_code(provider): return get_code_snippet(provider) model.change( fn=update_code, inputs=[model], outputs=[code_component] ) # Get the demo interface for the selected model demo_interface = src[default_model]() return demo
demo = get_app( models=list(PROVIDERS.keys()), default_model="OpenAI Coder",app.py+68