Skip to content

Commit

Permalink
Fix linters
Browse files Browse the repository at this point in the history
  • Loading branch information
wwakabobik committed Oct 14, 2023
1 parent c7c69c4 commit 00eec68
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 17 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/linters.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Linters
name: Linters-PR

on:
push:
Expand All @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11"]
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/master_linters.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Linters-Master
name: Linters

on:
push:
Expand All @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12"]
python-version: ["3.9", "3.10", "3.11"]
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
19 changes: 7 additions & 12 deletions src/openai_api/chatgpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,10 +602,6 @@ async def process_chat(self, prompt, default_choice=0, chat_name=None):
if "content" in chunk["choices"][default_choice]["delta"]:
if chunk["choices"][default_choice]["delta"]["content"]:
yield chunk
else:
continue
else:
continue
except GeneratorExit:
self.___logger.debug("Chat ended with uid=%s", uid)
try:
Expand Down Expand Up @@ -696,11 +692,11 @@ async def chat(self, prompt, chat_name=None, default_choice=0, extra_settings=""
# Add new message to chat
self.chats[chat_name].append({"role": "user", "content": prompt})
# Get last 'history_length' messages
messages = self.chats[chat_name][-self.history_length :]
messages = self.chats[chat_name][-self.history_length :] # flake8: noqa : E203
messages.insert(0, {"role": "system", "content": f"{self.system_settings} {extra_settings}"})

try:
async for prompt_response in self.process_chat(
async for prompt_response in self.process_chat( # flake8: noqa : WPS352
prompt=messages, default_choice=default_choice, chat_name=chat_name
):
if isinstance(prompt_response, dict):
Expand Down Expand Up @@ -913,12 +909,11 @@ async def __handle_chat_name(self, chat_name, prompt):
self.___chat_name_length,
chat_name,
)
else:
if len(chat_name) > self.___chat_name_length:
self.___logger.debug(
"Chat name is longer than %s characters, truncating it: %s", self.___chat_name_length, chat_name
)
chat_name = chat_name[: self.___chat_name_length]
elif len(chat_name) > self.___chat_name_length:
self.___logger.debug(
"Chat name is longer than %s characters, truncating it: %s", self.___chat_name_length, chat_name
)
chat_name = chat_name[: self.___chat_name_length]
if chat_name not in self.chats:
self.___logger.debug("Chat name '%s' is not present in self.chats, adding it", chat_name)
self.chats[chat_name] = []
Expand Down
2 changes: 1 addition & 1 deletion src/openai_api/dalle.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,4 +454,4 @@ def ___set_auth(self, token, organization):
"""
self.___logger.debug("Setting auth bearer")
openai.api_key = token
openai.organization = organization
openai.organization = organization

0 comments on commit 00eec68

Please sign in to comment.