Bloodacote commited on
Commit
96f045d
1 Parent(s): 3f9a9bf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -3
app.py CHANGED
@@ -1,7 +1,22 @@
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
  demo.launch()
 
1
  import gradio as gr
2
+ from transformers import pipeline
3
 
4
+ # Initialize the text generation pipeline
5
+ pipe = pipeline("text-generation", model="meta-llama/CodeLlama-7b-hf")
6
 
7
+ def generate_text(prompt):
8
+ # Generate text based on the provided prompt using the pipeline
9
+ generated_text = pipe(prompt, max_length=50, do_sample=True)[0]['generated_text']
10
+ return generated_text
11
+
12
+ # Create a Gradio interface
13
+ demo = gr.Interface(
14
+ fn=generate_text,
15
+ inputs="text",
16
+ outputs="text",
17
+ title="Text Generation with CodeLlama-7b-hf",
18
+ description="Enter a prompt and see the generated text."
19
+ )
20
+
21
+ # Launch the Gradio interface
22
  demo.launch()