aip-agents-binary 0.5.19__py3-none-any.whl → 0.5.21__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,47 @@
1
1
  """Initialize Tools Module for AIP Agents."""
2
2
 
3
+ from importlib import import_module
4
+ from typing import TYPE_CHECKING
5
+
3
6
  from aip_agents.tools.bosa_tools import BOSA_AUTOMATED_TOOLS
4
7
  from aip_agents.tools.gl_connector import GLConnectorTool
8
+ from aip_agents.tools.time_tool import TimeTool
9
+ from aip_agents.tools.web_search import GoogleSerperTool
10
+ from aip_agents.utils.logger import get_logger
11
+
12
+ logger = get_logger(__name__)
13
+
14
+ __all__ = ["BOSA_AUTOMATED_TOOLS", "GLConnectorTool", "GoogleSerperTool", "TimeTool"]
15
+
16
+
17
+ def _register_optional(module_path: str, export_name: str) -> None:
18
+ """Try to import optional tool module and expose it in __all__.
19
+
20
+ Args:
21
+ module_path: The module path to import.
22
+ export_name: The name to export in __all__.
23
+ """
24
+ try:
25
+ module = import_module(module_path)
26
+ tool = getattr(module, export_name)
27
+ __all__.append(export_name)
28
+ globals()[export_name] = tool
29
+
30
+ except ImportError as e:
31
+ logger.debug(f"Module {module_path} not found: {e}")
32
+ except AttributeError as e:
33
+ logger.debug(f"Tool {export_name} not found in module {module_path}: {e}")
34
+ except Exception as e:
35
+ logger.debug(f"Unexpected error loading {export_name}: {e}")
36
+
37
+
38
+ _register_optional("aip_agents.tools.browser_use", "BrowserUseTool")
39
+ _register_optional("aip_agents.tools.code_sandbox", "E2BCodeSandboxTool")
40
+ _register_optional("aip_agents.tools.document_loader", "DocxReaderTool")
41
+ _register_optional("aip_agents.tools.document_loader", "ExcelReaderTool")
42
+ _register_optional("aip_agents.tools.document_loader", "PDFReaderTool")
5
43
 
6
- __all__ = ["BOSA_AUTOMATED_TOOLS", "GLConnectorTool"]
44
+ if TYPE_CHECKING:
45
+ from aip_agents.tools.browser_use import BrowserUseTool
46
+ from aip_agents.tools.code_sandbox import E2BCodeSandboxTool
47
+ from aip_agents.tools.document_loader import DocxReaderTool, ExcelReaderTool, PDFReaderTool
@@ -1,4 +1,9 @@
1
1
  from aip_agents.tools.bosa_tools import BOSA_AUTOMATED_TOOLS as BOSA_AUTOMATED_TOOLS
2
+ from aip_agents.tools.browser_use import BrowserUseTool as BrowserUseTool
3
+ from aip_agents.tools.code_sandbox import E2BCodeSandboxTool as E2BCodeSandboxTool
4
+ from aip_agents.tools.document_loader import DocxReaderTool as DocxReaderTool, ExcelReaderTool as ExcelReaderTool, PDFReaderTool as PDFReaderTool
2
5
  from aip_agents.tools.gl_connector import GLConnectorTool as GLConnectorTool
6
+ from aip_agents.tools.time_tool import TimeTool as TimeTool
7
+ from aip_agents.tools.web_search import GoogleSerperTool as GoogleSerperTool
3
8
 
