Skip to content

Commit

Permalink
Fixes for chat_info etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
solovieff committed Sep 29, 2024
1 parent d49d44f commit 4046bc9
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
24 changes: 15 additions & 9 deletions kibernikto/bots/cybernoone/_cybernoone.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,24 +66,26 @@ def _reset(self):
super()._reset()
wai = self.full_config.who_am_i.format(self.full_config.name)
if self.chat_info and self.add_chat_info:
conversation_information = self._generate_chat_info()
wai += f"\n{conversation_information}"
conversation_information = self._get_telegram_chat_info()
wai += f"\n[{conversation_information}]"
self.about_me = dict(role=OpenAIRoles.system.value, content=f"{wai}")

def _generate_chat_info(self):
def _get_telegram_chat_info(self):
if self.chat_info is None:
return ""
if self.chat_info.is_personal:
chat_descr_string = f"{self.chat_info.aiogram_user.full_name} ищет твоей мудрости, не стесняйся иногда называть по имени (на русском!). При обращении учитывай мужчина это или женщина!"
chat_descr_string = "Interlocutor info:\n"
chat_descr_string += f"Name: {self.chat_info.aiogram_user.full_name}."
if self.chat_info.bio:
chat_descr_string += f"В bio собеседника указано: {self.chat_info.bio}, учитывай это."
chat_descr_string += f"Bio: {self.chat_info.bio}."
if self.chat_info.birthday:
chat_descr_string += f"День рождения: {self.chat_info.birthday}."
chat_descr_string += f"Birthday: {self.chat_info.birthday}."
else:
chat_descr_string = f"Участники группы {self.chat_info.full_name} ищут твоей мудрости."
chat_descr_string = "Chat group info:\n"
chat_descr_string += f"Title: {self.chat_info.full_name}."
if self.chat_info.description:
chat_descr_string += f"В description указано: {self.chat_info.description}."
chat_descr_string = f"[{chat_descr_string}]"
chat_descr_string += f"Description: {self.chat_info.description}."
chat_descr_string = f"{chat_descr_string}"

# print(f"{self.__class__.__name__}: {chat_descr_string}")
return chat_descr_string
Expand All @@ -102,4 +104,8 @@ async def update_configuration(self, config_to_use: OpenAiExecutorConfig):
self.max_messages = config_to_use.max_messages
self.tools = config_to_use.tools

print(f'- {self.__class__.__name__} for "{self.chat_info.full_name}" (id: {self.full_config.id}) update!')
print(f'- {self.tools_names}')
print(f'- {self.model}')
print(f'- {self.full_config.who_am_i}')
self._reset()
4 changes: 4 additions & 0 deletions kibernikto/interactors/openai_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ def __init__(self,
def tools_definitions(self):
return [toolbox.definition for toolbox in self.tools]

@property
def tools_names(self):
return [toolbox.function_name for toolbox in self.tools]

def _get_tool_implementation(self, name):
for x in self.tools:
if x.function_name == name:
Expand Down
2 changes: 1 addition & 1 deletion kibernikto/telegram/telegram_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def __init__(self, aiogram_chat: Chat, aiogram_user: User = None):
self.bio = aiogram_chat.bio
self.description = aiogram_chat.description
self.business_intro = aiogram_chat.business_intro
self.birthday = aiogram_chat.birthdate
self.birthday = None
self.is_personal = aiogram_chat.type == ChatType.PRIVATE
self.id = aiogram_chat.id
if self.is_personal and not aiogram_user:
Expand Down
1 change: 1 addition & 0 deletions scripts/rebuild.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#to be put in the main bot directory
#!/bin/bash
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
CONTAINER_NAME=$1
Expand Down

0 comments on commit 4046bc9

Please sign in to comment.