JJ94 commited on
Commit
c138cbc
·
verified ·
1 Parent(s): 0d6da06

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -1
app.py CHANGED
@@ -1,7 +1,14 @@
1
  from flask import Flask, request, jsonify, render_template
 
2
 
3
  app = Flask(__name__)
4
 
 
 
 
 
 
 
5
  @app.route("/")
6
  def home():
7
  return render_template("index.html")
@@ -12,7 +19,13 @@ def chat():
12
  if not user_input:
13
  return jsonify({"error": "Empty input"}), 400
14
 
15
- return jsonify({"response": f"Dummy response for: {user_input}"})
 
 
 
 
 
 
16
 
17
  if __name__ == "__main__":
18
  app.run(host="0.0.0.0", port=7860)
 
1
  from flask import Flask, request, jsonify, render_template
2
+ 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")
 
19
  if not user_input:
20
  return jsonify({"error": "Empty input"}), 400
21
 
22
+ response = llm.create_chat_completion(
23
+ messages=[{"role": "user", "content": user_input}]
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)