Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 32 additions & 18 deletions src/python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,35 +1,49 @@
[project]
name = "vectorize_client"
version = "1.0.0"
description = "Vectorize API (Beta)"
license = "NoLicense"
readme = "README.md"
keywords = [ "OpenAPI", "OpenAPI-Generator", "Vectorize API (Beta)" ]
requires-python = ">=3.9"
dependencies = [
"urllib3 (>=2.1.0,<3.0.0)",
"python-dateutil (>=2.8.2)",
"pydantic (>=2)",
"typing-extensions (>=4.7.1)"
]

[[project.authors]]
name = "Vectorize"
email = "team@openapitools.org"

[project.urls]
Repository = "https://github.com/GIT_USER_ID/GIT_REPO_ID"

[tool.poetry]
name = "vectorize-client"
requires-poetry = ">=2.0"
version = "0.2.1"
name = "vectorize-client"
description = "Python client for the Vectorize API"
authors = [ "Vectorize <contact@vectorize.io>" ]
license = "MIT"
readme = "README.md"
repository = "https://github.com/vectorize-io/vectorize-clients"
homepage = "https://vectorize.io"
keywords = [
"vectorize",
"vectorize.io",
"generative-ai",
"embeddings",
"rag"
]
include = [ "vectorize_client/py.typed" ]
homepage = "https://vectorize.io"

[tool.poetry.dependencies]
python = "^3.8"
urllib3 = ">= 1.25.3, < 3.0.0"
python-dateutil = ">= 2.8.2"
pydantic = ">= 2"
typing-extensions = ">= 4.7.1"

[tool.poetry.dev-dependencies]
pytest = ">= 7.2.1"
pytest-cov = ">= 2.8.1"
tox = ">= 3.9.0"
flake8 = ">= 4.0.0"
types-python-dateutil = ">= 2.8.19.14"
mypy = ">= 1.5"
[tool.poetry.group.dev.dependencies]
pytest = ">= 7.2.1"
pytest-cov = ">= 2.8.1"
tox = ">= 3.9.0"
flake8 = ">= 4.0.0"
types-python-dateutil = ">= 2.8.19.14"
mypy = ">= 1.5"

[tool.pylint."MESSAGES CONTROL"]
extension-pkg-whitelist = "pydantic"
Expand Down
297 changes: 200 additions & 97 deletions src/python/vectorize_client/__init__.py

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions src/python/vectorize_client/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,10 @@ def sanitize_for_serialization(self, obj):
else:
obj_dict = obj.__dict__

if isinstance(obj_dict, list):
# here we handle instances that can either be a list or something else, and only became a real list by calling to_dict()
return self.sanitize_for_serialization(obj_dict)

