retab 0.0.35__py3-none-any.whl → 0.0.36__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.
@@ -1,59 +0,0 @@
1
- import datetime
2
- from typing import Any, Literal, Optional
3
-
4
- import nanoid # type: ignore
5
- from openai.types.chat.chat_completion_reasoning_effort import ChatCompletionReasoningEffort
6
- from pydantic import BaseModel, Field, HttpUrl, field_serializer
7
- from pydantic_core import Url
8
-
9
- from ..modalities import Modality
10
-
11
-
12
- def scrapping_action(link: HttpUrl) -> dict[str, Any]:
13
- raise NotImplementedError("Scrapping action not implemented")
14
-
15
-
16
- class CronSchedule(BaseModel):
17
- second: Optional[int] = Field(0, ge=0, le=59, description="Second (0-59), defaults to 0")
18
- minute: int = Field(..., ge=0, le=59, description="Minute (0-59)")
19
- hour: int = Field(..., ge=0, le=23, description="Hour (0-23)")
20
- day_of_month: Optional[int] = Field(None, ge=1, le=31, description="Day of the month (1-31), None means any day")
21
- month: Optional[int] = Field(None, ge=1, le=12, description="Month (1-12), None means every month")
22
- day_of_week: Optional[int] = Field(None, ge=0, le=6, description="Day of the week (0-6, Sunday = 0), None means any day")
23
-
24
- def to_cron_string(self) -> str:
25
- return f"{self.second or '*'} {self.minute} {self.hour} {self.day_of_month or '*'} {self.month or '*'} {self.day_of_week or '*'}"
26
-
27
-
28
- from ..logs import AutomationConfig
29
-
30
-
31
- class ScrappingConfig(AutomationConfig):
32
- object: Literal['deployment.scrapping_cron'] = "deployment.scrapping_cron"
33
- id: str = Field(default_factory=lambda: "scrapping_" + nanoid.generate(), description="Unique identifier for the scrapping job")
34
-
35
- # Scrapping Specific Config
36
- link: HttpUrl = Field(..., description="Link to be scrapped")
37
- schedule: CronSchedule
38
-
39
- updated_at: datetime.datetime = Field(default_factory=lambda: datetime.datetime.now(datetime.timezone.utc))
40
-
41
- # HTTP Config
42
- webhook_url: HttpUrl = Field(..., description="Url of the webhook to send the data to")
43
- webhook_headers: dict[str, str] = Field(default_factory=dict, description="Headers to send with the request")
44
-
45
- modality: Modality
46
- image_resolution_dpi: int = Field(default=96, description="Resolution of the image sent to the LLM")
47
- browser_canvas: Literal['A3', 'A4', 'A5'] = Field(default='A4', description="Sets the size of the browser canvas for rendering documents in browser-based processing. Choose a size that matches the document type.")
48
-
49
- # New attributes
50
- model: str = Field(..., description="Model used for chat completion")
51
- json_schema: dict[str, Any] = Field(..., description="JSON schema format used to validate the output data.")
52
- temperature: float = Field(default=0.0, description="Temperature for sampling. If not provided, the default temperature for the model will be used.", examples=[0.0])
53
- reasoning_effort: ChatCompletionReasoningEffort = Field(
54
- default="medium", description="The effort level for the model to reason about the input data. If not provided, the default reasoning effort for the model will be used."
55
- )
56
-
57
- @field_serializer('webhook_url', 'link')
58
- def url2str(self, val: HttpUrl) -> str:
59
- return str(val)
@@ -1,28 +0,0 @@
1
- import copy
2
- import datetime
3
- import json
4
- from typing import Any, Literal, Optional
5
-
6
- import nanoid # type: ignore
7
- from openai.types.chat.chat_completion_reasoning_effort import ChatCompletionReasoningEffort
8
- from pydantic import BaseModel, Field, HttpUrl, computed_field, field_serializer
9
-
10
- from ..._utils.json_schema import clean_schema
11
- from ..._utils.mime import generate_blake2b_hash_from_string
12
- from ..logs import AutomationConfig, UpdateAutomationRequest
13
- from ..modalities import Modality
14
- from ..pagination import ListMetadata
15
-
16
-
17
- class Endpoint(AutomationConfig):
18
- object: Literal['deployment.endpoint'] = "deployment.endpoint"
19
- id: str = Field(default_factory=lambda: "endp_" + nanoid.generate(), description="Unique identifier for the extraction endpoint")
20
-
21
- class ListEndpoints(BaseModel):
22
- data: list[Endpoint]
23
- list_metadata: ListMetadata
24
-
25
-
26
- # Inherits from the methods of UpdateAutomationRequest
27
- class UpdateEndpointRequest(UpdateAutomationRequest):
28
- pass
@@ -1,36 +0,0 @@
1
- import copy
2
- import datetime
3
- import json
4
- from typing import Any, Dict, Literal, Optional
5
-
6
- import nanoid # type: ignore
7
- from openai.types.chat.chat_completion_reasoning_effort import ChatCompletionReasoningEffort
8
- from pydantic import BaseModel, Field, HttpUrl, computed_field, field_serializer
9
- from pydantic_core import Url
10
-
11
- from ..._utils.json_schema import clean_schema
12
- from ..._utils.mime import generate_blake2b_hash_from_string
13
- from ..logs import AutomationConfig, UpdateAutomationRequest
14
- from ..modalities import Modality
15
- from ..pagination import ListMetadata
16
-
17
-
18
- class Link(AutomationConfig):
19
- object: Literal['deployment.link'] = "deployment.link"
20
- id: str = Field(default_factory=lambda: "lnk_" + nanoid.generate(), description="Unique identifier for the extraction link")
21
-
22
- # Link Specific Config
23
- password: Optional[str] = Field(None, description="Password to access the link")
24
-
25
-
26
- class ListLinks(BaseModel):
27
- data: list[Link]
28
- list_metadata: ListMetadata
29
-
30
-
31
- # Inherits from the methods of UpdateAutomationRequest
32
- class UpdateLinkRequest(UpdateAutomationRequest):
33
- # ------------------------------
34
- # Link Config
35
- # ------------------------------
36
- password: Optional[str] = None
@@ -1,67 +0,0 @@
1
- import copy
2
- import datetime
3
- import json
4
- import os
5
- import re
6
- from typing import Any, ClassVar, Dict, List, Literal, Optional
7
-
8
- import nanoid # type: ignore
9
- from pydantic import BaseModel, EmailStr, Field, HttpUrl, computed_field, field_serializer, field_validator
10
- from pydantic_core import Url
11
-
12
- from ..._utils.json_schema import clean_schema
13
- from ..._utils.mime import generate_blake2b_hash_from_string
14
- from ..modalities import Modality
15
- from ..pagination import ListMetadata
16
-
17
- domain_pattern = re.compile(r"^(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}$")
18
-
19
- from openai.types.chat.chat_completion_reasoning_effort import ChatCompletionReasoningEffort
20
-
21
- from ..logs import AutomationConfig, UpdateAutomationRequest
22
-
23
-
24
- class Mailbox(AutomationConfig):
25
- EMAIL_PATTERN: ClassVar[str] = f".*@{os.getenv('EMAIL_DOMAIN', 'mailbox.uiform.com')}$"
26
- object: Literal['deployment.mailbox'] = "deployment.mailbox"
27
- id: str = Field(default_factory=lambda: "mb_" + nanoid.generate(), description="Unique identifier for the mailbox")
28
-
29
- # Email Specific config
30
- email: str = Field(..., pattern=EMAIL_PATTERN)
31
- authorized_domains: list[str] = Field(default_factory=list, description="List of authorized domains to receive the emails from")
32
- authorized_emails: List[EmailStr] = Field(default_factory=list, description="List of emails to access the link")
33
-
34
- # Normalize email fields (case-insensitive)
35
- @field_validator("email", mode="before")
36
- def normalize_email(cls, value: str) -> str:
37
- return value.strip().lower()
38
-
39
- @field_validator("authorized_emails", mode="before")
40
- def normalize_authorized_emails(cls, emails: List[str]) -> List[str]:
41
- return [email.strip().lower() for email in emails]
42
-
43
- @field_validator('authorized_domains', mode='before')
44
- def validate_domain(cls, list_domains: list[str]) -> list[str]:
45
- for domain in list_domains:
46
- if not domain_pattern.match(domain):
47
- raise ValueError(f"Invalid domain: {domain}")
48
- return list_domains
49
-
50
-
51
- class ListMailboxes(BaseModel):
52
- data: list[Mailbox]
53
- list_metadata: ListMetadata
54
-
55
-
56
- # Inherits from the methods of UpdateAutomationRequest
57
- class UpdateMailboxRequest(UpdateAutomationRequest):
58
-
59
- # ------------------------------
60
- # Email Specific config
61
- # ------------------------------
62
- authorized_domains: Optional[list[str]] = None
63
- authorized_emails: Optional[List[EmailStr]] = None
64
-
65
- @field_validator("authorized_emails", mode="before")
66
- def normalize_authorized_emails(cls, emails: Optional[List[str]]) -> Optional[List[str]]:
67
- return [email.strip().lower() for email in emails] if emails else None
@@ -1,76 +0,0 @@
1
- import copy
2
- import datetime
3
- import json
4
- import os
5
- import re
6
- from typing import Any, ClassVar, Dict, List, Literal, Optional
7
-
8
- import nanoid # type: ignore
9
- from openai.types.chat.chat_completion_reasoning_effort import ChatCompletionReasoningEffort
10
- from pydantic import BaseModel, EmailStr, Field, HttpUrl, computed_field, field_serializer, field_validator, model_validator
11
- from pydantic_core import Url
12
-
13
- from ..._utils.json_schema import clean_schema, convert_schema_to_layout
14
- from ..._utils.mime import generate_blake2b_hash_from_string
15
- from ..logs import AutomationConfig, UpdateAutomationRequest
16
- from ..modalities import Modality
17
- from ..pagination import ListMetadata
18
-
19
- domain_pattern = re.compile(r"^(?:[a-zA-Z0-9-]+\.)+[a-zA-Z]{2,}$")
20
-
21
-
22
- class AutomationLevel(BaseModel):
23
- distance_threshold: float = Field(default=0.9, description="Distance threshold for the automation")
24
- score_threshold: float = Field(default=0.9, description="Score threshold for the automation")
25
-
26
-
27
- class MatchParams(BaseModel):
28
- endpoint: str = Field(..., description="Endpoint for matching parameters")
29
- headers: Dict[str, str] = Field(..., description="Headers for the request")
30
- path: str = Field(..., description="Path for matching parameters")
31
-
32
-
33
- class FetchParams(BaseModel):
34
- endpoint: str = Field(..., description="Endpoint for fetching parameters")
35
- headers: Dict[str, str] = Field(..., description="Headers for the request")
36
- name: str = Field(..., description="Name of the fetch parameter")
37
-
38
-
39
- class Outlook(AutomationConfig):
40
- object: Literal['deployment.outlook'] = "deployment.outlook"
41
- id: str = Field(default_factory=lambda: "outlook_" + nanoid.generate(), description="Unique identifier for the outlook")
42
-
43
- authorized_domains: list[str] = Field(default_factory=list, description="List of authorized domains to receive the emails from")
44
- authorized_emails: List[EmailStr] = Field(default_factory=list, description="List of emails to access the link")
45
-
46
- layout_schema: Optional[dict[str, Any]] = Field(default=None, description="Layout schema format used to display the data")
47
-
48
- # Optional Fields for data integration
49
- match_params: List[MatchParams] = Field(default_factory=list, description="List of match parameters for the outlook automation")
50
- fetch_params: List[FetchParams] = Field(default_factory=list, description="List of fetch parameters for the outlook automation")
51
-
52
- @model_validator(mode='before')
53
- @classmethod
54
- def compute_layout_schema(cls, values: dict[str, Any]) -> dict[str, Any]:
55
- if values.get('layout_schema') is None:
56
- values['layout_schema'] = convert_schema_to_layout(values['json_schema'])
57
- return values
58
-
59
- class ListOutlooks(BaseModel):
60
- data: list[Outlook]
61
- list_metadata: ListMetadata
62
-
63
-
64
- # Inherits from the methods of UpdateAutomationRequest
65
- class UpdateOutlookRequest(UpdateAutomationRequest):
66
- authorized_domains: Optional[list[str]] = None
67
- authorized_emails: Optional[List[EmailStr]] = None
68
-
69
- match_params: Optional[List[MatchParams]] = None
70
- fetch_params: Optional[List[FetchParams]] = None
71
-
72
- layout_schema: Optional[dict[str, Any]] = None
73
-
74
- @field_validator("authorized_emails", mode="before")
75
- def normalize_authorized_emails(cls, emails: Optional[List[str]]) -> Optional[List[str]]:
76
- return [email.strip().lower() for email in emails] if emails else None
@@ -1,21 +0,0 @@
1
- from typing import Any, Optional
2
-
3
- from pydantic import BaseModel, EmailStr
4
-
5
- from uiform.types.documents.extractions import UiParsedChatCompletion
6
-
7
- from ..mime import BaseMIMEData, MIMEData
8
-
9
-
10
- class WebhookRequest(BaseModel):
11
- completion: UiParsedChatCompletion
12
- user: Optional[EmailStr] = None
13
- file_payload: MIMEData
14
- metadata: Optional[dict[str, Any]] = None
15
-
16
-
17
- class BaseWebhookRequest(BaseModel):
18
- completion: UiParsedChatCompletion
19
- user: Optional[EmailStr] = None
20
- file_payload: BaseMIMEData
21
- metadata: Optional[dict[str, Any]] = None
File without changes