crewAI: [BUG] Cannot create 'Knowledge': Failed to create or get collection
Description
I am following the documentation here: https://docs.crewai.com/concepts/knowledge#what-is-knowledge
Steps to Reproduce
crew = Crew(
tasks=[task],
process=Process.sequential,
verbose=True,
knowledge_sources: [
PDFKnowledgeSource(
file_paths=[local_path],
chunk_size=1000, # Tamanho dos chunks para processamento
chunk_overlap=100, # Sobreposição entre chunks para preservar contexto
metadata={
'source': 'Informações sobre a clínica',
'description': 'Documento com processos e procedimentos da clínica'
}
)
],
embedder={
"provider": "openai",
"config": {
"model": "text-embedding-3-small",
"dimensions": 256
}
}
)
When I create a Crew or Agent that has a parameter for knowledge_sources and then run the agent I get the error.
File "<path>/crewai_support_agent/.venv/lib/python3.12/site-packages/crewai/agent.py", line 140, in post_init_setup
self._set_knowledge()
File "<path>/crewai_support_agent/.venv/lib/python3.12/site-packages/crewai/agent.py", line 246, in _set_knowledge
self._knowledge = Knowledge(
^^^^^^^^^^
File "<path>crewai_support_agent/.venv/lib/python3.12/site-packages/crewai/knowledge/knowledge.py", line 43, in __init__
self.storage.initialize_knowledge_storage()
File "<path>/crewai_support_agent/.venv/lib/python3.12/site-packages/crewai/knowledge/storage/knowledge_storage.py", line 107, in initialize_knowledge_storage
raise Exception("Failed to create or get collection")
Exception: Failed to create or get collection
Expected behavior
That the knowledge_source was created and could be accessed by the agent or Crew.
Screenshots/Code snippets
See above.
Operating System
macOS Monterey
Python Version
3.11
crewAI Version
0.100.1
crewAI Tools Version
None
Virtual Environment
Venv
Evidence
File “<path>/crewai_support_agent/.venv/lib/python3.12/site-packages/pydantic/main.py”, line 214, in init validated_self = self.pydantic_validator.validate_python(data, self_instance=self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File “<path>/crewai_support_agent/.venv/lib/python3.12/site-packages/crewai/agent.py”, line 140, in post_init_setup self._set_knowledge() File “<path>/crewai_support_agent/.venv/lib/python3.12/site-packages/crewai/agent.py”, line 246, in _set_knowledge self._knowledge = Knowledge( ^^^^^^^^^^ File “<path>crewai_support_agent/.venv/lib/python3.12/site-packages/crewai/knowledge/knowledge.py”, line 43, in init self.storage.initialize_knowledge_storage() File “<path>/crewai_support_agent/.venv/lib/python3.12/site-packages/crewai/knowledge/storage/knowledge_storage.py”, line 107, in initialize_knowledge_storage raise Exception(“Failed to create or get collection”) Exception: Failed to create or get collection
Possible Solution
I don’t know.
Additional context
Same error: https://github.com/crewAIInc/crewAI/issues/1859#issuecomment-2601030610
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 20 (7 by maintainers)
I added the llm code like this
llm = LLM( model=f"vertex_ai/{CLAUDE_MODEL}", vertex_ai_project=GOOGLE_CLOUD_PROJECT, vertex_ai_location=GOOGLE_CLOUD_LOCATION, temperature=0.7, credentials=None # Uses default Google Cloud credentials )
and also tagged the agent with it
like this @agent def researcher(self) -> Agent: return Agent( config=self.agents_config[“researcher”], verbose=True, llm=self.llm, knowledge_sources = [self.csv_source],
Hi! It didn’t work. I migrated the solution to another library.