diff --git a/src/libs/ZAI/Generated/ZAI.AutoSDKHttpResponse.g.cs b/src/libs/ZAI/Generated/ZAI.AutoSDKHttpResponse.g.cs new file mode 100644 index 0000000..0676243 --- /dev/null +++ b/src/libs/ZAI/Generated/ZAI.AutoSDKHttpResponse.g.cs @@ -0,0 +1,121 @@ + +#nullable enable + +namespace ZAI +{ + /// + /// Represents a successful HTTP response with status code and headers. + /// + public partial class AutoSDKHttpResponse + { + /// + /// Initializes a new instance of the class. + /// + public AutoSDKHttpResponse( + global::System.Net.HttpStatusCode statusCode, + global::System.Collections.Generic.Dictionary> headers) + : this( + statusCode: statusCode, + headers: headers, + requestUri: null) + { + } + + /// + /// Initializes a new instance of the class. + /// + public AutoSDKHttpResponse( + global::System.Net.HttpStatusCode statusCode, + global::System.Collections.Generic.Dictionary> headers, + global::System.Uri? requestUri) + { + StatusCode = statusCode; + Headers = headers ?? throw new global::System.ArgumentNullException(nameof(headers)); + RequestUri = requestUri; + } + + /// + /// Gets the HTTP status code. + /// + public global::System.Net.HttpStatusCode StatusCode { get; } + /// + /// Gets the response headers. + /// + public global::System.Collections.Generic.Dictionary> Headers { get; } + /// + /// Gets the final request URI associated with the response. + /// + public global::System.Uri? RequestUri { get; } + + internal static global::System.Collections.Generic.Dictionary> CreateHeaders( + global::System.Net.Http.HttpResponseMessage response) + { + response = response ?? throw new global::System.ArgumentNullException(nameof(response)); + + var headers = global::System.Linq.Enumerable.ToDictionary( + response.Headers, + static header => header.Key, + static header => (global::System.Collections.Generic.IEnumerable)global::System.Linq.Enumerable.ToArray(header.Value), + global::System.StringComparer.OrdinalIgnoreCase); + + if (response.Content?.Headers == null) + { + return headers; + } + + foreach (var header in response.Content.Headers) + { + if (headers.TryGetValue(header.Key, out var existingValues)) + { + headers[header.Key] = global::System.Linq.Enumerable.ToArray( + global::System.Linq.Enumerable.Concat(existingValues, header.Value)); + } + else + { + headers[header.Key] = global::System.Linq.Enumerable.ToArray(header.Value); + } + } + + return headers; + } + } + + /// + /// Represents a successful HTTP response with status code, headers, and body. + /// + public partial class AutoSDKHttpResponse : AutoSDKHttpResponse + { + /// + /// Initializes a new instance of the class. + /// + public AutoSDKHttpResponse( + global::System.Net.HttpStatusCode statusCode, + global::System.Collections.Generic.Dictionary> headers, + T body) + : this( + statusCode: statusCode, + headers: headers, + requestUri: null, + body: body) + { + } + + /// + /// Initializes a new instance of the class. + /// + public AutoSDKHttpResponse( + global::System.Net.HttpStatusCode statusCode, + global::System.Collections.Generic.Dictionary> headers, + global::System.Uri? requestUri, + T body) + : base(statusCode, headers, requestUri) + { + Body = body; + } + + /// + /// Gets the response body. + /// + public T Body { get; } + } +} \ No newline at end of file diff --git a/src/libs/ZAI/Generated/ZAI.IZaiClient.CreateAgents.g.cs b/src/libs/ZAI/Generated/ZAI.IZaiClient.CreateAgents.g.cs index 89244da..b99f93d 100644 --- a/src/libs/ZAI/Generated/ZAI.IZaiClient.CreateAgents.g.cs +++ b/src/libs/ZAI/Generated/ZAI.IZaiClient.CreateAgents.g.cs @@ -34,6 +34,26 @@ public partial interface IZaiClient /// Default Value: en-US,en
/// Example: en-US,en /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task>> CreateAgentsAsResponseAsync( + + global::ZAI.OneOf request, + global::ZAI.CreateAgentsAcceptLanguage? acceptLanguage = default, + global::ZAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// General Translation: General Translation API provides large model-based multilingual translation services, including general translation, paraphrase translation, two-step translation, and three-pass translation strategies. It supports automatic language detection, glossary customization, translation suggestions, and streaming output. Users only need to call the Translation API, input the text to be processed, specify the source language (auto-detection supported) and target language to receive high-quality translation results.
+ /// Popular Special Effects Videos: Popular special effects videos are intelligent templates launched based on trending features from pan-entertainment platforms, designed to precisely adapt to short video creative production needs. Currently, three effect templates are available: `French Kiss`, `Body Shake Dance`, and `Sexy Me`. After selecting a template, users only need to upload an image and enter corresponding prompts to generate a special effects video.
+ /// GLM Slide/Poster Agent: An intelligent creation agent built for working people and creators. It goes beyond traditional engineering-style assembly tools—supporting one-click generation of slides or posters from natural language instructions. By natively integrating content generation with layout aesthetics and design conventions, it helps you quickly produce polished, professional-grade materials while lowering design barriers and boosting creative efficiency. + ///
+ /// + /// Config desired response language for HTTP requests.
+ /// Default Value: en-US,en
+ /// Example: en-US,en + /// /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// diff --git a/src/libs/ZAI/Generated/ZAI.IZaiClient.CreateAgentsAsyncResult.g.cs b/src/libs/ZAI/Generated/ZAI.IZaiClient.CreateAgentsAsyncResult.g.cs index a352ee0..abc19fe 100644 --- a/src/libs/ZAI/Generated/ZAI.IZaiClient.CreateAgentsAsyncResult.g.cs +++ b/src/libs/ZAI/Generated/ZAI.IZaiClient.CreateAgentsAsyncResult.g.cs @@ -30,6 +30,24 @@ public partial interface IZaiClient /// Default Value: en-US,en
/// Example: en-US,en /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> CreateAgentsAsyncResultAsResponseAsync( + + global::ZAI.CommonAgentResultRequest request, + global::ZAI.CreateAgentsAsyncResultAcceptLanguage? acceptLanguage = default, + global::ZAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// This endpoint is used to query the result of an asynchronous request. + /// + /// + /// Config desired response language for HTTP requests.
+ /// Default Value: en-US,en
+ /// Example: en-US,en + /// /// /// Agent ID: `vidu_template_agent`. /// diff --git a/src/libs/ZAI/Generated/ZAI.IZaiClient.CreateAgentsConversation.g.cs b/src/libs/ZAI/Generated/ZAI.IZaiClient.CreateAgentsConversation.g.cs index dd3fab0..6c789cd 100644 --- a/src/libs/ZAI/Generated/ZAI.IZaiClient.CreateAgentsConversation.g.cs +++ b/src/libs/ZAI/Generated/ZAI.IZaiClient.CreateAgentsConversation.g.cs @@ -30,6 +30,24 @@ public partial interface IZaiClient /// Default Value: en-US,en
/// Example: en-US,en /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> CreateAgentsConversationAsResponseAsync( + + global::ZAI.GlmSlideAgentConversationRequest request, + global::ZAI.CreateAgentsConversationAcceptLanguage? acceptLanguage = default, + global::ZAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// This endpoint is used to query the agent conversation history.Only support slides_glm_agent + /// + /// + /// Config desired response language for HTTP requests.
+ /// Default Value: en-US,en
+ /// Example: en-US,en + /// /// /// Agent ID /// diff --git a/src/libs/ZAI/Generated/ZAI.IZaiClient.CreatePaasV4AsyncImagesGenerations.g.cs b/src/libs/ZAI/Generated/ZAI.IZaiClient.CreatePaasV4AsyncImagesGenerations.g.cs index 77126fc..4a76758 100644 --- a/src/libs/ZAI/Generated/ZAI.IZaiClient.CreatePaasV4AsyncImagesGenerations.g.cs +++ b/src/libs/ZAI/Generated/ZAI.IZaiClient.CreatePaasV4AsyncImagesGenerations.g.cs @@ -21,6 +21,19 @@ public partial interface IZaiClient /// Generate Image (Async)
/// Use the [GLM-Image](/guides/image/glm-image) series models to generate high-quality images from text prompts. Through quick and accurate understanding of user text descriptions, `AI` image expression becomes more precise and personalized. Only supports `GLM-Image` model. /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> CreatePaasV4AsyncImagesGenerationsAsResponseAsync( + + global::ZAI.AsyncCreateImageRequest request, + global::ZAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Generate Image (Async)
+ /// Use the [GLM-Image](/guides/image/glm-image) series models to generate high-quality images from text prompts. Through quick and accurate understanding of user text descriptions, `AI` image expression becomes more precise and personalized. Only supports `GLM-Image` model. + ///
/// /// Model code
/// Example: glm-image diff --git a/src/libs/ZAI/Generated/ZAI.IZaiClient.CreatePaasV4AudioTranscriptions.g.cs b/src/libs/ZAI/Generated/ZAI.IZaiClient.CreatePaasV4AudioTranscriptions.g.cs index d65d773..192790f 100644 --- a/src/libs/ZAI/Generated/ZAI.IZaiClient.CreatePaasV4AudioTranscriptions.g.cs +++ b/src/libs/ZAI/Generated/ZAI.IZaiClient.CreatePaasV4AudioTranscriptions.g.cs @@ -21,6 +21,19 @@ public partial interface IZaiClient /// Speech to Text
/// Use the [GLM-ASR-2512](/guides/audio/glm-asr-2512) model to transcribe audio files into text, supporting multiple languages and real-time streaming transcription. /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> CreatePaasV4AudioTranscriptionsAsResponseAsync( + + global::ZAI.AudioTranscriptionRequest request, + global::ZAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Speech to Text
+ /// Use the [GLM-ASR-2512](/guides/audio/glm-asr-2512) model to transcribe audio files into text, supporting multiple languages and real-time streaming transcription. + ///
/// /// The audio file to be transcribed. Supported audio file formats: `.wav / .mp3`. Specifications: file size ≤ `25 MB`, audio duration ≤ `30 seconds`. /// @@ -60,5 +73,92 @@ public partial interface IZaiClient string? userId = default, global::ZAI.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); + + /// + /// Speech to Text
+ /// Use the [GLM-ASR-2512](/guides/audio/glm-asr-2512) model to transcribe audio files into text, supporting multiple languages and real-time streaming transcription. + ///
+ /// + /// The audio file to be transcribed. Supported audio file formats: `.wav / .mp3`. Specifications: file size ≤ `25 MB`, audio duration ≤ `30 seconds`. + /// + /// + /// The audio file to be transcribed. Supported audio file formats: `.wav / .mp3`. Specifications: file size ≤ `25 MB`, audio duration ≤ `30 seconds`. + /// + /// + /// Base64 encoded audio file. Only one of file_base64 or file needs to be provided (if both are provided, file takes precedence). + /// + /// + /// The model ID to invoke.
+ /// Default Value: glm-asr-2512 + /// + /// + /// In long text scenarios, you can provide previous transcription results as context. Recommended to be less than 8000 characters. + /// + /// + /// Hotword list to improve recognition accuracy for domain-specific vocabulary. Format example: ["person_name","place_name"]. Recommended not to exceed 100 items. + /// + /// + /// Passed by the client, must be unique. A unique identifier to distinguish each request. If not provided by the client, the platform will generate one by default. + /// + /// + /// A unique `ID` for the end user, helping the platform intervene in illegal activities, generation of illegal or inappropriate content, or other abusive behaviors by end users. `ID` length requirement: at least `6` characters, at most `128` characters. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task CreatePaasV4AudioTranscriptionsAsync( + global::System.IO.Stream file, + string filename, + string? fileBase64 = default, + global::ZAI.AudioTranscriptionRequestModel model = global::ZAI.AudioTranscriptionRequestModel.GlmAsr2512, + string? prompt = default, + global::System.Collections.Generic.IList? hotwords = default, + string? requestId = default, + string? userId = default, + global::ZAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Speech to Text
+ /// Use the [GLM-ASR-2512](/guides/audio/glm-asr-2512) model to transcribe audio files into text, supporting multiple languages and real-time streaming transcription. + ///
+ /// + /// The audio file to be transcribed. Supported audio file formats: `.wav / .mp3`. Specifications: file size ≤ `25 MB`, audio duration ≤ `30 seconds`. + /// + /// + /// The audio file to be transcribed. Supported audio file formats: `.wav / .mp3`. Specifications: file size ≤ `25 MB`, audio duration ≤ `30 seconds`. + /// + /// + /// Base64 encoded audio file. Only one of file_base64 or file needs to be provided (if both are provided, file takes precedence). + /// + /// + /// The model ID to invoke.
+ /// Default Value: glm-asr-2512 + /// + /// + /// In long text scenarios, you can provide previous transcription results as context. Recommended to be less than 8000 characters. + /// + /// + /// Hotword list to improve recognition accuracy for domain-specific vocabulary. Format example: ["person_name","place_name"]. Recommended not to exceed 100 items. + /// + /// + /// Passed by the client, must be unique. A unique identifier to distinguish each request. If not provided by the client, the platform will generate one by default. + /// + /// + /// A unique `ID` for the end user, helping the platform intervene in illegal activities, generation of illegal or inappropriate content, or other abusive behaviors by end users. `ID` length requirement: at least `6` characters, at most `128` characters. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> CreatePaasV4AudioTranscriptionsAsResponseAsync( + global::System.IO.Stream file, + string filename, + string? fileBase64 = default, + global::ZAI.AudioTranscriptionRequestModel model = global::ZAI.AudioTranscriptionRequestModel.GlmAsr2512, + string? prompt = default, + global::System.Collections.Generic.IList? hotwords = default, + string? requestId = default, + string? userId = default, + global::ZAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/ZAI/Generated/ZAI.IZaiClient.CreatePaasV4AudioTranscriptionsAsStream.g.cs b/src/libs/ZAI/Generated/ZAI.IZaiClient.CreatePaasV4AudioTranscriptionsAsStream.g.cs index 6440b6c..185d391 100644 --- a/src/libs/ZAI/Generated/ZAI.IZaiClient.CreatePaasV4AudioTranscriptionsAsStream.g.cs +++ b/src/libs/ZAI/Generated/ZAI.IZaiClient.CreatePaasV4AudioTranscriptionsAsStream.g.cs @@ -60,5 +60,49 @@ public partial interface IZaiClient string? userId = default, global::ZAI.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); + + /// + /// Speech to Text
+ /// Use the [GLM-ASR-2512](/guides/audio/glm-asr-2512) model to transcribe audio files into text, supporting multiple languages and real-time streaming transcription. + ///
+ /// + /// The audio file to be transcribed. Supported audio file formats: `.wav / .mp3`. Specifications: file size ≤ `25 MB`, audio duration ≤ `30 seconds`. + /// + /// + /// The audio file to be transcribed. Supported audio file formats: `.wav / .mp3`. Specifications: file size ≤ `25 MB`, audio duration ≤ `30 seconds`. + /// + /// + /// Base64 encoded audio file. Only one of file_base64 or file needs to be provided (if both are provided, file takes precedence). + /// + /// + /// The model ID to invoke.
+ /// Default Value: glm-asr-2512 + /// + /// + /// In long text scenarios, you can provide previous transcription results as context. Recommended to be less than 8000 characters. + /// + /// + /// Hotword list to improve recognition accuracy for domain-specific vocabulary. Format example: ["person_name","place_name"]. Recommended not to exceed 100 items. + /// + /// + /// Passed by the client, must be unique. A unique identifier to distinguish each request. If not provided by the client, the platform will generate one by default. + /// + /// + /// A unique `ID` for the end user, helping the platform intervene in illegal activities, generation of illegal or inappropriate content, or other abusive behaviors by end users. `ID` length requirement: at least `6` characters, at most `128` characters. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Collections.Generic.IAsyncEnumerable CreatePaasV4AudioTranscriptionsAsStreamAsync( + global::System.IO.Stream file, + string filename, + string? fileBase64 = default, + global::ZAI.AudioTranscriptionRequestModel model = global::ZAI.AudioTranscriptionRequestModel.GlmAsr2512, + string? prompt = default, + global::System.Collections.Generic.IList? hotwords = default, + string? requestId = default, + string? userId = default, + global::ZAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/ZAI/Generated/ZAI.IZaiClient.CreatePaasV4ChatCompletions.g.cs b/src/libs/ZAI/Generated/ZAI.IZaiClient.CreatePaasV4ChatCompletions.g.cs index 8c0167f..8b476bc 100644 --- a/src/libs/ZAI/Generated/ZAI.IZaiClient.CreatePaasV4ChatCompletions.g.cs +++ b/src/libs/ZAI/Generated/ZAI.IZaiClient.CreatePaasV4ChatCompletions.g.cs @@ -30,6 +30,24 @@ public partial interface IZaiClient /// Default Value: en-US,en
/// Example: en-US,en /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> CreatePaasV4ChatCompletionsAsResponseAsync( + + global::ZAI.OneOf request, + global::ZAI.CreatePaasV4ChatCompletionsAcceptLanguage? acceptLanguage = default, + global::ZAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Create a chat completion model that generates AI replies for given conversation messages. It supports multimodal inputs (text, images, audio, video, file), offers configurable parameters (like temperature, max tokens, tool use), and supports both streaming and non-streaming output modes. + /// + /// + /// Config desired response language for HTTP requests.
+ /// Default Value: en-US,en
+ /// Example: en-US,en + /// /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// diff --git a/src/libs/ZAI/Generated/ZAI.IZaiClient.CreatePaasV4Files.g.cs b/src/libs/ZAI/Generated/ZAI.IZaiClient.CreatePaasV4Files.g.cs index 73f76f7..1a81df8 100644 --- a/src/libs/ZAI/Generated/ZAI.IZaiClient.CreatePaasV4Files.g.cs +++ b/src/libs/ZAI/Generated/ZAI.IZaiClient.CreatePaasV4Files.g.cs @@ -19,6 +19,18 @@ public partial interface IZaiClient /// /// This API is designed for uploading auxiliary files (such as glossaries, terminology lists) to support the translation service. It allows users to upload reference materials that can enhance translation accuracy and consistency. /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> CreatePaasV4FilesAsResponseAsync( + + global::ZAI.CreatePaasV4FilesRequest request, + global::ZAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// This API is designed for uploading auxiliary files (such as glossaries, terminology lists) to support the translation service. It allows users to upload reference materials that can enhance translation accuracy and consistency. + /// /// /// Upload purpose (agent)
/// Default Value: agent @@ -38,5 +50,50 @@ public partial interface IZaiClient global::ZAI.CreatePaasV4FilesRequestPurpose purpose = global::ZAI.CreatePaasV4FilesRequestPurpose.Agent, global::ZAI.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); + + /// + /// This API is designed for uploading auxiliary files (such as glossaries, terminology lists) to support the translation service. It allows users to upload reference materials that can enhance translation accuracy and consistency. + /// + /// + /// Upload purpose (agent)
+ /// Default Value: agent + /// + /// + /// File to upload. Limit to `100MB`. Allowed formats: `pdf`, `doc`, `xlsx`, `ppt`, `txt`, `jpg`, `png`. + /// + /// + /// File to upload. Limit to `100MB`. Allowed formats: `pdf`, `doc`, `xlsx`, `ppt`, `txt`, `jpg`, `png`. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task CreatePaasV4FilesAsync( + global::System.IO.Stream file, + string filename, + global::ZAI.CreatePaasV4FilesRequestPurpose purpose = global::ZAI.CreatePaasV4FilesRequestPurpose.Agent, + global::ZAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// This API is designed for uploading auxiliary files (such as glossaries, terminology lists) to support the translation service. It allows users to upload reference materials that can enhance translation accuracy and consistency. + /// + /// + /// Upload purpose (agent)
+ /// Default Value: agent + /// + /// + /// File to upload. Limit to `100MB`. Allowed formats: `pdf`, `doc`, `xlsx`, `ppt`, `txt`, `jpg`, `png`. + /// + /// + /// File to upload. Limit to `100MB`. Allowed formats: `pdf`, `doc`, `xlsx`, `ppt`, `txt`, `jpg`, `png`. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> CreatePaasV4FilesAsResponseAsync( + global::System.IO.Stream file, + string filename, + global::ZAI.CreatePaasV4FilesRequestPurpose purpose = global::ZAI.CreatePaasV4FilesRequestPurpose.Agent, + global::ZAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/ZAI/Generated/ZAI.IZaiClient.CreatePaasV4ImagesGenerations.g.cs b/src/libs/ZAI/Generated/ZAI.IZaiClient.CreatePaasV4ImagesGenerations.g.cs index 0808409..1b87613 100644 --- a/src/libs/ZAI/Generated/ZAI.IZaiClient.CreatePaasV4ImagesGenerations.g.cs +++ b/src/libs/ZAI/Generated/ZAI.IZaiClient.CreatePaasV4ImagesGenerations.g.cs @@ -21,6 +21,19 @@ public partial interface IZaiClient /// Generate Image
/// Use [GLM-Image](/guides/image/glm-image) series models to generate high-quality images from text prompts. Through quick and accurate understanding of user text descriptions, `AI` image expression becomes more precise and personalized. /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> CreatePaasV4ImagesGenerationsAsResponseAsync( + + global::ZAI.CreateImageRequest request, + global::ZAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Generate Image
+ /// Use [GLM-Image](/guides/image/glm-image) series models to generate high-quality images from text prompts. Through quick and accurate understanding of user text descriptions, `AI` image expression becomes more precise and personalized. + ///
/// /// Model code
/// Example: glm-image diff --git a/src/libs/ZAI/Generated/ZAI.IZaiClient.CreatePaasV4LayoutParsing.g.cs b/src/libs/ZAI/Generated/ZAI.IZaiClient.CreatePaasV4LayoutParsing.g.cs index 6c364fc..f367c20 100644 --- a/src/libs/ZAI/Generated/ZAI.IZaiClient.CreatePaasV4LayoutParsing.g.cs +++ b/src/libs/ZAI/Generated/ZAI.IZaiClient.CreatePaasV4LayoutParsing.g.cs @@ -21,6 +21,19 @@ public partial interface IZaiClient /// Layout Parsing
/// Use the [GLM-OCR](/guides/vlm/glm-ocr) model to parse the layout of documents and images and extract text content. Support OCR recognition of images and PDF documents, returning detailed layout information and visualization results. /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> CreatePaasV4LayoutParsingAsResponseAsync( + + global::ZAI.LayoutParsingRequest request, + global::ZAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Layout Parsing
+ /// Use the [GLM-OCR](/guides/vlm/glm-ocr) model to parse the layout of documents and images and extract text content. Support OCR recognition of images and PDF documents, returning detailed layout information and visualization results. + ///
/// /// Model code: `glm-ocr`
/// Example: glm-ocr diff --git a/src/libs/ZAI/Generated/ZAI.IZaiClient.CreatePaasV4Reader.g.cs b/src/libs/ZAI/Generated/ZAI.IZaiClient.CreatePaasV4Reader.g.cs index 57d1445..3322275 100644 --- a/src/libs/ZAI/Generated/ZAI.IZaiClient.CreatePaasV4Reader.g.cs +++ b/src/libs/ZAI/Generated/ZAI.IZaiClient.CreatePaasV4Reader.g.cs @@ -21,6 +21,19 @@ public partial interface IZaiClient /// Web Reader
/// Reads and parses the content of the specified URL. Supports selectable return formats, cache control, image retention, and summary options. /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> CreatePaasV4ReaderAsResponseAsync( + + global::ZAI.ReaderRequest request, + global::ZAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Web Reader
+ /// Reads and parses the content of the specified URL. Supports selectable return formats, cache control, image retention, and summary options. + ///
/// /// The URL to retrieve /// diff --git a/src/libs/ZAI/Generated/ZAI.IZaiClient.CreatePaasV4Tokenizer.g.cs b/src/libs/ZAI/Generated/ZAI.IZaiClient.CreatePaasV4Tokenizer.g.cs index d346a54..19c8b32 100644 --- a/src/libs/ZAI/Generated/ZAI.IZaiClient.CreatePaasV4Tokenizer.g.cs +++ b/src/libs/ZAI/Generated/ZAI.IZaiClient.CreatePaasV4Tokenizer.g.cs @@ -21,6 +21,19 @@ public partial interface IZaiClient /// Text Tokenizer
/// `Tokenizer` is used to split text into `tokens` recognizable by the model and calculate the count. It receives user input text, processes it through the model for tokenization, and finally returns the corresponding `token` count. It is suitable for text length evaluation, model input estimation, dialogue context truncation, cost calculation, etc. /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> CreatePaasV4TokenizerAsResponseAsync( + + global::ZAI.TokenizerRequest request, + global::ZAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// Text Tokenizer
+ /// `Tokenizer` is used to split text into `tokens` recognizable by the model and calculate the count. It receives user input text, processes it through the model for tokenization, and finally returns the corresponding `token` count. It is suitable for text length evaluation, model input estimation, dialogue context truncation, cost calculation, etc. + ///
/// /// The model code to be called.
/// Default Value: glm-4.6
diff --git a/src/libs/ZAI/Generated/ZAI.IZaiClient.CreatePaasV4VideosGenerations.g.cs b/src/libs/ZAI/Generated/ZAI.IZaiClient.CreatePaasV4VideosGenerations.g.cs index f453763..cd87ec4 100644 --- a/src/libs/ZAI/Generated/ZAI.IZaiClient.CreatePaasV4VideosGenerations.g.cs +++ b/src/libs/ZAI/Generated/ZAI.IZaiClient.CreatePaasV4VideosGenerations.g.cs @@ -32,6 +32,25 @@ public partial interface IZaiClient /// Default Value: en-US,en
/// Example: en-US,en /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> CreatePaasV4VideosGenerationsAsResponseAsync( + + global::ZAI.OneOf request, + global::ZAI.CreatePaasV4VideosGenerationsAcceptLanguage? acceptLanguage = default, + global::ZAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// CogVideoX is a video generation large model developed by Z.AI, equipped with powerful video generation capabilities. Simply inputting text or images allows for effortless video creation.
+ /// Vidu: A high-performance video large model that combines high consistency and high dynamism, with precise semantic understanding and exceptional reasoning speed. + ///
+ /// + /// Config desired response language for HTTP requests.
+ /// Default Value: en-US,en
+ /// Example: en-US,en + /// /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. /// The token to cancel the operation with /// diff --git a/src/libs/ZAI/Generated/ZAI.IZaiClient.CreatePaasV4WebSearch.g.cs b/src/libs/ZAI/Generated/ZAI.IZaiClient.CreatePaasV4WebSearch.g.cs index e002527..513656b 100644 --- a/src/libs/ZAI/Generated/ZAI.IZaiClient.CreatePaasV4WebSearch.g.cs +++ b/src/libs/ZAI/Generated/ZAI.IZaiClient.CreatePaasV4WebSearch.g.cs @@ -30,6 +30,24 @@ public partial interface IZaiClient /// Default Value: en-US,en
/// Example: en-US,en /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task> CreatePaasV4WebSearchAsResponseAsync( + + global::ZAI.WebSearchRequest request, + global::ZAI.CreatePaasV4WebSearchAcceptLanguage? acceptLanguage = default, + global::ZAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); + /// + /// The [Web Search](/guides/tools/web-search) is a specialized search engine for large language models. Building upon traditional search engine capabilities like web crawling and ranking, it enhances intent recognition to return results better suited for LLM processing (including webpage titles, URLs, summaries, site names, favicons etc.). + /// + /// + /// Config desired response language for HTTP requests.
+ /// Default Value: en-US,en
+ /// Example: en-US,en + /// /// /// The search engine code to call.
/// search-prime: Z.AI Premium Version Search Engine
diff --git a/src/libs/ZAI/Generated/ZAI.IZaiClient.GetPaasV4AsyncResultById.g.cs b/src/libs/ZAI/Generated/ZAI.IZaiClient.GetPaasV4AsyncResultById.g.cs index b319e02..89c2443 100644 --- a/src/libs/ZAI/Generated/ZAI.IZaiClient.GetPaasV4AsyncResultById.g.cs +++ b/src/libs/ZAI/Generated/ZAI.IZaiClient.GetPaasV4AsyncResultById.g.cs @@ -23,5 +23,24 @@ public partial interface IZaiClient global::ZAI.GetPaasV4AsyncResultAcceptLanguage? acceptLanguage = default, global::ZAI.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default); + /// + /// This endpoint is used to query the result of an asynchronous request. + /// + /// + /// Config desired response language for HTTP requests.
+ /// Default Value: en-US,en
+ /// Example: en-US,en + /// + /// + /// Task id. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + global::System.Threading.Tasks.Task>> GetPaasV4AsyncResultByIdAsResponseAsync( + string id, + global::ZAI.GetPaasV4AsyncResultAcceptLanguage? acceptLanguage = default, + global::ZAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default); } } \ No newline at end of file diff --git a/src/libs/ZAI/Generated/ZAI.OptionsSupport.g.cs b/src/libs/ZAI/Generated/ZAI.OptionsSupport.g.cs index 1d47fc9..77fc85a 100644 --- a/src/libs/ZAI/Generated/ZAI.OptionsSupport.g.cs +++ b/src/libs/ZAI/Generated/ZAI.OptionsSupport.g.cs @@ -101,9 +101,45 @@ public sealed class AutoSDKRetryOptions public int MaxAttempts { get; set; } = 1; /// - /// Optional fixed delay between retry attempts. + /// Optional fixed delay between retry attempts. When set, this takes precedence over exponential backoff. /// public global::System.TimeSpan? Delay { get; set; } + + /// + /// Initial exponential backoff delay used when is not set. + /// + public global::System.TimeSpan InitialDelay { get; set; } = global::System.TimeSpan.FromSeconds(1); + + /// + /// Maximum retry delay after applying retry headers, backoff, and jitter. + /// + public global::System.TimeSpan MaxDelay { get; set; } = global::System.TimeSpan.FromSeconds(30); + + /// + /// Multiplier applied to exponential backoff after each failed attempt. + /// Values below 1 are normalized to 1. + /// + public double BackoffMultiplier { get; set; } = 2D; + + /// + /// Randomizes computed backoff by plus or minus this ratio. Values are clamped to 0..1. + /// + public double JitterRatio { get; set; } = 0.2D; + + /// + /// Whether Retry-After response headers should control retry delay when present. + /// + public bool UseRetryAfterHeader { get; set; } = true; + + /// + /// Whether a rate-limit reset response header should control retry delay when present. + /// + public bool UseRateLimitResetHeader { get; set; } + + /// + /// Optional provider-specific rate-limit reset header name. Values may be Unix seconds or an HTTP date. + /// + public string? RateLimitResetHeaderName { get; set; } = "X-RateLimit-Reset"; } @@ -231,6 +267,16 @@ public sealed class AutoSDKHookContext /// public bool WillRetry { get; set; } + /// + /// The computed retry delay when is true. + /// + public global::System.TimeSpan? RetryDelay { get; set; } + + /// + /// A short retry reason such as exception or status:429. + /// + public string RetryReason { get; set; } = string.Empty; + /// /// The effective cancellation token for the current request attempt. /// @@ -254,6 +300,8 @@ internal static class AutoSDKRequestOptionsSupport int attempt, int maxAttempts, bool willRetry, + global::System.TimeSpan? retryDelay, + string retryReason, global::System.Threading.CancellationToken cancellationToken) { return new global::ZAI.AutoSDKHookContext @@ -271,6 +319,8 @@ internal static class AutoSDKRequestOptionsSupport Attempt = attempt, MaxAttempts = maxAttempts, WillRetry = willRetry, + RetryDelay = retryDelay, + RetryReason = retryReason ?? string.Empty, CancellationToken = cancellationToken, }; } @@ -338,19 +388,188 @@ internal static int GetMaxAttempts( return maxAttempts < 1 ? 1 : maxAttempts; } - internal static async global::System.Threading.Tasks.Task DelayBeforeRetryAsync( + internal static global::System.TimeSpan GetRetryDelay( global::ZAI.AutoSDKClientOptions clientOptions, global::ZAI.AutoSDKRequestOptions? requestOptions, + global::System.Net.Http.HttpResponseMessage? response, + int attempt) + { + var retryOptions = requestOptions?.Retry ?? clientOptions.Retry ?? new global::ZAI.AutoSDKRetryOptions(); + + if (retryOptions.UseRetryAfterHeader && + TryGetRetryAfterDelay(response, out var retryAfterDelay)) + { + return ClampRetryDelay(retryAfterDelay, retryOptions); + } + + if (retryOptions.UseRateLimitResetHeader && + TryGetRateLimitResetDelay(response, retryOptions.RateLimitResetHeaderName, out var rateLimitResetDelay)) + { + return ClampRetryDelay(rateLimitResetDelay, retryOptions); + } + + if (retryOptions.Delay.HasValue) + { + return ClampRetryDelay(retryOptions.Delay.Value, retryOptions); + } + + var initialDelay = retryOptions.InitialDelay; + if (initialDelay <= global::System.TimeSpan.Zero) + { + return global::System.TimeSpan.Zero; + } + + var multiplier = retryOptions.BackoffMultiplier < 1D ? 1D : retryOptions.BackoffMultiplier; + var exponent = attempt <= 1 ? 0 : attempt - 1; + var delayMilliseconds = initialDelay.TotalMilliseconds * global::System.Math.Pow(multiplier, exponent); + if (double.IsNaN(delayMilliseconds) || double.IsInfinity(delayMilliseconds) || delayMilliseconds < 0D) + { + delayMilliseconds = 0D; + } + + var delay = global::System.TimeSpan.FromMilliseconds(delayMilliseconds); + delay = ApplyJitter(delay, retryOptions.JitterRatio); + return ClampRetryDelay(delay, retryOptions); + } + + internal static async global::System.Threading.Tasks.Task DelayBeforeRetryAsync( + global::System.TimeSpan retryDelay, global::System.Threading.CancellationToken cancellationToken) { - var delay = requestOptions?.Retry?.Delay ?? - clientOptions.Retry?.Delay; - if (!delay.HasValue || delay.Value <= global::System.TimeSpan.Zero) + if (retryDelay <= global::System.TimeSpan.Zero) { return; } - await global::System.Threading.Tasks.Task.Delay(delay.Value, cancellationToken).ConfigureAwait(false); + await global::System.Threading.Tasks.Task.Delay(retryDelay, cancellationToken).ConfigureAwait(false); + } + + private static bool TryGetRetryAfterDelay( + global::System.Net.Http.HttpResponseMessage? response, + out global::System.TimeSpan delay) + { + delay = global::System.TimeSpan.Zero; + var retryAfter = response?.Headers.RetryAfter; + if (retryAfter == null) + { + return false; + } + + if (retryAfter.Delta.HasValue) + { + delay = retryAfter.Delta.Value; + return delay > global::System.TimeSpan.Zero; + } + + if (retryAfter.Date.HasValue) + { + delay = retryAfter.Date.Value - global::System.DateTimeOffset.UtcNow; + return delay > global::System.TimeSpan.Zero; + } + + return false; + } + + private static bool TryGetRateLimitResetDelay( + global::System.Net.Http.HttpResponseMessage? response, + string? headerName, + out global::System.TimeSpan delay) + { + delay = global::System.TimeSpan.Zero; + if (response == null || string.IsNullOrWhiteSpace(headerName)) + { + return false; + } + + if (!response.Headers.TryGetValues(headerName, out var values) && + (response.Content?.Headers == null || !response.Content.Headers.TryGetValues(headerName, out values))) + { + return false; + } + + var value = global::System.Linq.Enumerable.FirstOrDefault(values); + if (string.IsNullOrWhiteSpace(value)) + { + return false; + } + + value = value.Trim(); + if (long.TryParse( + value, + global::System.Globalization.NumberStyles.Integer, + global::System.Globalization.CultureInfo.InvariantCulture, + out var unixSeconds)) + { + delay = global::System.DateTimeOffset.FromUnixTimeSeconds(unixSeconds) - global::System.DateTimeOffset.UtcNow; + return delay > global::System.TimeSpan.Zero; + } + + if (global::System.DateTimeOffset.TryParse( + value, + global::System.Globalization.CultureInfo.InvariantCulture, + global::System.Globalization.DateTimeStyles.AssumeUniversal | global::System.Globalization.DateTimeStyles.AdjustToUniversal, + out var resetAt)) + { + delay = resetAt - global::System.DateTimeOffset.UtcNow; + return delay > global::System.TimeSpan.Zero; + } + + return false; + } + + private static global::System.TimeSpan ApplyJitter( + global::System.TimeSpan delay, + double jitterRatio) + { + if (delay <= global::System.TimeSpan.Zero || jitterRatio <= 0D) + { + return delay; + } + + if (jitterRatio > 1D) + { + jitterRatio = 1D; + } + + var sample = NextJitterSample(); + var multiplier = 1D - jitterRatio + (sample * jitterRatio * 2D); + var milliseconds = delay.TotalMilliseconds * multiplier; + if (double.IsNaN(milliseconds) || double.IsInfinity(milliseconds) || milliseconds < 0D) + { + milliseconds = 0D; + } + + return global::System.TimeSpan.FromMilliseconds(milliseconds); + } + + private static double NextJitterSample() + { + var bytes = new byte[8]; + using (var randomNumberGenerator = global::System.Security.Cryptography.RandomNumberGenerator.Create()) + { + randomNumberGenerator.GetBytes(bytes); + } + + var value = global::System.BitConverter.ToUInt64(bytes, 0); + return value / (double)ulong.MaxValue; + } + + private static global::System.TimeSpan ClampRetryDelay( + global::System.TimeSpan delay, + global::ZAI.AutoSDKRetryOptions retryOptions) + { + if (delay <= global::System.TimeSpan.Zero) + { + return global::System.TimeSpan.Zero; + } + + var maxDelay = retryOptions.MaxDelay; + if (maxDelay > global::System.TimeSpan.Zero && delay > maxDelay) + { + return maxDelay; + } + + return delay; } internal static bool ShouldRetryStatusCode( diff --git a/src/libs/ZAI/Generated/ZAI.ZaiClient.CreateAgents.g.cs b/src/libs/ZAI/Generated/ZAI.ZaiClient.CreateAgents.g.cs index 6712a5d..27dbd85 100644 --- a/src/libs/ZAI/Generated/ZAI.ZaiClient.CreateAgents.g.cs +++ b/src/libs/ZAI/Generated/ZAI.ZaiClient.CreateAgents.g.cs @@ -59,6 +59,37 @@ partial void ProcessCreateAgentsResponseContent( /// public async global::System.Threading.Tasks.Task> CreateAgentsAsync( + global::ZAI.OneOf request, + global::ZAI.CreateAgentsAcceptLanguage? acceptLanguage = default, + global::ZAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await CreateAgentsAsResponseAsync( + + request: request, + acceptLanguage: acceptLanguage, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// General Translation: General Translation API provides large model-based multilingual translation services, including general translation, paraphrase translation, two-step translation, and three-pass translation strategies. It supports automatic language detection, glossary customization, translation suggestions, and streaming output. Users only need to call the Translation API, input the text to be processed, specify the source language (auto-detection supported) and target language to receive high-quality translation results.
+ /// Popular Special Effects Videos: Popular special effects videos are intelligent templates launched based on trending features from pan-entertainment platforms, designed to precisely adapt to short video creative production needs. Currently, three effect templates are available: `French Kiss`, `Body Shake Dance`, and `Sexy Me`. After selecting a template, users only need to upload an image and enter corresponding prompts to generate a special effects video.
+ /// GLM Slide/Poster Agent: An intelligent creation agent built for working people and creators. It goes beyond traditional engineering-style assembly tools—supporting one-click generation of slides or posters from natural language instructions. By natively integrating content generation with layout aesthetics and design conventions, it helps you quickly produce polished, professional-grade materials while lowering design barriers and boosting creative efficiency. + ///
+ /// + /// Config desired response language for HTTP requests.
+ /// Default Value: en-US,en
+ /// Example: en-US,en + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task>> CreateAgentsAsResponseAsync( + global::ZAI.OneOf request, global::ZAI.CreateAgentsAcceptLanguage? acceptLanguage = default, global::ZAI.AutoSDKRequestOptions? requestOptions = default, @@ -93,6 +124,7 @@ partial void ProcessCreateAgentsResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::ZAI.PathBuilder( path: "/v1/agents", baseUri: HttpClient.BaseAddress); @@ -179,6 +211,8 @@ partial void ProcessCreateAgentsResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -189,6 +223,11 @@ partial void ProcessCreateAgentsResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::ZAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::ZAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -206,6 +245,8 @@ partial void ProcessCreateAgentsResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -215,8 +256,7 @@ partial void ProcessCreateAgentsResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::ZAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -225,6 +265,11 @@ partial void ProcessCreateAgentsResponseContent( __attempt < __maxAttempts && global::ZAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::ZAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::ZAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::ZAI.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -241,14 +286,15 @@ partial void ProcessCreateAgentsResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::ZAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -288,6 +334,8 @@ partial void ProcessCreateAgentsResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -308,6 +356,8 @@ partial void ProcessCreateAgentsResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // The request has failed. @@ -370,9 +420,13 @@ partial void ProcessCreateAgentsResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::ZAI.OneOf.FromJson(__content, JsonSerializerContext) ?? + var __value = global::ZAI.OneOf.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::ZAI.AutoSDKHttpResponse>( + statusCode: __response.StatusCode, + headers: global::ZAI.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -400,9 +454,13 @@ partial void ProcessCreateAgentsResponseContent( #endif ).ConfigureAwait(false); - return - await global::ZAI.OneOf.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::ZAI.OneOf.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::ZAI.AutoSDKHttpResponse>( + statusCode: __response.StatusCode, + headers: global::ZAI.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { diff --git a/src/libs/ZAI/Generated/ZAI.ZaiClient.CreateAgentsAsyncResult.g.cs b/src/libs/ZAI/Generated/ZAI.ZaiClient.CreateAgentsAsyncResult.g.cs index 99b2392..ad47bed 100644 --- a/src/libs/ZAI/Generated/ZAI.ZaiClient.CreateAgentsAsyncResult.g.cs +++ b/src/libs/ZAI/Generated/ZAI.ZaiClient.CreateAgentsAsyncResult.g.cs @@ -57,6 +57,35 @@ partial void ProcessCreateAgentsAsyncResultResponseContent( /// public async global::System.Threading.Tasks.Task CreateAgentsAsyncResultAsync( + global::ZAI.CommonAgentResultRequest request, + global::ZAI.CreateAgentsAsyncResultAcceptLanguage? acceptLanguage = default, + global::ZAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await CreateAgentsAsyncResultAsResponseAsync( + + request: request, + acceptLanguage: acceptLanguage, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// This endpoint is used to query the result of an asynchronous request. + /// + /// + /// Config desired response language for HTTP requests.
+ /// Default Value: en-US,en
+ /// Example: en-US,en + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> CreateAgentsAsyncResultAsResponseAsync( + global::ZAI.CommonAgentResultRequest request, global::ZAI.CreateAgentsAsyncResultAcceptLanguage? acceptLanguage = default, global::ZAI.AutoSDKRequestOptions? requestOptions = default, @@ -93,6 +122,7 @@ partial void ProcessCreateAgentsAsyncResultResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::ZAI.PathBuilder( path: "/v1/agents/async-result", baseUri: HttpClient.BaseAddress); @@ -179,6 +209,8 @@ partial void ProcessCreateAgentsAsyncResultResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -189,6 +221,11 @@ partial void ProcessCreateAgentsAsyncResultResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::ZAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::ZAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -206,6 +243,8 @@ partial void ProcessCreateAgentsAsyncResultResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -215,8 +254,7 @@ partial void ProcessCreateAgentsAsyncResultResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::ZAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -225,6 +263,11 @@ partial void ProcessCreateAgentsAsyncResultResponseContent( __attempt < __maxAttempts && global::ZAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::ZAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::ZAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::ZAI.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -241,14 +284,15 @@ partial void ProcessCreateAgentsAsyncResultResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::ZAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -288,6 +332,8 @@ partial void ProcessCreateAgentsAsyncResultResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -308,6 +354,8 @@ partial void ProcessCreateAgentsAsyncResultResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // The request has failed. @@ -370,9 +418,13 @@ partial void ProcessCreateAgentsAsyncResultResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::ZAI.CommonAgentResultResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::ZAI.CommonAgentResultResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::ZAI.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::ZAI.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -400,9 +452,13 @@ partial void ProcessCreateAgentsAsyncResultResponseContent( #endif ).ConfigureAwait(false); - return - await global::ZAI.CommonAgentResultResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::ZAI.CommonAgentResultResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::ZAI.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::ZAI.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { diff --git a/src/libs/ZAI/Generated/ZAI.ZaiClient.CreateAgentsConversation.g.cs b/src/libs/ZAI/Generated/ZAI.ZaiClient.CreateAgentsConversation.g.cs index fc598e3..f237527 100644 --- a/src/libs/ZAI/Generated/ZAI.ZaiClient.CreateAgentsConversation.g.cs +++ b/src/libs/ZAI/Generated/ZAI.ZaiClient.CreateAgentsConversation.g.cs @@ -57,6 +57,35 @@ partial void ProcessCreateAgentsConversationResponseContent( /// public async global::System.Threading.Tasks.Task CreateAgentsConversationAsync( + global::ZAI.GlmSlideAgentConversationRequest request, + global::ZAI.CreateAgentsConversationAcceptLanguage? acceptLanguage = default, + global::ZAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await CreateAgentsConversationAsResponseAsync( + + request: request, + acceptLanguage: acceptLanguage, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// This endpoint is used to query the agent conversation history.Only support slides_glm_agent + /// + /// + /// Config desired response language for HTTP requests.
+ /// Default Value: en-US,en
+ /// Example: en-US,en + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> CreateAgentsConversationAsResponseAsync( + global::ZAI.GlmSlideAgentConversationRequest request, global::ZAI.CreateAgentsConversationAcceptLanguage? acceptLanguage = default, global::ZAI.AutoSDKRequestOptions? requestOptions = default, @@ -93,6 +122,7 @@ partial void ProcessCreateAgentsConversationResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::ZAI.PathBuilder( path: "/v1/agents/conversation", baseUri: HttpClient.BaseAddress); @@ -179,6 +209,8 @@ partial void ProcessCreateAgentsConversationResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -189,6 +221,11 @@ partial void ProcessCreateAgentsConversationResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::ZAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::ZAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -206,6 +243,8 @@ partial void ProcessCreateAgentsConversationResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -215,8 +254,7 @@ partial void ProcessCreateAgentsConversationResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::ZAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -225,6 +263,11 @@ partial void ProcessCreateAgentsConversationResponseContent( __attempt < __maxAttempts && global::ZAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::ZAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::ZAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::ZAI.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -241,14 +284,15 @@ partial void ProcessCreateAgentsConversationResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::ZAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -288,6 +332,8 @@ partial void ProcessCreateAgentsConversationResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -308,6 +354,8 @@ partial void ProcessCreateAgentsConversationResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // The request has failed. @@ -370,9 +418,13 @@ partial void ProcessCreateAgentsConversationResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::ZAI.GlmSlideAgentConversationResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::ZAI.GlmSlideAgentConversationResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::ZAI.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::ZAI.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -400,9 +452,13 @@ partial void ProcessCreateAgentsConversationResponseContent( #endif ).ConfigureAwait(false); - return - await global::ZAI.GlmSlideAgentConversationResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::ZAI.GlmSlideAgentConversationResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::ZAI.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::ZAI.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { diff --git a/src/libs/ZAI/Generated/ZAI.ZaiClient.CreatePaasV4AsyncImagesGenerations.g.cs b/src/libs/ZAI/Generated/ZAI.ZaiClient.CreatePaasV4AsyncImagesGenerations.g.cs index acd109b..d405449 100644 --- a/src/libs/ZAI/Generated/ZAI.ZaiClient.CreatePaasV4AsyncImagesGenerations.g.cs +++ b/src/libs/ZAI/Generated/ZAI.ZaiClient.CreatePaasV4AsyncImagesGenerations.g.cs @@ -51,6 +51,29 @@ partial void ProcessCreatePaasV4AsyncImagesGenerationsResponseContent( /// public async global::System.Threading.Tasks.Task CreatePaasV4AsyncImagesGenerationsAsync( + global::ZAI.AsyncCreateImageRequest request, + global::ZAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await CreatePaasV4AsyncImagesGenerationsAsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Generate Image (Async)
+ /// Use the [GLM-Image](/guides/image/glm-image) series models to generate high-quality images from text prompts. Through quick and accurate understanding of user text descriptions, `AI` image expression becomes more precise and personalized. Only supports `GLM-Image` model. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> CreatePaasV4AsyncImagesGenerationsAsResponseAsync( + global::ZAI.AsyncCreateImageRequest request, global::ZAI.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) @@ -85,6 +108,7 @@ partial void ProcessCreatePaasV4AsyncImagesGenerationsResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::ZAI.PathBuilder( path: "/paas/v4/async/images/generations", baseUri: HttpClient.BaseAddress); @@ -164,6 +188,8 @@ partial void ProcessCreatePaasV4AsyncImagesGenerationsResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -174,6 +200,11 @@ partial void ProcessCreatePaasV4AsyncImagesGenerationsResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::ZAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::ZAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -191,6 +222,8 @@ partial void ProcessCreatePaasV4AsyncImagesGenerationsResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -200,8 +233,7 @@ partial void ProcessCreatePaasV4AsyncImagesGenerationsResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::ZAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -210,6 +242,11 @@ partial void ProcessCreatePaasV4AsyncImagesGenerationsResponseContent( __attempt < __maxAttempts && global::ZAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::ZAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::ZAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::ZAI.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -226,14 +263,15 @@ partial void ProcessCreatePaasV4AsyncImagesGenerationsResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::ZAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -273,6 +311,8 @@ partial void ProcessCreatePaasV4AsyncImagesGenerationsResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -293,6 +333,8 @@ partial void ProcessCreatePaasV4AsyncImagesGenerationsResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // The request has failed. @@ -355,9 +397,13 @@ partial void ProcessCreatePaasV4AsyncImagesGenerationsResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::ZAI.AsyncResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::ZAI.AsyncResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::ZAI.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::ZAI.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -385,9 +431,13 @@ partial void ProcessCreatePaasV4AsyncImagesGenerationsResponseContent( #endif ).ConfigureAwait(false); - return - await global::ZAI.AsyncResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::ZAI.AsyncResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::ZAI.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::ZAI.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { diff --git a/src/libs/ZAI/Generated/ZAI.ZaiClient.CreatePaasV4AudioTranscriptions.g.cs b/src/libs/ZAI/Generated/ZAI.ZaiClient.CreatePaasV4AudioTranscriptions.g.cs index 0bb70ad..a68470b 100644 --- a/src/libs/ZAI/Generated/ZAI.ZaiClient.CreatePaasV4AudioTranscriptions.g.cs +++ b/src/libs/ZAI/Generated/ZAI.ZaiClient.CreatePaasV4AudioTranscriptions.g.cs @@ -51,6 +51,29 @@ partial void ProcessCreatePaasV4AudioTranscriptionsResponseContent( /// public async global::System.Threading.Tasks.Task CreatePaasV4AudioTranscriptionsAsync( + global::ZAI.AudioTranscriptionRequest request, + global::ZAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await CreatePaasV4AudioTranscriptionsAsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Speech to Text
+ /// Use the [GLM-ASR-2512](/guides/audio/glm-asr-2512) model to transcribe audio files into text, supporting multiple languages and real-time streaming transcription. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> CreatePaasV4AudioTranscriptionsAsResponseAsync( + global::ZAI.AudioTranscriptionRequest request, global::ZAI.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) @@ -93,10 +116,11 @@ partial void ProcessCreatePaasV4AudioTranscriptionsResponseContent( var __maxAttempts = global::ZAI.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::ZAI.PathBuilder( path: "/paas/v4/audio/transcriptions", baseUri: HttpClient.BaseAddress); @@ -129,6 +153,7 @@ partial void ProcessCreatePaasV4AudioTranscriptionsResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); var __contentFile = new global::System.Net.Http.ByteArrayContent(request.File ?? global::System.Array.Empty()); __contentFile.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( @@ -167,56 +192,66 @@ request.Filename is null { __contentFile.Headers.ContentDisposition.FileNameStar = null; } + if (request.FileBase64 != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.FileBase64 ?? string.Empty), name: "\"file_base64\""); - } + + } if (request.Model != global::ZAI.AudioTranscriptionRequestModel.GlmAsr2512) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.Model.ToValueString()), name: "\"model\""); - } + + } if (request.Prompt != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty), name: "\"prompt\""); - } + + } if (request.Hotwords != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.Hotwords, x => x))}]"), name: "\"hotwords\""); - } + + } if (request.Stream != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.Stream, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()), name: "\"stream\""); - } + + } if (request.RequestId != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.RequestId ?? string.Empty), name: "\"request_id\""); - } + + } if (request.UserId != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.UserId ?? string.Empty), name: "\"user_id\""); + } + __httpRequest.Content = __httpRequestContent; + global::ZAI.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -258,6 +293,8 @@ request.Filename is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -268,6 +305,11 @@ request.Filename is null } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::ZAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::ZAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -285,6 +327,8 @@ request.Filename is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -294,8 +338,7 @@ request.Filename is null __httpRequest.Dispose(); __httpRequest = null; await global::ZAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -304,6 +347,11 @@ request.Filename is null __attempt < __maxAttempts && global::ZAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::ZAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::ZAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::ZAI.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -320,14 +368,15 @@ request.Filename is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::ZAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -367,6 +416,8 @@ request.Filename is null attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -387,6 +438,8 @@ request.Filename is null attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Request failed. @@ -449,9 +502,13 @@ request.Filename is null { __response.EnsureSuccessStatusCode(); - return - global::ZAI.AudioTranscriptionResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::ZAI.AudioTranscriptionResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::ZAI.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::ZAI.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -479,9 +536,13 @@ request.Filename is null #endif ).ConfigureAwait(false); - return - await global::ZAI.AudioTranscriptionResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::ZAI.AudioTranscriptionResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::ZAI.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::ZAI.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -581,5 +642,1090 @@ request.Filename is null requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } + + /// + /// Speech to Text
+ /// Use the [GLM-ASR-2512](/guides/audio/glm-asr-2512) model to transcribe audio files into text, supporting multiple languages and real-time streaming transcription. + ///
+ /// + /// The audio file to be transcribed. Supported audio file formats: `.wav / .mp3`. Specifications: file size ≤ `25 MB`, audio duration ≤ `30 seconds`. + /// + /// + /// The audio file to be transcribed. Supported audio file formats: `.wav / .mp3`. Specifications: file size ≤ `25 MB`, audio duration ≤ `30 seconds`. + /// + /// + /// Base64 encoded audio file. Only one of file_base64 or file needs to be provided (if both are provided, file takes precedence). + /// + /// + /// The model ID to invoke.
+ /// Default Value: glm-asr-2512 + /// + /// + /// In long text scenarios, you can provide previous transcription results as context. Recommended to be less than 8000 characters. + /// + /// + /// Hotword list to improve recognition accuracy for domain-specific vocabulary. Format example: ["person_name","place_name"]. Recommended not to exceed 100 items. + /// + /// + /// Passed by the client, must be unique. A unique identifier to distinguish each request. If not provided by the client, the platform will generate one by default. + /// + /// + /// A unique `ID` for the end user, helping the platform intervene in illegal activities, generation of illegal or inappropriate content, or other abusive behaviors by end users. `ID` length requirement: at least `6` characters, at most `128` characters. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task CreatePaasV4AudioTranscriptionsAsync( + global::System.IO.Stream file, + string filename, + string? fileBase64 = default, + global::ZAI.AudioTranscriptionRequestModel model = global::ZAI.AudioTranscriptionRequestModel.GlmAsr2512, + string? prompt = default, + global::System.Collections.Generic.IList? hotwords = default, + string? requestId = default, + string? userId = default, + global::ZAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + file = file ?? throw new global::System.ArgumentNullException(nameof(file)); + var request = new global::ZAI.AudioTranscriptionRequest + { + File = global::System.Array.Empty(), + Filename = filename, + FileBase64 = fileBase64, + Model = model, + Prompt = prompt, + Hotwords = hotwords, + Stream = false, + RequestId = requestId, + UserId = userId, + }; + PrepareArguments( + client: HttpClient); + PrepareCreatePaasV4AudioTranscriptionsArguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::ZAI.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_CreatePaasV4AudioTranscriptionsSecurityRequirements, + operationName: "CreatePaasV4AudioTranscriptionsAsync"); + + using var __timeoutCancellationTokenSource = global::ZAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::ZAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::ZAI.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::ZAI.PathBuilder( + path: "/paas/v4/audio/transcriptions", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::ZAI.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + var __contentFile = new global::System.Net.Http.StreamContent(file); + __contentFile.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.Filename is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.Filename) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentFile, + name: "\"file\"", + fileName: request.Filename != null ? $"\"{request.Filename}\"" : string.Empty); + if (__contentFile.Headers.ContentDisposition != null) + { + __contentFile.Headers.ContentDisposition.FileNameStar = null; + } + + if (request.FileBase64 != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.FileBase64 ?? string.Empty), + name: "\"file_base64\""); + + } + if (request.Model != global::ZAI.AudioTranscriptionRequestModel.GlmAsr2512) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Model.ToValueString()), + name: "\"model\""); + + } + if (request.Prompt != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty), + name: "\"prompt\""); + + } + if (request.Hotwords != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.Hotwords, x => x))}]"), + name: "\"hotwords\""); + + } + if (request.Stream != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.Stream, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()), + name: "\"stream\""); + + } + if (request.RequestId != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.RequestId ?? string.Empty), + name: "\"request_id\""); + + } + if (request.UserId != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.UserId ?? string.Empty), + name: "\"user_id\""); + + } + + __httpRequest.Content = __httpRequestContent; + + global::ZAI.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreatePaasV4AudioTranscriptionsRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::ZAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::ZAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createPaasV4AudioTranscriptions", + methodName: "CreatePaasV4AudioTranscriptionsAsync", + pathTemplate: "\"/paas/v4/audio/transcriptions\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::ZAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::ZAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::ZAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createPaasV4AudioTranscriptions", + methodName: "CreatePaasV4AudioTranscriptionsAsync", + pathTemplate: "\"/paas/v4/audio/transcriptions\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::ZAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::ZAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::ZAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::ZAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::ZAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createPaasV4AudioTranscriptions", + methodName: "CreatePaasV4AudioTranscriptionsAsync", + pathTemplate: "\"/paas/v4/audio/transcriptions\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::ZAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreatePaasV4AudioTranscriptionsResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::ZAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::ZAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createPaasV4AudioTranscriptions", + methodName: "CreatePaasV4AudioTranscriptionsAsync", + pathTemplate: "\"/paas/v4/audio/transcriptions\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::ZAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::ZAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createPaasV4AudioTranscriptions", + methodName: "CreatePaasV4AudioTranscriptionsAsync", + pathTemplate: "\"/paas/v4/audio/transcriptions\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // Request failed. + if (!__response.IsSuccessStatusCode) + { + string? __content_default = null; + global::System.Exception? __exception_default = null; + global::ZAI.Error? __value_default = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_default = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_default = global::ZAI.Error.FromJson(__content_default, JsonSerializerContext); + } + else + { + __content_default = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_default = global::ZAI.Error.FromJson(__content_default, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_default = __ex; + } + + throw new global::ZAI.ApiException( + message: __content_default ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_default, + statusCode: __response.StatusCode) + { + ResponseBody = __content_default, + ResponseObject = __value_default, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessCreatePaasV4AudioTranscriptionsResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::ZAI.AudioTranscriptionResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::ZAI.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::ZAI.AudioTranscriptionResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::ZAI.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + + } + } + finally + { + __httpRequest?.Dispose(); + } + } + /// + /// Speech to Text
+ /// Use the [GLM-ASR-2512](/guides/audio/glm-asr-2512) model to transcribe audio files into text, supporting multiple languages and real-time streaming transcription. + ///
+ /// + /// The audio file to be transcribed. Supported audio file formats: `.wav / .mp3`. Specifications: file size ≤ `25 MB`, audio duration ≤ `30 seconds`. + /// + /// + /// The audio file to be transcribed. Supported audio file formats: `.wav / .mp3`. Specifications: file size ≤ `25 MB`, audio duration ≤ `30 seconds`. + /// + /// + /// Base64 encoded audio file. Only one of file_base64 or file needs to be provided (if both are provided, file takes precedence). + /// + /// + /// The model ID to invoke.
+ /// Default Value: glm-asr-2512 + /// + /// + /// In long text scenarios, you can provide previous transcription results as context. Recommended to be less than 8000 characters. + /// + /// + /// Hotword list to improve recognition accuracy for domain-specific vocabulary. Format example: ["person_name","place_name"]. Recommended not to exceed 100 items. + /// + /// + /// Passed by the client, must be unique. A unique identifier to distinguish each request. If not provided by the client, the platform will generate one by default. + /// + /// + /// A unique `ID` for the end user, helping the platform intervene in illegal activities, generation of illegal or inappropriate content, or other abusive behaviors by end users. `ID` length requirement: at least `6` characters, at most `128` characters. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> CreatePaasV4AudioTranscriptionsAsResponseAsync( + global::System.IO.Stream file, + string filename, + string? fileBase64 = default, + global::ZAI.AudioTranscriptionRequestModel model = global::ZAI.AudioTranscriptionRequestModel.GlmAsr2512, + string? prompt = default, + global::System.Collections.Generic.IList? hotwords = default, + string? requestId = default, + string? userId = default, + global::ZAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + file = file ?? throw new global::System.ArgumentNullException(nameof(file)); + var request = new global::ZAI.AudioTranscriptionRequest + { + File = global::System.Array.Empty(), + Filename = filename, + FileBase64 = fileBase64, + Model = model, + Prompt = prompt, + Hotwords = hotwords, + Stream = false, + RequestId = requestId, + UserId = userId, + }; + PrepareArguments( + client: HttpClient); + PrepareCreatePaasV4AudioTranscriptionsArguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::ZAI.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_CreatePaasV4AudioTranscriptionsSecurityRequirements, + operationName: "CreatePaasV4AudioTranscriptionsAsync"); + + using var __timeoutCancellationTokenSource = global::ZAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::ZAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::ZAI.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::ZAI.PathBuilder( + path: "/paas/v4/audio/transcriptions", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::ZAI.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + var __contentFile = new global::System.Net.Http.StreamContent(file); + __contentFile.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.Filename is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.Filename) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentFile, + name: "\"file\"", + fileName: request.Filename != null ? $"\"{request.Filename}\"" : string.Empty); + if (__contentFile.Headers.ContentDisposition != null) + { + __contentFile.Headers.ContentDisposition.FileNameStar = null; + } + + if (request.FileBase64 != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.FileBase64 ?? string.Empty), + name: "\"file_base64\""); + + } + if (request.Model != global::ZAI.AudioTranscriptionRequestModel.GlmAsr2512) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Model.ToValueString()), + name: "\"model\""); + + } + if (request.Prompt != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty), + name: "\"prompt\""); + + } + if (request.Hotwords != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.Hotwords, x => x))}]"), + name: "\"hotwords\""); + + } + if (request.Stream != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.Stream, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()), + name: "\"stream\""); + + } + if (request.RequestId != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.RequestId ?? string.Empty), + name: "\"request_id\""); + + } + if (request.UserId != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.UserId ?? string.Empty), + name: "\"user_id\""); + + } + + __httpRequest.Content = __httpRequestContent; + + global::ZAI.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreatePaasV4AudioTranscriptionsRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::ZAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::ZAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createPaasV4AudioTranscriptions", + methodName: "CreatePaasV4AudioTranscriptionsAsync", + pathTemplate: "\"/paas/v4/audio/transcriptions\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::ZAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::ZAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::ZAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createPaasV4AudioTranscriptions", + methodName: "CreatePaasV4AudioTranscriptionsAsync", + pathTemplate: "\"/paas/v4/audio/transcriptions\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::ZAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::ZAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::ZAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::ZAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::ZAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createPaasV4AudioTranscriptions", + methodName: "CreatePaasV4AudioTranscriptionsAsync", + pathTemplate: "\"/paas/v4/audio/transcriptions\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::ZAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreatePaasV4AudioTranscriptionsResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::ZAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::ZAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createPaasV4AudioTranscriptions", + methodName: "CreatePaasV4AudioTranscriptionsAsync", + pathTemplate: "\"/paas/v4/audio/transcriptions\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::ZAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::ZAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createPaasV4AudioTranscriptions", + methodName: "CreatePaasV4AudioTranscriptionsAsync", + pathTemplate: "\"/paas/v4/audio/transcriptions\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // Request failed. + if (!__response.IsSuccessStatusCode) + { + string? __content_default = null; + global::System.Exception? __exception_default = null; + global::ZAI.Error? __value_default = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_default = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_default = global::ZAI.Error.FromJson(__content_default, JsonSerializerContext); + } + else + { + __content_default = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_default = global::ZAI.Error.FromJson(__content_default, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_default = __ex; + } + + throw new global::ZAI.ApiException( + message: __content_default ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_default, + statusCode: __response.StatusCode) + { + ResponseBody = __content_default, + ResponseObject = __value_default, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessCreatePaasV4AudioTranscriptionsResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::ZAI.AudioTranscriptionResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::ZAI.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::ZAI.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::ZAI.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + var __value = await global::ZAI.AudioTranscriptionResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::ZAI.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::ZAI.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::ZAI.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + + } + } + finally + { + __httpRequest?.Dispose(); + } + } } } \ No newline at end of file diff --git a/src/libs/ZAI/Generated/ZAI.ZaiClient.CreatePaasV4AudioTranscriptionsAsStream.g.cs b/src/libs/ZAI/Generated/ZAI.ZaiClient.CreatePaasV4AudioTranscriptionsAsStream.g.cs index 4ce48d7..41d863c 100644 --- a/src/libs/ZAI/Generated/ZAI.ZaiClient.CreatePaasV4AudioTranscriptionsAsStream.g.cs +++ b/src/libs/ZAI/Generated/ZAI.ZaiClient.CreatePaasV4AudioTranscriptionsAsStream.g.cs @@ -88,10 +88,11 @@ partial void ProcessCreatePaasV4AudioTranscriptionsAsStreamResponse( var __maxAttempts = global::ZAI.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::ZAI.PathBuilder( path: "/paas/v4/audio/transcriptions", baseUri: HttpClient.BaseAddress); @@ -124,6 +125,7 @@ partial void ProcessCreatePaasV4AudioTranscriptionsAsStreamResponse( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); var __contentFile = new global::System.Net.Http.ByteArrayContent(request.File ?? global::System.Array.Empty()); __contentFile.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( @@ -162,56 +164,66 @@ request.Filename is null { __contentFile.Headers.ContentDisposition.FileNameStar = null; } + if (request.FileBase64 != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.FileBase64 ?? string.Empty), name: "\"file_base64\""); - } + + } if (request.Model != global::ZAI.AudioTranscriptionRequestModel.GlmAsr2512) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.Model.ToValueString()), name: "\"model\""); - } + + } if (request.Prompt != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty), name: "\"prompt\""); - } + + } if (request.Hotwords != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.Hotwords, x => x))}]"), name: "\"hotwords\""); - } + + } if (request.Stream != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.Stream, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()), name: "\"stream\""); - } + + } if (request.RequestId != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.RequestId ?? string.Empty), name: "\"request_id\""); - } + + } if (request.UserId != default) { __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.UserId ?? string.Empty), name: "\"user_id\""); + } + __httpRequest.Content = __httpRequestContent; + global::ZAI.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -253,6 +265,8 @@ request.Filename is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -263,6 +277,11 @@ request.Filename is null } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::ZAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::ZAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -280,6 +299,8 @@ request.Filename is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -289,8 +310,7 @@ request.Filename is null __httpRequest.Dispose(); __httpRequest = null; await global::ZAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -299,6 +319,11 @@ request.Filename is null __attempt < __maxAttempts && global::ZAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::ZAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::ZAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::ZAI.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -315,14 +340,15 @@ request.Filename is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::ZAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -362,6 +388,8 @@ request.Filename is null attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -382,6 +410,8 @@ request.Filename is null attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } @@ -521,5 +551,484 @@ request.Filename is null yield return __response; } } + + /// + /// Speech to Text
+ /// Use the [GLM-ASR-2512](/guides/audio/glm-asr-2512) model to transcribe audio files into text, supporting multiple languages and real-time streaming transcription. + ///
+ /// + /// The audio file to be transcribed. Supported audio file formats: `.wav / .mp3`. Specifications: file size ≤ `25 MB`, audio duration ≤ `30 seconds`. + /// + /// + /// The audio file to be transcribed. Supported audio file formats: `.wav / .mp3`. Specifications: file size ≤ `25 MB`, audio duration ≤ `30 seconds`. + /// + /// + /// Base64 encoded audio file. Only one of file_base64 or file needs to be provided (if both are provided, file takes precedence). + /// + /// + /// The model ID to invoke.
+ /// Default Value: glm-asr-2512 + /// + /// + /// In long text scenarios, you can provide previous transcription results as context. Recommended to be less than 8000 characters. + /// + /// + /// Hotword list to improve recognition accuracy for domain-specific vocabulary. Format example: ["person_name","place_name"]. Recommended not to exceed 100 items. + /// + /// + /// Passed by the client, must be unique. A unique identifier to distinguish each request. If not provided by the client, the platform will generate one by default. + /// + /// + /// A unique `ID` for the end user, helping the platform intervene in illegal activities, generation of illegal or inappropriate content, or other abusive behaviors by end users. `ID` length requirement: at least `6` characters, at most `128` characters. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Collections.Generic.IAsyncEnumerable CreatePaasV4AudioTranscriptionsAsStreamAsync( + global::System.IO.Stream file, + string filename, + string? fileBase64 = default, + global::ZAI.AudioTranscriptionRequestModel model = global::ZAI.AudioTranscriptionRequestModel.GlmAsr2512, + string? prompt = default, + global::System.Collections.Generic.IList? hotwords = default, + string? requestId = default, + string? userId = default, + global::ZAI.AutoSDKRequestOptions? requestOptions = default, + [global::System.Runtime.CompilerServices.EnumeratorCancellation] global::System.Threading.CancellationToken cancellationToken = default) + { + + file = file ?? throw new global::System.ArgumentNullException(nameof(file)); + var request = new global::ZAI.AudioTranscriptionRequest + { + File = global::System.Array.Empty(), + Filename = filename, + FileBase64 = fileBase64, + Model = model, + Prompt = prompt, + Hotwords = hotwords, + Stream = true, + RequestId = requestId, + UserId = userId, + }; + PrepareArguments( + client: HttpClient); + PrepareCreatePaasV4AudioTranscriptionsAsStreamArguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::ZAI.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_CreatePaasV4AudioTranscriptionsAsStreamSecurityRequirements, + operationName: "CreatePaasV4AudioTranscriptionsAsStreamAsync"); + + using var __timeoutCancellationTokenSource = global::ZAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::ZAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::ZAI.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::ZAI.PathBuilder( + path: "/paas/v4/audio/transcriptions", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::ZAI.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + var __contentFile = new global::System.Net.Http.StreamContent(file); + __contentFile.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.Filename is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.Filename) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentFile, + name: "\"file\"", + fileName: request.Filename != null ? $"\"{request.Filename}\"" : string.Empty); + if (__contentFile.Headers.ContentDisposition != null) + { + __contentFile.Headers.ContentDisposition.FileNameStar = null; + } + + if (request.FileBase64 != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.FileBase64 ?? string.Empty), + name: "\"file_base64\""); + + } + if (request.Model != global::ZAI.AudioTranscriptionRequestModel.GlmAsr2512) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Model.ToValueString()), + name: "\"model\""); + + } + if (request.Prompt != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Prompt ?? string.Empty), + name: "\"prompt\""); + + } + if (request.Hotwords != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent($"[{string.Join(",", global::System.Linq.Enumerable.Select(request.Hotwords, x => x))}]"), + name: "\"hotwords\""); + + } + if (request.Stream != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent((global::System.Convert.ToString(request.Stream, global::System.Globalization.CultureInfo.InvariantCulture) ?? string.Empty).ToLowerInvariant()), + name: "\"stream\""); + + } + if (request.RequestId != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.RequestId ?? string.Empty), + name: "\"request_id\""); + + } + if (request.UserId != default) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.UserId ?? string.Empty), + name: "\"user_id\""); + + } + + __httpRequest.Content = __httpRequestContent; + + global::ZAI.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreatePaasV4AudioTranscriptionsAsStreamRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::ZAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::ZAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createPaasV4AudioTranscriptionsAsStream", + methodName: "CreatePaasV4AudioTranscriptionsAsStreamAsync", + pathTemplate: "\"/paas/v4/audio/transcriptions\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseHeadersRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::ZAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::ZAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::ZAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createPaasV4AudioTranscriptionsAsStream", + methodName: "CreatePaasV4AudioTranscriptionsAsStreamAsync", + pathTemplate: "\"/paas/v4/audio/transcriptions\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::ZAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::ZAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::ZAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::ZAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::ZAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createPaasV4AudioTranscriptionsAsStream", + methodName: "CreatePaasV4AudioTranscriptionsAsStreamAsync", + pathTemplate: "\"/paas/v4/audio/transcriptions\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::ZAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreatePaasV4AudioTranscriptionsAsStreamResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::ZAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::ZAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createPaasV4AudioTranscriptionsAsStream", + methodName: "CreatePaasV4AudioTranscriptionsAsStreamAsync", + pathTemplate: "\"/paas/v4/audio/transcriptions\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::ZAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::ZAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createPaasV4AudioTranscriptionsAsStream", + methodName: "CreatePaasV4AudioTranscriptionsAsStreamAsync", + pathTemplate: "\"/paas/v4/audio/transcriptions\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + + try + { + __response.EnsureSuccessStatusCode(); + } + catch (global::System.Net.Http.HttpRequestException __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::ZAI.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + using var __stream = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + await foreach (var __sseEvent in global::System.Net.ServerSentEvents.SseParser + .Create(__stream).EnumerateAsync(__effectiveCancellationToken)) + { + var __content = __sseEvent.Data; + if (__content == "[DONE]") + { + yield break; + } + + var __streamedResponse = global::ZAI.AudioTranscriptionStreamResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::ZAI.ApiException( + message: $"Response deserialization failed for \"{__content}\" ", + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + + yield return __streamedResponse; + } + + } + } + finally + { + __httpRequest?.Dispose(); + } + } } } \ No newline at end of file diff --git a/src/libs/ZAI/Generated/ZAI.ZaiClient.CreatePaasV4ChatCompletions.g.cs b/src/libs/ZAI/Generated/ZAI.ZaiClient.CreatePaasV4ChatCompletions.g.cs index dd97f86..e006b6b 100644 --- a/src/libs/ZAI/Generated/ZAI.ZaiClient.CreatePaasV4ChatCompletions.g.cs +++ b/src/libs/ZAI/Generated/ZAI.ZaiClient.CreatePaasV4ChatCompletions.g.cs @@ -57,6 +57,35 @@ partial void ProcessCreatePaasV4ChatCompletionsResponseContent( /// public async global::System.Threading.Tasks.Task CreatePaasV4ChatCompletionsAsync( + global::ZAI.OneOf request, + global::ZAI.CreatePaasV4ChatCompletionsAcceptLanguage? acceptLanguage = default, + global::ZAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await CreatePaasV4ChatCompletionsAsResponseAsync( + + request: request, + acceptLanguage: acceptLanguage, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Create a chat completion model that generates AI replies for given conversation messages. It supports multimodal inputs (text, images, audio, video, file), offers configurable parameters (like temperature, max tokens, tool use), and supports both streaming and non-streaming output modes. + /// + /// + /// Config desired response language for HTTP requests.
+ /// Default Value: en-US,en
+ /// Example: en-US,en + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> CreatePaasV4ChatCompletionsAsResponseAsync( + global::ZAI.OneOf request, global::ZAI.CreatePaasV4ChatCompletionsAcceptLanguage? acceptLanguage = default, global::ZAI.AutoSDKRequestOptions? requestOptions = default, @@ -91,6 +120,7 @@ partial void ProcessCreatePaasV4ChatCompletionsResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::ZAI.PathBuilder( path: "/paas/v4/chat/completions", baseUri: HttpClient.BaseAddress); @@ -177,6 +207,8 @@ partial void ProcessCreatePaasV4ChatCompletionsResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -187,6 +219,11 @@ partial void ProcessCreatePaasV4ChatCompletionsResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::ZAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::ZAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -204,6 +241,8 @@ partial void ProcessCreatePaasV4ChatCompletionsResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -213,8 +252,7 @@ partial void ProcessCreatePaasV4ChatCompletionsResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::ZAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -223,6 +261,11 @@ partial void ProcessCreatePaasV4ChatCompletionsResponseContent( __attempt < __maxAttempts && global::ZAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::ZAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::ZAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::ZAI.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -239,14 +282,15 @@ partial void ProcessCreatePaasV4ChatCompletionsResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::ZAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -286,6 +330,8 @@ partial void ProcessCreatePaasV4ChatCompletionsResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -306,6 +352,8 @@ partial void ProcessCreatePaasV4ChatCompletionsResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // The request has failed. @@ -368,9 +416,13 @@ partial void ProcessCreatePaasV4ChatCompletionsResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::ZAI.ChatCompletionResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::ZAI.ChatCompletionResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::ZAI.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::ZAI.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -398,9 +450,13 @@ partial void ProcessCreatePaasV4ChatCompletionsResponseContent( #endif ).ConfigureAwait(false); - return - await global::ZAI.ChatCompletionResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::ZAI.ChatCompletionResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::ZAI.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::ZAI.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { diff --git a/src/libs/ZAI/Generated/ZAI.ZaiClient.CreatePaasV4Files.g.cs b/src/libs/ZAI/Generated/ZAI.ZaiClient.CreatePaasV4Files.g.cs index 4b3ceb1..296625f 100644 --- a/src/libs/ZAI/Generated/ZAI.ZaiClient.CreatePaasV4Files.g.cs +++ b/src/libs/ZAI/Generated/ZAI.ZaiClient.CreatePaasV4Files.g.cs @@ -50,6 +50,28 @@ partial void ProcessCreatePaasV4FilesResponseContent( /// public async global::System.Threading.Tasks.Task CreatePaasV4FilesAsync( + global::ZAI.CreatePaasV4FilesRequest request, + global::ZAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await CreatePaasV4FilesAsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// This API is designed for uploading auxiliary files (such as glossaries, terminology lists) to support the translation service. It allows users to upload reference materials that can enhance translation accuracy and consistency. + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> CreatePaasV4FilesAsResponseAsync( + global::ZAI.CreatePaasV4FilesRequest request, global::ZAI.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) @@ -80,10 +102,11 @@ partial void ProcessCreatePaasV4FilesResponseContent( var __maxAttempts = global::ZAI.AutoSDKRequestOptionsSupport.GetMaxAttempts( clientOptions: Options, requestOptions: requestOptions, - supportsRetry: true); + supportsRetry: false); global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::ZAI.PathBuilder( path: "/paas/v4/files", baseUri: HttpClient.BaseAddress); @@ -116,6 +139,7 @@ partial void ProcessCreatePaasV4FilesResponseContent( __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); } } + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); if (request.Purpose != global::ZAI.CreatePaasV4FilesRequestPurpose.Agent) { @@ -123,6 +147,7 @@ partial void ProcessCreatePaasV4FilesResponseContent( __httpRequestContent.Add( content: new global::System.Net.Http.StringContent(request.Purpose.ToValueString()), name: "\"purpose\""); + } var __contentFile = new global::System.Net.Http.ByteArrayContent(request.File ?? global::System.Array.Empty()); __contentFile.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( @@ -161,7 +186,9 @@ request.Filename is null { __contentFile.Headers.ContentDisposition.FileNameStar = null; } + __httpRequest.Content = __httpRequestContent; + global::ZAI.AutoSDKRequestOptionsSupport.ApplyHeaders( request: __httpRequest, clientHeaders: Options.Headers, @@ -203,6 +230,8 @@ request.Filename is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -213,6 +242,11 @@ request.Filename is null } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::ZAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::ZAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -230,6 +264,8 @@ request.Filename is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -239,8 +275,7 @@ request.Filename is null __httpRequest.Dispose(); __httpRequest = null; await global::ZAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -249,6 +284,11 @@ request.Filename is null __attempt < __maxAttempts && global::ZAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::ZAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::ZAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::ZAI.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -265,14 +305,15 @@ request.Filename is null attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::ZAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -312,6 +353,8 @@ request.Filename is null attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -332,6 +375,8 @@ request.Filename is null attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // The request has failed. @@ -394,9 +439,13 @@ request.Filename is null { __response.EnsureSuccessStatusCode(); - return - global::ZAI.CreatePaasV4FilesResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::ZAI.CreatePaasV4FilesResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::ZAI.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::ZAI.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -424,9 +473,13 @@ request.Filename is null #endif ).ConfigureAwait(false); - return - await global::ZAI.CreatePaasV4FilesResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::ZAI.CreatePaasV4FilesResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::ZAI.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::ZAI.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -499,5 +552,938 @@ request.Filename is null requestOptions: requestOptions, cancellationToken: cancellationToken).ConfigureAwait(false); } + + /// + /// This API is designed for uploading auxiliary files (such as glossaries, terminology lists) to support the translation service. It allows users to upload reference materials that can enhance translation accuracy and consistency. + /// + /// + /// Upload purpose (agent)
+ /// Default Value: agent + /// + /// + /// File to upload. Limit to `100MB`. Allowed formats: `pdf`, `doc`, `xlsx`, `ppt`, `txt`, `jpg`, `png`. + /// + /// + /// File to upload. Limit to `100MB`. Allowed formats: `pdf`, `doc`, `xlsx`, `ppt`, `txt`, `jpg`, `png`. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task CreatePaasV4FilesAsync( + global::System.IO.Stream file, + string filename, + global::ZAI.CreatePaasV4FilesRequestPurpose purpose = global::ZAI.CreatePaasV4FilesRequestPurpose.Agent, + global::ZAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + file = file ?? throw new global::System.ArgumentNullException(nameof(file)); + var request = new global::ZAI.CreatePaasV4FilesRequest + { + Purpose = purpose, + File = global::System.Array.Empty(), + Filename = filename, + }; + PrepareArguments( + client: HttpClient); + PrepareCreatePaasV4FilesArguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::ZAI.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_CreatePaasV4FilesSecurityRequirements, + operationName: "CreatePaasV4FilesAsync"); + + using var __timeoutCancellationTokenSource = global::ZAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::ZAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::ZAI.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::ZAI.PathBuilder( + path: "/paas/v4/files", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::ZAI.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + if (request.Purpose != global::ZAI.CreatePaasV4FilesRequestPurpose.Agent) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Purpose.ToValueString()), + name: "\"purpose\""); + + } + var __contentFile = new global::System.Net.Http.StreamContent(file); + __contentFile.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.Filename is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.Filename) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentFile, + name: "\"file\"", + fileName: request.Filename != null ? $"\"{request.Filename}\"" : string.Empty); + if (__contentFile.Headers.ContentDisposition != null) + { + __contentFile.Headers.ContentDisposition.FileNameStar = null; + } + + __httpRequest.Content = __httpRequestContent; + + global::ZAI.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreatePaasV4FilesRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::ZAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::ZAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createPaasV4Files", + methodName: "CreatePaasV4FilesAsync", + pathTemplate: "\"/paas/v4/files\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::ZAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::ZAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::ZAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createPaasV4Files", + methodName: "CreatePaasV4FilesAsync", + pathTemplate: "\"/paas/v4/files\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::ZAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::ZAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::ZAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::ZAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::ZAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createPaasV4Files", + methodName: "CreatePaasV4FilesAsync", + pathTemplate: "\"/paas/v4/files\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::ZAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreatePaasV4FilesResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::ZAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::ZAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createPaasV4Files", + methodName: "CreatePaasV4FilesAsync", + pathTemplate: "\"/paas/v4/files\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::ZAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::ZAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createPaasV4Files", + methodName: "CreatePaasV4FilesAsync", + pathTemplate: "\"/paas/v4/files\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // The request has failed. + if (!__response.IsSuccessStatusCode) + { + string? __content_default = null; + global::System.Exception? __exception_default = null; + global::ZAI.Error? __value_default = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_default = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_default = global::ZAI.Error.FromJson(__content_default, JsonSerializerContext); + } + else + { + __content_default = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_default = global::ZAI.Error.FromJson(__content_default, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_default = __ex; + } + + throw new global::ZAI.ApiException( + message: __content_default ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_default, + statusCode: __response.StatusCode) + { + ResponseBody = __content_default, + ResponseObject = __value_default, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessCreatePaasV4FilesResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + return + global::ZAI.CreatePaasV4FilesResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + } + catch (global::System.Exception __ex) + { + throw new global::ZAI.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + return + await global::ZAI.CreatePaasV4FilesResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::ZAI.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + + } + } + finally + { + __httpRequest?.Dispose(); + } + } + /// + /// This API is designed for uploading auxiliary files (such as glossaries, terminology lists) to support the translation service. It allows users to upload reference materials that can enhance translation accuracy and consistency. + /// + /// + /// Upload purpose (agent)
+ /// Default Value: agent + /// + /// + /// File to upload. Limit to `100MB`. Allowed formats: `pdf`, `doc`, `xlsx`, `ppt`, `txt`, `jpg`, `png`. + /// + /// + /// File to upload. Limit to `100MB`. Allowed formats: `pdf`, `doc`, `xlsx`, `ppt`, `txt`, `jpg`, `png`. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> CreatePaasV4FilesAsResponseAsync( + global::System.IO.Stream file, + string filename, + global::ZAI.CreatePaasV4FilesRequestPurpose purpose = global::ZAI.CreatePaasV4FilesRequestPurpose.Agent, + global::ZAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + + file = file ?? throw new global::System.ArgumentNullException(nameof(file)); + var request = new global::ZAI.CreatePaasV4FilesRequest + { + Purpose = purpose, + File = global::System.Array.Empty(), + Filename = filename, + }; + PrepareArguments( + client: HttpClient); + PrepareCreatePaasV4FilesArguments( + httpClient: HttpClient, + request: request); + + + var __authorizations = global::ZAI.EndPointSecurityResolver.ResolveAuthorizations( + availableAuthorizations: Authorizations, + securityRequirements: s_CreatePaasV4FilesSecurityRequirements, + operationName: "CreatePaasV4FilesAsync"); + + using var __timeoutCancellationTokenSource = global::ZAI.AutoSDKRequestOptionsSupport.CreateTimeoutCancellationTokenSource( + clientOptions: Options, + requestOptions: requestOptions, + cancellationToken: cancellationToken); + var __effectiveCancellationToken = __timeoutCancellationTokenSource?.Token ?? cancellationToken; + var __effectiveReadResponseAsString = global::ZAI.AutoSDKRequestOptionsSupport.GetReadResponseAsString( + clientOptions: Options, + requestOptions: requestOptions, + fallbackValue: ReadResponseAsString); + var __maxAttempts = global::ZAI.AutoSDKRequestOptionsSupport.GetMaxAttempts( + clientOptions: Options, + requestOptions: requestOptions, + supportsRetry: false); + + global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() + { + + var __pathBuilder = new global::ZAI.PathBuilder( + path: "/paas/v4/files", + baseUri: HttpClient.BaseAddress); + var __path = __pathBuilder.ToString(); + __path = global::ZAI.AutoSDKRequestOptionsSupport.AppendQueryParameters( + path: __path, + clientParameters: Options.QueryParameters, + requestParameters: requestOptions?.QueryParameters); + var __httpRequest = new global::System.Net.Http.HttpRequestMessage( + method: global::System.Net.Http.HttpMethod.Post, + requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute)); +#if NET6_0_OR_GREATER + __httpRequest.Version = global::System.Net.HttpVersion.Version11; + __httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher; +#endif + + foreach (var __authorization in __authorizations) + { + if (__authorization.Type == "Http" || + __authorization.Type == "OAuth2" || + __authorization.Type == "OpenIdConnect") + { + __httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue( + scheme: __authorization.Name, + parameter: __authorization.Value); + } + else if (__authorization.Type == "ApiKey" && + __authorization.Location == "Header") + { + __httpRequest.Headers.Add(__authorization.Name, __authorization.Value); + } + } + + var __httpRequestContent = new global::System.Net.Http.MultipartFormDataContent(); + if (request.Purpose != global::ZAI.CreatePaasV4FilesRequestPurpose.Agent) + { + + __httpRequestContent.Add( + content: new global::System.Net.Http.StringContent(request.Purpose.ToValueString()), + name: "\"purpose\""); + + } + var __contentFile = new global::System.Net.Http.StreamContent(file); + __contentFile.Headers.ContentType = new global::System.Net.Http.Headers.MediaTypeHeaderValue( + request.Filename is null + ? "application/octet-stream" + : (global::System.IO.Path.GetExtension(request.Filename) ?? string.Empty).ToLowerInvariant() switch + { + ".aac" => "audio/aac", + ".flac" => "audio/flac", + ".gif" => "image/gif", + ".jpeg" => "image/jpeg", + ".jpg" => "image/jpeg", + ".json" => "application/json", + ".m4a" => "audio/mp4", + ".mp3" => "audio/mpeg", + ".mp4" => "video/mp4", + ".mpeg" => "audio/mpeg", + ".mpga" => "audio/mpeg", + ".oga" => "audio/ogg", + ".ogg" => "audio/ogg", + ".opus" => "audio/ogg", + ".pdf" => "application/pdf", + ".png" => "image/png", + ".txt" => "text/plain", + ".wav" => "audio/wav", + ".weba" => "audio/webm", + ".webm" => "video/webm", + ".webp" => "image/webp", + _ => "application/octet-stream", + }); + __httpRequestContent.Add( + content: __contentFile, + name: "\"file\"", + fileName: request.Filename != null ? $"\"{request.Filename}\"" : string.Empty); + if (__contentFile.Headers.ContentDisposition != null) + { + __contentFile.Headers.ContentDisposition.FileNameStar = null; + } + + __httpRequest.Content = __httpRequestContent; + + global::ZAI.AutoSDKRequestOptionsSupport.ApplyHeaders( + request: __httpRequest, + clientHeaders: Options.Headers, + requestHeaders: requestOptions?.Headers); + + PrepareRequest( + client: HttpClient, + request: __httpRequest); + PrepareCreatePaasV4FilesRequest( + httpClient: HttpClient, + httpRequestMessage: __httpRequest, + request: request); + + return __httpRequest; + } + + global::System.Net.Http.HttpRequestMessage? __httpRequest = null; + global::System.Net.Http.HttpResponseMessage? __response = null; + var __attemptNumber = 0; + try + { + for (var __attempt = 1; __attempt <= __maxAttempts; __attempt++) + { + __attemptNumber = __attempt; + __httpRequest = __CreateHttpRequest(); + await global::ZAI.AutoSDKRequestOptionsSupport.OnBeforeRequestAsync( + clientOptions: Options, + context: global::ZAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createPaasV4Files", + methodName: "CreatePaasV4FilesAsync", + pathTemplate: "\"/paas/v4/files\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + try + { + __response = await HttpClient.SendAsync( + request: __httpRequest, + completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + } + catch (global::System.Net.Http.HttpRequestException __exception) + { + var __retryDelay = global::ZAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); + var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; + await global::ZAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::ZAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createPaasV4Files", + methodName: "CreatePaasV4FilesAsync", + pathTemplate: "\"/paas/v4/files\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: null, + exception: __exception, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + if (!__willRetry) + { + throw; + } + + __httpRequest.Dispose(); + __httpRequest = null; + await global::ZAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + if (__response != null && + __attempt < __maxAttempts && + global::ZAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) + { + var __retryDelay = global::ZAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); + await global::ZAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::ZAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createPaasV4Files", + methodName: "CreatePaasV4FilesAsync", + pathTemplate: "\"/paas/v4/files\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attempt, + maxAttempts: __maxAttempts, + willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + __response.Dispose(); + __response = null; + __httpRequest.Dispose(); + __httpRequest = null; + await global::ZAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( + retryDelay: __retryDelay, + cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); + continue; + } + + break; + } + + if (__response == null) + { + throw new global::System.InvalidOperationException("No response received."); + } + + using (__response) + { + + ProcessResponse( + client: HttpClient, + response: __response); + ProcessCreatePaasV4FilesResponse( + httpClient: HttpClient, + httpResponseMessage: __response); + if (__response.IsSuccessStatusCode) + { + await global::ZAI.AutoSDKRequestOptionsSupport.OnAfterSuccessAsync( + clientOptions: Options, + context: global::ZAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createPaasV4Files", + methodName: "CreatePaasV4FilesAsync", + pathTemplate: "\"/paas/v4/files\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + else + { + await global::ZAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( + clientOptions: Options, + context: global::ZAI.AutoSDKRequestOptionsSupport.CreateHookContext( + operationId: "createPaasV4Files", + methodName: "CreatePaasV4FilesAsync", + pathTemplate: "\"/paas/v4/files\"", + httpMethod: "POST", + baseUri: BaseUri, + request: __httpRequest!, + response: __response, + exception: null, + clientOptions: Options, + requestOptions: requestOptions, + attempt: __attemptNumber, + maxAttempts: __maxAttempts, + willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, + cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); + } + // The request has failed. + if (!__response.IsSuccessStatusCode) + { + string? __content_default = null; + global::System.Exception? __exception_default = null; + global::ZAI.Error? __value_default = null; + try + { + if (__effectiveReadResponseAsString) + { + __content_default = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + __value_default = global::ZAI.Error.FromJson(__content_default, JsonSerializerContext); + } + else + { + __content_default = await __response.Content.ReadAsStringAsync(__effectiveCancellationToken).ConfigureAwait(false); + + __value_default = global::ZAI.Error.FromJson(__content_default, JsonSerializerContext); + } + } + catch (global::System.Exception __ex) + { + __exception_default = __ex; + } + + throw new global::ZAI.ApiException( + message: __content_default ?? __response.ReasonPhrase ?? string.Empty, + innerException: __exception_default, + statusCode: __response.StatusCode) + { + ResponseBody = __content_default, + ResponseObject = __value_default, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + + if (__effectiveReadResponseAsString) + { + var __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + ProcessResponseContent( + client: HttpClient, + response: __response, + content: ref __content); + ProcessCreatePaasV4FilesResponseContent( + httpClient: HttpClient, + httpResponseMessage: __response, + content: ref __content); + + try + { + __response.EnsureSuccessStatusCode(); + + var __value = global::ZAI.CreatePaasV4FilesResponse.FromJson(__content, JsonSerializerContext) ?? + throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::ZAI.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::ZAI.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + throw new global::ZAI.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + else + { + try + { + __response.EnsureSuccessStatusCode(); + using var __content = await __response.Content.ReadAsStreamAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + + var __value = await global::ZAI.CreatePaasV4FilesResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::ZAI.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::ZAI.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); + } + catch (global::System.Exception __ex) + { + string? __content = null; + try + { + __content = await __response.Content.ReadAsStringAsync( + #if NET5_0_OR_GREATER + __effectiveCancellationToken + #endif + ).ConfigureAwait(false); + } + catch (global::System.Exception) + { + } + + throw new global::ZAI.ApiException( + message: __content ?? __response.ReasonPhrase ?? string.Empty, + innerException: __ex, + statusCode: __response.StatusCode) + { + ResponseBody = __content, + ResponseHeaders = global::System.Linq.Enumerable.ToDictionary( + __response.Headers, + h => h.Key, + h => h.Value), + }; + } + } + + } + } + finally + { + __httpRequest?.Dispose(); + } + } } } \ No newline at end of file diff --git a/src/libs/ZAI/Generated/ZAI.ZaiClient.CreatePaasV4ImagesGenerations.g.cs b/src/libs/ZAI/Generated/ZAI.ZaiClient.CreatePaasV4ImagesGenerations.g.cs index 2c7407e..634ed8c 100644 --- a/src/libs/ZAI/Generated/ZAI.ZaiClient.CreatePaasV4ImagesGenerations.g.cs +++ b/src/libs/ZAI/Generated/ZAI.ZaiClient.CreatePaasV4ImagesGenerations.g.cs @@ -51,6 +51,29 @@ partial void ProcessCreatePaasV4ImagesGenerationsResponseContent( /// public async global::System.Threading.Tasks.Task CreatePaasV4ImagesGenerationsAsync( + global::ZAI.CreateImageRequest request, + global::ZAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await CreatePaasV4ImagesGenerationsAsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Generate Image
+ /// Use [GLM-Image](/guides/image/glm-image) series models to generate high-quality images from text prompts. Through quick and accurate understanding of user text descriptions, `AI` image expression becomes more precise and personalized. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> CreatePaasV4ImagesGenerationsAsResponseAsync( + global::ZAI.CreateImageRequest request, global::ZAI.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) @@ -85,6 +108,7 @@ partial void ProcessCreatePaasV4ImagesGenerationsResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::ZAI.PathBuilder( path: "/paas/v4/images/generations", baseUri: HttpClient.BaseAddress); @@ -164,6 +188,8 @@ partial void ProcessCreatePaasV4ImagesGenerationsResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -174,6 +200,11 @@ partial void ProcessCreatePaasV4ImagesGenerationsResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::ZAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::ZAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -191,6 +222,8 @@ partial void ProcessCreatePaasV4ImagesGenerationsResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -200,8 +233,7 @@ partial void ProcessCreatePaasV4ImagesGenerationsResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::ZAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -210,6 +242,11 @@ partial void ProcessCreatePaasV4ImagesGenerationsResponseContent( __attempt < __maxAttempts && global::ZAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::ZAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::ZAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::ZAI.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -226,14 +263,15 @@ partial void ProcessCreatePaasV4ImagesGenerationsResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::ZAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -273,6 +311,8 @@ partial void ProcessCreatePaasV4ImagesGenerationsResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -293,6 +333,8 @@ partial void ProcessCreatePaasV4ImagesGenerationsResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Request Failed @@ -355,9 +397,13 @@ partial void ProcessCreatePaasV4ImagesGenerationsResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::ZAI.ImageGenerationResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::ZAI.ImageGenerationResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::ZAI.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::ZAI.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -385,9 +431,13 @@ partial void ProcessCreatePaasV4ImagesGenerationsResponseContent( #endif ).ConfigureAwait(false); - return - await global::ZAI.ImageGenerationResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::ZAI.ImageGenerationResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::ZAI.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::ZAI.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { diff --git a/src/libs/ZAI/Generated/ZAI.ZaiClient.CreatePaasV4LayoutParsing.g.cs b/src/libs/ZAI/Generated/ZAI.ZaiClient.CreatePaasV4LayoutParsing.g.cs index 752620b..0950ce8 100644 --- a/src/libs/ZAI/Generated/ZAI.ZaiClient.CreatePaasV4LayoutParsing.g.cs +++ b/src/libs/ZAI/Generated/ZAI.ZaiClient.CreatePaasV4LayoutParsing.g.cs @@ -51,6 +51,29 @@ partial void ProcessCreatePaasV4LayoutParsingResponseContent( /// public async global::System.Threading.Tasks.Task CreatePaasV4LayoutParsingAsync( + global::ZAI.LayoutParsingRequest request, + global::ZAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await CreatePaasV4LayoutParsingAsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Layout Parsing
+ /// Use the [GLM-OCR](/guides/vlm/glm-ocr) model to parse the layout of documents and images and extract text content. Support OCR recognition of images and PDF documents, returning detailed layout information and visualization results. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> CreatePaasV4LayoutParsingAsResponseAsync( + global::ZAI.LayoutParsingRequest request, global::ZAI.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) @@ -85,6 +108,7 @@ partial void ProcessCreatePaasV4LayoutParsingResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::ZAI.PathBuilder( path: "/paas/v4/layout_parsing", baseUri: HttpClient.BaseAddress); @@ -164,6 +188,8 @@ partial void ProcessCreatePaasV4LayoutParsingResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -174,6 +200,11 @@ partial void ProcessCreatePaasV4LayoutParsingResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::ZAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::ZAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -191,6 +222,8 @@ partial void ProcessCreatePaasV4LayoutParsingResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -200,8 +233,7 @@ partial void ProcessCreatePaasV4LayoutParsingResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::ZAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -210,6 +242,11 @@ partial void ProcessCreatePaasV4LayoutParsingResponseContent( __attempt < __maxAttempts && global::ZAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::ZAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::ZAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::ZAI.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -226,14 +263,15 @@ partial void ProcessCreatePaasV4LayoutParsingResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::ZAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -273,6 +311,8 @@ partial void ProcessCreatePaasV4LayoutParsingResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -293,6 +333,8 @@ partial void ProcessCreatePaasV4LayoutParsingResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // Request failed. @@ -355,9 +397,13 @@ partial void ProcessCreatePaasV4LayoutParsingResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::ZAI.LayoutParsingResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::ZAI.LayoutParsingResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::ZAI.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::ZAI.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -385,9 +431,13 @@ partial void ProcessCreatePaasV4LayoutParsingResponseContent( #endif ).ConfigureAwait(false); - return - await global::ZAI.LayoutParsingResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::ZAI.LayoutParsingResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::ZAI.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::ZAI.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { diff --git a/src/libs/ZAI/Generated/ZAI.ZaiClient.CreatePaasV4Reader.g.cs b/src/libs/ZAI/Generated/ZAI.ZaiClient.CreatePaasV4Reader.g.cs index 55a0080..8017d1d 100644 --- a/src/libs/ZAI/Generated/ZAI.ZaiClient.CreatePaasV4Reader.g.cs +++ b/src/libs/ZAI/Generated/ZAI.ZaiClient.CreatePaasV4Reader.g.cs @@ -51,6 +51,29 @@ partial void ProcessCreatePaasV4ReaderResponseContent( /// public async global::System.Threading.Tasks.Task CreatePaasV4ReaderAsync( + global::ZAI.ReaderRequest request, + global::ZAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await CreatePaasV4ReaderAsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Web Reader
+ /// Reads and parses the content of the specified URL. Supports selectable return formats, cache control, image retention, and summary options. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> CreatePaasV4ReaderAsResponseAsync( + global::ZAI.ReaderRequest request, global::ZAI.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) @@ -85,6 +108,7 @@ partial void ProcessCreatePaasV4ReaderResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::ZAI.PathBuilder( path: "/paas/v4/reader", baseUri: HttpClient.BaseAddress); @@ -164,6 +188,8 @@ partial void ProcessCreatePaasV4ReaderResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -174,6 +200,11 @@ partial void ProcessCreatePaasV4ReaderResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::ZAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::ZAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -191,6 +222,8 @@ partial void ProcessCreatePaasV4ReaderResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -200,8 +233,7 @@ partial void ProcessCreatePaasV4ReaderResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::ZAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -210,6 +242,11 @@ partial void ProcessCreatePaasV4ReaderResponseContent( __attempt < __maxAttempts && global::ZAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::ZAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::ZAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::ZAI.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -226,14 +263,15 @@ partial void ProcessCreatePaasV4ReaderResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::ZAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -273,6 +311,8 @@ partial void ProcessCreatePaasV4ReaderResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -293,6 +333,8 @@ partial void ProcessCreatePaasV4ReaderResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // The request has failed. @@ -355,9 +397,13 @@ partial void ProcessCreatePaasV4ReaderResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::ZAI.ReaderResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::ZAI.ReaderResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::ZAI.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::ZAI.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -385,9 +431,13 @@ partial void ProcessCreatePaasV4ReaderResponseContent( #endif ).ConfigureAwait(false); - return - await global::ZAI.ReaderResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::ZAI.ReaderResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::ZAI.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::ZAI.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { diff --git a/src/libs/ZAI/Generated/ZAI.ZaiClient.CreatePaasV4Tokenizer.g.cs b/src/libs/ZAI/Generated/ZAI.ZaiClient.CreatePaasV4Tokenizer.g.cs index 9241355..02893bf 100644 --- a/src/libs/ZAI/Generated/ZAI.ZaiClient.CreatePaasV4Tokenizer.g.cs +++ b/src/libs/ZAI/Generated/ZAI.ZaiClient.CreatePaasV4Tokenizer.g.cs @@ -51,6 +51,29 @@ partial void ProcessCreatePaasV4TokenizerResponseContent( /// public async global::System.Threading.Tasks.Task CreatePaasV4TokenizerAsync( + global::ZAI.TokenizerRequest request, + global::ZAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await CreatePaasV4TokenizerAsResponseAsync( + + request: request, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// Text Tokenizer
+ /// `Tokenizer` is used to split text into `tokens` recognizable by the model and calculate the count. It receives user input text, processes it through the model for tokenization, and finally returns the corresponding `token` count. It is suitable for text length evaluation, model input estimation, dialogue context truncation, cost calculation, etc. + ///
+ /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> CreatePaasV4TokenizerAsResponseAsync( + global::ZAI.TokenizerRequest request, global::ZAI.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) @@ -85,6 +108,7 @@ partial void ProcessCreatePaasV4TokenizerResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::ZAI.PathBuilder( path: "/paas/v4/tokenizer", baseUri: HttpClient.BaseAddress); @@ -164,6 +188,8 @@ partial void ProcessCreatePaasV4TokenizerResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -174,6 +200,11 @@ partial void ProcessCreatePaasV4TokenizerResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::ZAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::ZAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -191,6 +222,8 @@ partial void ProcessCreatePaasV4TokenizerResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -200,8 +233,7 @@ partial void ProcessCreatePaasV4TokenizerResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::ZAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -210,6 +242,11 @@ partial void ProcessCreatePaasV4TokenizerResponseContent( __attempt < __maxAttempts && global::ZAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::ZAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::ZAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::ZAI.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -226,14 +263,15 @@ partial void ProcessCreatePaasV4TokenizerResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::ZAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -273,6 +311,8 @@ partial void ProcessCreatePaasV4TokenizerResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -293,6 +333,8 @@ partial void ProcessCreatePaasV4TokenizerResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // The request has failed. @@ -355,9 +397,13 @@ partial void ProcessCreatePaasV4TokenizerResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::ZAI.TokenizerResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::ZAI.TokenizerResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::ZAI.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::ZAI.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -385,9 +431,13 @@ partial void ProcessCreatePaasV4TokenizerResponseContent( #endif ).ConfigureAwait(false); - return - await global::ZAI.TokenizerResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::ZAI.TokenizerResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::ZAI.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::ZAI.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { diff --git a/src/libs/ZAI/Generated/ZAI.ZaiClient.CreatePaasV4VideosGenerations.g.cs b/src/libs/ZAI/Generated/ZAI.ZaiClient.CreatePaasV4VideosGenerations.g.cs index d58b6e4..0fae40b 100644 --- a/src/libs/ZAI/Generated/ZAI.ZaiClient.CreatePaasV4VideosGenerations.g.cs +++ b/src/libs/ZAI/Generated/ZAI.ZaiClient.CreatePaasV4VideosGenerations.g.cs @@ -58,6 +58,36 @@ partial void ProcessCreatePaasV4VideosGenerationsResponseContent( /// public async global::System.Threading.Tasks.Task CreatePaasV4VideosGenerationsAsync( + global::ZAI.OneOf request, + global::ZAI.CreatePaasV4VideosGenerationsAcceptLanguage? acceptLanguage = default, + global::ZAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await CreatePaasV4VideosGenerationsAsResponseAsync( + + request: request, + acceptLanguage: acceptLanguage, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// CogVideoX is a video generation large model developed by Z.AI, equipped with powerful video generation capabilities. Simply inputting text or images allows for effortless video creation.
+ /// Vidu: A high-performance video large model that combines high consistency and high dynamism, with precise semantic understanding and exceptional reasoning speed. + ///
+ /// + /// Config desired response language for HTTP requests.
+ /// Default Value: en-US,en
+ /// Example: en-US,en + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> CreatePaasV4VideosGenerationsAsResponseAsync( + global::ZAI.OneOf request, global::ZAI.CreatePaasV4VideosGenerationsAcceptLanguage? acceptLanguage = default, global::ZAI.AutoSDKRequestOptions? requestOptions = default, @@ -92,6 +122,7 @@ partial void ProcessCreatePaasV4VideosGenerationsResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::ZAI.PathBuilder( path: "/paas/v4/videos/generations", baseUri: HttpClient.BaseAddress); @@ -178,6 +209,8 @@ partial void ProcessCreatePaasV4VideosGenerationsResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -188,6 +221,11 @@ partial void ProcessCreatePaasV4VideosGenerationsResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::ZAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::ZAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -205,6 +243,8 @@ partial void ProcessCreatePaasV4VideosGenerationsResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -214,8 +254,7 @@ partial void ProcessCreatePaasV4VideosGenerationsResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::ZAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -224,6 +263,11 @@ partial void ProcessCreatePaasV4VideosGenerationsResponseContent( __attempt < __maxAttempts && global::ZAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::ZAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::ZAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::ZAI.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -240,14 +284,15 @@ partial void ProcessCreatePaasV4VideosGenerationsResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::ZAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -287,6 +332,8 @@ partial void ProcessCreatePaasV4VideosGenerationsResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -307,6 +354,8 @@ partial void ProcessCreatePaasV4VideosGenerationsResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // The request has failed. @@ -369,9 +418,13 @@ partial void ProcessCreatePaasV4VideosGenerationsResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::ZAI.VideoResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::ZAI.VideoResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::ZAI.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::ZAI.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -399,9 +452,13 @@ partial void ProcessCreatePaasV4VideosGenerationsResponseContent( #endif ).ConfigureAwait(false); - return - await global::ZAI.VideoResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::ZAI.VideoResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::ZAI.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::ZAI.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { diff --git a/src/libs/ZAI/Generated/ZAI.ZaiClient.CreatePaasV4WebSearch.g.cs b/src/libs/ZAI/Generated/ZAI.ZaiClient.CreatePaasV4WebSearch.g.cs index e550376..9a4e2c0 100644 --- a/src/libs/ZAI/Generated/ZAI.ZaiClient.CreatePaasV4WebSearch.g.cs +++ b/src/libs/ZAI/Generated/ZAI.ZaiClient.CreatePaasV4WebSearch.g.cs @@ -57,6 +57,35 @@ partial void ProcessCreatePaasV4WebSearchResponseContent( /// public async global::System.Threading.Tasks.Task CreatePaasV4WebSearchAsync( + global::ZAI.WebSearchRequest request, + global::ZAI.CreatePaasV4WebSearchAcceptLanguage? acceptLanguage = default, + global::ZAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await CreatePaasV4WebSearchAsResponseAsync( + + request: request, + acceptLanguage: acceptLanguage, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// The [Web Search](/guides/tools/web-search) is a specialized search engine for large language models. Building upon traditional search engine capabilities like web crawling and ranking, it enhances intent recognition to return results better suited for LLM processing (including webpage titles, URLs, summaries, site names, favicons etc.). + /// + /// + /// Config desired response language for HTTP requests.
+ /// Default Value: en-US,en
+ /// Example: en-US,en + /// + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task> CreatePaasV4WebSearchAsResponseAsync( + global::ZAI.WebSearchRequest request, global::ZAI.CreatePaasV4WebSearchAcceptLanguage? acceptLanguage = default, global::ZAI.AutoSDKRequestOptions? requestOptions = default, @@ -93,6 +122,7 @@ partial void ProcessCreatePaasV4WebSearchResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::ZAI.PathBuilder( path: "/paas/v4/web_search", baseUri: HttpClient.BaseAddress); @@ -179,6 +209,8 @@ partial void ProcessCreatePaasV4WebSearchResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -189,6 +221,11 @@ partial void ProcessCreatePaasV4WebSearchResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::ZAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::ZAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -206,6 +243,8 @@ partial void ProcessCreatePaasV4WebSearchResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -215,8 +254,7 @@ partial void ProcessCreatePaasV4WebSearchResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::ZAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -225,6 +263,11 @@ partial void ProcessCreatePaasV4WebSearchResponseContent( __attempt < __maxAttempts && global::ZAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::ZAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::ZAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::ZAI.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -241,14 +284,15 @@ partial void ProcessCreatePaasV4WebSearchResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::ZAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -288,6 +332,8 @@ partial void ProcessCreatePaasV4WebSearchResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -308,6 +354,8 @@ partial void ProcessCreatePaasV4WebSearchResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // The request has failed. @@ -370,9 +418,13 @@ partial void ProcessCreatePaasV4WebSearchResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::ZAI.WebSearchResponse.FromJson(__content, JsonSerializerContext) ?? + var __value = global::ZAI.WebSearchResponse.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::ZAI.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::ZAI.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -400,9 +452,13 @@ partial void ProcessCreatePaasV4WebSearchResponseContent( #endif ).ConfigureAwait(false); - return - await global::ZAI.WebSearchResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::ZAI.WebSearchResponse.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::ZAI.AutoSDKHttpResponse( + statusCode: __response.StatusCode, + headers: global::ZAI.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { diff --git a/src/libs/ZAI/Generated/ZAI.ZaiClient.GetPaasV4AsyncResultById.g.cs b/src/libs/ZAI/Generated/ZAI.ZaiClient.GetPaasV4AsyncResultById.g.cs index effd03d..fe484d5 100644 --- a/src/libs/ZAI/Generated/ZAI.ZaiClient.GetPaasV4AsyncResultById.g.cs +++ b/src/libs/ZAI/Generated/ZAI.ZaiClient.GetPaasV4AsyncResultById.g.cs @@ -62,6 +62,35 @@ partial void ProcessGetPaasV4AsyncResultByIdResponseContent( global::ZAI.GetPaasV4AsyncResultAcceptLanguage? acceptLanguage = default, global::ZAI.AutoSDKRequestOptions? requestOptions = default, global::System.Threading.CancellationToken cancellationToken = default) + { + var __response = await GetPaasV4AsyncResultByIdAsResponseAsync( + id: id, + acceptLanguage: acceptLanguage, + requestOptions: requestOptions, + cancellationToken: cancellationToken + ).ConfigureAwait(false); + + return __response.Body; + } + /// + /// This endpoint is used to query the result of an asynchronous request. + /// + /// + /// Config desired response language for HTTP requests.
+ /// Default Value: en-US,en
+ /// Example: en-US,en + /// + /// + /// Task id. + /// + /// Per-request overrides such as headers, query parameters, timeout, retries, and response buffering. + /// The token to cancel the operation with + /// + public async global::System.Threading.Tasks.Task>> GetPaasV4AsyncResultByIdAsResponseAsync( + string id, + global::ZAI.GetPaasV4AsyncResultAcceptLanguage? acceptLanguage = default, + global::ZAI.AutoSDKRequestOptions? requestOptions = default, + global::System.Threading.CancellationToken cancellationToken = default) { PrepareArguments( client: HttpClient); @@ -92,6 +121,7 @@ partial void ProcessGetPaasV4AsyncResultByIdResponseContent( global::System.Net.Http.HttpRequestMessage __CreateHttpRequest() { + var __pathBuilder = new global::ZAI.PathBuilder( path: $"/paas/v4/async-result/{id}", baseUri: HttpClient.BaseAddress); @@ -172,6 +202,8 @@ partial void ProcessGetPaasV4AsyncResultByIdResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); try { @@ -182,6 +214,11 @@ partial void ProcessGetPaasV4AsyncResultByIdResponseContent( } catch (global::System.Net.Http.HttpRequestException __exception) { + var __retryDelay = global::ZAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: null, + attempt: __attempt); var __willRetry = __attempt < __maxAttempts && !__effectiveCancellationToken.IsCancellationRequested; await global::ZAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, @@ -199,6 +236,8 @@ partial void ProcessGetPaasV4AsyncResultByIdResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: __willRetry, + retryDelay: __willRetry ? __retryDelay : (global::System.TimeSpan?)null, + retryReason: "exception", cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); if (!__willRetry) { @@ -208,8 +247,7 @@ partial void ProcessGetPaasV4AsyncResultByIdResponseContent( __httpRequest.Dispose(); __httpRequest = null; await global::ZAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -218,6 +256,11 @@ partial void ProcessGetPaasV4AsyncResultByIdResponseContent( __attempt < __maxAttempts && global::ZAI.AutoSDKRequestOptionsSupport.ShouldRetryStatusCode(__response.StatusCode)) { + var __retryDelay = global::ZAI.AutoSDKRequestOptionsSupport.GetRetryDelay( + clientOptions: Options, + requestOptions: requestOptions, + response: __response, + attempt: __attempt); await global::ZAI.AutoSDKRequestOptionsSupport.OnAfterErrorAsync( clientOptions: Options, context: global::ZAI.AutoSDKRequestOptionsSupport.CreateHookContext( @@ -234,14 +277,15 @@ partial void ProcessGetPaasV4AsyncResultByIdResponseContent( attempt: __attempt, maxAttempts: __maxAttempts, willRetry: true, + retryDelay: __retryDelay, + retryReason: "status:" + ((int)__response.StatusCode).ToString(global::System.Globalization.CultureInfo.InvariantCulture), cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); __response.Dispose(); __response = null; __httpRequest.Dispose(); __httpRequest = null; await global::ZAI.AutoSDKRequestOptionsSupport.DelayBeforeRetryAsync( - clientOptions: Options, - requestOptions: requestOptions, + retryDelay: __retryDelay, cancellationToken: __effectiveCancellationToken).ConfigureAwait(false); continue; } @@ -281,6 +325,8 @@ partial void ProcessGetPaasV4AsyncResultByIdResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } else @@ -301,6 +347,8 @@ partial void ProcessGetPaasV4AsyncResultByIdResponseContent( attempt: __attemptNumber, maxAttempts: __maxAttempts, willRetry: false, + retryDelay: null, + retryReason: global::System.String.Empty, cancellationToken: __effectiveCancellationToken)).ConfigureAwait(false); } // The request has failed. @@ -363,9 +411,13 @@ partial void ProcessGetPaasV4AsyncResultByIdResponseContent( { __response.EnsureSuccessStatusCode(); - return - global::ZAI.OneOf.FromJson(__content, JsonSerializerContext) ?? + var __value = global::ZAI.OneOf.FromJson(__content, JsonSerializerContext) ?? throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" "); + return new global::ZAI.AutoSDKHttpResponse>( + statusCode: __response.StatusCode, + headers: global::ZAI.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { @@ -393,9 +445,13 @@ partial void ProcessGetPaasV4AsyncResultByIdResponseContent( #endif ).ConfigureAwait(false); - return - await global::ZAI.OneOf.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? + var __value = await global::ZAI.OneOf.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ?? throw new global::System.InvalidOperationException("Response deserialization failed."); + return new global::ZAI.AutoSDKHttpResponse>( + statusCode: __response.StatusCode, + headers: global::ZAI.AutoSDKHttpResponse.CreateHeaders(__response), + requestUri: __response.RequestMessage?.RequestUri, + body: __value); } catch (global::System.Exception __ex) { diff --git a/src/libs/ZAI/Generated/ZAI.ZaiClient.g.cs b/src/libs/ZAI/Generated/ZAI.ZaiClient.g.cs index 7321f2d..d5fdaa8 100644 --- a/src/libs/ZAI/Generated/ZAI.ZaiClient.g.cs +++ b/src/libs/ZAI/Generated/ZAI.ZaiClient.g.cs @@ -73,10 +73,10 @@ public ZaiClient( /// Client-wide request defaults such as headers, query parameters, retries, and timeout. /// Dispose the HttpClient when the instance is disposed. True by default. public ZaiClient( - global::System.Net.Http.HttpClient? httpClient = null, - global::System.Uri? baseUri = null, - global::System.Collections.Generic.List? authorizations = null, - global::ZAI.AutoSDKClientOptions? options = null, + global::System.Net.Http.HttpClient? httpClient, + global::System.Uri? baseUri, + global::System.Collections.Generic.List? authorizations, + global::ZAI.AutoSDKClientOptions? options, bool disposeHttpClient = true) {