File size: 657 Bytes
7c711ca | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | import gradio as gr
from transformers import pipeline
# โหลดโมเดล LLM (ตัวอย่าง: Mistral 7B)
generator = pipeline("text-generation", model="mistralai/Mistral-7B-Instruct-v0.1")
def chat_with_ai(prompt):
response = generator(prompt, max_new_tokens=200, do_sample=True)[0]["generated_text"]
return response
iface = gr.Interface(fn=chat_with_ai,
inputs=gr.Textbox(lines=5, placeholder="พิมพ์ข้อความของคุณ..."),
outputs="text",
title="🧠 AI Proxy Chat",
allow_flagging="never")
iface.launch()
|