Skip to content

Commit e5ae227

Browse files
HavenDVgithub-actions[bot]
andauthored
feat: Updated OpenAPI spec (#213)
Co-authored-by: github-actions[bot] <[email protected]>
1 parent 1eb72a8 commit e5ae227

File tree

158 files changed

+16037
-2566
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

158 files changed

+16037
-2566
lines changed

src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI..JsonSerializerContext.g.cs

Lines changed: 132 additions & 88 deletions
Large diffs are not rendered by default.
Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
2+
#nullable enable
3+
4+
namespace tryAGI.OpenAI
5+
{
6+
public partial class ConversationsClient
7+
{
8+
partial void PrepareCreateConversationArguments(
9+
global::System.Net.Http.HttpClient httpClient,
10+
global::tryAGI.OpenAI.CreateConversationRequest request);
11+
partial void PrepareCreateConversationRequest(
12+
global::System.Net.Http.HttpClient httpClient,
13+
global::System.Net.Http.HttpRequestMessage httpRequestMessage,
14+
global::tryAGI.OpenAI.CreateConversationRequest request);
15+
partial void ProcessCreateConversationResponse(
16+
global::System.Net.Http.HttpClient httpClient,
17+
global::System.Net.Http.HttpResponseMessage httpResponseMessage);
18+
19+
partial void ProcessCreateConversationResponseContent(
20+
global::System.Net.Http.HttpClient httpClient,
21+
global::System.Net.Http.HttpResponseMessage httpResponseMessage,
22+
ref string content);
23+
24+
/// <summary>
25+
/// Create a conversation<br/>
26+
/// Create a conversation with the given ID.
27+
/// </summary>
28+
/// <param name="request"></param>
29+
/// <param name="cancellationToken">The token to cancel the operation with</param>
30+
/// <exception cref="global::tryAGI.OpenAI.ApiException"></exception>
31+
public async global::System.Threading.Tasks.Task<global::tryAGI.OpenAI.ConversationResource> CreateConversationAsync(
32+
global::tryAGI.OpenAI.CreateConversationRequest request,
33+
global::System.Threading.CancellationToken cancellationToken = default)
34+
{
35+
request = request ?? throw new global::System.ArgumentNullException(nameof(request));
36+
37+
PrepareArguments(
38+
client: HttpClient);
39+
PrepareCreateConversationArguments(
40+
httpClient: HttpClient,
41+
request: request);
42+
43+
var __pathBuilder = new global::tryAGI.OpenAI.PathBuilder(
44+
path: "/conversations",
45+
baseUri: HttpClient.BaseAddress);
46+
var __path = __pathBuilder.ToString();
47+
using var __httpRequest = new global::System.Net.Http.HttpRequestMessage(
48+
method: global::System.Net.Http.HttpMethod.Post,
49+
requestUri: new global::System.Uri(__path, global::System.UriKind.RelativeOrAbsolute));
50+
#if NET6_0_OR_GREATER
51+
__httpRequest.Version = global::System.Net.HttpVersion.Version11;
52+
__httpRequest.VersionPolicy = global::System.Net.Http.HttpVersionPolicy.RequestVersionOrHigher;
53+
#endif
54+
55+
foreach (var __authorization in Authorizations)
56+
{
57+
if (__authorization.Type == "Http" ||
58+
__authorization.Type == "OAuth2")
59+
{
60+
__httpRequest.Headers.Authorization = new global::System.Net.Http.Headers.AuthenticationHeaderValue(
61+
scheme: __authorization.Name,
62+
parameter: __authorization.Value);
63+
}
64+
else if (__authorization.Type == "ApiKey" &&
65+
__authorization.Location == "Header")
66+
{
67+
__httpRequest.Headers.Add(__authorization.Name, __authorization.Value);
68+
}
69+
}
70+
var __httpRequestContentBody = request.ToJson(JsonSerializerContext);
71+
var __httpRequestContent = new global::System.Net.Http.StringContent(
72+
content: __httpRequestContentBody,
73+
encoding: global::System.Text.Encoding.UTF8,
74+
mediaType: "application/json");
75+
__httpRequest.Content = __httpRequestContent;
76+
77+
PrepareRequest(
78+
client: HttpClient,
79+
request: __httpRequest);
80+
PrepareCreateConversationRequest(
81+
httpClient: HttpClient,
82+
httpRequestMessage: __httpRequest,
83+
request: request);
84+
85+
using var __response = await HttpClient.SendAsync(
86+
request: __httpRequest,
87+
completionOption: global::System.Net.Http.HttpCompletionOption.ResponseContentRead,
88+
cancellationToken: cancellationToken).ConfigureAwait(false);
89+
90+
ProcessResponse(
91+
client: HttpClient,
92+
response: __response);
93+
ProcessCreateConversationResponse(
94+
httpClient: HttpClient,
95+
httpResponseMessage: __response);
96+
97+
if (ReadResponseAsString)
98+
{
99+
var __content = await __response.Content.ReadAsStringAsync(
100+
#if NET5_0_OR_GREATER
101+
cancellationToken
102+
#endif
103+
).ConfigureAwait(false);
104+
105+
ProcessResponseContent(
106+
client: HttpClient,
107+
response: __response,
108+
content: ref __content);
109+
ProcessCreateConversationResponseContent(
110+
httpClient: HttpClient,
111+
httpResponseMessage: __response,
112+
content: ref __content);
113+
114+
try
115+
{
116+
__response.EnsureSuccessStatusCode();
117+
118+
return
119+
global::tryAGI.OpenAI.ConversationResource.FromJson(__content, JsonSerializerContext) ??
120+
throw new global::System.InvalidOperationException($"Response deserialization failed for \"{__content}\" ");
121+
}
122+
catch (global::System.Exception __ex)
123+
{
124+
throw new global::tryAGI.OpenAI.ApiException(
125+
message: __content ?? __response.ReasonPhrase ?? string.Empty,
126+
innerException: __ex,
127+
statusCode: __response.StatusCode)
128+
{
129+
ResponseBody = __content,
130+
ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
131+
__response.Headers,
132+
h => h.Key,
133+
h => h.Value),
134+
};
135+
}
136+
}
137+
else
138+
{
139+
try
140+
{
141+
__response.EnsureSuccessStatusCode();
142+
143+
using var __content = await __response.Content.ReadAsStreamAsync(
144+
#if NET5_0_OR_GREATER
145+
cancellationToken
146+
#endif
147+
).ConfigureAwait(false);
148+
149+
return
150+
await global::tryAGI.OpenAI.ConversationResource.FromJsonStreamAsync(__content, JsonSerializerContext).ConfigureAwait(false) ??
151+
throw new global::System.InvalidOperationException("Response deserialization failed.");
152+
}
153+
catch (global::System.Exception __ex)
154+
{
155+
throw new global::tryAGI.OpenAI.ApiException(
156+
message: __response.ReasonPhrase ?? string.Empty,
157+
innerException: __ex,
158+
statusCode: __response.StatusCode)
159+
{
160+
ResponseHeaders = global::System.Linq.Enumerable.ToDictionary(
161+
__response.Headers,
162+
h => h.Key,
163+
h => h.Value),
164+
};
165+
}
166+
}
167+
}
168+
169+
/// <summary>
170+
/// Create a conversation<br/>
171+
/// Create a conversation with the given ID.
172+
/// </summary>
173+
/// <param name="items">
174+
/// Initial items to include in the conversation context.<br/>
175+
/// You may add up to 20 items at a time.
176+
/// </param>
177+
/// <param name="metadata">
178+
/// Set of 16 key-value pairs that can be attached to an object. This can be<br/>
179+
/// useful for storing additional information about the object in a structured<br/>
180+
/// format, and querying for objects via API or the dashboard. <br/>
181+
/// Keys are strings with a maximum length of 64 characters. Values are strings<br/>
182+
/// with a maximum length of 512 characters.
183+
/// </param>
184+
/// <param name="cancellationToken">The token to cancel the operation with</param>
185+
/// <exception cref="global::System.InvalidOperationException"></exception>
186+
public async global::System.Threading.Tasks.Task<global::tryAGI.OpenAI.ConversationResource> CreateConversationAsync(
187+
global::System.Collections.Generic.IList<global::tryAGI.OpenAI.InputItem>? items = default,
188+
global::System.Collections.Generic.Dictionary<string, string>? metadata = default,
189+
global::System.Threading.CancellationToken cancellationToken = default)
190+
{
191+
var __request = new global::tryAGI.OpenAI.CreateConversationRequest
192+
{
193+
Items = items,
194+
Metadata = metadata,
195+
};
196+
197+
return await CreateConversationAsync(
198+
request: __request,
199+
cancellationToken: cancellationToken).ConfigureAwait(false);
200+
}
201+
}
202+
}

0 commit comments

Comments
 (0)