Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,22 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
|
| 6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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()
|