diff options
author | Alexander_Kabui | 2024-05-24 15:22:08 +0300 |
---|---|---|
committer | Alexander_Kabui | 2024-05-24 15:22:08 +0300 |
commit | e75d484bf786176edcac4edfff65e3035fd493eb (patch) | |
tree | 52209af225cd6857488b0ab8d712c2097a72e568 /gn3/llms | |
parent | 2518b60722e5248db363405dee68d9edb0e79601 (diff) | |
download | genenetwork3-e75d484bf786176edcac4edfff65e3035fd493eb.tar.gz |
Remove try/block for get_answer/ask methods:Exception already raised
Diffstat (limited to 'gn3/llms')
-rw-r--r-- | gn3/llms/client.py | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/gn3/llms/client.py b/gn3/llms/client.py index 99df36a..07e9506 100644 --- a/gn3/llms/client.py +++ b/gn3/llms/client.py @@ -86,20 +86,13 @@ class GeneNetworkQAClient(Session): def ask(self, ex_url, *args, **kwargs): """fahamu ask api interface""" res = self.custom_request('POST', f"{self.base_url}{ex_url}", *args, **kwargs) - if res.status_code != 200: - return f"Error: Status code -{res.status_code}- Reason::{res.reason}", 0 return res, json.loads(res.text) def get_answer(self, taskid, *args, **kwargs): """Fahamu get answer interface""" - try: - query = f"{self.answer_url}?task_id={taskid['task_id']}" - res = self.custom_request('GET', query, *args, **kwargs) - if res.status_code != 200: - return f"Error: Status code -{res.status_code}- Reason::{res.reason}", 0 - return res, 1 - except TimeoutError: - return "Timeout error occured:try to rephrase your query", 0 + query = f"{self.answer_url}?task_id={taskid['task_id']}" + res = self.custom_request('GET', query, *args, **kwargs) + return res, 1 def custom_request(self, method, url, *args, **kwargs): """ make custom request to fahamu api ask and get response""" @@ -126,4 +119,4 @@ class GeneNetworkQAClient(Session): {response.status_code} occurred with reason:\ {response_msg.get(response.status_code,response.reason)}") #time.sleep(retry_delay) - raise LLMError("Time error occurred when querying the fahamu Api,Please a try the search again") + raise LLMError("Time error: Please try to rephrase of query to get an answer") |