Spaces:
Runtime error
Runtime error
AngelaKkkkkkkkk
commited on
Commit
•
e8122b5
1
Parent(s):
623059e
Update app.py
Browse files
app.py
CHANGED
@@ -1,29 +1,8 @@
|
|
1 |
import gradio as gr
|
2 |
-
from transformers import pipeline
|
3 |
|
4 |
-
|
5 |
-
|
6 |
-
"GPT-2": "gpt2",
|
7 |
-
"DistilGPT-2": "distilgpt2",
|
8 |
-
"BERT Base Uncased": "bert-base-uncased",
|
9 |
-
"T5 Small": "t5-small"
|
10 |
-
}
|
11 |
|
12 |
-
|
13 |
-
def generate_response(model_name, user_input):
|
14 |
-
generator = pipeline(task="text-generation", model=model_name)
|
15 |
-
output = generator(user_input, max_length=50)[0]["generated_text"]
|
16 |
-
return output
|
17 |
|
18 |
-
|
19 |
-
interface = gr.Interface(
|
20 |
-
fn=generate_response,
|
21 |
-
inputs=[gr.inputs.Dropdown(list(models.keys()), label="Select Model"),
|
22 |
-
gr.inputs.Textbox(label="Enter your text")],
|
23 |
-
outputs=gr.outputs.Textbox(label="Model Output"),
|
24 |
-
title="Chat with LLMs",
|
25 |
-
description="Select a model and enter a prompt to chat with different large language models."
|
26 |
-
)
|
27 |
-
|
28 |
-
# Launch the interface
|
29 |
-
interface.launch()
|
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
+
def greet(name):
|
4 |
+
return "Hello " + name + "!"
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
+
demo = gr.Interface(fn=greet, inputs="text", outputs="text")
|
|
|
|
|
|
|
|
|
7 |
|
8 |
+
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|