1+ from __future__ import annotations
2+
3+ from typing import TYPE_CHECKING , Optional
4+
5+ import httpx
6+
7+ from zai .core import (
8+ NOT_GIVEN ,
9+ BaseAPI ,
10+ Body ,
11+ Headers ,
12+ NotGiven ,
13+ deepcopy_minimal ,
14+ make_request_options ,
15+ maybe_transform ,
16+ )
17+ from zai .types .web_reader .web_reader_params import WebReaderParams
18+ from zai .types .web_reader .web_reader_resp import WebReaderResult
19+
20+ if TYPE_CHECKING :
21+ from zai ._client import ZaiClient
22+
23+
24+ class WebReaderApi (BaseAPI ):
25+ def __init__ (self , client : "ZaiClient" ) -> None :
26+ super ().__init__ (client )
27+
28+ def web_reader (
29+ self ,
30+ * ,
31+ url : str ,
32+ request_id : Optional [str ] | NotGiven = NOT_GIVEN ,
33+ user_id : Optional [str ] | NotGiven = NOT_GIVEN ,
34+ timeout : Optional [str ] | NotGiven = NOT_GIVEN ,
35+ no_cache : Optional [bool ] | NotGiven = NOT_GIVEN ,
36+ return_format : Optional [str ] | NotGiven = NOT_GIVEN ,
37+ retain_images : Optional [bool ] | NotGiven = NOT_GIVEN ,
38+ no_gfm : Optional [bool ] | NotGiven = NOT_GIVEN ,
39+ keep_img_data_url : Optional [bool ] | NotGiven = NOT_GIVEN ,
40+ with_images_summary : Optional [bool ] | NotGiven = NOT_GIVEN ,
41+ with_links_summary : Optional [bool ] | NotGiven = NOT_GIVEN ,
42+ extra_headers : Headers | None = None ,
43+ extra_body : Body | None = None ,
44+ timeout_override : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
45+ ) -> WebReaderResult :
46+ body = deepcopy_minimal (
47+ {
48+ "url" : url ,
49+ "request_id" : request_id ,
50+ "user_id" : user_id ,
51+ "timeout" : timeout ,
52+ "no_cache" : no_cache ,
53+ "return_format" : return_format ,
54+ "retain_images" : retain_images ,
55+ "no_gfm" : no_gfm ,
56+ "keep_img_data_url" : keep_img_data_url ,
57+ "with_images_summary" : with_images_summary ,
58+ "with_links_summary" : with_links_summary ,
59+ }
60+ )
61+ return self ._post (
62+ "/reader" ,
63+ body = maybe_transform (body , WebReaderParams ),
64+ options = make_request_options (
65+ extra_headers = extra_headers , extra_body = extra_body , timeout = timeout_override
66+ ),
67+ cast_type = WebReaderResult ,
68+ )
0 commit comments