This commit is contained in:
ahmed531998 2023-04-19 05:54:49 +02:00
parent b371fd5b0c
commit 2a2aa797b8
2 changed files with 7 additions and 7 deletions

12
main.py
View File

@ -31,7 +31,7 @@ cors = CORS(app, resources={r"/api/predict": {"origins": url},
r"/api/dm": {"origins": url},
r"/health": {"origins": "*"}
})
"""
conn = psycopg2.connect(
host="janet-pg",
database=os.getenv("POSTGRES_DB"),
@ -39,7 +39,7 @@ conn = psycopg2.connect(
password=os.getenv("POSTGRES_PASSWORD"))
cur = conn.cursor()
"""
users = {}
def vre_fetch(token):
@ -160,7 +160,7 @@ def predict():
def feedback():
data = request.get_json().get("feedback")
print(data)
"""
cur.execute('INSERT INTO feedback_experimental (query, history, janet_modified_query, is_modified_query_correct, user_modified_query, evidence_useful, response, preferred_response, response_length_feedback, response_fluency_feedback, response_truth_feedback, response_useful_feedback, response_time_feedback, response_intent) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)',
(data['query'], data['history'], data['modQuery'],
data['queryModCorrect'], data['correctQuery'], data['evidence'], data['janetResponse'], data['preferredResponse'], data['length'],
@ -168,7 +168,7 @@ def feedback():
data['speed'], data['intent'])
)
conn.commit()
"""
reply = jsonify({"status": "done"})
return reply
@ -200,7 +200,7 @@ if __name__ == "__main__":
threading.Thread(target=clear_inactive, name='clear').start()
rec = Recommender(retriever)
"""
cur.execute('CREATE TABLE IF NOT EXISTS feedback_experimental (id serial PRIMARY KEY,'
'query text NOT NULL,'
'history text NOT NULL,'
@ -217,5 +217,5 @@ if __name__ == "__main__":
'response_intent text NOT NULL);'
)
conn.commit()
"""
app.run(host='0.0.0.0')

View File

@ -1 +1 @@
Run main.py to start the backend!
Run main.py to start the backend.