Spaces:
Runtime error
Runtime error
hereoncollab
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -1,19 +1,23 @@
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
4 |
-
# Use a smaller model for lower memory usage
|
5 |
-
pipe = pipeline("text-generation", model="distilgpt2") # DistilGPT-2 is smaller and more efficient
|
6 |
|
7 |
-
|
8 |
-
|
9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
interface = gr.Interface(
|
12 |
fn=generate_response,
|
13 |
-
inputs=gr.Textbox(label="
|
14 |
outputs="text",
|
15 |
-
title="
|
16 |
-
description="
|
17 |
)
|
18 |
|
19 |
interface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
from transformers import pipeline
|
3 |
|
|
|
|
|
4 |
|
5 |
+
pipe = pipeline("text-generation", model="distilgpt2")
|
6 |
+
|
7 |
+
def generate_response(user_input):
|
8 |
+
formatted_input = f"Human: {user_input}\nAI:"
|
9 |
+
response = pipe(formatted_input, max_length=150, num_return_sequences=1)
|
10 |
+
generated_text = response[0]['generated_text']
|
11 |
+
ai_response = generated_text.split('AI:')[-1].strip()
|
12 |
+
return ai_response
|
13 |
+
|
14 |
|
15 |
interface = gr.Interface(
|
16 |
fn=generate_response,
|
17 |
+
inputs=gr.Textbox(label="shitty mesage:", lines=2, placeholder="Type your message here..."),
|
18 |
outputs="text",
|
19 |
+
title="distilgpt2",
|
20 |
+
description="distel gppt 20"
|
21 |
)
|
22 |
|
23 |
interface.launch()
|