return {
key: self.sanitize_for_serialization(val)
for key, val in obj_dict.items()
Expand Down
11 changes: 9 additions & 2 deletions src/python/vectorize_client/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from logging import FileHandler
import multiprocessing
import sys
from typing import Any, ClassVar, Dict, List, Literal, Optional, TypedDict
from typing import Any, ClassVar, Dict, List, Literal, Optional, TypedDict, Union
from typing_extensions import NotRequired, Self

import urllib3
Expand Down Expand Up @@ -161,6 +161,8 @@ class Configuration:
:param ssl_ca_cert: str - the path to a file of concatenated CA certificates
in PEM format.
:param retries: Number of retries for API requests.
:param ca_cert_data: verify the peer using concatenated CA certificate data
in PEM (str) or DER (bytes) format.

:Example:
"""
Expand All @@ -175,13 +177,14 @@ def __init__(
username: Optional[str]=None,
password: Optional[str]=None,
access_token: Optional[str]=None,
server_index: Optional[int]=None,
server_index: Optional[int]=None,
server_variables: Optional[ServerVariablesT]=None,
server_operation_index: Optional[Dict[int, int]]=None,
server_operation_variables: Optional[Dict[int, ServerVariablesT]]=None,
ignore_operation_servers: bool=False,
ssl_ca_cert: Optional[str]=None,
retries: Optional[int] = None,
ca_cert_data: Optional[Union[str, bytes]] = None,
*,
debug: Optional[bool] = None,
) -> None:
Expand Down Expand Up @@ -259,6 +262,10 @@ def __init__(
self.ssl_ca_cert = ssl_ca_cert
"""Set this to customize the certificate file to verify the peer.
"""
self.ca_cert_data = ca_cert_data
"""Set this to verify the peer using PEM (str) or DER (bytes)
certificate data.
"""
self.cert_file = None
"""client certificate file
"""
Expand Down
1 change: 1 addition & 0 deletions src/python/vectorize_client/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from vectorize_client.models.add_user_from_source_connector_response import AddUserFromSourceConnectorResponse
from vectorize_client.models.add_user_to_source_connector_request import AddUserToSourceConnectorRequest
from vectorize_client.models.add_user_to_source_connector_request_selected_files_value import AddUserToSourceConnectorRequestSelectedFilesValue
from vectorize_client.models.advanced_query import AdvancedQuery
from vectorize_client.models.create_ai_platform_connector import CreateAIPlatformConnector
from vectorize_client.models.create_ai_platform_connector_response import CreateAIPlatformConnectorResponse
from vectorize_client.models.create_destination_connector import CreateDestinationConnector
Expand Down
115 changes: 115 additions & 0 deletions src/python/vectorize_client/models/advanced_query.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# coding: utf-8

"""
Vectorize API (Beta)

API for Vectorize services

The version of the OpenAPI document: 0.0.1
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
""" # noqa: E501


from __future__ import annotations
import pprint
import re # noqa: F401
import json

from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional, Union
from typing import Optional, Set
from typing_extensions import Self

class AdvancedQuery(BaseModel):
"""
AdvancedQuery
""" # noqa: E501
mode: Optional[StrictStr] = 'vector'
text_fields: Optional[List[StrictStr]] = Field(default=None, alias="text-fields")
match_type: Optional[StrictStr] = Field(default=None, alias="match-type")
text_boost: Optional[Union[StrictFloat, StrictInt]] = Field(default=1.0, alias="text-boost")
filters: Optional[Dict[str, Any]] = None
__properties: ClassVar[List[str]] = ["mode", "text-fields", "match-type", "text-boost", "filters"]

@field_validator('mode')
def mode_validate_enum(cls, value):
"""Validates the enum"""
if value is None:
return value

if value not in set(['text', 'vector', 'hybrid']):
raise ValueError("must be one of enum values ('text', 'vector', 'hybrid')")
return value

@field_validator('match_type')
def match_type_validate_enum(cls, value):
"""Validates the enum"""
if value is None:
return value

if value not in set(['match', 'match_phrase', 'multi_match']):
raise ValueError("must be one of enum values ('match', 'match_phrase', 'multi_match')")
return value

model_config = ConfigDict(
populate_by_name=True,
validate_assignment=True,
protected_namespaces=(),
)


def to_str(self) -> str:
"""Returns the string representation of the model using alias"""
return pprint.pformat(self.model_dump(by_alias=True))

def to_json(self) -> str:
"""Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict())

@classmethod
def from_json(cls, json_str: str) -> Optional[Self]:
"""Create an instance of AdvancedQuery from a JSON string"""
return cls.from_dict(json.loads(json_str))

def to_dict(self) -> Dict[str, Any]:
"""Return the dictionary representation of the model using alias.

This has the following differences from calling pydantic's
`self.model_dump(by_alias=True)`:

* `None` is only added to the output dict for nullable fields that
were set at model initialization. Other fields with value `None`
are ignored.
"""
excluded_fields: Set[str] = set([
])

_dict = self.model_dump(
by_alias=True,
exclude=excluded_fields,
exclude_none=True,
)
return _dict

@classmethod
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
"""Create an instance of AdvancedQuery from a dict"""
if obj is None:
return None

if not isinstance(obj, dict):
return cls.model_validate(obj)

