aiochat / app.py
aionicvision's picture
Update app.py
fe6b6c1 verified
raw
history blame
765 Bytes
import gradio as gr
from transformers import pipeline
# بارگذاری مدل DeepSeek-Coder
coder = pipeline("text-generation", model="deepseek-ai/deepseek-coder-33b-instruct")
def respond(message, history):
prompt = f"<|system|>You are an expert programming assistant. Use Persian when needed.</s><|user|>{message}</s><|assistant|>"
response = coder(prompt, max_new_tokens=200)[0]['generated_text']
return response.split("<|assistant|>")[-1].strip()
# استفاده از تمپلت آماده Chat Interface
gr.ChatInterface(
respond,
title="👨‍💻 دستیار کدنویسی شما",
examples=["چطوری در React از useState استفاده کنم؟", "خطای SyntaxError در پایتون را رفع کن"]
).launch()