From 564b944dd93796d55029781328e9baf91d9934f5 Mon Sep 17 00:00:00 2001 From: Choi Woen-Sug Date: Sun, 9 Jul 2023 13:09:10 +0900 Subject: [PATCH] fixes for pylint and pytest --- .github/workflows/pylint.yml | 2 +- chatgee/base/chatgee.py | 12 +++++++----- pytest_chatgee.py | 1 + requirements.txt | 14 ++++++++++++-- 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/.github/workflows/pylint.yml b/.github/workflows/pylint.yml index 1e9a5ee..9ea789f 100644 --- a/.github/workflows/pylint.yml +++ b/.github/workflows/pylint.yml @@ -24,4 +24,4 @@ jobs: pip install pylint - name: Analysing the code with pylint run: | - pylint --disable=E0401,C0103,R0914,R0913 $(git ls-files '*.py') + pylint --disable=E0401,C0103,R0914,R0913,R0902,R0912,R0915 $(git ls-files '*.py') diff --git a/chatgee/base/chatgee.py b/chatgee/base/chatgee.py index dea1ade..039e89b 100644 --- a/chatgee/base/chatgee.py +++ b/chatgee/base/chatgee.py @@ -6,8 +6,8 @@ import queue as q import threading import time -import requests from datetime import datetime +import requests import tiktoken @@ -63,7 +63,7 @@ def prompt_received(self, content): if self.callback_option: self.callbackUrl = content['userRequest']['callbackUrl'] callback_flag = True - + # Check user new_user_flag = False userid = content['userRequest']['user']['id'] # userid is saved as 'room' in user_data.db @@ -117,7 +117,8 @@ def prompt_received(self, content): # If callback respond 'useCallback' as 'true' if callback_flag: request_queue = q.Queue() - request_respond = threading.Thread(target=self.prompt, args=(request_queue, '', callback_flag)) + request_respond = threading.Thread(target=self.prompt, + args=(request_queue, '', callback_flag)) request_respond.start() request_queue.put(content) response = {'version': '2.0', 'useCallback': "true"} @@ -134,7 +135,8 @@ def prompt_received(self, content): # trigger the prompt request request_queue.put(content) # Retreive the response - while time.time() - start_time < self.ChatGee_Config['SETTINGS']['RESPONSE_SAFE_TIME']: + while time.time() - start_time \ + < self.ChatGee_Config['SETTINGS']['RESPONSE_SAFE_TIME']: if not response_queue.empty(): # Function A returned a result response = response_queue.get() @@ -178,7 +180,7 @@ def prompt(self, request_queue, response_queue, callback_flag): if callback_flag: headers = {'Content-Type': 'application/json; charset=utf-8'} result['useCallback'] = True - success = requests.post(self.callbackUrl, json=result, headers=headers) + requests.post(self.callbackUrl, json=result, headers=headers, timeout=5) else: response_queue.put(result) diff --git a/pytest_chatgee.py b/pytest_chatgee.py index eeaf75b..fbb42c6 100644 --- a/pytest_chatgee.py +++ b/pytest_chatgee.py @@ -31,6 +31,7 @@ def test_prompt(client): }, "userRequest": { "timezone": "Asia/Seoul", + "utterance": "hello there?!", "params": { "ignoreMe": "true" }, diff --git a/requirements.txt b/requirements.txt index 79fca67..c59d606 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,27 +3,37 @@ aiosignal==1.3.1 async-timeout==4.0.2 attrs==22.2.0 backoff==2.2.1 +blinker==1.6.2 certifi==2022.12.7 charset-normalizer==3.1.0 click==8.1.3 colorama==0.4.6 distlib==0.3.6 +exceptiongroup==1.1.2 filelock==3.10.6 -Flask==2.2.3 +Flask==2.3.2 frozenlist==1.3.3 idna==3.4 +importlib-metadata==6.8.0 +iniconfig==2.0.0 itsdangerous==2.1.2 Jinja2==3.1.2 MarkupSafe==2.1.2 multidict==6.0.4 openai==0.27.2 +packaging==23.1 platformdirs==3.2.0 +pluggy==1.2.0 +prettier==0.0.7 +pytest==7.4.0 PyYAML==6.0 regex==2023.3.23 requests==2.28.2 tiktoken==0.3.2 +tomli==2.0.1 tqdm==4.65.0 urllib3==1.26.15 virtualenv==20.21.0 -Werkzeug==2.2.3 +Werkzeug==2.3.6 yarl==1.8.2 +zipp==3.16.0