vectorize_client.models.document

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.

  1# coding: utf-8
  2
  3"""
  4    Vectorize API (Beta)
  5
  6    API for Vectorize services
  7
  8    The version of the OpenAPI document: 0.0.1
  9    Generated by OpenAPI Generator (https://openapi-generator.tech)
 10
 11    Do not edit the class manually.
 12"""  # noqa: E501
 13
 14
 15from __future__ import annotations
 16import pprint
 17import re  # noqa: F401
 18import json
 19
 20from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt, StrictStr
 21from typing import Any, ClassVar, Dict, List, Optional, Union
 22from typing import Optional, Set
 23from typing_extensions import Self
 24
 25class Document(BaseModel):
 26    """
 27    Document
 28    """ # noqa: E501
 29    relevancy: Union[StrictFloat, StrictInt]
 30    id: StrictStr
 31    text: StrictStr
 32    chunk_id: StrictStr
 33    total_chunks: StrictStr
 34    origin: StrictStr
 35    origin_id: StrictStr
 36    similarity: Union[StrictFloat, StrictInt]
 37    source: StrictStr
 38    unique_source: StrictStr
 39    source_display_name: StrictStr
 40    pipeline_id: Optional[StrictStr] = None
 41    org_id: Optional[StrictStr] = None
 42    additional_properties: Dict[str, Any] = {}
 43    __properties: ClassVar[List[str]] = ["relevancy", "id", "text", "chunk_id", "total_chunks", "origin", "origin_id", "similarity", "source", "unique_source", "source_display_name", "pipeline_id", "org_id"]
 44
 45    model_config = ConfigDict(
 46        populate_by_name=True,
 47        validate_assignment=True,
 48        protected_namespaces=(),
 49    )
 50
 51
 52    def to_str(self) -> str:
 53        """Returns the string representation of the model using alias"""
 54        return pprint.pformat(self.model_dump(by_alias=True))
 55
 56    def to_json(self) -> str:
 57        """Returns the JSON representation of the model using alias"""
 58        # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
 59        return json.dumps(self.to_dict())
 60
 61    @classmethod
 62    def from_json(cls, json_str: str) -> Optional[Self]:
 63        """Create an instance of Document from a JSON string"""
 64        return cls.from_dict(json.loads(json_str))
 65
 66    def to_dict(self) -> Dict[str, Any]:
 67        """Return the dictionary representation of the model using alias.
 68
 69        This has the following differences from calling pydantic's
 70        `self.model_dump(by_alias=True)`:
 71
 72        * `None` is only added to the output dict for nullable fields that
 73          were set at model initialization. Other fields with value `None`
 74          are ignored.
 75        * Fields in `self.additional_properties` are added to the output dict.
 76        """
 77        excluded_fields: Set[str] = set([
 78            "additional_properties",
 79        ])
 80
 81        _dict = self.model_dump(
 82            by_alias=True,
 83            exclude=excluded_fields,
 84            exclude_none=True,
 85        )
 86        # puts key-value pairs in additional_properties in the top level
 87        if self.additional_properties is not None:
 88            for _key, _value in self.additional_properties.items():
 89                _dict[_key] = _value
 90
 91        return _dict
 92
 93    @classmethod
 94    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
 95        """Create an instance of Document from a dict"""
 96        if obj is None:
 97            return None
 98
 99        if not isinstance(obj, dict):
100            return cls.model_validate(obj)
101
102        _obj = cls.model_validate({
103            "relevancy": obj.get("relevancy"),
104            "id": obj.get("id"),
105            "text": obj.get("text"),
106            "chunk_id": obj.get("chunk_id"),
107            "total_chunks": obj.get("total_chunks"),
108            "origin": obj.get("origin"),
109            "origin_id": obj.get("origin_id"),
110            "similarity": obj.get("similarity"),
111            "source": obj.get("source"),
112            "unique_source": obj.get("unique_source"),
113            "source_display_name": obj.get("source_display_name"),
114            "pipeline_id": obj.get("pipeline_id"),
115            "org_id": obj.get("org_id")
116        })
117        # store additional fields in additional_properties
118        for _key in obj.keys():
119            if _key not in cls.__properties:
120                _obj.additional_properties[_key] = obj.get(_key)
121
122        return _obj
class Document(pydantic.main.BaseModel):
 26class Document(BaseModel):
 27    """
 28    Document
 29    """ # noqa: E501
 30    relevancy: Union[StrictFloat, StrictInt]
 31    id: StrictStr
 32    text: StrictStr
 33    chunk_id: StrictStr
 34    total_chunks: StrictStr
 35    origin: StrictStr
 36    origin_id: StrictStr
 37    similarity: Union[StrictFloat, StrictInt]
 38    source: StrictStr
 39    unique_source: StrictStr
 40    source_display_name: StrictStr
 41    pipeline_id: Optional[StrictStr] = None
 42    org_id: Optional[StrictStr] = None
 43    additional_properties: Dict[str, Any] = {}
 44    __properties: ClassVar[List[str]] = ["relevancy", "id", "text", "chunk_id", "total_chunks", "origin", "origin_id", "similarity", "source", "unique_source", "source_display_name", "pipeline_id", "org_id"]
 45
 46    model_config = ConfigDict(
 47        populate_by_name=True,
 48        validate_assignment=True,
 49        protected_namespaces=(),
 50    )
 51
 52
 53    def to_str(self) -> str:
 54        """Returns the string representation of the model using alias"""
 55        return pprint.pformat(self.model_dump(by_alias=True))
 56
 57    def to_json(self) -> str:
 58        """Returns the JSON representation of the model using alias"""
 59        # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
 60        return json.dumps(self.to_dict())
 61
 62    @classmethod
 63    def from_json(cls, json_str: str) -> Optional[Self]:
 64        """Create an instance of Document from a JSON string"""
 65        return cls.from_dict(json.loads(json_str))
 66
 67    def to_dict(self) -> Dict[str, Any]:
 68        """Return the dictionary representation of the model using alias.
 69
 70        This has the following differences from calling pydantic's
 71        `self.model_dump(by_alias=True)`:
 72
 73        * `None` is only added to the output dict for nullable fields that
 74          were set at model initialization. Other fields with value `None`
 75          are ignored.
 76        * Fields in `self.additional_properties` are added to the output dict.
 77        """
 78        excluded_fields: Set[str] = set([
 79            "additional_properties",
 80        ])
 81
 82        _dict = self.model_dump(
 83            by_alias=True,
 84            exclude=excluded_fields,
 85            exclude_none=True,
 86        )
 87        # puts key-value pairs in additional_properties in the top level
 88        if self.additional_properties is not None:
 89            for _key, _value in self.additional_properties.items():
 90                _dict[_key] = _value
 91
 92        return _dict
 93
 94    @classmethod
 95    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
 96        """Create an instance of Document from a dict"""
 97        if obj is None:
 98            return None
 99
