[BUG] Custom embedder crashes Knowledge on ChromaDB: CustomEmbeddingFunction has no name()
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Start with crewai/rag/embeddings/providers/custom/embedding_callable.py and compare CustomEmbeddingFunction with the crewAI embedding functions that define name() for ChromaDB compatibility. Reproduce with the supplied script and ChromaDB 1.5.9; done means knowledge.add_sources() succeeds with the custom embedder on ChromaDB. A linked pull request (#9842) is already open.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Description
Knowledge with a custom embedder (provider: "custom") fails on the ChromaDB backend with AttributeError: '<cls>' object has no attribute 'name' when sources are added. ChromaDB 1.x calls embedding_function.name() in get_or_create_collection. crewAI's own embedding functions define it (OpenAIEmbeddingFunction.name() is documented "for ChromaDB compatibility"; voyageai, ibm and oracle do too), but CustomEmbeddingFunction does not, and because crewAI's EmbeddingFunction is its own Protocol it does not inherit ChromaDB's fallback either. The same embedder works on the default Qdrant backend, so this hits anyone who opts in to ChromaDB with set_rag_config(ChromaDBConfig(...)), as the Knowledge docs describe for sharing a store across processes.
Steps to Reproduce
uv sync --all-groups --all-extras(chromadb 1.5.9 fromuv.lock).- Save the script under "Screenshots/Code snippets" as
repro.py. uv run python repro.py- See
AttributeError: 'MyEmbedding' object has no attribute 'name'. - Comment out the
set_rag_config(...)line (default Qdrant backend) and run again: it printsok.
Expected behavior
knowledge.add_sources() succeeds on ChromaDB with a CustomEmbeddingFunction subclass, the same as it does on Qdrant.
Screenshots/Code snippets
import os
import tempfile
os.environ["CREWAI_STORAGE_DIR"] = tempfile.mkdtemp() # fresh store
from crewai.knowledge.knowledge import Knowledge
from crewai.knowledge.source.string_knowledge_source import StringKnowledgeSource
from crewai.rag.chromadb.config import ChromaDBConfig
from crewai.rag.config.utils import set_rag_config
from crewai.rag.embeddings.providers.custom.embedding_callable import (
CustomEmbeddingFunction,
)
class MyEmbedding(CustomEmbeddingFunction):
def __call__(self, input: list[str]) -> list[list[float]]:
return [[float(len(doc)), 1.0, 0.0] for doc in input]
# Opt in to ChromaDB as docs/edge/en/concepts/knowledge.mdx describes.
# Comment this line out (default Qdrant backend) and the script succeeds.
set_rag_config(ChromaDBConfig(embedding_function=MyEmbedding()))
knowledge = Knowledge(
collection_name="demo",
sources=[StringKnowledgeSource(content="Chroma stores embeddings.")],
embedder={"provider": "custom", "config": {"embedding_callable": MyEmbedding}},
)
knowledge.add_sources()
print("ok")
Operating System
Other (specify in additional context)
Python Version
3.12
crewAI Version
1.15.45 (main @ 77237aec)
crewAI Tools Version
1.15.45
Virtual Environment
Venv
Evidence
Traceback (paths shortened):
Traceback (most recent call last):
File "repro.py", line 29, in <module>
File ".../crewai/knowledge/knowledge.py", line 158, in add_sources
File ".../crewai/knowledge/source/string_knowledge_source.py", line 28, in add
File ".../crewai/knowledge/source/base_knowledge_source.py", line 69, in _save_documents
File ".../crewai/knowledge/storage/knowledge_storage.py", line 174, in save
File ".../crewai/rag/chromadb/client.py", line 247, in get_or_create_collection
File ".../chromadb/api/client.py", line 372, in get_or_create_collection
File ".../chromadb/api/collection_configuration.py", line 791, in validate_embedding_function_conflict_on_get
AttributeError: 'MyEmbedding' object has no attribute 'name'
Same result on Python 3.13.15. With the default Qdrant backend the script prints ok.
Possible Solution
Define name() on CustomEmbeddingFunction, as the other crewAI embedding functions do. This is the same class of bug as #3597 (WatsonEmbeddingFunction), which was fixed in 73e932bfe; CustomEmbeddingFunction was not part of that change. I'd like to open a PR for this.
Additional context
- OS: macOS 26.6. Python 3.12.14 and 3.13.15, chromadb 1.5.9, environment from the repo's
uv.lock(uv-managed venv). - Related, separate issue (not part of this report): the custom-embedder example in
docs/edge/en/tools/ai-ml/ragtool.mdxsubclassescrewai.rag.core.base_embeddings_callable.EmbeddingFunctionand documentsembedding_callable (type[EmbeddingFunction]), butCustomProvider.embedding_callableis typedtype[CustomEmbeddingFunction], so that class is rejected withInput should be a subclass of CustomEmbeddingFunction(in bothRagToolandKnowledge).
Prepared with Claude Code assistance. Could a maintainer please add the llm-generated label?
- Ngôn ngữ chính
- Python
- Star
- 61.2k
- Fork
- 9.2k
- Merge trung bình
- 1 ngày 14 giờ
- Pull request đã merge (30 ngày)
- 180
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của crewAIInc/crewAI
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[FEATURE] Add Straitly as a native OpenAI-compatible LLM providerCó thể đã có người làm @HashimSyedUBC đã nhận 2 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG] Native OpenAI sync streaming with response_model returns an empty string and emits no completed event when the parse is missingCó thể đã có người làm @basil-k-aji-dev đã nhận 2 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG] Native Azure provider ignores the seed settingCó thể đã có người làm @basil-k-aji-dev đã nhận 2 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
crewAIInc/crewAI#9787 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[BUG] LiteLLM path reports 0 cached and reasoning tokens in the usage summaryCó thể đã có người làm @basil-k-aji-dev đã nhận 2 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của crewAIInc/crewAI
Issue tương tự
-
[BUG] SMTP listener now binds to EMAIL_PORT instead of 2525 since the gunicorn switch 5.0.3-ls373Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
linuxserver/docker-healthchecks#137 · 1 bình luận ·
-
RequirementAgent treats list -> add -> list as a tool call cycle and drops the second list call (Python)Có thể đã có người làm @chaitanya0305 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
i-am-bee/beeai-framework#2049 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
fedora-infra/anitya#2272 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 80/100
unitaryfoundation/mitiq#3205 ·
Maintainer thường phản hồi trong vòng 6 ngày
-
[Bug]: Index worker test drops empty Git config values on WindowsCó thể đã có người làm @xiaoyesoso đã nhận hôm nay. Đang mởtriage/confirmed
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
agentscope-ai/agentscope#4377 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 2 ngày