vectorize_client.models.retrieve_documents_response
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, Union 22from vectorize_client.models.document import Document 23from typing import Optional, Set 24from typing_extensions import Self 25 26class RetrieveDocumentsResponse(BaseModel): 27 """ 28 RetrieveDocumentsResponse 29 """ # noqa: E501 30 question: StrictStr 31 documents: List[Document] 32 average_relevancy: Union[StrictFloat, StrictInt] 33 ndcg: Union[StrictFloat, StrictInt] 34 __properties: ClassVar[List[str]] = ["question", "documents", "average_relevancy", "ndcg"] 35 36 model_config = ConfigDict( 37 populate_by_name=True, 38 validate_assignment=True, 39 protected_namespaces=(), 40 ) 41 42 43 def to_str(self) -> str: 44 """Returns the string representation of the model using alias""" 45 return pprint.pformat(self.model_dump(by_alias=True)) 46 47 def to_json(self) -> str: 48 """Returns the JSON representation of the model using alias""" 49 # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead 50 return json.dumps(self.to_dict()) 51 52 @classmethod 53 def from_json(cls, json_str: str) -> Optional[Self]: 54 """Create an instance of RetrieveDocumentsResponse from a JSON string""" 55 return cls.from_dict(json.loads(json_str)) 56 57 def to_dict(self) -> Dict[str, Any]: 58 """Return the dictionary representation of the model using alias. 59 60 This has the following differences from calling pydantic's 61 `self.model_dump(by_alias=True)`: 62 63 * `None` is only added to the output dict for nullable fields that 64 were set at model initialization. Other fields with value `None` 65 are ignored. 66 """ 67 excluded_fields: Set[str] = set([ 68 ]) 69 70 _dict = self.model_dump( 71 by_alias=True, 72 exclude=excluded_fields, 73 exclude_none=True, 74 ) 75 # override the default output from pydantic by calling `to_dict()` of each item in documents (list) 76 _items = [] 77 if self.documents: 78 for _item_documents in self.documents: 79 if _item_documents: 80 _items.append(_item_documents.to_dict()) 81 _dict['documents'] = _items 82 return _dict 83 84 @classmethod 85 def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: 86 """Create an instance of RetrieveDocumentsResponse from a dict""" 87 if obj is None: 88 return None 89 90 if not isinstance(obj, dict): 91 return cls.model_validate(obj) 92 93 _obj = cls.model_validate({ 94 "question": obj.get("question"), 95 "documents": [Document.from_dict(_item) for _item in obj["documents"]] if obj.get("documents") is not None else None, 96 "average_relevancy": obj.get("average_relevancy"), 97 "ndcg": obj.get("ndcg") 98 }) 99 return _obj
class
RetrieveDocumentsResponse(pydantic.main.BaseModel):
27class RetrieveDocumentsResponse(BaseModel): 28 """ 29 RetrieveDocumentsResponse 30 """ # noqa: E501 31 question: StrictStr 32 documents: List[Document] 33 average_relevancy: Union[StrictFloat, StrictInt] 34 ndcg: Union[StrictFloat, StrictInt] 35 __properties: ClassVar[List[str]] = ["question", "documents", "average_relevancy", "ndcg"] 36 37 model_config = ConfigDict( 38 populate_by_name=True, 39 validate_assignment=True, 40 protected_namespaces=(), 41 ) 42 43 44 def to_str(self) -> str: 45 """Returns the string representation of the model using alias""" 46 return pprint.pformat(self.model_dump(by_alias=True)) 47 48 def to_json(self) -> str: 49 """Returns the JSON representation of the model using alias""" 50 # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead 51 return json.dumps(self.to_dict()) 52 53 @classmethod 54 def from_json(cls, json_str: str) -> Optional[Self]: 55 """Create an instance of RetrieveDocumentsResponse from a JSON string""" 56 return cls.from_dict(json.loads(json_str)) 57 58 def to_dict(self) -> Dict[str, Any]: 59 """Return the dictionary representation of the model using alias. 60 61 This has the following differences from calling pydantic's 62 `self.model_dump(by_alias=True)`: 63 64 * `None` is only added to the output dict for nullable fields that 65 were set at model initialization. Other fields with value `None` 66 are ignored. 67 """ 68 excluded_fields: Set[str] = set([ 69 ]) 70 71 _dict = self.model_dump( 72 by_alias=True, 73 exclude=excluded_fields, 74 exclude_none=True, 75 ) 76 # override the default output from pydantic by calling `to_dict()` of each item in documents (list) 77 _items = [] 78 if self.documents: 79 for _item_documents in self.documents: 80 if _item_documents: 81 _items.append(_item_documents.to_dict()) 82 _dict['documents'] = _items 83 return _dict 84 85 @classmethod 86 def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: 87 """Create an instance of RetrieveDocumentsResponse from a dict""" 88 if obj is None: 89 return None 90 91 if not isinstance(obj, dict): 92 return cls.model_validate(obj) 93 94 _obj = cls.model_validate({ 95 "question": obj.get("question"), 96 "documents": [Document.from_dict(_item) for _item in obj["documents"]] if obj.get("documents") is not None else None, 97 "average_relevancy": obj.get("average_relevancy"), 98 "ndcg": obj.get("ndcg") 99 }) 100 return _obj
RetrieveDocumentsResponse
documents: List[vectorize_client.models.document.Document]
average_relevancy: Union[Annotated[float, Strict(strict=True)], Annotated[int, Strict(strict=True)]]
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:
44 def to_str(self) -> str: 45 """Returns the string representation of the model using alias""" 46 return pprint.pformat(self.model_dump(by_alias=True))
Returns the string representation of the model using alias
def
to_json(self) -> str:
48 def to_json(self) -> str: 49 """Returns the JSON representation of the model using alias""" 50 # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead 51 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]:
53 @classmethod 54 def from_json(cls, json_str: str) -> Optional[Self]: 55 """Create an instance of RetrieveDocumentsResponse from a JSON string""" 56 return cls.from_dict(json.loads(json_str))
Create an instance of RetrieveDocumentsResponse from a JSON string
def
to_dict(self) -> Dict[str, Any]:
58 def to_dict(self) -> Dict[str, Any]: 59 """Return the dictionary representation of the model using alias. 60 61 This has the following differences from calling pydantic's 62 `self.model_dump(by_alias=True)`: 63 64 * `None` is only added to the output dict for nullable fields that 65 were set at model initialization. Other fields with value `None` 66 are ignored. 67 """ 68 excluded_fields: Set[str] = set([ 69 ]) 70 71 _dict = self.model_dump( 72 by_alias=True, 73 exclude=excluded_fields, 74 exclude_none=True, 75 ) 76 # override the default output from pydantic by calling `to_dict()` of each item in documents (list) 77 _items = [] 78 if self.documents: 79 for _item_documents in self.documents: 80 if _item_documents: 81 _items.append(_item_documents.to_dict()) 82 _dict['documents'] = _items 83 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 valueNone
are ignored.
@classmethod
def
from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
85 @classmethod 86 def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: 87 """Create an instance of RetrieveDocumentsResponse from a dict""" 88 if obj is None: 89 return None 90 91 if not isinstance(obj, dict): 92 return cls.model_validate(obj) 93 94 _obj = cls.model_validate({ 95 "question": obj.get("question"), 96 "documents": [Document.from_dict(_item) for _item in obj["documents"]] if obj.get("documents") is not None else None, 97 "average_relevancy": obj.get("average_relevancy"), 98 "ndcg": obj.get("ndcg") 99 }) 100 return _obj
Create an instance of RetrieveDocumentsResponse from a dict