100        if not isinstance(obj, dict):
101            return cls.model_validate(obj)
102
103        _obj = cls.model_validate({
104            "relevancy": obj.get("relevancy"),
105            "id": obj.get("id"),
106            "text": obj.get("text"),
107            "chunk_id": obj.get("chunk_id"),
108            "total_chunks": obj.get("total_chunks"),
109            "origin": obj.get("origin"),
110            "origin_id": obj.get("origin_id"),
111            "similarity": obj.get("similarity"),
112            "source": obj.get("source"),
113            "unique_source": obj.get("unique_source"),
114            "source_display_name": obj.get("source_display_name"),
115            "pipeline_id": obj.get("pipeline_id"),
116            "org_id": obj.get("org_id")
117        })
118        # store additional fields in additional_properties
119        for _key in obj.keys():
120            if _key not in cls.__properties:
121                _obj.additional_properties[_key] = obj.get(_key)
122
123        return _obj

Document

relevancy: Union[Annotated[float, Strict(strict=True)], Annotated[int, Strict(strict=True)]]
id: typing.Annotated[str, Strict(strict=True)]
text: typing.Annotated[str, Strict(strict=True)]
chunk_id: typing.Annotated[str, Strict(strict=True)]
total_chunks: typing.Annotated[str, Strict(strict=True)]
origin: typing.Annotated[str, Strict(strict=True)]
origin_id: typing.Annotated[str, Strict(strict=True)]
similarity: Union[Annotated[float, Strict(strict=True)], Annotated[int, Strict(strict=True)]]
source: typing.Annotated[str, Strict(strict=True)]
unique_source: typing.Annotated[str, Strict(strict=True)]
source_display_name: typing.Annotated[str, Strict(strict=True)]
pipeline_id: Optional[Annotated[str, Strict(strict=True)]]
org_id: Optional[Annotated[str, Strict(strict=True)]]
additional_properties: Dict[str, Any]
model_config = {'populate_by_name': True, 'validate_assignment': True, 'protected_namespaces': ()}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

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

Returns the string representation of the model using alias

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

Returns the JSON representation of the model using alias

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

Create an instance of Document from a JSON string

def to_dict(self) -> Dict[str, Any]:
67    def to_dict(self) -> Dict[str, Any]:
68        """Return the dictionary representation of the model using alias.
69
70        This has the following differences from calling pydantic's
71        `self.model_dump(by_alias=True)`:
72
73        * `None` is only added to the output dict for nullable fields that
74          were set at model initialization. Other fields with value `None`
75          are ignored.
76        * Fields in `self.additional_properties` are added to the output dict.
77        """
78        excluded_fields: Set[str] = set([
79            "additional_properties",
80        ])
81
82        _dict = self.model_dump(
83            by_alias=True,
84            exclude=excluded_fields,
85            exclude_none=True,
86        )
87        # puts key-value pairs in additional_properties in the top level
88        if self.additional_properties is not None:
89            for _key, _value in self.additional_properties.items():
90                _dict[_key] = _value
91
92        return _dict

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.
  • Fields in self.additional_properties are added to the output dict.
@classmethod
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
 94    @classmethod
 95    def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
 96        """Create an instance of Document from a dict"""
 97        if obj is None:
 98            return None
 99
100        if not isinstance(obj, dict):
101            return cls.model_validate(obj)
102
103        _obj = cls.model_validate({
104            "relevancy": obj.get("relevancy"),
105            "id": obj.get("id"),
106            "text": obj.get("text"),
107            "chunk_id": obj.get("chunk_id"),
108            "total_chunks": obj.get("total_chunks"),
109            "origin": obj.get("origin"),
110            "origin_id": obj.get("origin_id"),
111            "similarity": obj.get("similarity"),
112            "source": obj.get("source"),
113            "unique_source": obj.get("unique_source"),
114            "source_display_name": obj.get("source_display_name"),
115            "pipeline_id": obj.get("pipeline_id"),
116            "org_id": obj.get("org_id")
117        })
118        # store additional fields in additional_properties
119        for _key in obj.keys():
120            if _key not in cls.__properties:
121                _obj.additional_properties[_key] = obj.get(_key)
122
123        return _obj

Create an instance of Document from a dict