about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlexander_Kabui2024-05-24 15:59:30 +0300
committerAlexander_Kabui2024-05-24 15:59:30 +0300
commit651f307a4b8e60aaea0c8a7649a5b02aafce7a98 (patch)
treecac2f1dbe9d42f3fab1066d73a22166a3eb941e8
parentee1345535817a6b3e6943b268057f53840d78b8f (diff)
downloadgenenetwork3-651f307a4b8e60aaea0c8a7649a5b02aafce7a98.tar.gz
Removed status check on get_gnqa function.
-rw-r--r--gn3/llms/process.py23
1 files changed, 6 insertions, 17 deletions
diff --git a/gn3/llms/process.py b/gn3/llms/process.py
index d53a7fd..ab2a80e 100644
--- a/gn3/llms/process.py
+++ b/gn3/llms/process.py
@@ -116,22 +116,11 @@ def get_gnqa(query, auth_token, data_dir=""):
          answer
          references: contains doc_name,reference,pub_med_info
     """
-
     api_client = GeneNetworkQAClient(api_key=auth_token)
     res, task_id = api_client.ask('?ask=' + quote(query), query=query)
-    if task_id == 0:
-        raise RuntimeError(f"Error connecting to Fahamu Api: {str(res)}")
-    res, status = api_client.get_answer(task_id)
-    if status == 1:
-        resp_text = filter_response_text(res.text)
-        if resp_text.get("data") is None:
-            return task_id, "Please try to rephrase your question to receive feedback", []
-        answer = resp_text['data']['answer']
-        context = resp_text['data']['context']
-        references = parse_context(
-            context, DocIDs().get_info, format_bibliography_info)
-        references = fetch_pubmed(references, "pubmed.json", data_dir)
-
-        return task_id, answer, references
-    else:
-        return task_id, "We couldn't provide a response,Please try to rephrase your question to receive feedback", []
+    res, _status = api_client.get_answer(task_id)
+    resp_text = filter_response_text(res.text)
+    answer = resp_text['data']['answer']
+    context = resp_text['data']['context']
+    return task_id, answer, fetch_pubmed(parse_context(
+        context, DocIDs().get_info, format_bibliography_info), "pubmed.json", data_dir)