jk12p's picture
Update app.py
281ed4d verified
raw
history blame contribute delete
782 Bytes
import gradio as gr
from transformers import pipeline
# Load the text-generation pipeline
pipe = pipeline("text-generation", model="jk12p/qwen3-finetuned-mini")
# Define function
def chat(user_input, history):
result = pipe(user_input, max_new_tokens=100, do_sample=True, temperature=0.7)
response = result[0]["generated_text"]
history.append((user_input, response))
return history, history
# Gradio UI
with gr.Blocks() as demo:
gr.Markdown("## 💬 JP AI Chatbot")
chatbot = gr.Chatbot()
msg = gr.Textbox(label="Your Message", placeholder="Ask something...")
clear = gr.Button("Clear Chat")
state = gr.State([])
msg.submit(chat, [msg, state], [chatbot, state])
clear.click(lambda: ([], []), None, [chatbot, state])
demo.launch()