Skip to content

Commit

Permalink
Merge branch 'fix/chore-fix' into dev/plugin-deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
Yeuoly committed Nov 15, 2024
1 parent cc28daf commit 59b7690
Show file tree
Hide file tree
Showing 12 changed files with 17,307 additions and 15,329 deletions.
7 changes: 0 additions & 7 deletions api/core/tools/builtin_tool/providers/qrcode/_assets/icon.svg

This file was deleted.

8 changes: 0 additions & 8 deletions api/core/tools/builtin_tool/providers/qrcode/qrcode.py

This file was deleted.

14 changes: 0 additions & 14 deletions api/core/tools/builtin_tool/providers/qrcode/qrcode.yaml

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from datetime import datetime, timezone
from typing import Any, Union
from typing import Any, Optional, Union

from pytz import timezone as pytz_timezone

Expand All @@ -12,6 +12,9 @@ def _invoke(
self,
user_id: str,
tool_parameters: dict[str, Any],
conversation_id: Optional[str] = None,
app_id: Optional[str] = None,
message_id: Optional[str] = None,
) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
"""
invoke tools
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from datetime import datetime
from typing import Any, Union
from typing import Any, Optional, Union

import pytz

Expand All @@ -13,6 +13,9 @@ def _invoke(
self,
user_id: str,
tool_parameters: dict[str, Any],
conversation_id: Optional[str] = None,
app_id: Optional[str] = None,
message_id: Optional[str] = None,
) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
"""
Convert localtime to timestamp
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from datetime import datetime
from typing import Any, Union
from typing import Any, Optional, Union

import pytz

Expand All @@ -13,6 +13,9 @@ def _invoke(
self,
user_id: str,
tool_parameters: dict[str, Any],
conversation_id: Optional[str] = None,
app_id: Optional[str] = None,
message_id: Optional[str] = None,
) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
"""
Convert timestamp to localtime
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from datetime import datetime
from typing import Any, Union
from typing import Any, Optional, Union

import pytz

Expand All @@ -13,6 +13,9 @@ def _invoke(
self,
user_id: str,
tool_parameters: dict[str, Any],
conversation_id: Optional[str] = None,
app_id: Optional[str] = None,
message_id: Optional[str] = None,
) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
"""
Convert time to equivalent time zone
Expand Down
5 changes: 4 additions & 1 deletion api/core/tools/builtin_tool/providers/time/tools/weekday.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import calendar
from datetime import datetime
from typing import Any, Union
from typing import Any, Optional, Union

from core.tools.builtin_tool.tool import BuiltinTool
from core.tools.entities.tool_entities import ToolInvokeMessage
Expand All @@ -11,6 +11,9 @@ def _invoke(
self,
user_id: str,
tool_parameters: dict[str, Any],
conversation_id: Optional[str] = None,
app_id: Optional[str] = None,
message_id: Optional[str] = None,
) -> Union[ToolInvokeMessage, list[ToolInvokeMessage]]:
"""
Calculate the day of the week for a given date
Expand Down
12 changes: 7 additions & 5 deletions api/core/tools/tool_engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,16 @@ def message_callback(
conversation_id=message.conversation_id,
)

message_list = list(messages)

# extract binary data from tool invoke message
binary_files = ToolEngine._extract_tool_response_binary(messages)
binary_files = ToolEngine._extract_tool_response_binary_and_text(message_list)
# create message file
message_files = ToolEngine._create_message_files(
tool_messages=binary_files, agent_message=message, invoke_from=invoke_from, user_id=user_id
)

plain_text = ToolEngine._convert_tool_response_to_str(messages)
plain_text = ToolEngine._convert_tool_response_to_str(message_list)

meta = invocation_meta_dict["meta"]

Expand Down Expand Up @@ -219,7 +221,7 @@ def _invoke(
yield meta

@staticmethod
def _convert_tool_response_to_str(tool_response: Generator[ToolInvokeMessage, None, None]) -> str:
def _convert_tool_response_to_str(tool_response: list[ToolInvokeMessage]) -> str:
"""
Handle tool response
"""
Expand All @@ -246,8 +248,8 @@ def _convert_tool_response_to_str(tool_response: Generator[ToolInvokeMessage, No
return result

@staticmethod
def _extract_tool_response_binary(
tool_response: Generator[ToolInvokeMessage, None, None],
def _extract_tool_response_binary_and_text(
tool_response: list[ToolInvokeMessage],
) -> Generator[ToolInvokeMessageBinary, None, None]:
"""
Extract tool response binary
Expand Down
Loading

0 comments on commit 59b7690

Please sign in to comment.