Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| from transformers import pipeline | |
| # Load the text generation pipeline | |
| pipe = pipeline("text-generation", model="meta-llama/Meta-Llama-3-8B-Instruct") | |
| # Define the chatbot function | |
| def chatbot(user_input): | |
| # Create a message with the user input | |
| message = {"role": "user", "content": user_input} | |
| # Generate a response using the pipeline | |
| response = pipe([message])[0]["generated_text"] | |
| return response | |
| # Create a Gradio interface for the chatbot | |
| demo = gr.Interface(fn=chatbot, inputs="text", outputs="text") | |
| # Launch the Gradio app | |
| demo.launch() |