Skip to content

`factory_allowed_embedders`

Customize which embedders are available.

Name Type Description
allowed List[EmbedderSettings] List of EmbedderSettings classes, contains the allowed embedders.
cat Cat Cheshire Cat instance, allows you to use the framework components.

Type: List[EmbedderSettings]

The list of embedders that the cat is allowed to use.

from cat.factory.embedder import EmbedderSettings
from langchain.embeddings import JinaEmbeddings
# Define your custome embedder based on the cat's "EmbedderSettings"
class JinaEmbedderConfig(EmbedderSettings):
jina_api_key: str
model_name: str='jina-embeddings-v2-base-en'
_pyclass: Type = JinaEmbeddings
model_config = ConfigDict(
json_schema_extra = {
"humanReadableName": "Jina embedder",
"description": "Jina embedder",
"link": "https://jina.ai/embeddings/",
}
)
# Add it to the allowed list.
@hook
def factory_allowed_embedders(allowed, cat) -> List:
allowed.append(JinaEmbedderConfig)
return allowed