File size: 640 Bytes
c7c9474
cb7c13e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c7c9474
 
cb7c13e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import gradio as gr
from transformers import pipeline

# بارگیری مدل فارسی (مثلاً mBERT یا پارسBERT)
chatbot = pipeline("text-generation", model="HooshvareLab/bert-fa-base-uncased")

def chat(message, history):
    # تولید پاسخ با استفاده از مدل
    response = chatbot(message, max_length=50)[0]['generated_text']
    return response

# ایجاد رابط کاربری با Gradio
iface = gr.Interface(
    fn=chat,
    inputs="text",
    outputs="text",
    title="چت بات فارسی",
    description="یک چت بات ساده با استفاده از Hugging Face"
)

iface.launch()