kyegomez / swarms

The Enterprise-Grade Production-Ready Multi-Agent Orchestration Framework Join our Community: https://discord.com/servers/agora-999382051935506503
https://docs.swarms.world
Other
1.2k stars 173 forks source link

[BUG] Agent with Long Term Memory ++ Tools #508

Open evelynmitchell opened 3 months ago

evelynmitchell commented 3 months ago

In colab, after installing chromadb, running the Agent with Long Term Memory ++ Tools example:


ChromaDB collection created: results with metric: cosine and output directory: results
Traversing directory: docs
2024-06-25T00:38:18.631828+0000 Tools provided make sure the functions have documentation ++ type hints, otherwise tool execution won't be reliable.
2024-06-25T00:38:18.635862+0000 Tools granted, initializing tool protocol.
2024-06-25T00:38:18.636406+0000 Number of tools: 1
2024-06-25T00:38:18.637085+0000 Tool -> OpenAI Schema Process Starting Now.
2024-06-25T00:38:18.641185+0000 There was an error converting your tool into a OpenAI certified function calling schema. Add documentation and type hints: 1 validation error for Function
description
  Input should be a valid string [type=string_type, input_value=None, input_type=NoneType]
    For further information visit https://errors.pydantic.dev/2.7/v/string_type
2024-06-25T00:38:18.642498+0000 Error detected: 1 validation error for Function
description
  Input should be a valid string [type=string_type, input_value=None, input_type=NoneType]
    For further information visit https://errors.pydantic.dev/2.7/v/string_type make sure you have inputted a callable and that it has documentation as docstrings
