JJ94 commited on
Commit
f79962c
Β·
verified Β·
1 Parent(s): e24e31f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -3
app.py CHANGED
@@ -3,20 +3,26 @@ from llama_cpp import Llama
3
 
4
  app = Flask(__name__)
5
 
6
- # Load the Llama model (Ensure the GGUF file is in the same directory)
 
7
  llm = Llama.from_pretrained(
8
  repo_id="bartowski/google_gemma-3-1b-it-GGUF",
9
  filename="google_gemma-3-1b-it-IQ4_XS.gguf",
10
  )
 
11
 
12
  @app.route("/")
13
  def home():
 
14
  return render_template("index.html")
15
 
16
  @app.route("/chat", methods=["POST"])
17
  def chat():
18
  user_input = request.json.get("message", "")
 
 
19
  if not user_input:
 
20
  return jsonify({"error": "Empty input"}), 400
21
 
22
  response = llm.create_chat_completion(
@@ -24,9 +30,12 @@ def chat():
24
  )
25
 
26
  bot_reply = response["choices"][0]["message"]["content"]
27
-
 
28
  return jsonify({"response": bot_reply})
29
 
30
  if __name__ == "__main__":
31
- app.run(host="0.0.0.0", port=7860)
 
 
32
 
 
3
 
4
  app = Flask(__name__)
5
 
6
+ # Load the model
7
+ print("πŸ”„ Loading model... (this may take a while)")
8
  llm = Llama.from_pretrained(
9
  repo_id="bartowski/google_gemma-3-1b-it-GGUF",
10
  filename="google_gemma-3-1b-it-IQ4_XS.gguf",
11
  )
12
+ print("βœ… Model loaded!")
13
 
14
  @app.route("/")
15
  def home():
16
+ print("πŸ“’ Serving index.html")
17
  return render_template("index.html")
18
 
19
  @app.route("/chat", methods=["POST"])
20
  def chat():
21
  user_input = request.json.get("message", "")
22
+ print(f"πŸ’¬ Received message: {user_input}")
23
+
24
  if not user_input:
25
+ print("⚠️ Empty input received!")
26
  return jsonify({"error": "Empty input"}), 400
27
 
28
  response = llm.create_chat_completion(
 
30
  )
31
 
32
  bot_reply = response["choices"][0]["message"]["content"]
33
+ print(f"πŸ€– Bot response: {bot_reply}")
34
+
35
  return jsonify({"response": bot_reply})
36
 
37
  if __name__ == "__main__":
38
+ print("πŸš€ Starting Flask app on port 7860")
39
+ app.run(host="0.0.0.0", port=7860, debug=True)
40
+
41