File size: 794 Bytes
faa579e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import gradio as gr
from transformers import pipeline

# Initialize the text generation pipeline with the LLaMA model
pipe = pipeline("text-generation", model="mlabonne/Hermes-3-Llama-3.1-8B-lorablated")

# Define the function that generates a response
def generate_response(prompt):
    # Generate text using the pipeline
    responses = pipe(prompt, max_length=100, num_return_sequences=1)
    # Extract and return the text from the generated responses
    return responses[0]['generated_text']

# Create the Gradio interface
interface = gr.Interface(
    fn=generate_response,
    inputs="text",
    outputs="text",
    title="LLaMA Chatbot",
    description="A simple chatbot using LLaMA for text generation. Enter a prompt and get a response."
)

# Launch the Gradio app
interface.launch()