Skip to content

embedding_type may be mandatory in some cases but is marked as optional. #719

@wj3171868

Description

@wj3171868

Related to pydantic/pydantic-ai#4044

SDK Version (required)

Python: 3.11
Pydantic AI: 1.40.0
LLM provider SDK: cohere 5.20.1

Describe the bug
"embedding_type" field on the "embed" method may be mandatory in some cases but is marked as optional.

Exception when embedding type is not specified:
File cohere/core/unchecked_base_model.py line 304 in construct_type TypeError: cohere.core.unchecked_base_model.UncheckedBaseModel.model_construct() argument after ** must be a mapping, not a list

From issue with Pydantic AI:

Cohere embedding may require an "embedding_types" attribute when calling the "embed" method of their client in > some cases. It appears this value cannot be set in pydantic-ai interaction with the cohere client.
It was noted there that the "embedding_type" field is marked as optional

The fix may be set the "embedding_type" to default to "float". If "float" is an assumed default. The exception noted above could be caught earlier or avoided.

Example Code:
client.embed( model=self.model_name, texts=inputs, output_dimension=settings.get('dimensions'), input_type=cohere_input_type, max_tokens=settings.get('cohere_max_tokens'), truncate=settings.get('cohere_truncate', 'NONE'), request_options=request_options, embedding_types=["float"] # hack: added as workaround )

Screenshots
If applicable, add screenshots to help explain your problem.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions