From eebc59b36e81881f048f5b04370679e65b71be9b Mon Sep 17 00:00:00 2001 From: asolovieff Date: Fri, 2 Aug 2024 22:48:38 +0700 Subject: [PATCH] Multiple tools calls in a raw. --- kibernikto/interactors/openai_executor.py | 5 +++-- kibernikto/telegram/telegram_bot.py | 1 - 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/kibernikto/interactors/openai_executor.py b/kibernikto/interactors/openai_executor.py index d954d76..a41fd8e 100644 --- a/kibernikto/interactors/openai_executor.py +++ b/kibernikto/interactors/openai_executor.py @@ -259,6 +259,7 @@ async def process_tool_calls(self, choice: Choice, original_request_text: str, s if not choice.message.tool_calls: raise ValueError("No tools provided!") message_dict = None + tool_call_messages = [] for tool_call in choice.message.tool_calls: fn_name = tool_call.function.name function_impl = self._get_tool_implementation(fn_name) @@ -269,8 +270,8 @@ async def process_tool_calls(self, choice: Choice, original_request_text: str, s additional_params=additional_params) message_dict = dict(content=f"{original_request_text}", role=OpenAIRoles.user.value) prompt.append(message_dict) - tool_call_messages = ai_tools.get_tool_call_serving_messages(tool_call, tool_call_result, - xml=self.xml_tools) + tool_call_messages += ai_tools.get_tool_call_serving_messages(tool_call, tool_call_result, + xml=self.xml_tools) choice, usage = await self._run_for_messages(full_prompt=prompt + tool_call_messages) response_message: ChatCompletionMessage = choice.message diff --git a/kibernikto/telegram/telegram_bot.py b/kibernikto/telegram/telegram_bot.py index 8d070d0..2f4bb27 100644 --- a/kibernikto/telegram/telegram_bot.py +++ b/kibernikto/telegram/telegram_bot.py @@ -19,7 +19,6 @@ def __init__(self, aiogram_chat: Chat, aiogram_user: User = None): self.aiogram_user = aiogram_user - class TelegramBot(OpenAIExecutor): def __init__(self, config: OpenAiExecutorConfig, master_id, username, key=NOT_GIVEN, chat_info: KiberniktoChatInfo = None):