stract-api 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- stract_api/__init__.py +141 -0
- stract_api/api/__init__.py +16 -0
- stract_api/api/account_api.py +1098 -0
- stract_api/api/account_credit_ledger_api.py +286 -0
- stract_api/api/api_key_api.py +286 -0
- stract_api/api/catalog_api.py +837 -0
- stract_api/api/credits_api.py +534 -0
- stract_api/api/document_api.py +2799 -0
- stract_api/api/field_api.py +1168 -0
- stract_api/api/job_api.py +2857 -0
- stract_api/api/job_document_api.py +575 -0
- stract_api/api/llm_model_api.py +286 -0
- stract_api/api/struct_api.py +837 -0
- stract_api/api/user_api.py +572 -0
- stract_api/api_client.py +866 -0
- stract_api/api_response.py +21 -0
- stract_api/configuration.py +655 -0
- stract_api/exceptions.py +219 -0
- stract_api/models/__init__.py +52 -0
- stract_api/models/account.py +130 -0
- stract_api/models/account_credit_cache.py +112 -0
- stract_api/models/account_credit_ledger.py +125 -0
- stract_api/models/account_user.py +104 -0
- stract_api/models/account_user_role.py +38 -0
- stract_api/models/api_key.py +102 -0
- stract_api/models/catalog.py +100 -0
- stract_api/models/create_account_user_request.py +97 -0
- stract_api/models/create_catalog_request.py +90 -0
- stract_api/models/create_field_request.py +102 -0
- stract_api/models/create_job_request.py +109 -0
- stract_api/models/create_struct_request.py +90 -0
- stract_api/models/deleted_document.py +91 -0
- stract_api/models/deleted_field.py +91 -0
- stract_api/models/document.py +107 -0
- stract_api/models/document_link.py +90 -0
- stract_api/models/document_processing_status.py +39 -0
- stract_api/models/document_text.py +95 -0
- stract_api/models/edit_account_request.py +90 -0
- stract_api/models/edit_field_request.py +102 -0
- stract_api/models/edit_my_user_request.py +92 -0
- stract_api/models/field_type.py +42 -0
- stract_api/models/job.py +129 -0
- stract_api/models/job_document.py +123 -0
- stract_api/models/job_output.py +98 -0
- stract_api/models/job_output_record.py +103 -0
- stract_api/models/job_status.py +41 -0
- stract_api/models/llm_model.py +126 -0
- stract_api/models/login_request.py +92 -0
- stract_api/models/login_response.py +90 -0
- stract_api/models/model_field.py +110 -0
- stract_api/models/struct.py +100 -0
- stract_api/models/sync_text_job_request.py +118 -0
- stract_api/models/upload_text_document_request.py +93 -0
- stract_api/models/user.py +102 -0
- stract_api/py.typed +0 -0
- stract_api/rest.py +335 -0
- stract_api-0.1.0.dist-info/METADATA +266 -0
- stract_api-0.1.0.dist-info/RECORD +61 -0
- stract_api-0.1.0.dist-info/WHEEL +5 -0
- stract_api-0.1.0.dist-info/licenses/LICENSE +21 -0
- stract_api-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Stract API
|
|
5
|
+
|
|
6
|
+
Get structured output from unstructured inputs ## Machine authentication Programmatic access to the API is authenticated with an API key. Include the API key in every request as a bearer token in the `authorization` header: ``` authorization: bearer [apiKey] ``` ## SDKs Official SDKs are available for the following languages: - **Node (JavaScript / TypeScript)**: [`stract-api` on npm](https://www.npmjs.com/package/stract-api) - **Java (17+)**: [`com.stract-api:stract-api` on Maven Central](https://central.sonatype.com/artifact/com.stract-api/stract-api)
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 0.9.4
|
|
9
|
+
Contact: matt@stract-api.com
|
|
10
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
11
|
+
|
|
12
|
+
Do not edit the class manually.
|
|
13
|
+
""" # noqa: E501
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
import pprint
|
|
18
|
+
import re # noqa: F401
|
|
19
|
+
import json
|
|
20
|
+
|
|
21
|
+
from datetime import datetime
|
|
22
|
+
from pydantic import BaseModel, ConfigDict, Field
|
|
23
|
+
from typing import Any, ClassVar, Dict, List
|
|
24
|
+
from uuid import UUID
|
|
25
|
+
from typing import Optional, Set
|
|
26
|
+
from typing_extensions import Self
|
|
27
|
+
from pydantic_core import to_jsonable_python
|
|
28
|
+
from pydantic import field_validator as _coerce_field_validator
|
|
29
|
+
|
|
30
|
+
class JobOutput(BaseModel):
|
|
31
|
+
"""
|
|
32
|
+
JobOutput
|
|
33
|
+
""" # noqa: E501
|
|
34
|
+
id: UUID = Field(description="Unique identifier of the job output")
|
|
35
|
+
job_document_id: UUID = Field(description="ID of the job document this output belongs to")
|
|
36
|
+
data: Dict[str, Any] = Field(description="Extracted structured data for the document, keyed by field name")
|
|
37
|
+
dt_created: datetime = Field(description="Timestamp when the output was created")
|
|
38
|
+
__properties: ClassVar[List[str]] = ["id", "job_document_id", "data", "dt_created"]
|
|
39
|
+
|
|
40
|
+
model_config = ConfigDict(
|
|
41
|
+
validate_by_name=True,
|
|
42
|
+
validate_by_alias=True,
|
|
43
|
+
validate_assignment=True,
|
|
44
|
+
protected_namespaces=(),
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def to_str(self) -> str:
|
|
49
|
+
"""Returns the string representation of the model using alias"""
|
|
50
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
|
51
|
+
|
|
52
|
+
def to_json(self) -> str:
|
|
53
|
+
"""Returns the JSON representation of the model using alias"""
|
|
54
|
+
return json.dumps(to_jsonable_python(self.to_dict()))
|
|
55
|
+
|
|
56
|
+
@classmethod
|
|
57
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
|
58
|
+
"""Create an instance of JobOutput 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
|
+
return _dict
|
|
80
|
+
|
|
81
|
+
@classmethod
|
|
82
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
83
|
+
"""Create an instance of JobOutput from a dict"""
|
|
84
|
+
if obj is None:
|
|
85
|
+
return None
|
|
86
|
+
|
|
87
|
+
if not isinstance(obj, dict):
|
|
88
|
+
return cls.model_validate(obj)
|
|
89
|
+
|
|
90
|
+
_obj = cls.model_validate({
|
|
91
|
+
"id": obj.get("id"),
|
|
92
|
+
"job_document_id": obj.get("job_document_id"),
|
|
93
|
+
"data": obj.get("data"),
|
|
94
|
+
"dt_created": obj.get("dt_created")
|
|
95
|
+
})
|
|
96
|
+
return _obj
|
|
97
|
+
|
|
98
|
+
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Stract API
|
|
5
|
+
|
|
6
|
+
Get structured output from unstructured inputs ## Machine authentication Programmatic access to the API is authenticated with an API key. Include the API key in every request as a bearer token in the `authorization` header: ``` authorization: bearer [apiKey] ``` ## SDKs Official SDKs are available for the following languages: - **Node (JavaScript / TypeScript)**: [`stract-api` on npm](https://www.npmjs.com/package/stract-api) - **Java (17+)**: [`com.stract-api:stract-api` on Maven Central](https://central.sonatype.com/artifact/com.stract-api/stract-api)
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 0.9.4
|
|
9
|
+
Contact: matt@stract-api.com
|
|
10
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
11
|
+
|
|
12
|
+
Do not edit the class manually.
|
|
13
|
+
""" # noqa: E501
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
import pprint
|
|
18
|
+
import re # noqa: F401
|
|
19
|
+
import json
|
|
20
|
+
|
|
21
|
+
from pydantic import BaseModel, ConfigDict, Field, StrictStr
|
|
22
|
+
from typing import Any, ClassVar, Dict, List
|
|
23
|
+
from typing import Optional, Set
|
|
24
|
+
from typing_extensions import Self
|
|
25
|
+
from pydantic_core import to_jsonable_python
|
|
26
|
+
from pydantic import field_validator as _coerce_field_validator
|
|
27
|
+
|
|
28
|
+
class JobOutputRecord(BaseModel):
|
|
29
|
+
"""
|
|
30
|
+
Extracted structured data fields for the document, plus the document name
|
|
31
|
+
""" # noqa: E501
|
|
32
|
+
document_name: StrictStr = Field(description="Name of the document this output belongs to")
|
|
33
|
+
additional_properties: Dict[str, Any] = {}
|
|
34
|
+
__properties: ClassVar[List[str]] = ["document_name"]
|
|
35
|
+
|
|
36
|
+
model_config = ConfigDict(
|
|
37
|
+
validate_by_name=True,
|
|
38
|
+
validate_by_alias=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
|
+
return json.dumps(to_jsonable_python(self.to_dict()))
|
|
51
|
+
|
|
52
|
+
@classmethod
|
|
53
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
|
54
|
+
"""Create an instance of JobOutputRecord 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
|
+
* Fields in `self.additional_properties` are added to the output dict.
|
|
67
|
+
"""
|
|
68
|
+
excluded_fields: Set[str] = set([
|
|
69
|
+
"additional_properties",
|
|
70
|
+
])
|
|
71
|
+
|
|
72
|
+
_dict = self.model_dump(
|
|
73
|
+
by_alias=True,
|
|
74
|
+
exclude=excluded_fields,
|
|
75
|
+
exclude_none=True,
|
|
76
|
+
)
|
|
77
|
+
# puts key-value pairs in additional_properties in the top level
|
|
78
|
+
if self.additional_properties is not None:
|
|
79
|
+
for _key, _value in self.additional_properties.items():
|
|
80
|
+
_dict[_key] = _value
|
|
81
|
+
|
|
82
|
+
return _dict
|
|
83
|
+
|
|
84
|
+
@classmethod
|
|
85
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
86
|
+
"""Create an instance of JobOutputRecord 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
|
+
"document_name": obj.get("document_name")
|
|
95
|
+
})
|
|
96
|
+
# store additional fields in additional_properties
|
|
97
|
+
for _key in obj.keys():
|
|
98
|
+
if _key not in cls.__properties:
|
|
99
|
+
_obj.additional_properties[_key] = obj.get(_key)
|
|
100
|
+
|
|
101
|
+
return _obj
|
|
102
|
+
|
|
103
|
+
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Stract API
|
|
5
|
+
|
|
6
|
+
Get structured output from unstructured inputs ## Machine authentication Programmatic access to the API is authenticated with an API key. Include the API key in every request as a bearer token in the `authorization` header: ``` authorization: bearer [apiKey] ``` ## SDKs Official SDKs are available for the following languages: - **Node (JavaScript / TypeScript)**: [`stract-api` on npm](https://www.npmjs.com/package/stract-api) - **Java (17+)**: [`com.stract-api:stract-api` on Maven Central](https://central.sonatype.com/artifact/com.stract-api/stract-api)
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 0.9.4
|
|
9
|
+
Contact: matt@stract-api.com
|
|
10
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
11
|
+
|
|
12
|
+
Do not edit the class manually.
|
|
13
|
+
""" # noqa: E501
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
import json
|
|
18
|
+
from enum import Enum
|
|
19
|
+
from typing_extensions import Self
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class JobStatus(str, Enum):
|
|
23
|
+
"""
|
|
24
|
+
The current status of the job
|
|
25
|
+
"""
|
|
26
|
+
|
|
27
|
+
"""
|
|
28
|
+
allowed enum values
|
|
29
|
+
"""
|
|
30
|
+
NOT_STARTED = 'not_started'
|
|
31
|
+
IN_PROGRESS = 'in_progress'
|
|
32
|
+
COMPLETE = 'complete'
|
|
33
|
+
ERROR = 'error'
|
|
34
|
+
CANCELLED = 'cancelled'
|
|
35
|
+
|
|
36
|
+
@classmethod
|
|
37
|
+
def from_json(cls, json_str: str) -> Self:
|
|
38
|
+
"""Create an instance of JobStatus from a JSON string"""
|
|
39
|
+
return cls(json.loads(json_str))
|
|
40
|
+
|
|
41
|
+
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Stract API
|
|
5
|
+
|
|
6
|
+
Get structured output from unstructured inputs ## Machine authentication Programmatic access to the API is authenticated with an API key. Include the API key in every request as a bearer token in the `authorization` header: ``` authorization: bearer [apiKey] ``` ## SDKs Official SDKs are available for the following languages: - **Node (JavaScript / TypeScript)**: [`stract-api` on npm](https://www.npmjs.com/package/stract-api) - **Java (17+)**: [`com.stract-api:stract-api` on Maven Central](https://central.sonatype.com/artifact/com.stract-api/stract-api)
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 0.9.4
|
|
9
|
+
Contact: matt@stract-api.com
|
|
10
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
11
|
+
|
|
12
|
+
Do not edit the class manually.
|
|
13
|
+
""" # noqa: E501
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
import pprint
|
|
18
|
+
import re # noqa: F401
|
|
19
|
+
import json
|
|
20
|
+
|
|
21
|
+
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictFloat, StrictInt, StrictStr
|
|
22
|
+
from typing import Any, ClassVar, Dict, List, Union
|
|
23
|
+
from typing import Optional, Set
|
|
24
|
+
from typing_extensions import Self
|
|
25
|
+
from pydantic_core import to_jsonable_python
|
|
26
|
+
from pydantic import field_validator as _coerce_field_validator
|
|
27
|
+
|
|
28
|
+
class LlmModel(BaseModel):
|
|
29
|
+
"""
|
|
30
|
+
LlmModel
|
|
31
|
+
""" # noqa: E501
|
|
32
|
+
id: StrictStr = Field(description="Unique identifier of the model, used as the llm_model_id when creating a job", json_schema_extra={"examples": ["google.gemma-3-27b-it"]})
|
|
33
|
+
maker: StrictStr = Field(description="Company that makes the model", json_schema_extra={"examples": ["Google"]})
|
|
34
|
+
name: StrictStr = Field(description="Human-readable name of the model", json_schema_extra={"examples": ["Gemma 3 27B"]})
|
|
35
|
+
credits_per_m_input: Union[StrictFloat, StrictInt] = Field(description="Credits consumed per one million input tokens")
|
|
36
|
+
credits_per_m_output: Union[StrictFloat, StrictInt] = Field(description="Credits consumed per one million output tokens")
|
|
37
|
+
can_do_images: StrictBool = Field(description="Whether the model can process image inputs")
|
|
38
|
+
can_do_audio: StrictBool = Field(description="Whether the model can process audio inputs")
|
|
39
|
+
can_do_video: StrictBool = Field(description="Whether the model can process video inputs")
|
|
40
|
+
is_available: StrictBool = Field(description="Whether the model is currently available for use")
|
|
41
|
+
__properties: ClassVar[List[str]] = ["id", "maker", "name", "credits_per_m_input", "credits_per_m_output", "can_do_images", "can_do_audio", "can_do_video", "is_available"]
|
|
42
|
+
|
|
43
|
+
@_coerce_field_validator('credits_per_m_input', mode="before")
|
|
44
|
+
def credits_per_m_input_coerce_numeric_string(cls, value):
|
|
45
|
+
"""The API sends numbers as strings (e.g. '29532'); convert them before strict validation"""
|
|
46
|
+
if isinstance(value, str):
|
|
47
|
+
try:
|
|
48
|
+
return int(value)
|
|
49
|
+
except ValueError:
|
|
50
|
+
return float(value)
|
|
51
|
+
return value
|
|
52
|
+
|
|
53
|
+
@_coerce_field_validator('credits_per_m_output', mode="before")
|
|
54
|
+
def credits_per_m_output_coerce_numeric_string(cls, value):
|
|
55
|
+
"""The API sends numbers as strings (e.g. '29532'); convert them before strict validation"""
|
|
56
|
+
if isinstance(value, str):
|
|
57
|
+
try:
|
|
58
|
+
return int(value)
|
|
59
|
+
except ValueError:
|
|
60
|
+
return float(value)
|
|
61
|
+
return value
|
|
62
|
+
|
|
63
|
+
model_config = ConfigDict(
|
|
64
|
+
validate_by_name=True,
|
|
65
|
+
validate_by_alias=True,
|
|
66
|
+
validate_assignment=True,
|
|
67
|
+
protected_namespaces=(),
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def to_str(self) -> str:
|
|
72
|
+
"""Returns the string representation of the model using alias"""
|
|
73
|
+
return pprint.pformat(self.model_dump(by_alias=True))
|
|
74
|
+
|
|
75
|
+
def to_json(self) -> str:
|
|
76
|
+
"""Returns the JSON representation of the model using alias"""
|
|
77
|
+
return json.dumps(to_jsonable_python(self.to_dict()))
|
|
78
|
+
|
|
79
|
+
@classmethod
|
|
80
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
|
81
|
+
"""Create an instance of LlmModel from a JSON string"""
|
|
82
|
+
return cls.from_dict(json.loads(json_str))
|
|
83
|
+
|
|
84
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
85
|
+
"""Return the dictionary representation of the model using alias.
|
|
86
|
+
|
|
87
|
+
This has the following differences from calling pydantic's
|
|
88
|
+
`self.model_dump(by_alias=True)`:
|
|
89
|
+
|
|
90
|
+
* `None` is only added to the output dict for nullable fields that
|
|
91
|
+
were set at model initialization. Other fields with value `None`
|
|
92
|
+
are ignored.
|
|
93
|
+
"""
|
|
94
|
+
excluded_fields: Set[str] = set([
|
|
95
|
+
])
|
|
96
|
+
|
|
97
|
+
_dict = self.model_dump(
|
|
98
|
+
by_alias=True,
|
|
99
|
+
exclude=excluded_fields,
|
|
100
|
+
exclude_none=True,
|
|
101
|
+
)
|
|
102
|
+
return _dict
|
|
103
|
+
|
|
104
|
+
@classmethod
|
|
105
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
106
|
+
"""Create an instance of LlmModel from a dict"""
|
|
107
|
+
if obj is None:
|
|
108
|
+
return None
|
|
109
|
+
|
|
110
|
+
if not isinstance(obj, dict):
|
|
111
|
+
return cls.model_validate(obj)
|
|
112
|
+
|
|
113
|
+
_obj = cls.model_validate({
|
|
114
|
+
"id": obj.get("id"),
|
|
115
|
+
"maker": obj.get("maker"),
|
|
116
|
+
"name": obj.get("name"),
|
|
117
|
+
"credits_per_m_input": obj.get("credits_per_m_input"),
|
|
118
|
+
"credits_per_m_output": obj.get("credits_per_m_output"),
|
|
119
|
+
"can_do_images": obj.get("can_do_images"),
|
|
120
|
+
"can_do_audio": obj.get("can_do_audio"),
|
|
121
|
+
"can_do_video": obj.get("can_do_video"),
|
|
122
|
+
"is_available": obj.get("is_available")
|
|
123
|
+
})
|
|
124
|
+
return _obj
|
|
125
|
+
|
|
126
|
+
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Stract API
|
|
5
|
+
|
|
6
|
+
Get structured output from unstructured inputs ## Machine authentication Programmatic access to the API is authenticated with an API key. Include the API key in every request as a bearer token in the `authorization` header: ``` authorization: bearer [apiKey] ``` ## SDKs Official SDKs are available for the following languages: - **Node (JavaScript / TypeScript)**: [`stract-api` on npm](https://www.npmjs.com/package/stract-api) - **Java (17+)**: [`com.stract-api:stract-api` on Maven Central](https://central.sonatype.com/artifact/com.stract-api/stract-api)
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 0.9.4
|
|
9
|
+
Contact: matt@stract-api.com
|
|
10
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
11
|
+
|
|
12
|
+
Do not edit the class manually.
|
|
13
|
+
""" # noqa: E501
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
import pprint
|
|
18
|
+
import re # noqa: F401
|
|
19
|
+
import json
|
|
20
|
+
|
|
21
|
+
from pydantic import BaseModel, ConfigDict, Field, SecretStr, StrictStr
|
|
22
|
+
from typing import Any, ClassVar, Dict, List
|
|
23
|
+
from typing import Optional, Set
|
|
24
|
+
from typing_extensions import Self
|
|
25
|
+
from pydantic_core import to_jsonable_python
|
|
26
|
+
from pydantic import field_validator as _coerce_field_validator
|
|
27
|
+
|
|
28
|
+
class LoginRequest(BaseModel):
|
|
29
|
+
"""
|
|
30
|
+
LoginRequest
|
|
31
|
+
""" # noqa: E501
|
|
32
|
+
email: StrictStr = Field(description="User's email address", json_schema_extra={"examples": ["user@example.com"]})
|
|
33
|
+
password: SecretStr = Field(description="User's password", json_schema_extra={"examples": ["secretpassword"]})
|
|
34
|
+
__properties: ClassVar[List[str]] = ["email", "password"]
|
|
35
|
+
|
|
36
|
+
model_config = ConfigDict(
|
|
37
|
+
validate_by_name=True,
|
|
38
|
+
validate_by_alias=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
|
+
return json.dumps(to_jsonable_python(self.to_dict()))
|
|
51
|
+
|
|
52
|
+
@classmethod
|
|
53
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
|
54
|
+
"""Create an instance of LoginRequest 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
|
+
return _dict
|
|
76
|
+
|
|
77
|
+
@classmethod
|
|
78
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
79
|
+
"""Create an instance of LoginRequest from a dict"""
|
|
80
|
+
if obj is None:
|
|
81
|
+
return None
|
|
82
|
+
|
|
83
|
+
if not isinstance(obj, dict):
|
|
84
|
+
return cls.model_validate(obj)
|
|
85
|
+
|
|
86
|
+
_obj = cls.model_validate({
|
|
87
|
+
"email": obj.get("email"),
|
|
88
|
+
"password": obj.get("password")
|
|
89
|
+
})
|
|
90
|
+
return _obj
|
|
91
|
+
|
|
92
|
+
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Stract API
|
|
5
|
+
|
|
6
|
+
Get structured output from unstructured inputs ## Machine authentication Programmatic access to the API is authenticated with an API key. Include the API key in every request as a bearer token in the `authorization` header: ``` authorization: bearer [apiKey] ``` ## SDKs Official SDKs are available for the following languages: - **Node (JavaScript / TypeScript)**: [`stract-api` on npm](https://www.npmjs.com/package/stract-api) - **Java (17+)**: [`com.stract-api:stract-api` on Maven Central](https://central.sonatype.com/artifact/com.stract-api/stract-api)
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 0.9.4
|
|
9
|
+
Contact: matt@stract-api.com
|
|
10
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
11
|
+
|
|
12
|
+
Do not edit the class manually.
|
|
13
|
+
""" # noqa: E501
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
import pprint
|
|
18
|
+
import re # noqa: F401
|
|
19
|
+
import json
|
|
20
|
+
|
|
21
|
+
from pydantic import BaseModel, ConfigDict, Field, StrictStr
|
|
22
|
+
from typing import Any, ClassVar, Dict, List
|
|
23
|
+
from typing import Optional, Set
|
|
24
|
+
from typing_extensions import Self
|
|
25
|
+
from pydantic_core import to_jsonable_python
|
|
26
|
+
from pydantic import field_validator as _coerce_field_validator
|
|
27
|
+
|
|
28
|
+
class LoginResponse(BaseModel):
|
|
29
|
+
"""
|
|
30
|
+
LoginResponse
|
|
31
|
+
""" # noqa: E501
|
|
32
|
+
token: StrictStr = Field(description="JWT token for authentication", json_schema_extra={"examples": ["eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."]})
|
|
33
|
+
__properties: ClassVar[List[str]] = ["token"]
|
|
34
|
+
|
|
35
|
+
model_config = ConfigDict(
|
|
36
|
+
validate_by_name=True,
|
|
37
|
+
validate_by_alias=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
|
+
return json.dumps(to_jsonable_python(self.to_dict()))
|
|
50
|
+
|
|
51
|
+
@classmethod
|
|
52
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
|
53
|
+
"""Create an instance of LoginResponse from a JSON string"""
|
|
54
|
+
return cls.from_dict(json.loads(json_str))
|
|
55
|
+
|
|
56
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
57
|
+
"""Return the dictionary representation of the model using alias.
|
|
58
|
+
|
|
59
|
+
This has the following differences from calling pydantic's
|
|
60
|
+
`self.model_dump(by_alias=True)`:
|
|
61
|
+
|
|
62
|
+
* `None` is only added to the output dict for nullable fields that
|
|
63
|
+
were set at model initialization. Other fields with value `None`
|
|
64
|
+
are ignored.
|
|
65
|
+
"""
|
|
66
|
+
excluded_fields: Set[str] = set([
|
|
67
|
+
])
|
|
68
|
+
|
|
69
|
+
_dict = self.model_dump(
|
|
70
|
+
by_alias=True,
|
|
71
|
+
exclude=excluded_fields,
|
|
72
|
+
exclude_none=True,
|
|
73
|
+
)
|
|
74
|
+
return _dict
|
|
75
|
+
|
|
76
|
+
@classmethod
|
|
77
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
78
|
+
"""Create an instance of LoginResponse from a dict"""
|
|
79
|
+
if obj is None:
|
|
80
|
+
return None
|
|
81
|
+
|
|
82
|
+
if not isinstance(obj, dict):
|
|
83
|
+
return cls.model_validate(obj)
|
|
84
|
+
|
|
85
|
+
_obj = cls.model_validate({
|
|
86
|
+
"token": obj.get("token")
|
|
87
|
+
})
|
|
88
|
+
return _obj
|
|
89
|
+
|
|
90
|
+
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
"""
|
|
4
|
+
Stract API
|
|
5
|
+
|
|
6
|
+
Get structured output from unstructured inputs ## Machine authentication Programmatic access to the API is authenticated with an API key. Include the API key in every request as a bearer token in the `authorization` header: ``` authorization: bearer [apiKey] ``` ## SDKs Official SDKs are available for the following languages: - **Node (JavaScript / TypeScript)**: [`stract-api` on npm](https://www.npmjs.com/package/stract-api) - **Java (17+)**: [`com.stract-api:stract-api` on Maven Central](https://central.sonatype.com/artifact/com.stract-api/stract-api)
|
|
7
|
+
|
|
8
|
+
The version of the OpenAPI document: 0.9.4
|
|
9
|
+
Contact: matt@stract-api.com
|
|
10
|
+
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
|
11
|
+
|
|
12
|
+
Do not edit the class manually.
|
|
13
|
+
""" # noqa: E501
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
from __future__ import annotations
|
|
17
|
+
import pprint
|
|
18
|
+
import re # noqa: F401
|
|
19
|
+
import json
|
|
20
|
+
|
|
21
|
+
from datetime import date
|
|
22
|
+
from pydantic import BaseModel, ConfigDict, Field, StrictStr
|
|
23
|
+
from typing import Any, ClassVar, Dict, List, Optional
|
|
24
|
+
from uuid import UUID
|
|
25
|
+
from stract_api.models.field_type import FieldType
|
|
26
|
+
from typing import Optional, Set
|
|
27
|
+
from typing_extensions import Self
|
|
28
|
+
from pydantic_core import to_jsonable_python
|
|
29
|
+
from pydantic import field_validator as _coerce_field_validator
|
|
30
|
+
|
|
31
|
+
class ModelField(BaseModel):
|
|
32
|
+
"""
|
|
33
|
+
ModelField
|
|
34
|
+
""" # noqa: E501
|
|
35
|
+
id: UUID = Field(description="Unique identifier of the field")
|
|
36
|
+
struct_id: UUID = Field(description="ID of the struct this field belongs to")
|
|
37
|
+
date_created: date = Field(description="Date when the field was created")
|
|
38
|
+
name: StrictStr = Field(description="Name of the field")
|
|
39
|
+
description: StrictStr = Field(description="Description of the field")
|
|
40
|
+
type: FieldType
|
|
41
|
+
enum_values: Optional[List[StrictStr]] = Field(default=None, description="Allowed values for the field. Required if type is enum.")
|
|
42
|
+
__properties: ClassVar[List[str]] = ["id", "struct_id", "date_created", "name", "description", "type", "enum_values"]
|
|
43
|
+
|
|
44
|
+
model_config = ConfigDict(
|
|
45
|
+
validate_by_name=True,
|
|
46
|
+
validate_by_alias=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
|
+
return json.dumps(to_jsonable_python(self.to_dict()))
|
|
59
|
+
|
|
60
|
+
@classmethod
|
|
61
|
+
def from_json(cls, json_str: str) -> Optional[Self]:
|
|
62
|
+
"""Create an instance of ModelField from a JSON string"""
|
|
63
|
+
return cls.from_dict(json.loads(json_str))
|
|
64
|
+
|
|
65
|
+
def to_dict(self) -> Dict[str, Any]:
|
|
66
|
+
"""Return the dictionary representation of the model using alias.
|
|
67
|
+
|
|
68
|
+
This has the following differences from calling pydantic's
|
|
69
|
+
`self.model_dump(by_alias=True)`:
|
|
70
|
+
|
|
71
|
+
* `None` is only added to the output dict for nullable fields that
|
|
72
|
+
were set at model initialization. Other fields with value `None`
|
|
73
|
+
are ignored.
|
|
74
|
+
"""
|
|
75
|
+
excluded_fields: Set[str] = set([
|
|
76
|
+
])
|
|
77
|
+
|
|
78
|
+
_dict = self.model_dump(
|
|
79
|
+
by_alias=True,
|
|
80
|
+
exclude=excluded_fields,
|
|
81
|
+
exclude_none=True,
|
|
82
|
+
)
|
|
83
|
+
# set to None if enum_values (nullable) is None
|
|
84
|
+
# and model_fields_set contains the field
|
|
85
|
+
if self.enum_values is None and "enum_values" in self.model_fields_set:
|
|
86
|
+
_dict['enum_values'] = None
|
|
87
|
+
|
|
88
|
+
return _dict
|
|
89
|
+
|
|
90
|
+
@classmethod
|
|
91
|
+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
|
92
|
+
"""Create an instance of ModelField from a dict"""
|
|
93
|
+
if obj is None:
|
|
94
|
+
return None
|
|
95
|
+
|
|
96
|
+
if not isinstance(obj, dict):
|
|
97
|
+
return cls.model_validate(obj)
|
|
98
|
+
|
|
99
|
+
_obj = cls.model_validate({
|
|
100
|
+
"id": obj.get("id"),
|
|
101
|
+
"struct_id": obj.get("struct_id"),
|
|
102
|
+
"date_created": obj.get("date_created"),
|
|
103
|
+
"name": obj.get("name"),
|
|
104
|
+
"description": obj.get("description"),
|
|
105
|
+
"type": obj.get("type"),
|
|
106
|
+
"enum_values": obj.get("enum_values")
|
|
107
|
+
})
|
|
108
|
+
return _obj
|
|
109
|
+
|
|
110
|
+
|