4
- __all__ = ['BOSA_AUTOMATED_TOOLS', 'GLConnectorTool']
9
+ __all__ = ['BOSA_AUTOMATED_TOOLS', 'GLConnectorTool', 'GoogleSerperTool', 'TimeTool', 'BrowserUseTool', 'E2BCodeSandboxTool', 'DocxReaderTool', 'ExcelReaderTool', 'PDFReaderTool']
@@ -0,0 +1,117 @@
1
+ """Tool to get the current time.
2
+
3
+ Authors:
4
+ Saul Sayers (saul.sayers@gdplabs.id)
5
+ """
6
+
7
+ import re
8
+ from datetime import datetime, timedelta, timezone, tzinfo
9
+
10
+ from dateutil import tz
11
+ from langchain_core.tools import BaseTool
12
+ from pydantic import BaseModel, Field
13
+
14
+ FORMAT_STRING = "%m/%d/%y %H:%M:%S"
15
+ DEFAULT_TIMEZONE = "UTC+7"
16
+
17
+
18
+ class TimeToolInput(BaseModel):
19
+ """Input schema for the TimeTool."""
20
+
21
+ datetime_format: str = Field(
22
+ default=FORMAT_STRING,
23
+ description="""
24
+ Optional datetime format string. Default: '%m/%d/%y %H:%M:%S'
25
+
26
+ Common format codes:
27
+ %Y: Year with century (2024)
28
+ %m: Month as number (01-12)
29
+ %d: Day of month (01-31)
30
+ %A: Full weekday name (Wednesday)
31
+ %a: Short weekday name (Wed)
32
+ %H: Hour (00-23)
33
+ %M: Minute (00-59)
34
+ %S: Second (00-59)
35
+ %Z: Timezone name
36
+ %j: Day of year (001-366)
37
+ %W: Week number (00-53, Monday first)
38
+ %U: Week number (00-53, Sunday first)
39
+ %c: Locale's date and time
40
+ %x: Locale's date
41
+ %X: Locale's time
42
+ """,
43
+ )
44
+ timezone: str | None = Field(
45
+ default=DEFAULT_TIMEZONE,
46
+ description="""
47
+ Optional timezone identifier. Supports IANA names (e.g., 'Asia/Jakarta')
48
+ or offsets (e.g., 'UTC+7', 'UTC-04:30'). Default: 'UTC+7' (Asia/Jakarta).
49
+ Highly recommended to be filled when getting the current time to ensure
50
+ the time is in the correct timezone.
51
+ """,
52
+ )
53
+
54
+
55
+ def _parse_timezone(timezone_value: str | None) -> tzinfo | None:
56
+ """Return a tzinfo instance for a given timezone string.
57
+
58
+ Args:
59
+ timezone_value: Timezone string (e.g., "UTC+7", "UTC-5:30") or None.
60
+
61
+ Returns:
62
+ tzinfo instance or None if invalid/None input.
63
+ """
64
+ if timezone_value is None:
65
+ return None
66
+
67
+ tz_string = timezone_value.strip()
68
+ if not tz_string:
69
+ return None
70
+
71
+ offset_match = re.fullmatch(r"UTC([+-])(\d{1,2})(?::?(\d{2}))?$", tz_string.upper())
72
+ if offset_match:
73
+ sign, hours_str, minutes_str = offset_match.groups()
74
+ hours = int(hours_str)
75
+ minutes = int(minutes_str) if minutes_str else 0
76
+ MAX_HOURS_OFFSET = 12
77
+ MINUTES_OFFSETS = [0, 30, 45]
78
+ if hours > MAX_HOURS_OFFSET or minutes not in MINUTES_OFFSETS:
79
+ raise ValueError(f"Invalid timezone offset: {timezone_value}")
80
+ delta = timedelta(hours=hours, minutes=minutes)
81
+ if sign == "-":
82
+ delta = -delta
83
+ return timezone(delta)
84
+
85
+ tzinfo = tz.gettz(tz_string)
86
+ if tzinfo is not None:
87
+ return tzinfo
88
+
89
+ raise ValueError(f"Unknown timezone: {timezone_value}")
90
+
91
+
92
+ class TimeTool(BaseTool):
93
+ """Tool to get the current time."""
94
+
95
+ name: str = "time_tool"
96
+ description: str = """
97
+ Useful for getting the current time in a specified format and timezone.
98
+ Default format: '%m/%d/%y %H:%M:%S' (e.g., '05/15/24 17:30:00')
99
+
100
+ Supports timezone specification to get the current time in any timezone.
101
+ It is highly recommended to specify a timezone to ensure accurate results.
102
+ """
103
+ args_schema: type[BaseModel] = TimeToolInput
104
+
105
+ def _run(self, datetime_format: str = FORMAT_STRING, timezone: str | None = DEFAULT_TIMEZONE) -> str:
106
+ """Get current time formatted according to the specified format and timezone.
107
+
108
+ Args:
109
+ datetime_format: Format string for datetime (default: ISO format).
110
+ timezone: Timezone string (default: UTC).
111
+
112
+ Returns:
113
+ Formatted datetime string.
114
+ """
115
+ tzinfo = _parse_timezone(timezone)
116
+ current_time = datetime.now(tz=tzinfo)
117
+ return current_time.strftime(datetime_format)
@@ -0,0 +1,16 @@
1
+ from langchain_core.tools import BaseTool
2
+ from pydantic import BaseModel
3
+
4
+ FORMAT_STRING: str
5
+ DEFAULT_TIMEZONE: str
6
+
7
+ class TimeToolInput(BaseModel):
8
+ """Input schema for the TimeTool."""
9
+ datetime_format: str
10
+ timezone: str | None
11
+
12
+ class TimeTool(BaseTool):
13
+ """Tool to get the current time."""
14
+ name: str
15
+ description: str
16
+ args_schema: type[BaseModel]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: aip-agents-binary
3
- Version: 0.5.19
3
+ Version: 0.5.21
4
4
  Summary: A library for managing agents in Gen AI applications.
5
5
  Author-email: Raymond Christopher <raymond.christopher@gdplabs.id>
6
6
  Requires-Python: <3.13,>=3.11
@@ -370,14 +370,16 @@ aip_agents/storage/providers/memory.py,sha256=Zd7QwYacEfaHLCpjvV3XaHSRulhfS464U0
370
370
  aip_agents/storage/providers/memory.pyi,sha256=NpsqKzboQGWtxtFV1ch_C3KT0KHOLyac6TtBgkLRgjI,2188
