typesdigital commited on
Commit
dbc88bc
·
1 Parent(s): 27f6505

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -0
app.py ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Create a text generation pipeline using Hugging Face Transformers
5
+ generator = pipeline("text-generation", model="EleutherAI/gpt-neo-2.7B")
6
+
7
+ # Define the chat function
8
+ def chat(input_text):
9
+ response = generator(input_text, max_length=50, do_sample=True)[0]["generated_text"]
10
+ return response
11
+
12
+ # Create a Gradio interface
13
+ iface = gr.Interface(
14
+ fn=chat,
15
+ inputs=gr.inputs.Textbox(label="Input Text"),
16
+ outputs=gr.outputs.Textbox(label="Response"),
17
+ live=True,
18
+ )
19
+
20
+ # Launch the Gradio interface
21
+ iface.launch()