Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save system message in case of chat summarization error #580

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Save system message in case of chat summarization error
  • Loading branch information
lukintrees committed May 18, 2024
commit 418eb9b2672da50d670fa9a7b63855cb7b3a2abe
4 changes: 2 additions & 2 deletions bot/openai_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ async def __common_get_chat_response(self, chat_id: int, query: str, stream=Fals
self.__add_to_history(chat_id, role="user", content=query)
except Exception as e:
logging.warning(f'Error while summarising chat history: {str(e)}. Popping elements instead...')
self.conversations[chat_id] = self.conversations[chat_id][-self.config['max_history_size']:]
self.conversations[chat_id] = [self.conversations[chat_id][0]] + self.conversations[chat_id][-self.config['max_history_size'] - 1:]

common_args = {
'model': self.config['model'] if not self.conversations_vision[chat_id] else self.config['vision_model'],
Expand Down Expand Up @@ -438,7 +438,7 @@ async def __common_get_chat_response_vision(self, chat_id: int, content: list, s
self.conversations[chat_id] += [last]
except Exception as e:
logging.warning(f'Error while summarising chat history: {str(e)}. Popping elements instead...')
self.conversations[chat_id] = self.conversations[chat_id][-self.config['max_history_size']:]
self.conversations[chat_id] = [self.conversations[chat_id][0]] + self.conversations[chat_id][-self.config['max_history_size'] - 1:]

message = {'role':'user', 'content':content}

Expand Down