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