saiful-ai-dev commited on
Commit
1d99f3c
·
verified ·
1 Parent(s): 2c89e98

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -0
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import gradio as gr
3
+ from huggingface_hub import hf_hub_download
4
+ from llama_cpp import Llama
5
+
6
+ # মডেল ডাউনলোড (তোমার অরিজিনাল মডেল রিপো থেকে)
7
+ print("⏳ মডেল লোড হচ্ছে, এটি প্রথমবার ২-৩ মিনিট সময় নিতে পারে...")
8
+ model_path = hf_hub_download(
9
+ repo_id="saiful-ai-dev/MotionMindX",
10
+ filename="Qwen2.5-3B-Instruct-Q4_K_M.gguf"
11
+ )
12
+
13
+ # মডেল সেটআপ
14
+ llm = Llama(model_path=model_path, n_ctx=2048, n_threads=2)
15
+
16
+ def respond(message, history):
17
+ system_prompt = "You are Motion Mind X, a helpful AI tutor for SSC/HSC students in Bangladesh. Answer in a friendly way."
18
+ prompt = f"<|im_start|>system\n{system_prompt}<|im_end|>\n<|im_start|>user\n{message}<|im_end|>\n<|im_start|>assistant\n"
19
+
20
+ response = llm(prompt, max_tokens=512, stop=["<|im_end|>"], echo=False)
21
+ return response['choices'][0]['text']
22
+
23
+ # চ্যাট ইন্টারফেস
24
+ demo = gr.ChatInterface(
25
+ respond,
26
+ title="Motion Mind X 🚀",
27
+ description="SSC/HSC শিক্ষার্থীদের জন্য এআই টিউটর"
28
+ )
29
+
30
+ if __name__ == "__main__":
31
+ demo.launch()