1+ //HintName: G.AppClient.AppPublicServiceChat.g.cs
2+
3+ #nullable enable
4+
5+ namespace G
6+ {
7+ public partial class AppClient
8+ {
9+ partial void PrepareAppPublicServiceChatArguments (
10+ global ::System . Net . Http . HttpClient httpClient ,
11+ ref string namespaceId ,
12+ ref string appId ,
13+ global ::G . ChatBody request ) ;
14+ partial void PrepareAppPublicServiceChatRequest (
15+ global ::System . Net . Http . HttpClient httpClient ,
16+ global ::System . Net . Http . HttpRequestMessage httpRequestMessage ,
17+ string namespaceId ,
18+ string appId ,
19+ global ::G . ChatBody request ) ;
20+ partial void ProcessAppPublicServiceChatResponse (
21+ global ::System . Net . Http . HttpClient httpClient ,
22+ global ::System . Net . Http . HttpResponseMessage httpResponseMessage ) ;
23+
24+ partial void ProcessAppPublicServiceChatResponseContent (
25+ global ::System . Net . Http . HttpClient httpClient ,
26+ global ::System . Net . Http . HttpResponseMessage httpResponseMessage ,
27+ ref string content ) ;
28+
29+ /// <summary>
30+ /// Chat<br/>
31+ /// Chat sends a message asynchronously and streams back the response.<br/>
32+ /// This method is intended for real-time conversation with a chatbot<br/>
33+ /// and the response needs to be processed incrementally.
34+ /// </summary>
35+ /// <param name="namespaceId"></param>
36+ /// <param name="appId"></param>
37+ /// <param name="request"></param>
38+ /// <param name="cancellationToken">The token to cancel the operation with</param>
39+ /// <exception cref="global::System.InvalidOperationException"></exception>
40+ public async global ::System . Threading . Tasks . Task < global ::G . ChatResponse > AppPublicServiceChatAsync (
41+ string namespaceId ,
42+ string appId ,
43+ global ::G . ChatBody request ,
44+ global ::System . Threading . CancellationToken cancellationToken = default )
45+ {
46+ request = request ?? throw new global ::System . ArgumentNullException ( nameof ( request ) ) ;
47+
48+ PrepareArguments (
49+ client : HttpClient ) ;
50+ PrepareAppPublicServiceChatArguments (
51+ httpClient : HttpClient ,
52+ namespaceId : ref namespaceId ,
53+ appId : ref appId ,
54+ request : request ) ;
55+
56+ var __pathBuilder = new PathBuilder (
57+ path : $ "/v1alpha/namespaces/{ namespaceId } /apps/{ appId } /chat",
58+ baseUri : HttpClient . BaseAddress ) ;
59+ var __path = __pathBuilder . ToString ( ) ;
60+ using var __httpRequest = new global ::System . Net . Http . HttpRequestMessage (
61+ method : global ::System . Net . Http . HttpMethod . Post ,
62+ requestUri : new global ::System . Uri ( __path , global ::System . UriKind . RelativeOrAbsolute ) ) ;
63+
64+ foreach ( var __authorization in Authorizations )
65+ {
66+ if ( __authorization . Type == "Http" ||
67+ __authorization . Type == "OAuth2" )
68+ {
69+ __httpRequest . Headers . Authorization = new global ::System . Net . Http . Headers . AuthenticationHeaderValue (
70+ scheme : __authorization . Name ,
71+ parameter : __authorization . Value ) ;
72+ }
73+ else if ( __authorization . Type == "ApiKey" &&
74+ __authorization . Location == "Header" )
75+ {
76+ __httpRequest . Headers . Add ( __authorization . Name , __authorization . Value ) ;
77+ }
78+ }
79+ var __httpRequestContentBody = request . ToJson ( JsonSerializerOptions ) ;
80+ var __httpRequestContent = new global ::System . Net . Http . StringContent (
81+ content : __httpRequestContentBody ,
82+ encoding : global ::System . Text . Encoding . UTF8 ,
83+ mediaType : "application/json" ) ;
84+ __httpRequest . Content = __httpRequestContent ;
85+
86+ PrepareRequest (
87+ client : HttpClient ,
88+ request : __httpRequest ) ;
89+ PrepareAppPublicServiceChatRequest (
90+ httpClient : HttpClient ,
91+ httpRequestMessage : __httpRequest ,
92+ namespaceId : namespaceId ,
93+ appId : appId ,
94+ request : request ) ;
95+
96+ using var __response = await HttpClient . SendAsync (
97+ request : __httpRequest ,
98+ completionOption : global ::System . Net . Http . HttpCompletionOption . ResponseContentRead ,
99+ cancellationToken : cancellationToken ) . ConfigureAwait ( false ) ;
100+
101+ ProcessResponse (
102+ client : HttpClient ,
103+ response : __response ) ;
104+ ProcessAppPublicServiceChatResponse (
105+ httpClient : HttpClient ,
106+ httpResponseMessage : __response ) ;
107+
108+ var __content = await __response . Content . ReadAsStringAsync ( ) . ConfigureAwait ( false ) ;
109+
110+ ProcessResponseContent (
111+ client : HttpClient ,
112+ response : __response ,
113+ content : ref __content ) ;
114+ ProcessAppPublicServiceChatResponseContent (
115+ httpClient : HttpClient ,
116+ httpResponseMessage : __response ,
117+ content : ref __content ) ;
118+
119+ try
120+ {
121+ __response . EnsureSuccessStatusCode ( ) ;
122+ }
123+ catch ( global ::System . Net . Http . HttpRequestException __ex )
124+ {
125+ throw new global ::System . InvalidOperationException ( __content , __ex ) ;
126+ }
127+
128+ return
129+ global ::G . ChatResponse . FromJson ( __content , JsonSerializerOptions ) ??
130+ throw new global ::System . InvalidOperationException ( $ "Response deserialization failed for \" { __content } \" ") ;
131+ }
132+
133+ /// <summary>
134+ /// Chat<br/>
135+ /// Chat sends a message asynchronously and streams back the response.<br/>
136+ /// This method is intended for real-time conversation with a chatbot<br/>
137+ /// and the response needs to be processed incrementally.
138+ /// </summary>
139+ /// <param name="namespaceId"></param>
140+ /// <param name="appId"></param>
141+ /// <param name="catalogId"></param>
142+ /// <param name="conversationUid"></param>
143+ /// <param name="message"></param>
144+ /// <param name="topK"></param>
145+ /// <param name="cancellationToken">The token to cancel the operation with</param>
146+ /// <exception cref="global::System.InvalidOperationException"></exception>
147+ public async global ::System . Threading . Tasks . Task < global ::G . ChatResponse > AppPublicServiceChatAsync (
148+ string namespaceId ,
149+ string appId ,
150+ string catalogId ,
151+ string conversationUid ,
152+ string message ,
153+ long ? topK = default ,
154+ global ::System . Threading . CancellationToken cancellationToken = default )
155+ {
156+ var __request = new global ::G . ChatBody
157+ {
158+ CatalogId = catalogId ,
159+ ConversationUid = conversationUid ,
160+ Message = message ,
161+ TopK = topK ,
162+ } ;
163+
164+ return await AppPublicServiceChatAsync (
165+ namespaceId : namespaceId ,
166+ appId : appId ,
167+ request : __request ,
168+ cancellationToken : cancellationToken ) . ConfigureAwait ( false ) ;
169+ }
170+ }
171+ }
0 commit comments