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