pa3lo commited on
Commit
00028ad
1 Parent(s): e7e1740

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -9
app.py CHANGED
@@ -4,7 +4,7 @@ from langchain.chains import RetrievalQA
4
  from langchain_community.vectorstores import Pinecone
5
  from langchain.prompts import PromptTemplate
6
  from langchain_community.llms import CTransformers
7
- #from flask_limiter import Limiter
8
  from flask_limiter.util import get_remote_address
9
  from langchain_community.llms import LlamaCpp
10
  import time
@@ -13,11 +13,11 @@ import time
13
  app = Flask(__name__)
14
 
15
  # Setup Flask-Limiter
16
- #limiter = Limiter(
17
- # app=app,
18
- # key_func=get_remote_address, # Correctly specify key_func as a keyword argument
19
- # default_limits=["200 per day", "20 per hour"]
20
- #)
21
 
22
 
23
  # Initialize embeddings directly
@@ -40,7 +40,7 @@ llm = LlamaCpp(
40
  model_path="model/phi-2.Q2_K.gguf",
41
  temperature=0.1,
42
  max_tokens=128,
43
- # repetition_penalty=1,
44
  top_p=1,
45
  verbose=True, # Verbose is required to pass to the callback manager
46
  )
@@ -65,7 +65,7 @@ messages = []
65
 
66
 
67
  @app.route("/", methods=["GET"])
68
- #@limiter.limit("10/minute")
69
  def home():
70
  return render_template("home.html", messages=messages)
71
 
@@ -90,5 +90,5 @@ def post_message():
90
 
91
 
92
  if __name__ == "__main__":
93
- app.run(host='0.0.0.0', port=7860, debug=True)
94
 
 
4
  from langchain_community.vectorstores import Pinecone
5
  from langchain.prompts import PromptTemplate
6
  from langchain_community.llms import CTransformers
7
+ from flask_limiter import Limiter
8
  from flask_limiter.util import get_remote_address
9
  from langchain_community.llms import LlamaCpp
10
  import time
 
13
  app = Flask(__name__)
14
 
15
  # Setup Flask-Limiter
16
+ limiter = Limiter(
17
+ app=app,
18
+ key_func=get_remote_address, # Correctly specify key_func as a keyword argument
19
+ default_limits=["200 per day", "20 per hour"]
20
+ )
21
 
22
 
23
  # Initialize embeddings directly
 
40
  model_path="model/phi-2.Q2_K.gguf",
41
  temperature=0.1,
42
  max_tokens=128,
43
+ repetition_penalty=1,
44
  top_p=1,
45
  verbose=True, # Verbose is required to pass to the callback manager
46
  )
 
65
 
66
 
67
  @app.route("/", methods=["GET"])
68
+ @limiter.limit("10/minute")
69
  def home():
70
  return render_template("home.html", messages=messages)
71
 
 
90
 
91
 
92
  if __name__ == "__main__":
93
+ app.run(host='0.0.0.0', port=7860)
94