minzo456 commited on
Commit
87f1729
·
verified ·
1 Parent(s): a2ebe5b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -30
app.py CHANGED
@@ -1,34 +1,13 @@
1
  import gradio as gr
2
- import requests
3
 
4
- # 🛡️ STRATEGIC KEYS
5
- GROQ_API_KEY = "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"
6
- STABLE_MODEL = "qwen-2.5-32b"
7
 
8
- def minzo_engine(message, history):
9
- try:
10
- headers = {
11
- "Authorization": f"Bearer {GROQ_API_KEY}",
12
- "Content-Type": "application/json"
13
- }
14
- payload = {
15
- "model": STABLE_MODEL,
16
- "messages": [
17
- {"role": "system", "content": "You are MINZO AI. Speak in Sinhala."},
18
- {"role": "user", "content": message}
19
- ]
20
- }
21
- r = requests.post("https://api.groq.com/openai/v1/chat/completions", headers=headers, json=payload, timeout=20)
22
- return r.json()['choices'][0]['message']['content']
23
- except Exception as e:
24
- return f"⚠️ Neural Link Error: {str(e)}"
25
 
26
- # 🔱 UI DEPLOYMENT (Ultra-Stable Version)
27
- demo = gr.ChatInterface(
28
- fn=minzo_engine,
29
- title="🔱 MINZO AI | STRATEGIC CORE",
30
- theme="soft"
31
- )
32
-
33
- if __name__ == "__main__":
34
- demo.launch()
 
1
  import gradio as gr
2
+ from transformers import pipeline
3
 
4
+ # මොඩල් එක මෙතනදී Load වෙනවා
5
+ pipe = pipeline("text-generation", model="Qwen/Qwen2.5-1.5B-Instruct")
 
6
 
7
+ def predict(message, history):
8
+ # AI පිළිතුර උත්පාදනය කිරීම
9
+ response = pipe(message, max_new_tokens=512)[0]['generated_text']
10
+ return response
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
+ # API එකක් ලෙස මෙය විවෘත කිරීම
13
+ gr.ChatInterface(predict).launch()