diff options
Diffstat (limited to 'gn3/llms')
-rw-r--r-- | gn3/llms/client.py | 8 | ||||
-rw-r--r-- | gn3/llms/process.py | 5 |
2 files changed, 10 insertions, 3 deletions
diff --git a/gn3/llms/client.py b/gn3/llms/client.py index 4a43d2a..880df1d 100644 --- a/gn3/llms/client.py +++ b/gn3/llms/client.py @@ -12,6 +12,8 @@ from requests.packages.urllib3.util.retry import Retry from requests import HTTPError from requests import Session from requests.adapters import HTTPAdapter +from urllib.request import urlretrieve +from urllib.parse import quote basedir = os.path.join(os.path.dirname(__file__)) @@ -133,7 +135,7 @@ class GeneNetworkQAClient(Session): def custom_request(self, method, url, *args, **kwargs): - max_retries = 5 + max_retries = 8 retry_delay = 10 response = super().request(method, url, *args, **kwargs) @@ -195,7 +197,8 @@ class GeneNetworkQAClient(Session): return '?task_id=' + str(task_id['task_id']) def get_gnqa(self, query): - res, task_id = api_client.ask('?ask=' + query) + qstr = quote(query) + res, task_id = api_client.ask('?ask=' + qstr) res, success = api_client.get_answer(task_id) if success == 1: @@ -205,3 +208,4 @@ class GeneNetworkQAClient(Session): return answer, context else: return res, "Unfortunately, I have nothing." + diff --git a/gn3/llms/process.py b/gn3/llms/process.py index 58d565a..526c1b3 100644 --- a/gn3/llms/process.py +++ b/gn3/llms/process.py @@ -7,6 +7,9 @@ import time import string import json import os +from urllib.request import urlretrieve +from urllib.parse import quote + from gn3.llms.client import GeneNetworkQAClient from gn3.llms.response import DocIDs @@ -77,7 +80,7 @@ def filterResponseText(val): def getGNQA(query, auth_token): apiClient = GeneNetworkQAClient(requests.Session(), api_key=auth_token) - res, task_id = apiClient.ask('?ask=' + query, auth_token) + res, task_id = apiClient.ask('?ask=' + quote(query), auth_token) res, success = apiClient.get_answer(task_id) if (success == 1): |