Spaces:
Runtime error
Runtime error
hereoncollab
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,23 +1,24 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
-
|
5 |
-
pipe = pipeline("text-generation", model="
|
6 |
|
7 |
def generate_response(user_input):
|
8 |
-
|
9 |
-
response = pipe(
|
|
|
10 |
generated_text = response[0]['generated_text']
|
11 |
-
|
12 |
-
return ai_response
|
13 |
-
|
14 |
|
|
|
15 |
interface = gr.Interface(
|
16 |
fn=generate_response,
|
17 |
-
inputs=gr.Textbox(label="
|
18 |
outputs="text",
|
19 |
-
title="
|
20 |
-
description="
|
21 |
)
|
22 |
|
|
|
23 |
interface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
+
# Initialize the text generation pipeline with the Gemma 2-2B IT model
|
5 |
+
pipe = pipeline("text-generation", model="google/gemma-2-2b-it")
|
6 |
|
7 |
def generate_response(user_input):
|
8 |
+
# Generate text based on the user's input
|
9 |
+
response = pipe(user_input, max_length=100, num_return_sequences=1)
|
10 |
+
# Extract the generated text
|
11 |
generated_text = response[0]['generated_text']
|
12 |
+
return generated_text
|
|
|
|
|
13 |
|
14 |
+
# Create the Gradio interface
|
15 |
interface = gr.Interface(
|
16 |
fn=generate_response,
|
17 |
+
inputs=gr.Textbox(label="prompt:", lines=2, placeholder="prompt"),
|
18 |
outputs="text",
|
19 |
+
title="Gemma",
|
20 |
+
description="Prompt gemma-2b"
|
21 |
)
|
22 |
|
23 |
+
# Launch the Gradio app
|
24 |
interface.launch()
|