You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Running this code would give it a validation error:
import numpy as np
cf.run(
"Convert to np array: [1,2,3]",
result_type=str,
agents=[agent_name],
tools=[np.array],
)
{
"name": "ValidationError",
"message": "1 validation error for Task
tools
Value error, Invalid tool: <built-in function array> [type=value_error, input_value=[<built-in function array>], input_type=list]
For further information visit https://errors.pydantic.dev/2.9/v/value_error",
"stack": "---------------------------------------------------------------------------
ValidationError Traceback (most recent call last)
Cell In[18], line 1
----> 1 cf.run(
2 \"Convert to np array: [1,2,3]\",
3 result_type=str,
4 agents=[thinker],
5 tools=[np.array],
6 )
File ~/.local/lib/python3.12/site-packages/controlflow/run.py:109, in run(objective, turn_strategy, max_llm_calls, max_agent_turns, raise_on_failure, handlers, **task_kwargs)
99 def run(
100 objective: str,
101 *,
(...)
107 **task_kwargs,
108 ) -> Any:
--> 109 task = Task(objective=objective, **task_kwargs)
110 results = run_tasks(
111 tasks=[task],
112 raise_on_failure=raise_on_failure,
(...)
116 handlers=handlers,
117 )
118 return results[0]
File ~/.local/lib/python3.12/site-packages/controlflow/tasks/task.py:215, in Task.__init__(self, objective, user_access, **kwargs)
209 warnings.warn(
210 \"The `user_access` argument is deprecated. Use `interactive=True` instead.\",
211 DeprecationWarning,
212 )
213 kwargs[\"interactive\"] = True
--> 215 super().__init__(**kwargs)
217 # create dependencies to tasks passed in as depends_on
218 for task in self.depends_on:
File ~/.local/lib/python3.12/site-packages/pydantic/main.py:209, in BaseModel.__init__(self, **data)
207 # `__tracebackhide__` tells pytest and some other tools to omit this function from tracebacks
208 __tracebackhide__ = True
--> 209 validated_self = self.__pydantic_validator__.validate_python(data, self_instance=self)
210 if self is not validated_self:
211 warnings.warn(
212 'A custom validator is returning a value other than `self`.\
'
213 \"Returning anything other than `self` from a top level model validator isn't supported when validating via `__init__`.\
\"
214 'See the `model_validator` docs (https://docs.pydantic.dev/latest/concepts/validators/#model-validators) for more details.',
215 category=None,
216 )
ValidationError: 1 validation error for Task
tools
Value error, Invalid tool: <built-in function array> [type=value_error, input_value=[<built-in function array>], input_type=list]
For further information visit https://errors.pydantic.dev/2.9/v/value_error"
}
The same is true for built-in functions, like print, and functions import with from module import function
A workaround is creating a wrapper that just does the original imported function:
import numpy as np
def getarray(input):
return np.array(input)
cf.run(
"Convert to np array: [1,2,3]",
result_type=str,
agents=[agent_name],
tools=[getarray],
)
I was trying to add all modules from os to the run so the model can interact with my file system, but I stumbled upon this error. To do that I had to manually create 1-line functions that just wrap over the original which became tedious. Would love to see some fix/explanation to this.
Version Information
controlflow==0.10.0
pydantic==2.9.2
The text was updated successfully, but these errors were encountered:
Description
Running this code would give it a validation error:
The same is true for built-in functions, like
print
, and functions import withfrom module import function
A workaround is creating a wrapper that just does the original imported function:
I was trying to add all modules from
os
to the run so the model can interact with my file system, but I stumbled upon this error. To do that I had to manually create 1-line functions that just wrap over the original which became tedious. Would love to see some fix/explanation to this.Version Information
The text was updated successfully, but these errors were encountered: