aboutsummaryrefslogtreecommitdiff
path: root/gn3/llms
diff options
context:
space:
mode:
authorAlexander_Kabui2024-03-25 16:15:23 +0300
committerAlexander_Kabui2024-03-25 16:15:23 +0300
commitd797efb7c71e001e50830c10f30a89f1642cafd7 (patch)
tree74db2c6b8496dec315bdf23a3766c201677ec20c /gn3/llms
parentec60064a8ba992bc2005d3d583dca1694f5a9fa6 (diff)
downloadgenenetwork3-d797efb7c71e001e50830c10f30a89f1642cafd7.tar.gz
fetch tmpdir from current app connfig
Diffstat (limited to 'gn3/llms')
-rw-r--r--gn3/llms/process.py10
1 files changed, 5 insertions, 5 deletions
diff --git a/gn3/llms/process.py b/gn3/llms/process.py
index 549c7e6..e33d3bc 100644
--- a/gn3/llms/process.py
+++ b/gn3/llms/process.py
@@ -69,16 +69,16 @@ def rate_document(task_id, doc_id, rating, auth_token):
raise RuntimeError(f"An error occurred: {str(error)}") from error
-def load_file(filename):
+def load_file(filename, dir_path):
"""function to open and load json file"""
- file_path = os.path.join(TMPDIR, filename)
+ file_path = os.path.join(dir_path, f"/{filename}")
if not os.path.isfile(file_path):
raise FileNotFoundError(f"{filename} was not found or is a directory")
with open(file_path, "rb") as file_handler:
return json.load(file_handler)
-def fetch_pubmed(references, file_name):
+def fetch_pubmed(references, file_name, tmp_dir=""):
"""method to fetch and populate references with pubmed"""
try:
@@ -92,7 +92,7 @@ def fetch_pubmed(references, file_name):
return references
-def get_gnqa(query, auth_token):
+def get_gnqa(query, auth_token, tmp_dir=""):
"""entry function for the gn3 api endpoint()"""
api_client = GeneNetworkQAClient(requests.Session(), api_key=auth_token)
@@ -108,7 +108,7 @@ def get_gnqa(query, auth_token):
context = resp_text['data']['context']
references = parse_context(
context, DocIDs().getInfo, format_bibliography_info)
- references = fetch_pubmed(references, "pubmed.json")
+ references = fetch_pubmed(references, "pubmed.json", tmp_dir)
return task_id, answer, references
else: