Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add baseURL and dimensions params to text2vec-jinaai #1308

Merged
merged 2 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions weaviate/collections/classes/config_named_vectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -951,6 +951,8 @@ def text2vec_jinaai(
source_properties: Optional[List[str]] = None,
vector_index_config: Optional[_VectorIndexConfigCreate] = None,
vectorize_collection_name: bool = True,
base_url: Optional[str] = None,
dimensions: Optional[int] = None,
model: Optional[Union[JinaModel, str]] = None,
) -> _NamedVectorConfigCreate:
"""Create a named vector using the `text2vec-jinaai` model.
Expand All @@ -967,6 +969,10 @@ def text2vec_jinaai(
The configuration for Weaviate's vector index. Use wvc.config.Configure.VectorIndex to create a vector index configuration. None by default
`vectorize_collection_name`
Whether to vectorize the collection name. Defaults to `True`.
`base_url`
The base URL to send the vectorization requests to. Defaults to `None`, which uses the server-defined default.
`dimensions`
The number of dimensions for the generated embeddings. Defaults to `None`, which uses the server-defined default.
`model`
The model to use. Defaults to `None`, which uses the server-defined default.
See the
Expand All @@ -976,6 +982,8 @@ def text2vec_jinaai(
name=name,
source_properties=source_properties,
vectorizer=_Text2VecJinaConfigCreate(
baseURL=base_url,
dimensions=dimensions,
model=model,
vectorizeClassName=vectorize_collection_name,
),
Expand Down
26 changes: 24 additions & 2 deletions weaviate/collections/classes/config_vectorizers.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,16 @@
OpenAIModel: TypeAlias = Literal[
"text-embedding-3-small", "text-embedding-3-large", "text-embedding-ada-002"
]
JinaModel: TypeAlias = Literal["jina-embeddings-v2-base-en", "jina-embeddings-v2-small-en"]
JinaModel: TypeAlias = Literal[
"jina-embeddings-v2-base-en",
"jina-embeddings-v2-small-en",
"jina-embeddings-v2-base-zh",
"jina-embeddings-v2-base-es",
"jina-embeddings-v2-base-code",
"jina-colbert-v1-en",
"jina-colbert-v2",
"jina-embeddings-v3",
tsmith023 marked this conversation as resolved.
Show resolved Hide resolved
]
VoyageModel: TypeAlias = Literal[
"voyage-large-2",
"voyage-code-2",
Expand Down Expand Up @@ -341,6 +350,8 @@ class _Text2VecJinaConfig(_ConfigCreateModel):
vectorizer: Union[Vectorizers, _EnumLikeStr] = Field(
default=Vectorizers.TEXT2VEC_JINAAI, frozen=True, exclude=True
)
baseURL: Optional[str]
dimensions: Optional[int]
model: Optional[str]
vectorizeClassName: bool

Expand Down Expand Up @@ -1094,6 +1105,8 @@ def text2vec_transformers(
def text2vec_jinaai(
model: Optional[Union[JinaModel, str]] = None,
vectorize_collection_name: bool = True,
base_url: Optional[str] = None,
dimensions: Optional[int] = None,
) -> _VectorizerConfigCreate:
"""Create a `_Text2VecJinaConfigCreate` object for use when vectorizing using the `text2vec-jinaai` model.

Expand All @@ -1107,8 +1120,17 @@ def text2vec_jinaai(
[documentation](https://weaviate.io/developers/weaviate/modules/retriever-vectorizer-modules/text2vec-jinaai#available-models) for more details.
`vectorize_collection_name`
Whether to vectorize the collection name. Defaults to `True`.
`base_url`
The base URL to send the vectorization requests to. Defaults to `None`, which uses the server-defined default.
`dimensions`
The number of dimensions for the generated embeddings. Defaults to `None`, which uses the server-defined default.
"""
return _Text2VecJinaConfigCreate(model=model, vectorizeClassName=vectorize_collection_name)
return _Text2VecJinaConfigCreate(
model=model,
vectorizeClassName=vectorize_collection_name,
baseURL=base_url,
dimensions=dimensions,
)

@staticmethod
def text2vec_voyageai(
Expand Down
Loading