1+ from __future__ import annotations
2+
3+
4+ from typing import TYPE_CHECKING , List , Mapping , cast , Optional , Dict
5+ from typing_extensions import Literal
6+
7+ from ...types .video import video_create_params
8+ from ...types .video import VideoObject
9+ from ...core import BaseAPI , maybe_transform
10+ from ...core import NOT_GIVEN , Body , Headers , NotGiven
11+
12+ import httpx
13+
14+ from ...core import (
15+ make_request_options ,
16+ )
17+ from ...core import deepcopy_minimal , extract_files
18+
19+ if TYPE_CHECKING :
20+ from ..._client import ZhipuAI
21+
22+ __all__ = ["Videos" ]
23+
24+
25+ class Videos (BaseAPI ):
26+
27+ def __init__ (self , client : "ZhipuAI" ) -> None :
28+ super ().__init__ (client )
29+
30+ def generations (
31+ self ,
32+ model : str ,
33+ prompt : str ,
34+ * ,
35+ request_id : str = None ,
36+ extra_headers : Headers | None = None ,
37+ extra_body : Body | None = None ,
38+ timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
39+ ) -> VideoObject :
40+
41+ if not model and not model :
42+ raise ValueError ("At least one of `model` and `prompt` must be provided." )
43+ body = deepcopy_minimal (
44+ {
45+ "model" : model ,
46+ "prompt" : prompt ,
47+ "request_id" : request_id ,
48+ }
49+ )
50+ return self ._post (
51+ "/videos/generations" ,
52+ body = maybe_transform (body , video_create_params .VideoCreateParams ),
53+ options = make_request_options (
54+ extra_headers = extra_headers , extra_body = extra_body , timeout = timeout
55+ ),
56+ cast_type = VideoObject ,
57+ )
58+
59+ def retrieve_videos_result (
60+ self ,
61+ id : str ,
62+ * ,
63+ extra_headers : Headers | None = None ,
64+ extra_body : Body | None = None ,
65+ timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
66+ ) -> VideoObject :
67+
68+ if not id :
69+ raise ValueError ("At least one of `id` must be provided." )
70+
71+ return self ._get (
72+ f"/async-result/{ id } " ,
73+ options = make_request_options (
74+ extra_headers = extra_headers , extra_body = extra_body , timeout = timeout
75+ ),
76+ cast_type = VideoObject ,
77+ )
0 commit comments