_obj = cls.model_validate({
"mode": obj.get("mode") if obj.get("mode") is not None else 'vector',
"text-fields": obj.get("text-fields"),
"match-type": obj.get("match-type"),
"text-boost": obj.get("text-boost") if obj.get("text-boost") is not None else 1.0,
"filters": obj.get("filters")
})
return _obj


10 changes: 8 additions & 2 deletions src/python/vectorize_client/models/retrieve_documents_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr
from typing import Any, ClassVar, Dict, List, Optional, Union
from typing_extensions import Annotated
from vectorize_client.models.advanced_query import AdvancedQuery
from vectorize_client.models.retrieve_context import RetrieveContext
from typing import Optional, Set
from typing_extensions import Self
Expand All @@ -33,7 +34,8 @@ class RetrieveDocumentsRequest(BaseModel):
rerank: Optional[StrictBool] = True
metadata_filters: Optional[List[Dict[str, Any]]] = Field(default=None, alias="metadata-filters")
context: Optional[RetrieveContext] = None
__properties: ClassVar[List[str]] = ["question", "numResults", "rerank", "metadata-filters", "context"]
advanced_query: Optional[AdvancedQuery] = Field(default=None, alias="advanced-query")
__properties: ClassVar[List[str]] = ["question", "numResults", "rerank", "metadata-filters", "context", "advanced-query"]

model_config = ConfigDict(
populate_by_name=True,
Expand Down Expand Up @@ -77,6 +79,9 @@ def to_dict(self) -> Dict[str, Any]:
# override the default output from pydantic by calling `to_dict()` of context
if self.context:
_dict['context'] = self.context.to_dict()
# override the default output from pydantic by calling `to_dict()` of advanced_query
if self.advanced_query:
_dict['advanced-query'] = self.advanced_query.to_dict()
return _dict

@classmethod
Expand All @@ -93,7 +98,8 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
"numResults": obj.get("numResults"),
"rerank": obj.get("rerank") if obj.get("rerank") is not None else True,
"metadata-filters": obj.get("metadata-filters"),
"context": RetrieveContext.from_dict(obj["context"]) if obj.get("context") is not None else None
"context": RetrieveContext.from_dict(obj["context"]) if obj.get("context") is not None else None,
"advanced-query": AdvancedQuery.from_dict(obj["advanced-query"]) if obj.get("advanced-query") is not None else None
})
return _obj

Expand Down
1 change: 1 addition & 0 deletions src/python/vectorize_client/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def __init__(self, configuration) -> None:
"ca_certs": configuration.ssl_ca_cert,
"cert_file": configuration.cert_file,
"key_file": configuration.key_file,
"ca_cert_data": configuration.ca_cert_data,
}
if configuration.assert_hostname is not None:
pool_args['assert_hostname'] = (
Expand Down
14 changes: 5 additions & 9 deletions src/ts/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Vectorize Client
Typescript Api Client for Vectorize
For more information, please visit [https://vectorize.io](https://vectorize.io)
Node Api Client for [Vectorize](https://vectorize.io).
For the full documentation, please visit [docs.vectorize.io](https://docs.vectorize.io/api/api-getting-started).

## Installation & Usage
## Installation
```sh
npm install @vectorize-io/vectorize-client
```

## Getting Started

Please follow the [installation procedure](#installation--usage) and then run the following:
List all your pipelines:

```typescript

Expand All @@ -23,8 +23,4 @@ const pipelines = connectorsApi.getPipelines({
console.log(pipelines)
```

## Documentation for API Endpoints

All URIs are relative to *https://api.vectorize.io/v1*

See the full [reference](https://vectorize.readme.io/reference) for more information.
Visit [docs.vectorize.io](https://docs.vectorize.io/api/api-getting-started) to learn more about the API.
2 changes: 1 addition & 1 deletion src/ts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"preinstall": "npm install typescript"
},
"devDependencies": {
"typescript": "^5.8.3"
"typescript": "^4.0 || ^5.0"
},
"publishConfig": {
"registry": "https://registry.npmjs.org",
Expand Down
Loading
Loading