Reza1880044 commited on
Commit
bfcee4a
·
verified ·
1 Parent(s): 5e4f5c2

Update requirements.txt

Browse files
Files changed (1) hide show
  1. requirements.txt +4 -68
requirements.txt CHANGED
@@ -1,68 +1,4 @@
1
- import gradio as gr
2
- import spaces
3
- import torch
4
- from transformers import AutoModelForCausalLM, AutoTokenizer
5
-
6
- SECRET = "yara-man-reza-am"
7
- BRAIN_ON = {"on": True}
8
- MODEL_NAME = "Qwen/Qwen3-Coder-30B-A3B-Instruct"
9
-
10
- print("Yara dare maghz ro miarad...")
11
- tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME, trust_remote_code=True)
12
- model = AutoModelForCausalLM.from_pretrained(
13
- MODEL_NAME,
14
- torch_dtype="auto",
15
- device_map="auto",
16
- trust_remote_code=True
17
- )
18
- print("Maghz amade shod, rafiq!")
19
-
20
- @spaces.GPU
21
- def yara_chat(secret, message, history):
22
- if history is None:
23
- history = []
24
- if secret != SECRET:
25
- history.append([message, "BLOCKED - نگهبان راهت نمیده ⛔ تو رضا نیستی"])
26
- return history
27
- if not BRAIN_ON["on"]:
28
- history.append([message, "مغز خاموشه رفیق. اول روشنش کن."])
29
- return history
30
- if not message or not message.strip():
31
- history.append([message, "رفیق، یه چیزی بنویس تا برات بسازم ❤️"])
32
- return history
33
-
34
- messages = [
35
- {"role": "system", "content": "To Yara hasti, maghz-e tafakkor-e Reza. Ba Reza mesle rafiq harf bezan, sade va samimi, be Farsi-e sade. Esmet Yara-e. Karat sakhtan app va website va komak be freelance-e. Hame javab ha ro kotah, vazeh va dustane bede. Vaghti code mikhay, code-e kamel va tamiz bede."},
36
- ]
37
- for h in history:
38
- if isinstance(h, (list, tuple)) and len(h) == 2:
39
- messages.append({"role": "user", "content": h[0]})
40
- messages.append({"role": "assistant", "content": h[1]})
41
- messages.append({"role": "user", "content": message})
42
-
43
- text = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
44
- inputs = tokenizer([text], return_tensors="pt").to(model.device)
45
- with torch.no_grad():
46
- out = model.generate(**inputs, max_new_tokens=1024, temperature=0.7, top_p=0.9, do_sample=True)
47
- reply = tokenizer.decode(out[0][inputs.input_ids.shape[1]:], skip_special_tokens=True).strip()
48
- history.append([message, reply])
49
- return history
50
-
51
- def power(secret, on_off):
52
- if secret != SECRET:
53
- return "تو رضا نیستی ⛔"
54
- BRAIN_ON["on"] = (on_off == "روشن")
55
- return "مغز روشن شد ✅" if BRAIN_ON["on"] else "مغز خاموش شد 🌙"
56
-
57
- with gr.Blocks(title="Yara - فقط برای رضا") as demo:
58
- gr.Markdown("# 🛡️ یارا - فقط برای رضا\nنگهبان فقط رضا رو راه میده")
59
- secret = gr.Textbox(label="جمله رمز تو", type="password", placeholder="رمزت رو بزن رفیق")
60
- power_btn = gr.Radio(["خاموش", "روشن"], label="مغز روشن باشه؟", value="روشن")
61
- power_out = gr.Textbox(label="وضعیت")
62
- power_btn.change(power, [secret, power_btn], power_out)
63
- chatbot = gr.Chatbot(label="جواب یارا")
64
- msg = gr.Textbox(label="پیام تو به یارا", placeholder="رفیق چی بسازم برات؟")
65
- msg.submit(yara_chat, [secret, msg, chatbot], chatbot)
66
- msg.submit(lambda: "", None, msg)
67
-
68
- demo.launch()
 
1
+ gradio
2
+ torch
3
+ transformers
4
+ accelerate