praisonaiagents 0.0.26__py3-none-any.whl → 0.0.27__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.
@@ -18,6 +18,7 @@ from ..main import (
18
18
  client,
19
19
  error_logs
20
20
  )
21
+ import inspect
21
22
 
22
23
  if TYPE_CHECKING:
23
24
  from ..task.task import Task
@@ -67,9 +68,24 @@ class Agent:
67
68
  return None
68
69
 
69
70
  import inspect
71
+ # Langchain tools
72
+ if inspect.isclass(func) and hasattr(func, 'run'):
73
+ original_func = func
74
+ func = func.run
75
+ function_name = original_func.__name__
76
+
70
77
  sig = inspect.signature(func)
71
78
  logging.debug(f"Function signature: {sig}")
72
79
 
80
+ # Skip self, *args, **kwargs, so they don't get passed in arguments
81
+ parameters_list = []
82
+ for name, param in sig.parameters.items():
83
+ if name == "self":
84
+ continue
85
+ if param.kind in (inspect.Parameter.VAR_POSITIONAL, inspect.Parameter.VAR_KEYWORD):
86
+ continue
87
+ parameters_list.append((name, param))
88
+
73
89
  parameters = {
74
90
  "type": "object",
75
91
  "properties": {},
@@ -95,7 +111,7 @@ class Agent:
95
111
 
96
112
  logging.debug(f"Parameter descriptions: {param_descriptions}")
97
113
 
98
- for name, param in sig.parameters.items():
114
+ for name, param in parameters_list:
99
115
  param_type = "string" # Default type
100
116
  if param.annotation != inspect.Parameter.empty:
101
117
  if param.annotation == int:
@@ -249,25 +265,31 @@ Your Goal: {self.goal}
249
265
  # Try to find the function in the agent's tools list first
250
266
  func = None
251
267
  for tool in self.tools:
252
- if callable(tool) and getattr(tool, '__name__', '') == function_name:
268
+ if (callable(tool) and getattr(tool, '__name__', '') == function_name) or \
269
+ (inspect.isclass(tool) and tool.__name__ == function_name):
253
270
  func = tool
254
271
  break
255
272
 
256
- logging.debug(f"Looking for {function_name} in agent tools: {func is not None}")
257
-
258
- # If not found in tools, try globals and main
259
- if not func:
273
+ if func is None:
274
+ # If not found in tools, try globals and main
260
275
  func = globals().get(function_name)
261
- logging.debug(f"Looking for {function_name} in globals: {func is not None}")
262
-
263
276
  if not func:
264
277
  import __main__
265
278
  func = getattr(__main__, function_name, None)
266
- logging.debug(f"Looking for {function_name} in __main__: {func is not None}")
267
279
 
268
- if func and callable(func):
280
+ if func:
269
281
  try:
270
- return func(**arguments)
282
+ # If it's a class with run method, instantiate and call run
283
+ if inspect.isclass(func) and hasattr(func, 'run'):
284
+ instance = func()
285
+ # Extract only the parameters that run() expects
286
+ run_params = {k: v for k, v in arguments.items()
287
+ if k in inspect.signature(instance.run).parameters
288
+ and k != 'self'}
289
+ return instance.run(**run_params)
290
+ # Otherwise treat as regular function
291
+ elif callable(func):
292
+ return func(**arguments)
271
293
  except Exception as e:
272
294
  error_msg = str(e)
273
295
  logging.error(f"Error executing tool {function_name}: {error_msg}")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: praisonaiagents
3
- Version: 0.0.26
3
+ Version: 0.0.27
4
4
  Summary: Praison AI agents for completing complex tasks with Self Reflection Agents
5
5
  Author: Mervin Praison
6
6
  Requires-Dist: pydantic
@@ -1,7 +1,7 @@
1
1
  praisonaiagents/__init__.py,sha256=xJLN8i6V9SRmJFMxSRWDQt_hBePoupVd3WanNIgbBbc,1052
2
2
  praisonaiagents/main.py,sha256=7Phfe0gdxHzbhPb3WRzBTfq9CaLq0K31M5DM_4oCiCQ,12451
3
3
  praisonaiagents/agent/__init__.py,sha256=sKO8wGEXvtCrvV1e834r1Okv0XAqAxqZCqz6hKLiTvA,79
4
- praisonaiagents/agent/agent.py,sha256=3Y8-eaebjOEculRgiz5IobAf5oadBKEpvNWJE5qaa4A,32305
4
+ praisonaiagents/agent/agent.py,sha256=0nNGMoP_SO8sM2uR0-fXKx7d2-OxaMLft-a5Mo6o-8s,33273
5
5
  praisonaiagents/agents/__init__.py,sha256=7RDeQNSqZg5uBjD4M_0p_F6YgfWuDuxPFydPU50kDYc,120
6
6
  praisonaiagents/agents/agents.py,sha256=BikzgqE469uUg3OeiBBihpYzuK1RUvRaB_CTc3DPdOM,23589
7
7
  praisonaiagents/build/lib/praisonaiagents/__init__.py,sha256=Nqnn8clbgv-5l0PgxcTOldg8mkMKrFn4TvPL-rYUUGg,1
@@ -36,7 +36,7 @@ praisonaiagents/tools/wikipedia_tools.py,sha256=pGko-f33wqXgxJTv8db7TbizY5XnzBQR
36
36
  praisonaiagents/tools/xml_tools.py,sha256=iYTMBEk5l3L3ryQ1fkUnNVYK-Nnua2Kx2S0dxNMMs1A,17122
37
37
  praisonaiagents/tools/yaml_tools.py,sha256=uogAZrhXV9O7xvspAtcTfpKSQYL2nlOTvCQXN94-G9A,14215
38
38
  praisonaiagents/tools/yfinance_tools.py,sha256=nmzjS7G_5GqMQD4r867mt17dHg5xvtsYDDfOPh68SgE,8105
39
- praisonaiagents-0.0.26.dist-info/METADATA,sha256=G8cw1HxMSy0OyKcqyOTpF_5C4tHUwnkXtSBriAOzl6M,233
40
- praisonaiagents-0.0.26.dist-info/WHEEL,sha256=A3WOREP4zgxI0fKrHUG8DC8013e3dK3n7a6HDbcEIwE,91
41
- praisonaiagents-0.0.26.dist-info/top_level.txt,sha256=_HsRddrJ23iDx5TTqVUVvXG2HeHBL5voshncAMDGjtA,16
42
- praisonaiagents-0.0.26.dist-info/RECORD,,
39
+ praisonaiagents-0.0.27.dist-info/METADATA,sha256=PBOP4EDkaq4vlKhH8RUz-75vCuAgkIRhrxnMWy-CsDM,233
40
+ praisonaiagents-0.0.27.dist-info/WHEEL,sha256=A3WOREP4zgxI0fKrHUG8DC8013e3dK3n7a6HDbcEIwE,91
41
+ praisonaiagents-0.0.27.dist-info/top_level.txt,sha256=_HsRddrJ23iDx5TTqVUVvXG2HeHBL5voshncAMDGjtA,16
42
+ praisonaiagents-0.0.27.dist-info/RECORD,,