Update app.py
Browse files
app.py
CHANGED
|
@@ -1,34 +1,13 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
import
|
| 3 |
|
| 4 |
-
#
|
| 5 |
-
|
| 6 |
-
STABLE_MODEL = "qwen-2.5-32b"
|
| 7 |
|
| 8 |
-
def
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 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 |
-
#
|
| 27 |
-
|
| 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()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|