CyberCoder225 commited on
Commit
bb83df7
·
verified ·
1 Parent(s): 5ce4894

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +23 -0
  2. requirements.txt +2 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Flask, request, jsonify
2
+ from llama_cpp import Llama
3
+
4
+ app = Flask(__name__)
5
+
6
+ # Load Maira - using the exact filename you downloaded
7
+ llm = Llama(model_path="SmolLM2-360M-Instruct.Q4_K_M.gguf", n_ctx=2048)
8
+
9
+ @app.route('/chat', methods=['POST'])
10
+ def chat():
11
+ data = request.json
12
+ user_input = data.get("message", "")
13
+
14
+ # The format she learned in training
15
+ prompt = f"### User: {user_input}\n### Maira:"
16
+
17
+ output = llm(prompt, max_tokens=150, stop=["###", "</s>"], echo=False)
18
+ response = output["choices"][0]["text"].strip()
19
+
20
+ return jsonify({"maira": response})
21
+
22
+ if __name__ == "__main__":
23
+ app.run(host="0.0.0.0", port=10000)
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ flask
2
+ llama-cpp-python