crewAIInc / crewAI

Framework for orchestrating role-playing, autonomous AI agents. By fostering collaborative intelligence, CrewAI empowers agents to work together seamlessly, tackling complex tasks.
https://crewai.com
MIT License
19.1k stars 2.64k forks source link

I keep on getting invalid path when trying to execute my crew on windows. Any help would be appreciated. I'm using Version: 0.35.8 #944

Open jm101093 opened 1 month ago

jm101093 commented 1 month ago

I keep on getting invalid path when trying to execute my crew on windows. Full error below. Any help would be appreciated. I'm using Version: 0.35.8. Thanks in advance.

I have been troubleshooting it and i think I may have narrowed it down to the \Lib\site-packages\crewai\utilities\paths.py Not sure if I'm on the right track. it created folders in the project file but with names from the conda environment when I sanitize the inputs.

@staticmethod
    def sanitize_path(path):
    # Remove or replace invalid characters
     sanitized = re.sub(r'[<>:"/\\|?*\n\r\t{}]', '_', str(path))
    # Ensure the path doesn't end with a space or period
     return Path(sanitized.rstrip('. '))
    # Set environment variables for storage
    os.environ["CREWAI_STORAGE_DIR"] = str(Path.home() )
    os.environ["CHROMADB_DIR"] = str(Path.home())
