pratik-aivantage commited on
Commit
a8061c1
·
verified ·
1 Parent(s): 4698165

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load the pre-trained model
5
+ generator = pipeline("text-generation", model="EleutherAI/gpt-neo-2.7B")
6
+
7
+ # Define Gradio interface
8
+ def generate_response(prompt):
9
+ # Generate response based on the prompt
10
+ response = generator(prompt, max_length=50, do_sample=True, temperature=0.9)
11
+ return response[0]['generated_text']
12
+
13
+ # Create Gradio interface
14
+ iface = gr.Interface(
15
+ fn=generate_response,
16
+ inputs="text",
17
+ outputs="text",
18
+ title="OpenAI Text Generation Model",
19
+ description="Enter a prompt and get a generated text response.",
20
+ )
21
+
22
+ # Deploy the Gradio interface
23
+ iface.launch(share=True)