aboutsummaryrefslogtreecommitdiff
path: root/gn3/api/llm.py
diff options
context:
space:
mode:
authorAlexander_Kabui2024-05-24 17:34:59 +0300
committerAlexander_Kabui2024-05-24 17:34:59 +0300
commit22a1517e71ff6058090596498b9e829fb4e19664 (patch)
treef7f5851f2ffe838307e34f43001797ccf2cb6671 /gn3/api/llm.py
parenta3284926aaa73ce27565e4a1131d4447a3a7face (diff)
downloadgenenetwork3-22a1517e71ff6058090596498b9e829fb4e19664.tar.gz
Add created_at timestamp for Rating table.
Diffstat (limited to 'gn3/api/llm.py')
-rw-r--r--gn3/api/llm.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/gn3/api/llm.py b/gn3/api/llm.py
index 5924f12..ab33c7a 100644
--- a/gn3/api/llm.py
+++ b/gn3/api/llm.py
@@ -1,5 +1,6 @@
"""Api endpoints for gnqa"""
import json
+from datetime import datetime, timezone
from flask import Blueprint
from flask import current_app
from flask import jsonify
@@ -69,15 +70,17 @@ def rate_queries(task_id):
query TEXT NOT NULL,
answer TEXT NOT NULL,
weight INTEGER NOT NULL DEFAULT 0,
- task_id TEXT NOT NULL UNIQUE
+ task_id TEXT NOT NULL UNIQUE,
+ created_at TIMESTAMP
)"""
cursor.execute(create_table)
cursor.execute("""INSERT INTO Rating(user_id, query,
- answer, weight, task_id)
- VALUES(?,?,?,?,?)
+ answer, weight, task_id, created_at)
+ VALUES(?, ?, ?, ?, ?, ?)
ON CONFLICT(task_id) DO UPDATE SET
weight=excluded.weight
- """, (str(user_id), query, answer, weight, task_id))
+ """, (str(user_id), query, answer, weight, task_id,
+ datetime.now(timezone.utc)))
return {
"message": "You have successfully rated this query.Thank you!"
}, 200