File "<string>", line 1, in <module>
      File "E:\AI Projects\firstnew\src\firstnew\main.py", line 11, in run
        FirstnewCrew().crew().kickoff(inputs=inputs)
        ^^^^^^^^^^^^^^^^^^^^^
      File "C:\Users\jklre\.conda\envs\crewai1\Lib\site-packages\crewai\project\annotations.py", line 80, in wrapper
        return func(self, *args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "E:\AI Projects\firstnew\src\firstnew\crew.py", line 111, in crew
        return Crew(
               ^^^^^
      File "C:\Users\jklre\.conda\envs\crewai1\Lib\site-packages\pydantic\main.py", line 193, in __init__
        self.__pydantic_validator__.validate_python(data, self_instance=self)
      File "C:\Users\jklre\.conda\envs\crewai1\Lib\site-packages\crewai\crew.py", line 173, in create_crew_memory
        self._short_term_memory = ShortTermMemory(
                                  ^^^^^^^^^^^^^^^^
      File "C:\Users\jklre\.conda\envs\crewai1\Lib\site-packages\crewai\memory\short_term\short_term_memory.py", line 16, in __init__
        storage = RAGStorage(
                  ^^^^^^^^^^^
      File "C:\Users\jklre\.conda\envs\crewai1\Lib\site-packages\crewai\memory\storage\rag_storage.py", line 75, in __init__
        self.app = App.from_config(config=config)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Users\jklre\.conda\envs\crewai1\Lib\site-packages\embedchain\app.py", line 375, in from_config
        vector_db = VectorDBFactory.create(vector_db_provider, vector_db_config_data.get("config", {}))
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Users\jklre\.conda\envs\crewai1\Lib\site-packages\embedchain\factory.py", line 118, in create
        return embedder_class(config=embedder_config_class(**config_data))
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Users\jklre\.conda\envs\crewai1\Lib\site-packages\embedchain\vectordb\chroma.py", line 64, in __init__
        self.client = chromadb.Client(self.settings)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Users\jklre\.conda\envs\crewai1\Lib\site-packages\chromadb\__init__.py", line 274, in Client
        return ClientCreator(tenant=tenant, database=database, settings=settings)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Users\jklre\.conda\envs\crewai1\Lib\site-packages\chromadb\api\client.py", line 139, in __init__
        super().__init__(settings=settings)
      File "C:\Users\jklre\.conda\envs\crewai1\Lib\site-packages\chromadb\api\client.py", line 43, in __init__
        SharedSystemClient._create_system_if_not_exists(self._identifier, settings)
      File "C:\Users\jklre\.conda\envs\crewai1\Lib\site-packages\chromadb\api\client.py", line 54, in _create_system_if_not_exists
        new_system.instance(ServerAPI)
      File "C:\Users\jklre\.conda\envs\crewai1\Lib\site-packages\chromadb\config.py", line 382, in instance
        impl = type(self)
               ^^^^^^^^^^
      File "C:\Users\jklre\.conda\envs\crewai1\Lib\site-packages\chromadb\api\segment.py", line 102, in __init__
        self._sysdb = self.require(SysDB)
                      ^^^^^^^^^^^^^^^^^^^
      File "C:\Users\jklre\.conda\envs\crewai1\Lib\site-packages\chromadb\config.py", line 281, in require
        inst = self._system.instance(type)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "C:\Users\jklre\.conda\envs\crewai1\Lib\site-packages\chromadb\config.py", line 382, in instance
        impl = type(self)
               ^^^^^^^^^^
      File "C:\Users\jklre\.conda\envs\crewai1\Lib\site-packages\chromadb\db\impl\sqlite.py", line 88, in __init__
        os.makedirs(os.path.dirname(self._db_file), exist_ok=True)
      File "<frozen os>", line 225, in makedirs
    OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: 'C:\\Users\\jklre\\AppData\\Local\\CrewAI\\firstnew/short_term/{topic} Senior Data Researcher\n_{topic} Reporting Analyst\n'
theCyberTech commented 1 month ago

Before we investigate this can you upgrade to the latest version?

crewai 0.36.1 crewai-tools 0.4.8

jm101093 commented 1 month ago

Before we investigate this can you upgrade to the latest version?

crewai 0.36.1 crewai-tools 0.4.8

Thank you for the quick response. I went ahead and upgraded and removed all my code that was trying to sanitize the paths but I'm still receiving this error when running the crew. Its creating the long_term_memory_storage.db in the root of the project and created the short_term folder but dies after that. I have this running in a conda environment and my project is on a different drive if that helps with troubleshooting. Let me know if you need any additional information.

(crewai1) E:\AI Projects\firstnew>poetry run firstnew
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "E:\AI Projects\firstnew\src\firstnew\main.py", line 11, in run
    FirstnewCrew().crew().kickoff(inputs=inputs)
    ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\jklre\.conda\envs\crewai1\Lib\site-packages\crewai\project\annotations.py", line 80, in wrapper
    return func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "E:\AI Projects\firstnew\src\firstnew\crew.py", line 109, in crew
    return Crew(
           ^^^^^
  File "C:\Users\jklre\.conda\envs\crewai1\Lib\site-packages\pydantic\main.py", line 193, in __init__
    self.__pydantic_validator__.validate_python(data, self_instance=self)
  File "C:\Users\jklre\.conda\envs\crewai1\Lib\site-packages\crewai\crew.py", line 179, in create_crew_memory
    self._short_term_memory = ShortTermMemory(
                              ^^^^^^^^^^^^^^^^
  File "C:\Users\jklre\.conda\envs\crewai1\Lib\site-packages\crewai\memory\short_term\short_term_memory.py", line 16, in __init__
    storage = RAGStorage(
              ^^^^^^^^^^^
  File "C:\Users\jklre\.conda\envs\crewai1\Lib\site-packages\crewai\memory\storage\rag_storage.py", line 75, in __init__
    self.app = App.from_config(config=config)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\jklre\.conda\envs\crewai1\Lib\site-packages\embedchain\app.py", line 389, in from_config
    vector_db = VectorDBFactory.create(vector_db_provider, vector_db_config_data.get("config", {}))
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\jklre\.conda\envs\crewai1\Lib\site-packages\embedchain\factory.py", line 118, in create
    return embedder_class(config=embedder_config_class(**config_data))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\jklre\.conda\envs\crewai1\Lib\site-packages\embedchain\vectordb\chroma.py", line 63, in __init__
    self.client = chromadb.Client(self.settings)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\jklre\.conda\envs\crewai1\Lib\site-packages\chromadb\__init__.py", line 274, in Client
    return ClientCreator(tenant=tenant, database=database, settings=settings)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\jklre\.conda\envs\crewai1\Lib\site-packages\chromadb\api\client.py", line 139, in __init__
    super().__init__(settings=settings)
  File "C:\Users\jklre\.conda\envs\crewai1\Lib\site-packages\chromadb\api\client.py", line 43, in __init__
    SharedSystemClient._create_system_if_not_exists(self._identifier, settings)
  File "C:\Users\jklre\.conda\envs\crewai1\Lib\site-packages\chromadb\api\client.py", line 54, in _create_system_if_not_exists
    new_system.instance(ServerAPI)
  File "C:\Users\jklre\.conda\envs\crewai1\Lib\site-packages\chromadb\config.py", line 382, in instance
    impl = type(self)
           ^^^^^^^^^^
  File "C:\Users\jklre\.conda\envs\crewai1\Lib\site-packages\chromadb\api\segment.py", line 102, in __init__
    self._sysdb = self.require(SysDB)
                  ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\jklre\.conda\envs\crewai1\Lib\site-packages\chromadb\config.py", line 281, in require
    inst = self._system.instance(type)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\jklre\.conda\envs\crewai1\Lib\site-packages\chromadb\config.py", line 382, in instance
    impl = type(self)
           ^^^^^^^^^^
  File "C:\Users\jklre\.conda\envs\crewai1\Lib\site-packages\chromadb\db\impl\sqlite.py", line 88, in __init__
    os.makedirs(os.path.dirname(self._db_file), exist_ok=True)
  File "<frozen os>", line 225, in makedirs
OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: 'E:\\AI Projects\\firstnew/short_term/{topic} Senior Data Researcher\n_{topic} Reporting Analyst\n'
emilio-gagliardi commented 1 month ago

I get this error without doing any special customizations using latest crewai and tools. On windows 11. all code stored locally. Only happens when I attempt to set memory=True

robsonc commented 1 month ago

Try this

This problem occurs because of the yaml configuration file, if you remove the ">" after the word "role", the error will probably disappear.

Note the name of the folder being created, there is a \n that is causing the problem.

image

jm101093 commented 1 month ago

Try this

This problem occurs because of the yaml configuration file, if you remove the ">" after the word "role", the error will probably disappear.

Note the name of the folder being created, there is a \n that is causing the problem.

image

Was worth a try but :( do you have memory working on windows?

  File "C:\Users\jklre\AppData\Roaming\Python\Python311\site-packages\yaml\composer.py", line 84, in compose_node
    node = self.compose_mapping_node(anchor)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\jklre\AppData\Roaming\Python\Python311\site-packages\yaml\composer.py", line 133, in compose_mapping_node       
    item_value = self.compose_node(node, item_key)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\jklre\AppData\Roaming\Python\Python311\site-packages\yaml\composer.py", line 84, in compose_node
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\jklre\AppData\Roaming\Python\Python311\site-packages\yaml\composer.py", line 127, in compose_mapping_node       
    while not self.check_event(MappingEndEvent):
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\jklre\AppData\Roaming\Python\Python311\site-packages\yaml\parser.py", line 98, in check_event
    self.current_event = self.state()
                         ^^^^^^^^^^^^
  File "C:\Users\jklre\AppData\Roaming\Python\Python311\site-packages\yaml\parser.py", line 438, in parse_block_mapping_key      
    raise ParserError("while parsing a block mapping", self.marks[-1],
yaml.parser.ParserError: while parsing a block mapping
  in "E:\AI Projects\firstnew\src\firstnew\config/agents.yaml", line 2, column 3
expected <block end>, but found '<scalar>'
  in "E:\AI Projects\firstnew\src\firstnew\config/agents.yaml", line 3, column 13
CalebMieszko commented 1 month ago

On the latest version, having the same issue. You can also experience this by downloading the official marketing crew example and adding memory=True to the crew config at the bottom of crew.py.