diff options
author | Alexander_Kabui | 2024-05-24 16:30:59 +0300 |
---|---|---|
committer | Alexander_Kabui | 2024-05-24 16:30:59 +0300 |
commit | 188f84ef3895de613e998c63da7ec2338e25a55c (patch) | |
tree | c4fa6bc4f36cf03eff0e709d3f803f25c678c8de | |
parent | 8512d9a606fbfff864345d82c210e281a6d943bf (diff) | |
download | genenetwork3-188f84ef3895de613e998c63da7ec2338e25a55c.tar.gz |
Remove kwargs from LLMErrorr Exceptions and update relevant code.
-rw-r--r-- | gn3/api/llm.py | 7 | ||||
-rw-r--r-- | gn3/llms/client.py | 6 | ||||
-rw-r--r-- | gn3/llms/errors.py | 1 |
3 files changed, 4 insertions, 10 deletions
diff --git a/gn3/api/llm.py b/gn3/api/llm.py index 03ce815..c1f6304 100644 --- a/gn3/api/llm.py +++ b/gn3/api/llm.py @@ -1,7 +1,5 @@ """Api endpoints for gnqa""" import json -import sqlite3 -from authlib.integrations.flask_oauth2.errors import _HTTPException from flask import Blueprint from flask import current_app from flask import jsonify @@ -10,7 +8,6 @@ from flask import request from gn3.llms.process import get_gnqa from gn3.llms.errors import LLMError from gn3.auth.authorisation.oauth2.resource_server import require_oauth -from gn3.auth.authorisation.errors import AuthorisationError from gn3.auth import db @@ -26,8 +23,7 @@ def search(): fahamu_token = current_app.config.get("FAHAMU_AUTH_TOKEN") if not fahamu_token: raise LLMError( - "Request failed:an LLM authorisation token is required ", - query=query) + "Request failed:an LLM authorisation token is required ", query) task_id, answer, refs = get_gnqa( query, fahamu_token, current_app.config.get("DATA_DIR")) response = { @@ -61,7 +57,6 @@ def rate_queries(task_id): """Endpoint for rating qnqa query and answer""" with (require_oauth.acquire("profile") as token, db.connection(current_app.config["LLM_DB_PATH"]) as conn): - results = request.json user_id, query, answer, weight = (token.user.user_id, results.get("query"), diff --git a/gn3/llms/client.py b/gn3/llms/client.py index 5c4fa0e..d29d2a1 100644 --- a/gn3/llms/client.py +++ b/gn3/llms/client.py @@ -117,11 +117,11 @@ class GeneNetworkQAClient(Session): continue return response else: - raise LLMError( f"Request error with code:\ + raise LLMError(f"Request error with code:\ {response.status_code} occurred with reason:\ {response_msg.get(response.status_code,response.reason)}", - query=self.query) + self.query) #time.sleep(retry_delay) raise LLMError("Time error: We couldn't provide a response,Please try\ to rephrase your question to receive feedback", - query=self.query) + self.query) diff --git a/gn3/llms/errors.py b/gn3/llms/errors.py index c5439d6..77e0f9a 100644 --- a/gn3/llms/errors.py +++ b/gn3/llms/errors.py @@ -39,4 +39,3 @@ class LLMError(Exception): """custom exception for LLMErrorMIxins""" def __init__(self, *args, **kwargs): super().__init__(*args) - self.query = kwargs.get("query") |