aboutsummaryrefslogtreecommitdiff
path: root/gn3
diff options
context:
space:
mode:
authorAlexander_Kabui2024-05-24 15:33:51 +0300
committerAlexander_Kabui2024-05-24 15:33:51 +0300
commit9806f3cf708f8eb4e1248eb5059deee53a3887c6 (patch)
tree100126a3f8b39650407af96d18801365f94bc841 /gn3
parente75d484bf786176edcac4edfff65e3035fd493eb (diff)
downloadgenenetwork3-9806f3cf708f8eb4e1248eb5059deee53a3887c6.tar.gz
Initialize new class attribute self.query for to pass to LLMError.
Diffstat (limited to 'gn3')
-rw-r--r--gn3/llms/client.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/gn3/llms/client.py b/gn3/llms/client.py
index 07e9506..fa1e36e 100644
--- a/gn3/llms/client.py
+++ b/gn3/llms/client.py
@@ -55,6 +55,7 @@ class GeneNetworkQAClient(Session):
self.base_url = "https://genenetwork.fahamuai.com/api/tasks"
self.answer_url = f"{self.base_url}/answers"
self.feedback_url = f"{self.base_url}/feedback"
+ self.query = ""
adapter = TimeoutHTTPAdapter(
timeout=timeout,
@@ -83,8 +84,9 @@ class GeneNetworkQAClient(Session):
""" handler for non 200 response from fahamu api"""
return f"Error: Status code -{response.status_code}- Reason::{response.reason}"
- def ask(self, ex_url, *args, **kwargs):
+ def ask(self, ex_url, query, *args, **kwargs):
"""fahamu ask api interface"""
+ self.query = query
res = self.custom_request('POST', f"{self.base_url}{ex_url}", *args, **kwargs)
return res, json.loads(res.text)
@@ -117,6 +119,8 @@ class GeneNetworkQAClient(Session):
else:
raise LLMError( f"Request error with code:\
{response.status_code} occurred with reason:\
- {response_msg.get(response.status_code,response.reason)}")
+ {response_msg.get(response.status_code,response.reason)}",
+ query=self.query)
#time.sleep(retry_delay)
- raise LLMError("Time error: Please try to rephrase of query to get an answer")
+ raise LLMError("Time error: Please try to rephrase of query to get an answer",
+ query=self.query)