Spaces:
Runtime error
Runtime error
Update app.py
Browse filesChanged the interface : chat generation now chat completions .
Model querying is now done by the backend and users now select model from dropdown window
app.py
CHANGED
@@ -37,12 +37,11 @@ def generate_media(prompt, model_name, media_type):
|
|
37 |
# Create a Gradio interface
|
38 |
with gr.Blocks() as demo:
|
39 |
with gr.Tab("Chat"):
|
40 |
-
|
41 |
-
language_model_input = gr.Textbox(label="Language Model")
|
42 |
-
query_button = gr.Button("Query HuggingFace Hub")
|
43 |
chat_input = gr.Textbox(label="Chat Input")
|
44 |
-
chat_output = gr.Textbox(label="Chat Output")
|
45 |
generate_button = gr.Button("Generate Text")
|
|
|
46 |
|
47 |
with gr.Tab("Image Generation"):
|
48 |
image_input = gr.Textbox(label="Image Prompt")
|
@@ -57,11 +56,8 @@ with gr.Blocks() as demo:
|
|
57 |
generate_media_button = gr.Button("Generate Media")
|
58 |
media_output = gr.Video(label="Generated Media") if media_type_input == "video" else gr.Audio(label="Generated Media")
|
59 |
|
60 |
-
# Query Hugging Face Hub for language models
|
61 |
-
query_button.click(fn=lambda x: [model.modelId for model in api.list_models(filter=x)], inputs=language_model_input, outputs=language_model_input)
|
62 |
-
|
63 |
# Generate text with a language model
|
64 |
-
generate_button.click(fn=generate_text, inputs=[language_model_input, chat_input], outputs=chat_output)
|
65 |
|
66 |
# Generate an image with Stable Diffusion
|
67 |
generate_image_button.click(fn=generate_image, inputs=[image_input, image_model_input], outputs=image_output)
|
|
|
37 |
# Create a Gradio interface
|
38 |
with gr.Blocks() as demo:
|
39 |
with gr.Tab("Chat"):
|
40 |
+
language_model_input = gr.Dropdown(label="Language Model", choices=[model.modelId for model in api.list_models()])
|
|
|
|
|
41 |
chat_input = gr.Textbox(label="Chat Input")
|
42 |
+
chat_output = gr.Textbox(label="Chat Output", interactive=False)
|
43 |
generate_button = gr.Button("Generate Text")
|
44 |
+
chat_history = gr.Chatbot(label="Chat History")
|
45 |
|
46 |
with gr.Tab("Image Generation"):
|
47 |
image_input = gr.Textbox(label="Image Prompt")
|
|
|
56 |
generate_media_button = gr.Button("Generate Media")
|
57 |
media_output = gr.Video(label="Generated Media") if media_type_input == "video" else gr.Audio(label="Generated Media")
|
58 |
|
|
|
|
|
|
|
59 |
# Generate text with a language model
|
60 |
+
generate_button.click(fn=generate_text, inputs=[language_model_input, chat_input], outputs=[chat_output, chat_history])
|
61 |
|
62 |
# Generate an image with Stable Diffusion
|
63 |
generate_image_button.click(fn=generate_image, inputs=[image_input, image_model_input], outputs=image_output)
|