Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import AutoModelForCausalLM
|
3 |
+
|
4 |
+
# Load the Llama-2-7b-chat model
|
5 |
+
model = AutoModelForCausalLM.from_pretrained("google/lama-2-7b-chat")
|
6 |
+
|
7 |
+
# Define a function to generate text using the model
|
8 |
+
def generate_text(prompt):
|
9 |
+
# Generate text using the model
|
10 |
+
generated_text = model.generate(prompt, max_length=4000)
|
11 |
+
|
12 |
+
# Return the generated text
|
13 |
+
return generated_text
|
14 |
+
|
15 |
+
# Create a Gradio app
|
16 |
+
interface = gr.Interface(fn=generate_text, inputs="text", outputs="text")
|
17 |
+
|
18 |
+
# Launch the Gradio app
|
19 |
+
interface.launch()
|