taha-mz87 commited on
Commit
3c822e8
·
verified ·
1 Parent(s): acc4e90

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -0
app.py CHANGED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # مدل تولید متن (برای کدنویسی و چت ساده)
5
+ generator = pipeline("text-generation", model="bigcode/starcoderbase")
6
+
7
+ def chat_with_ai(prompt):
8
+ response = generator(prompt, max_length=200, do_sample=True)[0]["generated_text"]
9
+ return response
10
+
11
+ with gr.Blocks() as demo:
12
+ gr.Markdown("## 🤖 دستیار برنامه‌نویسی شما")
13
+ chat_input = gr.Textbox(label="سوال یا درخواست خود را وارد کنید")
14
+ chat_output = gr.Textbox(label="پاسخ AI")
15
+ submit_btn = gr.Button("ارسال")
16
+
17
+ submit_btn.click(chat_with_ai, inputs=chat_input, outputs=chat_output)
18
+
19
+ demo.launch()