cedervall-ai / app.py
egillf's picture
Create app.py
4c75b3b verified
raw
history blame contribute delete
720 Bytes
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()