---------------------------------------------------------------------------
ValidationError                           Traceback (most recent call last)
[<ipython-input-7-b98c3025d47c>](https://localhost:8080/#) in <cell line: 195>()
    193 
    194 # Initializing the agent with the Gemini instance and other parameters
--> 195 agent = Agent(
    196     agent_name="Covid-19-Chat",
    197     agent_description=(

5 frames
[/usr/local/lib/python3.10/dist-packages/swarms/structs/agent.py](https://localhost:8080/#) in __init__(self, id, llm, template, max_loops, stopping_condition, loop_interval, retry_attempts, retry_interval, return_history, stopping_token, dynamic_loops, interactive, dashboard, agent_name, agent_description, system_prompt, tools, dynamic_temperature_enabled, sop, sop_list, saved_state_path, autosave, context_length, user_name, self_healing_enabled, code_interpreter, multi_modal, pdf_path, list_of_pdf, tokenizer, long_term_memory, preset_stopping_token, traceback, traceback_handlers, streaming_on, docs, docs_folder, verbose, parser, best_of_n, callback, metadata, callbacks, logger_handler, search_algorithm, logs_to_filename, evaluator, output_json, stopping_func, custom_loop_condition, sentiment_threshold, custom_exit_command, sentiment_analyzer, limit_tokens_from_string, custom_tools_prompt, tool_schema, output_type, function_calling_type, output_cleaner, function_calling_format_type, list_base_models, metadata_output_type, state_save_file_type, chain_of_thoughts, algorithm_of_thoughts, tree_of_thoughts, tool_choice, execute_tool, rules, planning, planning_prompt, device, custom_planning_prompt, memory_chunk_size, agent_ops_on, *args, **kwargs)
    425 
    426             # Transform the tools into an openai schema
--> 427             self.convert_tool_into_openai_schema()
    428 
    429             # Now create a function calling map for every tools

[/usr/local/lib/python3.10/dist-packages/swarms/structs/agent.py](https://localhost:8080/#) in convert_tool_into_openai_schema(self)
   1702                 f"Error detected: {error} make sure you have inputted a callable and that it has documentation as docstrings"
   1703             )
-> 1704             raise error
   1705 
   1706     def memory_query(self, task: str = None, *args, **kwargs):

[/usr/local/lib/python3.10/dist-packages/swarms/structs/agent.py](https://localhost:8080/#) in convert_tool_into_openai_schema(self)
   1697                         f"There was an error converting your tool into a OpenAI certified function calling schema. Add documentation and type hints: {error}"
   1698                     )
-> 1699                     raise error
   1700         except Exception as error:
   1701             logger.info(

[/usr/local/lib/python3.10/dist-packages/swarms/structs/agent.py](https://localhost:8080/#) in convert_tool_into_openai_schema(self)
   1675                     )
   1676                     tool_schema_list = (
-> 1677                         get_openai_function_schema_from_func(
   1678                             tool, name=name, description=description
   1679                         )

[/usr/local/lib/python3.10/dist-packages/swarms/tools/py_func_to_openai_func_str.py](https://localhost:8080/#) in get_openai_function_schema_from_func(function, name, description)
    445 
    446     function = ToolFunction(
--> 447         function=Function(
    448             description=description,
    449             name=fname,

[/usr/local/lib/python3.10/dist-packages/pydantic/main.py](https://localhost:8080/#) in __init__(self, **data)
    174         # `__tracebackhide__` tells pytest and some other tools to omit this function from tracebacks
    175         __tracebackhide__ = True
--> 176         self.__pydantic_validator__.validate_python(data, self_instance=self)
    177 
    178     # The following line sets a flag that we use to determine when `__init__` gets overridden by the user

ValidationError: 1 validation error for Function
description
  Input should be a valid string [type=string_type, input_value=None, input_type=NoneType]
    For further information visit https://errors.pydantic.dev/2.7/v/string_typeChromaDB collection created: results with metric: cosine and output directory: results
Traversing directory: docs
2024-06-25T00:38:18.631828+0000 Tools provided make sure the functions have documentation ++ type hints, otherwise tool execution won't be reliable.
2024-06-25T00:38:18.635862+0000 Tools granted, initializing tool protocol.
2024-06-25T00:38:18.636406+0000 Number of tools: 1
2024-06-25T00:38:18.637085+0000 Tool -> OpenAI Schema Process Starting Now.
2024-06-25T00:38:18.641185+0000 There was an error converting your tool into a OpenAI certified function calling schema. Add documentation and type hints: 1 validation error for Function
description
  Input should be a valid string [type=string_type, input_value=None, input_type=NoneType]
    For further information visit https://errors.pydantic.dev/2.7/v/string_type
2024-06-25T00:38:18.642498+0000 Error detected: 1 validation error for Function
description
  Input should be a valid string [type=string_type, input_value=None, input_type=NoneType]
    For further information visit https://errors.pydantic.dev/2.7/v/string_type make sure you have inputted a callable and that it has documentation as docstrings
---------------------------------------------------------------------------
ValidationError                           Traceback (most recent call last)
[<ipython-input-7-b98c3025d47c>](https://localhost:8080/#) in <cell line: 195>()
    193 
    194 # Initializing the agent with the Gemini instance and other parameters
--> 195 agent = Agent(
    196     agent_name="Covid-19-Chat",
    197     agent_description=(

5 frames
[/usr/local/lib/python3.10/dist-packages/swarms/structs/agent.py](https://localhost:8080/#) in __init__(self, id, llm, template, max_loops, stopping_condition, loop_interval, retry_attempts, retry_interval, return_history, stopping_token, dynamic_loops, interactive, dashboard, agent_name, agent_description, system_prompt, tools, dynamic_temperature_enabled, sop, sop_list, saved_state_path, autosave, context_length, user_name, self_healing_enabled, code_interpreter, multi_modal, pdf_path, list_of_pdf, tokenizer, long_term_memory, preset_stopping_token, traceback, traceback_handlers, streaming_on, docs, docs_folder, verbose, parser, best_of_n, callback, metadata, callbacks, logger_handler, search_algorithm, logs_to_filename, evaluator, output_json, stopping_func, custom_loop_condition, sentiment_threshold, custom_exit_command, sentiment_analyzer, limit_tokens_from_string, custom_tools_prompt, tool_schema, output_type, function_calling_type, output_cleaner, function_calling_format_type, list_base_models, metadata_output_type, state_save_file_type, chain_of_thoughts, algorithm_of_thoughts, tree_of_thoughts, tool_choice, execute_tool, rules, planning, planning_prompt, device, custom_planning_prompt, memory_chunk_size, agent_ops_on, *args, **kwargs)
    425 
    426             # Transform the tools into an openai schema
--> 427             self.convert_tool_into_openai_schema()
    428 
    429             # Now create a function calling map for every tools

[/usr/local/lib/python3.10/dist-packages/swarms/structs/agent.py](https://localhost:8080/#) in convert_tool_into_openai_schema(self)
   1702                 f"Error detected: {error} make sure you have inputted a callable and that it has documentation as docstrings"
   1703             )
-> 1704             raise error
   1705 
   1706     def memory_query(self, task: str = None, *args, **kwargs):

[/usr/local/lib/python3.10/dist-packages/swarms/structs/agent.py](https://localhost:8080/#) in convert_tool_into_openai_schema(self)
   1697                         f"There was an error converting your tool into a OpenAI certified function calling schema. Add documentation and type hints: {error}"
   1698                     )
-> 1699                     raise error
   1700         except Exception as error:
   1701             logger.info(

[/usr/local/lib/python3.10/dist-packages/swarms/structs/agent.py](https://localhost:8080/#) in convert_tool_into_openai_schema(self)
   1675                     )
   1676                     tool_schema_list = (
-> 1677                         get_openai_function_schema_from_func(
   1678                             tool, name=name, description=description
   1679                         )

[/usr/local/lib/python3.10/dist-packages/swarms/tools/py_func_to_openai_func_str.py](https://localhost:8080/#) in get_openai_function_schema_from_func(function, name, description)
    445 
    446     function = ToolFunction(
--> 447         function=Function(
    448             description=description,
    449             name=fname,

[/usr/local/lib/python3.10/dist-packages/pydantic/main.py](https://localhost:8080/#) in __init__(self, **data)
    174         # `__tracebackhide__` tells pytest and some other tools to omit this function from tracebacks
    175         __tracebackhide__ = True
--> 176         self.__pydantic_validator__.validate_python(data, self_instance=self)
    177 
    178     # The following line sets a flag that we use to determine when `__init__` gets overridden by the user

ValidationError: 1 validation error for Function
description
  Input should be a valid string [type=string_type, input_value=None, input_type=NoneType]
    For further information visit https://errors.pydantic.dev/2.7/v/string_type```

<!-- POLAR PLEDGE BADGE START -->
## Upvote & Fund

- We're using [Polar.sh](https://polar.sh/kyegomez) so you can upvote and help fund this issue.
- We receive the funding once the issue is completed & confirmed by you.
- Thank you in advance for helping prioritize & fund our backlog.

<a href="https://polar.sh/kyegomez/swarms/issues/508">
<picture>
  <source media="(prefers-color-scheme: dark)" srcset="https://polar.sh/api/github/kyegomez/swarms/issues/508/pledge.svg?darkmode=1">
  <img alt="Fund with Polar" src="https://polar.sh/api/github/kyegomez/swarms/issues/508/pledge.svg">
</picture>
</a>
<!-- POLAR PLEDGE BADGE END -->
evelynmitchell commented 3 months ago

I believe this is failing because there is no docs dir, and it is empty.