camel.embeddings package#
Submodules#
camel.embeddings.base module#
- class camel.embeddings.base.BaseEmbedding[source]#
Bases:
ABC
,Generic
[T
]Abstract base class for text embedding functionalities.
- embed(obj: T, **kwargs: Any) list[float] [source]#
Generates an embedding for the given text.
- Parameters:
obj (T) – The object for which to generate the embedding.
**kwargs (Any) – Extra kwargs passed to the embedding API.
- Returns:
- A list of floating-point numbers representing the
generated embedding.
- Return type:
list[float]
- abstract embed_list(objs: list[T], **kwargs: Any) list[list[float]] [source]#
Generates embeddings for the given texts.
- Parameters:
objs (list[T]) – The objects for which to generate the embeddings.
**kwargs (Any) – Extra kwargs passed to the embedding API.
- Returns:
- A list that represents the
generated embedding as a list of floating-point numbers.
- Return type:
list[list[float]]
camel.embeddings.mistral_embedding module#
- class camel.embeddings.mistral_embedding.MistralEmbedding(model_type: EmbeddingModelType = EmbeddingModelType.MISTRAL_EMBED, api_key: str | None = None, dimensions: int | None = None)[source]#
Bases:
BaseEmbedding
[str
]Provides text embedding functionalities using Mistral’s models.
- Parameters:
model_type (EmbeddingModelType, optional) – The model type to be used for text embeddings. (default:
MISTRAL_EMBED
)api_key (str, optional) – The API key for authenticating with the Mistral service. (default:
None
)dimensions (int, optional) – The text embedding output dimensions. (default:
None
)
- Raises:
RuntimeError – If an unsupported model type is specified.
- embed_list(objs: list[str], **kwargs: Any) list[list[float]] [source]#
Generates embeddings for the given texts.
- Parameters:
objs (list[str]) – The texts for which to generate the embeddings.
**kwargs (Any) – Extra kwargs passed to the embedding API.
- Returns:
- A list that represents the generated embedding
as a list of floating-point numbers.
- Return type:
list[list[float]]
camel.embeddings.openai_embedding module#
- class camel.embeddings.openai_embedding.OpenAIEmbedding(model_type: EmbeddingModelType = EmbeddingModelType.TEXT_EMBEDDING_3_SMALL, api_key: str | None = None, dimensions: int | NotGiven = NOT_GIVEN)[source]#
Bases:
BaseEmbedding
[str
]Provides text embedding functionalities using OpenAI’s models.
- Parameters:
model_type (EmbeddingModelType, optional) – The model type to be used for text embeddings. (default:
TEXT_EMBEDDING_3_SMALL
)api_key (str, optional) – The API key for authenticating with the OpenAI service. (default:
None
)dimensions (int, optional) – The text embedding output dimensions. (default:
NOT_GIVEN
)
- Raises:
RuntimeError – If an unsupported model type is specified.
- embed_list(objs: list[str], **kwargs: Any) list[list[float]] [source]#
Generates embeddings for the given texts.
- Parameters:
objs (list[str]) – The texts for which to generate the embeddings.
**kwargs (Any) – Extra kwargs passed to the embedding API.
- Returns:
- A list that represents the generated embedding
as a list of floating-point numbers.
- Return type:
list[list[float]]
camel.embeddings.sentence_transformers_embeddings module#
- class camel.embeddings.sentence_transformers_embeddings.SentenceTransformerEncoder(model_name: str = 'intfloat/e5-large-v2', **kwargs)[source]#
Bases:
BaseEmbedding
[str
]This class provides functionalities to generate text embeddings using Sentence Transformers.
References
- embed_list(objs: list[str], **kwargs: Any) list[list[float]] [source]#
Generates embeddings for the given texts using the model.
- Parameters:
objs (list[str]) – The texts for which to generate the embeddings.
- Returns:
- A list that represents the generated embedding
as a list of floating-point numbers.
- Return type:
list[list[float]]
camel.embeddings.vlm_embedding module#
- class camel.embeddings.vlm_embedding.VisionLanguageEmbedding(model_name: str = 'openai/clip-vit-base-patch32')[source]#
Bases:
BaseEmbedding
[str
|Image
]Provides image embedding functionalities using multimodal model.
- Parameters:
model_name – The model type to be used for generating embeddings. And the default value is: obj:openai/clip-vit-base-patch32.
- Raises:
RuntimeError – If an unsupported model type is specified.
- embed_list(objs: List[Image | str], **kwargs: Any) List[List[float]] [source]#
Generates embeddings for the given images or texts.
- Parameters:
objs (List[Image.Image|str]) – The list of images or texts for which to generate the embeddings.
image_processor_kwargs – Extra kwargs passed to the image processor.
tokenizer_kwargs – Extra kwargs passed to the text tokenizer (processor).
model_kwargs – Extra kwargs passed to the main model.
- Returns:
- A list that represents the generated embedding
as a list of floating-point numbers.
- Return type:
List[List[float]]
- Raises:
ValueError – If the input type is not Image.Image or str.
Module contents#
- class camel.embeddings.BaseEmbedding[source]#
Bases:
ABC
,Generic
[T
]Abstract base class for text embedding functionalities.
- embed(obj: T, **kwargs: Any) list[float] [source]#
Generates an embedding for the given text.
- Parameters:
obj (T) – The object for which to generate the embedding.
**kwargs (Any) – Extra kwargs passed to the embedding API.
- Returns:
- A list of floating-point numbers representing the
generated embedding.
- Return type:
list[float]
- abstract embed_list(objs: list[T], **kwargs: Any) list[list[float]] [source]#
Generates embeddings for the given texts.
- Parameters:
objs (list[T]) – The objects for which to generate the embeddings.
**kwargs (Any) – Extra kwargs passed to the embedding API.
- Returns:
- A list that represents the
generated embedding as a list of floating-point numbers.
- Return type:
list[list[float]]
- class camel.embeddings.MistralEmbedding(model_type: EmbeddingModelType = EmbeddingModelType.MISTRAL_EMBED, api_key: str | None = None, dimensions: int | None = None)[source]#
Bases:
BaseEmbedding
[str
]Provides text embedding functionalities using Mistral’s models.
- Parameters:
model_type (EmbeddingModelType, optional) – The model type to be used for text embeddings. (default:
MISTRAL_EMBED
)api_key (str, optional) – The API key for authenticating with the Mistral service. (default:
None
)dimensions (int, optional) – The text embedding output dimensions. (default:
None
)
- Raises:
RuntimeError – If an unsupported model type is specified.
- embed_list(objs: list[str], **kwargs: Any) list[list[float]] [source]#
Generates embeddings for the given texts.
- Parameters:
objs (list[str]) – The texts for which to generate the embeddings.
**kwargs (Any) – Extra kwargs passed to the embedding API.
- Returns:
- A list that represents the generated embedding
as a list of floating-point numbers.
- Return type:
list[list[float]]
- class camel.embeddings.OpenAIEmbedding(model_type: EmbeddingModelType = EmbeddingModelType.TEXT_EMBEDDING_3_SMALL, api_key: str | None = None, dimensions: int | NotGiven = NOT_GIVEN)[source]#
Bases:
BaseEmbedding
[str
]Provides text embedding functionalities using OpenAI’s models.
- Parameters:
model_type (EmbeddingModelType, optional) – The model type to be used for text embeddings. (default:
TEXT_EMBEDDING_3_SMALL
)api_key (str, optional) – The API key for authenticating with the OpenAI service. (default:
None
)dimensions (int, optional) – The text embedding output dimensions. (default:
NOT_GIVEN
)
- Raises:
RuntimeError – If an unsupported model type is specified.
- embed_list(objs: list[str], **kwargs: Any) list[list[float]] [source]#
Generates embeddings for the given texts.
- Parameters:
objs (list[str]) – The texts for which to generate the embeddings.
**kwargs (Any) – Extra kwargs passed to the embedding API.
- Returns:
- A list that represents the generated embedding
as a list of floating-point numbers.
- Return type:
list[list[float]]
- class camel.embeddings.SentenceTransformerEncoder(model_name: str = 'intfloat/e5-large-v2', **kwargs)[source]#
Bases:
BaseEmbedding
[str
]This class provides functionalities to generate text embeddings using Sentence Transformers.
References
- embed_list(objs: list[str], **kwargs: Any) list[list[float]] [source]#
Generates embeddings for the given texts using the model.
- Parameters:
objs (list[str]) – The texts for which to generate the embeddings.
- Returns:
- A list that represents the generated embedding
as a list of floating-point numbers.
- Return type:
list[list[float]]
- class camel.embeddings.VisionLanguageEmbedding(model_name: str = 'openai/clip-vit-base-patch32')[source]#
Bases:
BaseEmbedding
[str
|Image
]Provides image embedding functionalities using multimodal model.
- Parameters:
model_name – The model type to be used for generating embeddings. And the default value is: obj:openai/clip-vit-base-patch32.
- Raises:
RuntimeError – If an unsupported model type is specified.
- embed_list(objs: List[Image | str], **kwargs: Any) List[List[float]] [source]#
Generates embeddings for the given images or texts.
- Parameters:
objs (List[Image.Image|str]) – The list of images or texts for which to generate the embeddings.
image_processor_kwargs – Extra kwargs passed to the image processor.
tokenizer_kwargs – Extra kwargs passed to the text tokenizer (processor).
model_kwargs – Extra kwargs passed to the main model.
- Returns:
- A list that represents the generated embedding
as a list of floating-point numbers.
- Return type:
List[List[float]]
- Raises:
ValueError – If the input type is not Image.Image or str.