Skip to content

Commit 96ac52f

Browse files
HavenDVgithub-actions[bot]
andauthored
feat: Updated OpenAPI spec (#299)
Co-authored-by: github-actions[bot] <dependabot@bot.com>
1 parent 58fd169 commit 96ac52f

3 files changed

Lines changed: 125 additions & 2 deletions

File tree

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
2+
#nullable enable
3+
4+
namespace tryAGI.OpenAI
5+
{
6+
/// <summary>
7+
/// Represents a successful HTTP response with status code and headers.
8+
/// </summary>
9+
public partial class AutoSDKHttpResponse
10+
{
11+
/// <summary>
12+
/// Initializes a new instance of the <see cref="AutoSDKHttpResponse"/> class.
13+
/// </summary>
14+
public AutoSDKHttpResponse(
15+
global::System.Net.HttpStatusCode statusCode,
16+
global::System.Collections.Generic.Dictionary<string, global::System.Collections.Generic.IEnumerable<string>> headers)
17+
{
18+
StatusCode = statusCode;
19+
Headers = headers ?? throw new global::System.ArgumentNullException(nameof(headers));
20+
}
21+
22+
/// <summary>
23+
/// Gets the HTTP status code.
24+
/// </summary>
25+
public global::System.Net.HttpStatusCode StatusCode { get; }
26+
/// <summary>
27+
/// Gets the response headers.
28+
/// </summary>
29+
public global::System.Collections.Generic.Dictionary<string, global::System.Collections.Generic.IEnumerable<string>> Headers { get; }
30+
31+
internal static global::System.Collections.Generic.Dictionary<string, global::System.Collections.Generic.IEnumerable<string>> CreateHeaders(
32+
global::System.Net.Http.HttpResponseMessage response)
33+
{
34+
response = response ?? throw new global::System.ArgumentNullException(nameof(response));
35+
36+
var headers = global::System.Linq.Enumerable.ToDictionary(
37+
response.Headers,
38+
static header => header.Key,
39+
static header => (global::System.Collections.Generic.IEnumerable<string>)global::System.Linq.Enumerable.ToArray(header.Value),
40+
global::System.StringComparer.OrdinalIgnoreCase);
41+
42+
if (response.Content?.Headers == null)
43+
{
44+
return headers;
45+
}
46+
47+
foreach (var header in response.Content.Headers)
48+
{
49+
if (headers.TryGetValue(header.Key, out var existingValues))
50+
{
51+
headers[header.Key] = global::System.Linq.Enumerable.ToArray(
52+
global::System.Linq.Enumerable.Concat(existingValues, header.Value));
53+
}
54+
else
55+
{
56+
headers[header.Key] = global::System.Linq.Enumerable.ToArray(header.Value);
57+
}
58+
}
59+
60+
return headers;
61+
}
62+
}
63+
64+
/// <summary>
65+
/// Represents a successful HTTP response with status code, headers, and body.
66+
/// </summary>
67+
public partial class AutoSDKHttpResponse<T> : AutoSDKHttpResponse
68+
{
69+
/// <summary>
70+
/// Initializes a new instance of the <see cref="AutoSDKHttpResponse{T}"/> class.
71+
/// </summary>
72+
public AutoSDKHttpResponse(
73+
global::System.Net.HttpStatusCode statusCode,
74+
global::System.Collections.Generic.Dictionary<string, global::System.Collections.Generic.IEnumerable<string>> headers,
75+
T body)
76+
: base(statusCode, headers)
77+
{
78+
Body = body;
79+
}
80+
81+
/// <summary>
82+
/// Gets the response body.
83+
/// </summary>
84+
public T Body { get; }
85+
}
86+
}

src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.IRealtimeClient.CreateCall.g.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,17 @@ public partial interface IRealtimeClient
1919
/// Create a new Realtime API call over WebRTC and receive the SDP answer needed<br/>
2020
/// to complete the peer connection.
2121
/// </summary>
22+
/// <param name="request"></param>
23+
/// <param name="cancellationToken">The token to cancel the operation with</param>
24+
/// <exception cref="global::tryAGI.OpenAI.ApiException"></exception>
25+
global::System.Threading.Tasks.Task<global::tryAGI.OpenAI.AutoSDKHttpResponse<string>> CreateCallAsResponseAsync(
26+
27+
global::tryAGI.OpenAI.RealtimeCallCreateRequest request,
28+
global::System.Threading.CancellationToken cancellationToken = default);
29+
/// <summary>
30+
/// Create a new Realtime API call over WebRTC and receive the SDP answer needed<br/>
31+
/// to complete the peer connection.
32+
/// </summary>
2233
/// <param name="sdp">
2334
/// WebRTC Session Description Protocol (SDP) offer generated by the caller.
2435
/// </param>

src/libs/tryAGI.OpenAI/Generated/tryAGI.OpenAI.RealtimeClient.CreateCall.g.cs

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,26 @@ partial void ProcessCreateCallResponseContent(
3030
/// <exception cref="global::tryAGI.OpenAI.ApiException"></exception>
3131
public async global::System.Threading.Tasks.Task<string> CreateCallAsync(
3232

33+
global::tryAGI.OpenAI.RealtimeCallCreateRequest request,
34+
global::System.Threading.CancellationToken cancellationToken = default)
35+
{
36+
var __response = await CreateCallAsResponseAsync(
37+
38+
request: request,
39+
cancellationToken: cancellationToken
40+
).ConfigureAwait(false);
41+
42+
return __response.Body;
43+
}
44+
/// <summary>
45+
/// Create a new Realtime API call over WebRTC and receive the SDP answer needed<br/>
46+
/// to complete the peer connection.
47+
/// </summary>
48+
/// <param name="request"></param>
49+
/// <param name="cancellationToken">The token to cancel the operation with</param>
50+
/// <exception cref="global::tryAGI.OpenAI.ApiException"></exception>
51+
public async global::System.Threading.Tasks.Task<global::tryAGI.OpenAI.AutoSDKHttpResponse<string>> CreateCallAsResponseAsync(
52+
3353
global::tryAGI.OpenAI.RealtimeCallCreateRequest request,
3454
global::System.Threading.CancellationToken cancellationToken = default)
3555
{
@@ -122,7 +142,10 @@ partial void ProcessCreateCallResponseContent(
122142
{
123143
__response.EnsureSuccessStatusCode();
124144

125-
return __content;
145+
return new global::tryAGI.OpenAI.AutoSDKHttpResponse<string>(
146+
statusCode: __response.StatusCode,
147+
headers: global::tryAGI.OpenAI.AutoSDKHttpResponse.CreateHeaders(__response),
148+
body: __content);
126149
}
127150
catch (global::System.Exception __ex)
128151
{
@@ -151,7 +174,10 @@ partial void ProcessCreateCallResponseContent(
151174
#endif
152175
).ConfigureAwait(false);
153176

154-
return __content;
177+
return new global::tryAGI.OpenAI.AutoSDKHttpResponse<string>(
178+
statusCode: __response.StatusCode,
179+
headers: global::tryAGI.OpenAI.AutoSDKHttpResponse.CreateHeaders(__response),
180+
body: __content);
155181
}
156182
catch (global::System.Exception __ex)
157183
{

0 commit comments

Comments
 (0)