scp4950 commited on
Commit
9ed466e
1 Parent(s): d853866

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -2
app.py CHANGED
@@ -1,2 +1,23 @@
1
- pip install gradio
2
- pip install transformers
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Replace 'gpt2' with the correct model identifier if you have a specific model.
5
+ # For example, you could use 'gpt2', 'gpt2-medium', 'gpt3', etc.
6
+ model_name = 'meta-llama/Llama-2-7b'
7
+ generator = pipeline(model=model_name)
8
+
9
+ def generate_text(prompt):
10
+ return generator(prompt, max_length=100)[0]['generated_text']
11
+
12
+ # Gradio interface setup
13
+ iface = gr.Interface(
14
+ fn=generate_text,
15
+ inputs=gr.Textbox(),
16
+ outputs=gr.Textbox(),
17
+ title="Meta-Llama Chat",
18
+ description="Enter a prompt to chat with the Meta-Llama model.",
19
+ live=True
20
+ )
21
+
22
+ # Launch the Gradio interface
23
+ iface.launch()