File size: 720 Bytes
4c75b3b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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

# Load the model
pipe = pipeline("text-generation", model="defog/llama-3-sqlcoder-8b")

# Define a function that will take user input and generate text
def generate_response(user_input):
    messages = [{"role": "user", "content": user_input}]
    result = pipe(messages)
    return result[0]['generated_text']

# Create a Gradio interface
iface = gr.Interface(
    fn=generate_response,  # The function to call for generating responses
    inputs="text",         # The type of input: a text box
    outputs="text",        # The type of output: a text box
    title="Text Generation with LLaMA-3",
    description="Ask anything!"
)

# Launch the app
iface.launch()