371
371
  aip_agents/storage/providers/object_storage.py,sha256=RlhXdaL1YTH9oqf7crvftsicHRxJlaLO3UgLPRCWlfg,6627
372
372
  aip_agents/storage/providers/object_storage.pyi,sha256=4pvDaNqhDleOm3ijMe_Yk3meBn2UCpLP9bKAH1l6C7w,2976
373
- aip_agents/tools/__init__.py,sha256=1-kGfOGy-z1k_FHcCT9UOTDGGhM6ik2W72dkGYdcpPk,227
374
- aip_agents/tools/__init__.pyi,sha256=JvKGI44VA6i7hwKM9NuUqudYYvxX5u4n2D2U7w3RP5k,221
373
+ aip_agents/tools/__init__.py,sha256=HoTjIH5o3xFwa5FYGugmwAhi7MXkBc0vf6IDG9qiOgU,1887
374
+ aip_agents/tools/__init__.pyi,sha256=-yGiktAQqVJt-nspG79nQWEUCplAT4v-TadqQQb4rRc,792
375
375
  aip_agents/tools/bosa_tools.py,sha256=Zu5hhHx2LCBtvw9A30wYf1x5v4DQiB6MxePh12J77a4,3516
376
376
  aip_agents/tools/bosa_tools.pyi,sha256=ZidEMjX8TfdlSzLicwJQDbyoet9LeRqH8NSUSZ2tM7o,1165
377
377
  aip_agents/tools/constants.py,sha256=YZJFHKJvU9XkRKG_9hOpZ9ZreMoMoBXjF3SNsN51WhI,5439
378
378
  aip_agents/tools/constants.pyi,sha256=_M2Hm3OoCke51rxH4Pei5TPufD1stvpBqsQzmyFHNCk,3528
379
379
  aip_agents/tools/memory_search_tool.py,sha256=ClXW6BEjZNHb6NHe44KxbwZ6GSGo7v7AUzaV99LMouc,679
380
380
  aip_agents/tools/memory_search_tool.pyi,sha256=kjUaPWFrUIHrCTla_7ccnEWUNb44v0ZHLxyKGLPyeWg,456
381
+ aip_agents/tools/time_tool.py,sha256=4m6PrLwLyyF-2UM7VqwhnyqPAWpbxub2SR1t6RIftkY,3849
382
+ aip_agents/tools/time_tool.pyi,sha256=veJnkeyD_rco2Jah-m_LbtsOgziECPheCLFabKeuDH8,390
381
383
  aip_agents/tools/tool_config_injector.py,sha256=gEOzukaC3KzU00IVCKyhjJUKy6o59ple2PXiwiib5Rw,10859
382
384
  aip_agents/tools/tool_config_injector.pyi,sha256=9m6SDm3cq9fm3BvL2E1Q4_h_Vt9kY3VANB9edDnY8x4,1081
383
385
  aip_agents/tools/browser_use/__init__.py,sha256=ARD9Y7nfd3uEUUbNIly97-Bib5RKrniWOQA_9WptbUY,2200
@@ -538,7 +540,7 @@ aip_agents/utils/pii/pii_helper.py,sha256=8QGVC9lb7dic_vSfLDUaDvqm45BUbYyPeQTVva
538
540
  aip_agents/utils/pii/pii_helper.pyi,sha256=wEgOasJxwKObtQ9Cb1UsiyIaqq2JUYmdRwOZR9PnIjA,3017
539
541
  aip_agents/utils/pii/uuid_deanonymizer_mapping.py,sha256=X9zeX1bhb3rlCc8P5QnbHCILx2AIhGmZwjsjh_2G4ZQ,7543
540
542
  aip_agents/utils/pii/uuid_deanonymizer_mapping.pyi,sha256=6H1xRV2Nr0LpP5K6fbz2uCobehTpM2626v8kiOd9W9Y,3157
541
- aip_agents_binary-0.5.19.dist-info/METADATA,sha256=evsObf3q80xbgQb8RkQNdYN3JWr6v5l9yGUbPU9molg,22888
542
- aip_agents_binary-0.5.19.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
543
- aip_agents_binary-0.5.19.dist-info/top_level.txt,sha256=PEz8vcwC1bH4UrkhF0LkIYCNfXGWZUHdSklbvkBe25E,11
544
- aip_agents_binary-0.5.19.dist-info/RECORD,,
543
+ aip_agents_binary-0.5.21.dist-info/METADATA,sha256=L2JUdnr6SuTg8JVn4SIKQyl7e7hko0OPrrNcCe9DEQ4,22888
544
+ aip_agents_binary-0.5.21.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
545
+ aip_agents_binary-0.5.21.dist-info/top_level.txt,sha256=PEz8vcwC1bH4UrkhF0LkIYCNfXGWZUHdSklbvkBe25E,11
546
+ aip_agents_binary-0.5.21.dist-info/RECORD,,