Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,7 +1,19 @@
|
|
| 1 |
import gradio as gr
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from transformers import pipeline
|
| 3 |
|
| 4 |
+
# Load the text generation pipeline
|
| 5 |
+
pipe = pipeline("text-generation", model="meta-llama/Meta-Llama-3-8B-Instruct")
|
| 6 |
|
| 7 |
+
# Define the chatbot function
|
| 8 |
+
def chatbot(user_input):
|
| 9 |
+
# Create a message with the user input
|
| 10 |
+
message = {"role": "user", "content": user_input}
|
| 11 |
+
# Generate a response using the pipeline
|
| 12 |
+
response = pipe([message])[0]["generated_text"]
|
| 13 |
+
return response
|
| 14 |
+
|
| 15 |
+
# Create a Gradio interface for the chatbot
|
| 16 |
+
demo = gr.Interface(fn=chatbot, inputs="text", outputs="text")
|
| 17 |
+
|
| 18 |
+
# Launch the Gradio app
|
| 19 |
+
demo.launch()
|