PraisonAI icon indicating copy to clipboard operation
PraisonAI copied to clipboard

error using tools

Open ciaotesla opened this issue 1 year ago • 0 comments

I am getting the following error: [16:01:23] INFO [16:01:23] agents.py:283 INFO Created manager task with ID 2 agents.py:283 INFO [16:01:23] agents.py:287 INFO Need to complete 2 tasks (excluding manager task) agents.py:287 INFO [16:01:23] agents.py:302 INFO Task 0 status: {'task_id': 0, 'name': 'research_task', 'description': 'Analyze YouTube videos title and description from YouTube agents.py:302 similar to mine to increase SEO, views and subscribers', 'status': 'not started', 'agent': 'Researcher'} INFO [16:01:23] agents.py:302 INFO Task 1 status: {'task_id': 1, 'name': 'writing_task', 'description': 'Create the most engaging Titles and Description for my YouTube agents.py:302 videos based on the research done on the topic of my video.', 'status': 'not started', 'agent': 'Writer'} INFO [16:01:23] agents.py:317 INFO Requesting manager instructions... agents.py:317 [16:11:23] INFO [16:11:23] _base_client.py:1089 INFO Retrying request to /chat/completions in 0.391922 seconds _base_client.py:1089 [16:20:44] INFO [16:20:44] _client.py:1038 INFO HTTP Request: POST http://localhost:11434/v1/chat/completions "HTTP/1.1 200 OK" _client.py:1038 ╭───────────────────────────────────────────────────────────────────────── Error ─────────────────────────────────────────────────────────────────────────╮ │ Manager parse error: 1 validation error for ManagerInstructions │ │ Invalid JSON: expected value at line 1 column 1 [type=json_invalid, input_value='To manage the tasks and ...t working on this task.', input_type=str] │ │ For further information visit https://errors.pydantic.dev/2.10/v/json_invalid │ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ERROR [16:20:44] agents.py:331 ERROR Manager parse error: 1 validation error for ManagerInstructions agents.py:331 Invalid JSON: expected value at line 1 column 1 [type=json_invalid, input_value='To manage the tasks and ...t working on this task.', input_type=str] For further information visit https://errors.pydantic.dev/2.10/v/json_invalid ╭──────────────────────────────────────────────────────────────── Traceback (most recent call last) ────────────────────────────────────────────────────────────────╮ │ /home/pi5/PraisonAI/lib/python3.11/site-packages/praisonaiagents/agents/agents.py:318 in run_all_tasks │ │ │ │ 315 │ │ │ │ │ │ 316 │ │ │ │ try: │ │ 317 │ │ │ │ │ logging.info("Requesting manager instructions...") │ │ ❱ 318 │ │ │ │ │ manager_response = client.beta.chat.completions.parse( │ │ 319 │ │ │ │ │ │ model=self.manager_llm, │ │ 320 │ │ │ │ │ │ messages=[ │ │ 321 │ │ │ │ │ │ │ {"role": "system", "content": manager_task.description}, │ │ │ │ /home/pi5/PraisonAI/lib/python3.11/site-packages/openai/resources/beta/chat/completions.py:160 in parse │ │ │ │ 157 │ │ │ │ input_tools=tools, │ │ 158 │ │ │ ) │ │ 159 │ │ │ │ ❱ 160 │ │ return self._post( │ │ 161 │ │ │ "/chat/completions", │ │ 162 │ │ │ body=maybe_transform( │ │ 163 │ │ │ │ { │ │ │ │ /home/pi5/PraisonAI/lib/python3.11/site-packages/openai/_base_client.py:1280 in post │ │ │ │ 1277 │ │ opts = FinalRequestOptions.construct( │ │ 1278 │ │ │ method="post", url=path, json_data=body, files=to_httpx_files(files), │ │ **options │ │ 1279 │ │ ) │ │ ❱ 1280 │ │ return cast(ResponseT, self.request(cast_to, opts, stream=stream, │ │ stream_cls=stream_cls)) │ │ 1281 │ │ │ 1282 │ def patch( │ │ 1283 │ │ self, │ │ │ │ /home/pi5/PraisonAI/lib/python3.11/site-packages/openai/_base_client.py:957 in request │ │ │ │ 954 │ │ else: │ │ 955 │ │ │ retries_taken = 0 │ │ 956 │ │ │ │ ❱ 957 │ │ return self._request( │ │ 958 │ │ │ cast_to=cast_to, │ │ 959 │ │ │ options=options, │ │ 960 │ │ │ stream=stream, │ │ │ │ /home/pi5/PraisonAI/lib/python3.11/site-packages/openai/_base_client.py:1002 in _request │ │ │ │ 999 │ │ │ log.debug("Encountered httpx.TimeoutException", exc_info=True) │ │ 1000 │ │ │ │ │ 1001 │ │ │ if remaining_retries > 0: │ │ ❱ 1002 │ │ │ │ return self._retry_request( │ │ 1003 │ │ │ │ │ input_options, │ │ 1004 │ │ │ │ │ cast_to, │ │ 1005 │ │ │ │ │ retries_taken=retries_taken, │ │ │ │ /home/pi5/PraisonAI/lib/python3.11/site-packages/openai/_base_client.py:1095 in _retry_request │ │ │ │ 1092 │ │ # different thread if necessary. │ │ 1093 │ │ time.sleep(timeout) │ │ 1094 │ │ │ │ ❱ 1095 │ │ return self._request( │ │ 1096 │ │ │ options=options, │ │ 1097 │ │ │ cast_to=cast_to, │ │ 1098 │ │ │ retries_taken=retries_taken + 1, │ │ │ │ /home/pi5/PraisonAI/lib/python3.11/site-packages/openai/_base_client.py:1063 in _request │ │ │ │ 1060 │ │ │ log.debug("Re-raising status error") │ │ 1061 │ │ │ raise self._make_status_error_from_response(err.response) from None │ │ 1062 │ │ │ │ ❱ 1063 │ │ return self._process_response( │ │ 1064 │ │ │ cast_to=cast_to, │ │ 1065 │ │ │ options=options, │ │ 1066 │ │ │ response=response, │ │ │ │ /home/pi5/PraisonAI/lib/python3.11/site-packages/openai/_base_client.py:1162 in _process_response │ │ │ │ 1159 │ │ if bool(response.request.headers.get(RAW_RESPONSE_HEADER)): │ │ 1160 │ │ │ return cast(ResponseT, api_response) │ │ 1161 │ │ │ │ ❱ 1162 │ │ return api_response.parse() │ │ 1163 │ │ │ 1164 │ def _request_api_list( │ │ 1165 │ │ self, │ │ │ │ /home/pi5/PraisonAI/lib/python3.11/site-packages/openai/_response.py:319 in parse │ │ │ │ 316 │ │ │ │ 317 │ │ parsed = self._parse(to=to) │ │ 318 │ │ if is_given(self._options.post_parser): │ │ ❱ 319 │ │ │ parsed = self._options.post_parser(parsed) │ │ 320 │ │ │ │ 321 │ │ if isinstance(parsed, BaseModel): │ │ 322 │ │ │ add_request_id(parsed, self.request_id) │ │ │ │ /home/pi5/PraisonAI/lib/python3.11/site-packages/openai/resources/beta/chat/completions.py:154 in parser │ │ │ │ 151 │ │ } │ │ 152 │ │ │ │ 153 │ │ def parser(raw_completion: ChatCompletion) -> │ │ ParsedChatCompletion[ResponseFormatT]: │ │ ❱ 154 │ │ │ return _parse_chat_completion( │ │ 155 │ │ │ │ response_format=response_format, │ │ 156 │ │ │ │ chat_completion=raw_completion, │ │ 157 │ │ │ │ input_tools=tools, │ │ │ │ /home/pi5/PraisonAI/lib/python3.11/site-packages/openai/lib/_parsing/_completions.py:110 in parse_chat_completion │ │ │ │ 107 │ │ │ │ │ **choice.to_dict(), │ │ 108 │ │ │ │ │ "message": { │ │ 109 │ │ │ │ │ │ **message.to_dict(), │ │ ❱ 110 │ │ │ │ │ │ "parsed": maybe_parse_content( │ │ 111 │ │ │ │ │ │ │ response_format=response_format, │ │ 112 │ │ │ │ │ │ │ message=message, │ │ 113 │ │ │ │ │ │ ), │ │ │ │ /home/pi5/PraisonAI/lib/python3.11/site-packages/openai/lib/_parsing/_completions.py:161 in maybe_parse_content │ │ │ │ 158 │ message: ChatCompletionMessage | ParsedChatCompletionMessage[object], │ │ 159 ) -> ResponseFormatT | None: │ │ 160 │ if has_rich_response_format(response_format) and message.content is not None and not │ │ message.refusal: │ │ ❱ 161 │ │ return _parse_content(response_format, message.content) │ │ 162 │ │ │ 163 │ return None │ │ 164 │ │ │ │ /home/pi5/PraisonAI/lib/python3.11/site-packages/openai/lib/_parsing/_completions.py:221 in _parse_content │ │ │ │ 218 │ │ 219 def _parse_content(response_format: type[ResponseFormatT], content: str) -> │ │ ResponseFormatT: │ │ 220 │ if is_basemodel_type(response_format): │ │ ❱ 221 │ │ return cast(ResponseFormatT, model_parse_json(response_format, content)) │ │ 222 │ │ │ 223 │ if is_dataclass_like_type(response_format): │ │ 224 │ │ if not PYDANTIC_V2: │ │ │ │ /home/pi5/PraisonAI/lib/python3.11/site-packages/openai/_compat.py:169 in model_parse_json │ │ │ │ 166 │ │ 167 def model_parse_json(model: type[_ModelT], data: str | bytes) -> _ModelT: │ │ 168 │ if PYDANTIC_V2: │ │ ❱ 169 │ │ return model.model_validate_json(data) │ │ 170 │ return model.parse_raw(data) # pyright: ignore[reportDeprecated] │ │ 171 │ │ 172 │ │ │ │ /home/pi5/PraisonAI/lib/python3.11/site-packages/pydantic/main.py:656 in model_validate_json │ │ │ │ 653 │ │ """ │ │ 654 │ │ # tracebackhide tells pytest and some other tools to omit this function │ │ from tracebacks │ │ 655 │ │ __tracebackhide__ = True │ │ ❱ 656 │ │ return cls.__pydantic_validator__.validate_json(json_data, strict=strict, │ │ context=context) │ │ 657 │ │ │ 658 │ @classmethod │ │ 659 │ def model_validate_strings( │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ValidationError: 1 validation error for ManagerInstructions Invalid JSON: expected value at line 1 column 1 [type=json_invalid, input_value='To manage the tasks and ...t working on this task.', input_type=str] For further information visit https://errors.pydantic.dev/2.10/v/json_invalid [16:20:45] INFO [16:20:45] agents.py:368 INFO All tasks completed under manager supervision. agents.py:368 INFO [16:20:45] agents.py:369 INFO Hierarchical task execution finished

and using the example in the code I just added the YouTube search tool: tools="YoutubeChannelSearchTool, YouTubeSearchTool",

Is there any other changes I need to make? thx

ciaotesla avatar Dec 30 '24 16:12 ciaotesla