44
55import os
66import importlib .metadata
7- from typing import Any , Dict , Mapping , Optional , cast
7+ from typing import Any , Dict , Mapping , Iterable , Optional , cast
88from typing_extensions import Self , Literal , override
99
1010import httpx
1111
1212from . import _exceptions
1313from ._qs import Querystring
14- from .types import client_parse_params , client_extract_params
14+ from .types import client_parse_params , client_split_params , client_extract_params
1515from ._types import (
1616 Body ,
1717 Omit ,
5252)
5353from .lib .url_utils import convert_url_to_file_if_local
5454from .types .parse_response import ParseResponse
55+ from .types .split_response import SplitResponse
5556from .types .extract_response import ExtractResponse
5657
5758_LIB_VERSION = importlib .metadata .version ("landingai-ade" )
@@ -391,6 +392,71 @@ def parse(
391392 cast_to = ParseResponse ,
392393 )
393394
395+ def split (
396+ self ,
397+ * ,
398+ options : Iterable [client_split_params .Option ],
399+ markdown : Optional [FileTypes ] | Omit = omit ,
400+ markdown_url : Optional [str ] | Omit = omit ,
401+ model : Optional [str ] | Omit = omit ,
402+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
403+ # The extra values given here take precedence over values defined on the client or passed to this method.
404+ extra_headers : Headers | None = None ,
405+ extra_query : Query | None = None ,
406+ extra_body : Body | None = None ,
407+ timeout : float | httpx .Timeout | None | NotGiven = not_given ,
408+ ) -> SplitResponse :
409+ """
410+ Split classification for documents.
411+
412+ This endpoint classifies document sections based on markdown content and split
413+ options.
414+
415+ For EU users, use this endpoint:
416+
417+ `https://api.va.eu-west-1.landing.ai/v1/ade/split`.
418+
419+ Args:
420+ options: List of split classification options/configuration. Can be provided as JSON
421+ string in form data.
422+
423+ markdown: The Markdown file or Markdown content to split.
424+
425+ markdown_url: The URL to the Markdown file to split.
426+
427+ model: Model version to use for split classification. Defaults to the latest version.
428+
429+ extra_headers: Send extra headers
430+
431+ extra_query: Add additional query parameters to the request
432+
433+ extra_body: Add additional JSON properties to the request
434+
435+ timeout: Override the client-level default timeout for this request, in seconds
436+ """
437+ body = deepcopy_minimal (
438+ {
439+ "options" : options ,
440+ "markdown" : markdown ,
441+ "markdown_url" : markdown_url ,
442+ "model" : model ,
443+ }
444+ )
445+ files = extract_files (cast (Mapping [str , object ], body ), paths = [["markdown" ]])
446+ # It should be noted that the actual Content-Type header that will be
447+ # sent to the server will contain a `boundary` parameter, e.g.
448+ # multipart/form-data; boundary=---abc--
449+ extra_headers = {"Content-Type" : "multipart/form-data" , ** (extra_headers or {})}
450+ return self .post (
451+ "/v1/ade/split" ,
452+ body = maybe_transform (body , client_split_params .ClientSplitParams ),
453+ files = files ,
454+ options = make_request_options (
455+ extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
456+ ),
457+ cast_to = SplitResponse ,
458+ )
459+
394460 @override
395461 def _make_status_error (
396462 self ,
@@ -742,6 +808,71 @@ async def parse(
742808 cast_to = ParseResponse ,
743809 )
744810
811+ async def split (
812+ self ,
813+ * ,
814+ options : Iterable [client_split_params .Option ],
815+ markdown : Optional [FileTypes ] | Omit = omit ,
816+ markdown_url : Optional [str ] | Omit = omit ,
817+ model : Optional [str ] | Omit = omit ,
818+ # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
819+ # The extra values given here take precedence over values defined on the client or passed to this method.
820+ extra_headers : Headers | None = None ,
821+ extra_query : Query | None = None ,
822+ extra_body : Body | None = None ,
823+ timeout : float | httpx .Timeout | None | NotGiven = not_given ,
824+ ) -> SplitResponse :
825+ """
826+ Split classification for documents.
827+
828+ This endpoint classifies document sections based on markdown content and split
829+ options.
830+
831+ For EU users, use this endpoint:
832+
833+ `https://api.va.eu-west-1.landing.ai/v1/ade/split`.
834+
835+ Args:
836+ options: List of split classification options/configuration. Can be provided as JSON
837+ string in form data.
838+
839+ markdown: The Markdown file or Markdown content to split.
840+
841+ markdown_url: The URL to the Markdown file to split.
842+
843+ model: Model version to use for split classification. Defaults to the latest version.
844+
845+ extra_headers: Send extra headers
846+
847+ extra_query: Add additional query parameters to the request
848+
849+ extra_body: Add additional JSON properties to the request
850+
851+ timeout: Override the client-level default timeout for this request, in seconds
852+ """
853+ body = deepcopy_minimal (
854+ {
855+ "options" : options ,
856+ "markdown" : markdown ,
857+ "markdown_url" : markdown_url ,
858+ "model" : model ,
859+ }
860+ )
861+ files = extract_files (cast (Mapping [str , object ], body ), paths = [["markdown" ]])
862+ # It should be noted that the actual Content-Type header that will be
863+ # sent to the server will contain a `boundary` parameter, e.g.
864+ # multipart/form-data; boundary=---abc--
865+ extra_headers = {"Content-Type" : "multipart/form-data" , ** (extra_headers or {})}
866+ return await self .post (
867+ "/v1/ade/split" ,
868+ body = await async_maybe_transform (body , client_split_params .ClientSplitParams ),
869+ files = files ,
870+ options = make_request_options (
871+ extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
872+ ),
873+ cast_to = SplitResponse ,
874+ )
875+
745876 @override
746877 def _make_status_error (
747878 self ,
@@ -786,6 +917,9 @@ def __init__(self, client: LandingAIADE) -> None:
786917 self .parse = to_raw_response_wrapper (
787918 client .parse ,
788919 )
920+ self .split = to_raw_response_wrapper (
921+ client .split ,
922+ )
789923
790924
791925class AsyncLandingAIADEWithRawResponse :
@@ -798,6 +932,9 @@ def __init__(self, client: AsyncLandingAIADE) -> None:
798932 self .parse = async_to_raw_response_wrapper (
799933 client .parse ,
800934 )
935+ self .split = async_to_raw_response_wrapper (
936+ client .split ,
937+ )
801938
802939
803940class LandingAIADEWithStreamedResponse :
@@ -810,6 +947,9 @@ def __init__(self, client: LandingAIADE) -> None:
810947 self .parse = to_streamed_response_wrapper (
811948 client .parse ,
812949 )
950+ self .split = to_streamed_response_wrapper (
951+ client .split ,
952+ )
813953
814954
815955class AsyncLandingAIADEWithStreamedResponse :
@@ -822,6 +962,9 @@ def __init__(self, client: AsyncLandingAIADE) -> None:
822962 self .parse = async_to_streamed_response_wrapper (
823963 client .parse ,
824964 )
965+ self .split = async_to_streamed_response_wrapper (
966+ client .split ,
967+ )
825968
826969
827970Client = LandingAIADE
0 commit comments