quantalogic 0.50.3__py3-none-any.whl → 0.50.5__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,28 +1,31 @@
1
1
  """Tool for interacting with Composio API services."""
2
2
 
3
+ import importlib
4
+ import importlib.util
3
5
  import json
4
6
  import os
5
7
  import traceback
6
8
  from datetime import datetime
7
- from typing import Any, Dict, Optional, Union
9
+ from typing import Any, Dict, Optional, Union, TYPE_CHECKING
10
+
11
+ # Type checking imports - these are only used for type hints and not at runtime
12
+ if TYPE_CHECKING:
13
+ from composio import ComposioToolSet
8
14
 
9
15
  from loguru import logger
10
16
  from pydantic import BaseModel, ConfigDict, Field
11
17
 
12
- # Try to import composio, but don't fail if it's not installed
18
+ from quantalogic.tools.tool import Tool, ToolArgument
19
+
20
+ # Flag to check if composio is available
21
+ COMPOSIO_AVAILABLE = False
22
+
23
+ # Try to check if composio is importable without actually importing it
13
24
  try:
14
- from composio import Action, ComposioToolSet
15
- COMPOSIO_AVAILABLE = True
25
+ spec = importlib.util.find_spec("composio")
26
+ COMPOSIO_AVAILABLE = spec is not None
16
27
  except ImportError:
17
- logger.warning("composio module not installed. ComposioTool will not be available.")
18
- COMPOSIO_AVAILABLE = False
19
- # Create dummy classes to avoid errors
20
- class Action:
21
- pass
22
- class ComposioToolSet:
23
- pass
24
-
25
- from quantalogic.tools.tool import Tool, ToolArgument
28
+ pass
26
29
 
27
30
 
28
31
  def setup_logger():
@@ -84,7 +87,7 @@ class ComposioTool(Tool):
84
87
  )
85
88
  action: str = Field(default="") # Single action per tool instance
86
89
  action_schema: Optional[ActionSchema] = None
87
- toolset: Optional[ComposioToolSet] = None
90
+ toolset: Optional['ComposioToolSet'] = None
88
91
 
89
92
  # Performance tracking
90
93
  _last_execution_time: Optional[datetime] = None
@@ -113,6 +116,14 @@ class ComposioTool(Tool):
113
116
  logger.error("ComposioTool cannot be initialized: composio module is not installed")
114
117
  raise ImportError("The 'composio' package is required to use ComposioTool. "
115
118
  "Install it with 'pip install composio' or include it in your dependencies.")
119
+
120
+ # Import composio only when needed
121
+ try:
122
+ from composio import Action, ComposioToolSet
123
+ except ImportError:
124
+ logger.error("Failed to import composio module")
125
+ raise ImportError("The 'composio' package is required to use ComposioTool. "
126
+ "Install it with 'pip install composio' or include it in your dependencies.")
116
127
 
117
128
  logger.info(f"Initializing ComposioTool for action: {action}")
118
129
  start_time = datetime.now()
@@ -168,6 +179,14 @@ class ComposioTool(Tool):
168
179
 
169
180
  def _setup_action(self) -> None:
170
181
  """Set up the Composio action with its schema and parameters."""
182
+ # Import composio only when needed
183
+ try:
184
+ from composio import Action, ComposioToolSet
185
+ except ImportError:
186
+ logger.error("Failed to import composio module")
187
+ raise ImportError("The 'composio' package is required to use ComposioTool. "
188
+ "Install it with 'pip install composio' or include it in your dependencies.")
189
+
171
190
  logger.debug(f"Setting up action: {self.action}")
172
191
  start_time = datetime.now()
173
192
 
@@ -363,6 +382,14 @@ class ComposioTool(Tool):
363
382
 
364
383
  def execute(self, **kwargs: Any) -> str:
365
384
  """Execute the Composio action with the given parameters."""
