Skip to content

Commit

Permalink
Merge pull request #1308 from weaviate/modules/update-text2vec-jinaai…
Browse files Browse the repository at this point in the history
…-inputs

Add `baseURL` and `dimensions` params to `text2vec-jinaai`
  • Loading branch information
tsmith023 authored Sep 18, 2024
2 parents 76b8dd4 + 3a7e182 commit 5c5cb07
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
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
24 changes: 22 additions & 2 deletions weaviate/collections/classes/config_vectorizers.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,14 @@
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-embeddings-v3",
]
VoyageModel: TypeAlias = Literal[
"voyage-large-2",
"voyage-code-2",
Expand Down Expand Up @@ -341,6 +348,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 +1103,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 +1118,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

0 comments on commit 5c5cb07

Please sign in to comment.