YaserDS-777 commited on
Commit
47ab986
1 Parent(s): 4b88455

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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/Meta-Llama-3.1-405B")
6
+
7
+ # Define the function to generate text
8
+ def generate_text(prompt):
9
+ result = pipe(prompt, max_length=50, num_return_sequences=1)
10
+ return result[0]['generated_text']
11
+
12
+ # Create a Gradio interface
13
+ iface = gr.Interface(
14
+ fn=generate_text,
15
+ inputs=gr.inputs.Textbox(lines=2, placeholder="Enter your prompt here..."),
16
+ outputs="text",
17
+ title="Meta-Llama Text Generation",
18
+ description="Generate text using the Meta-Llama 3.1 405B model."
19
+ )
20
+
21
+ # Launch the interface
22
+ iface.launch()