385
+ # Import composio only when needed
386
+ try:
387
+ from composio import Action, ComposioToolSet
388
+ except ImportError:
389
+ logger.error("Failed to import composio module")
390
+ raise ImportError("The 'composio' package is required to use ComposioTool. "
391
+ "Install it with 'pip install composio' or include it in your dependencies.")
392
+
366
393
  start_time = datetime.now()
367
394
  self._execution_count += 1
368
395
  self._last_execution_time = start_time
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: quantalogic
3
- Version: 0.50.3
3
+ Version: 0.50.5
4
4
  Summary: QuantaLogic ReAct Agents
5
5
  Author: Raphaël MANSUY
6
6
  Author-email: raphael.mansuy@gmail.com
@@ -40,7 +40,7 @@ quantalogic/task_runner.py,sha256=c2QVGKZfHA0wZIBUvehpjMvtRaKZuhuYQerjIiCC9iY,10
40
40
  quantalogic/tool_manager.py,sha256=vNA7aBKgdU3wpw_goom6i9rg_64pNZapNxvg4cUhhCI,6983
41
41
  quantalogic/tools/__init__.py,sha256=Hpgt8RslYAwAfaKYunTFz_tsNdIZUXH5ovssNZu0H0c,5142
42
42
  quantalogic/tools/agent_tool.py,sha256=MXCXxWHRch7VK4UWhtRP1jeI8Np9Ne2CUGo8vm1oZiM,3064
43
- quantalogic/tools/composio/composio.py,sha256=1FJ8lyZUslQpewX7WUF-sanF0f52gmL0-ZQFBXkiqaE,18373
43
+ quantalogic/tools/composio/composio.py,sha256=l12notWc2okQYq_vrXRirLZyfc4WiTwY1AyLP96qidQ,19657
44
44
  quantalogic/tools/database/generate_database_report_tool.py,sha256=lGgER2VuHqnxliPM806tbwJh7WRW9HJcbBLL7QMvVBQ,1861
45
45
  quantalogic/tools/database/sql_query_tool_advanced.py,sha256=Vale-5nR3e-Mm4joOBII8T1PbLcshXYbM8Mp4TJsS30,9425
46
46
  quantalogic/tools/document_tools/markdown_to_docx_tool.py,sha256=r5AOyQfpcDoqQ6_g2uYyVjTEPtfeNn4mDmmefNZmJyM,22553
@@ -141,8 +141,8 @@ quantalogic/version_check.py,sha256=JyQFTNMDWtpHCLnN-BiakzB2cyXf6kUFsTjvmSruZi4,
141
141
  quantalogic/welcome_message.py,sha256=o4tHdgabNuIV9kbIDPgS3_2yzJhayK30oKad2UouYDc,3020
142
142
  quantalogic/xml_parser.py,sha256=AKuMdJC3QAX3Z_tErHVlZ-msjPemWaZUFiTwkHz76jg,11614
143
143
  quantalogic/xml_tool_parser.py,sha256=Vz4LEgDbelJynD1siLOVkJ3gLlfHsUk65_gCwbYJyGc,3784
144
- quantalogic-0.50.3.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
145
- quantalogic-0.50.3.dist-info/METADATA,sha256=8yPjleuhCSPRiv7lwPRB5vObHFWMyrU0Ih7A4W2PA1Y,22785
146
- quantalogic-0.50.3.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
147
- quantalogic-0.50.3.dist-info/entry_points.txt,sha256=h74O_Q3qBRCrDR99qvwB4BpBGzASPUIjCfxHq6Qnups,183
148
- quantalogic-0.50.3.dist-info/RECORD,,
144
+ quantalogic-0.50.5.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
145
+ quantalogic-0.50.5.dist-info/METADATA,sha256=CfJryWRRsudR8N1CYEcEpizlRo438fLxRTCCeVdIk9Q,22785
146
+ quantalogic-0.50.5.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
147
+ quantalogic-0.50.5.dist-info/entry_points.txt,sha256=h74O_Q3qBRCrDR99qvwB4BpBGzASPUIjCfxHq6Qnups,183
148
+ quantalogic-0.50.5.dist-info/RECORD,,