Skip to content

Commit

Permalink
fixes for pylint and pytest
Browse files Browse the repository at this point in the history
  • Loading branch information
woensug-choi committed Jul 9, 2023
1 parent 86df4ce commit 564b944
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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')
12 changes: 7 additions & 5 deletions chatgee/base/chatgee.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import queue as q
import threading
import time
import requests
from datetime import datetime
import requests

import tiktoken

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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"}
Expand All @@ -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()
Expand Down Expand Up @@ -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)

Expand Down
1 change: 1 addition & 0 deletions pytest_chatgee.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def test_prompt(client):
},
"userRequest": {
"timezone": "Asia/Seoul",
"utterance": "hello there?!",
"params": {
"ignoreMe": "true"
},
Expand Down
14 changes: 12 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 564b944

Please sign in to comment.