aboutsummaryrefslogtreecommitdiff
path: root/gn3/api
diff options
context:
space:
mode:
authorAlexander Kabui2024-01-16 15:31:55 +0300
committerGitHub2024-01-16 15:31:55 +0300
commit482a8908dc08d6e5a13e576c4ba4bc3ff934bb8d (patch)
tree7d8421bd095c257038d047e21ab96922d3114676 /gn3/api
parentb73518251065c7584527eee3b0cde1670dae06b0 (diff)
downloadgenenetwork3-482a8908dc08d6e5a13e576c4ba4bc3ff934bb8d.tar.gz
add api endpoint for rating reference documents (#146)
Diffstat (limited to 'gn3/api')
-rw-r--r--gn3/api/llm.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/gn3/api/llm.py b/gn3/api/llm.py
index 68e6acc..5fcc1f5 100644
--- a/gn3/api/llm.py
+++ b/gn3/api/llm.py
@@ -6,6 +6,8 @@ from flask import jsonify, request, Blueprint, current_app
from gn3.llms.process import getGNQA
+from gn3.llms.process import rate_document
+
GnQNA = Blueprint("GnQNA", __name__)
@@ -17,10 +19,11 @@ def gnqa():
try:
auth_token = current_app.config.get("FAHAMU_AUTH_TOKEN")
- answer, refs = getGNQA(
+ task_id, answer, refs = getGNQA(
query, auth_token)
return jsonify({
+ "task_id": task_id,
"query": query,
"answer": answer,
"references": refs
@@ -28,3 +31,17 @@ def gnqa():
except Exception as error:
return jsonify({"query": query, "error": "Internal server error"}), 500
+
+
+@GnQNA.route("/rating/<task_id>/<doc_id>/<int:rating>", methods=["POST"])
+def rating(task_id, doc_id, rating):
+ try:
+ results = rate_document(task_id, doc_id, rating,
+ current_app.config.get("FAHAMU_AUTH_TOKEN"))
+ return jsonify({
+ **results,
+ "doc_id": doc_id,
+ "task_id": task_id,
+ }),
+ except Exception as error:
+ return jsonify({"error": str(error), doc_id: doc_id}), 500