Skip to content

Commit eb15dfe

Browse files
committed
merge
2 parents b2eed35 + 0a6582e commit eb15dfe

File tree

21 files changed

+13072
-9716
lines changed

21 files changed

+13072
-9716
lines changed

.github/workflows/codegen-validation.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ on:
66
pull_request:
77
paths:
88
- 'codegen/**'
9+
- 'specification/**'
910
- '.github/workflows/codegen-validation.yml'
1011
- 'scripts/Invoke-CodeGen.ps1'
1112
types: [opened, reopened, synchronize]
@@ -35,7 +36,7 @@ jobs:
3536
shell: pwsh
3637
run: |
3738
Write-Host "Running code generation validation..."
38-
./scripts/Invoke-CodeGen.ps1
39+
./scripts/Invoke-CodeGen.ps1 -Clean
3940
4041
if ($LASTEXITCODE -ne 0) {
4142
Write-Error "Code generation failed with exit code: $LASTEXITCODE"

api/OpenAI.net8.0.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ public class OpenAIClient {
4242
public virtual RealtimeClient GetRealtimeClient();
4343
[Experimental("OPENAI001")]
4444
public virtual VectorStoreClient GetVectorStoreClient();
45+
[Experimental("OPENAI001")]
46+
public virtual VideoClient GetVideoClient();
4547
}
4648
public class OpenAIClientOptions : ClientPipelineOptions {
4749
public Uri Endpoint { get; set; }
@@ -7122,6 +7124,33 @@ public enum VectorStoreStatus {
71227124
Expired = 3
71237125
}
71247126
}
7127+
namespace OpenAI.Videos {
7128+
[Experimental("OPENAI001")]
7129+
public class VideoClient {
7130+
protected VideoClient();
7131+
public VideoClient(ApiKeyCredential credential, OpenAIClientOptions options);
7132+
public VideoClient(ApiKeyCredential credential);
7133+
public VideoClient(AuthenticationPolicy authenticationPolicy, OpenAIClientOptions options);
7134+
public VideoClient(AuthenticationPolicy authenticationPolicy);
7135+
protected internal VideoClient(ClientPipeline pipeline, OpenAIClientOptions options);
7136+
public VideoClient(string apiKey);
7137+
[Experimental("OPENAI001")]
7138+
public Uri Endpoint { get; }
7139+
public ClientPipeline Pipeline { get; }
7140+
public virtual ClientResult CreateVideo(BinaryContent content, string contentType, RequestOptions options = null);
7141+
public virtual Task<ClientResult> CreateVideoAsync(BinaryContent content, string contentType, RequestOptions options = null);
7142+
public virtual ClientResult CreateVideoRemix(string videoId, BinaryContent content, string contentType, RequestOptions options = null);
7143+
public virtual Task<ClientResult> CreateVideoRemixAsync(string videoId, BinaryContent content, string contentType, RequestOptions options = null);
7144+
public virtual ClientResult DeleteVideo(string videoId, RequestOptions options = null);
7145+
public virtual Task<ClientResult> DeleteVideoAsync(string videoId, RequestOptions options = null);
7146+
public virtual ClientResult DownloadVideo(string videoId, string variant = null, RequestOptions options = null);
7147+
public virtual Task<ClientResult> DownloadVideoAsync(string videoId, string variant = null, RequestOptions options = null);
7148+
public virtual ClientResult GetVideo(string videoId, RequestOptions options = null);
7149+
public virtual Task<ClientResult> GetVideoAsync(string videoId, RequestOptions options = null);
7150+
public virtual ClientResult GetVideos(long? limit = null, string order = null, string after = null, RequestOptions options = null);
7151+
public virtual Task<ClientResult> GetVideosAsync(long? limit = null, string order = null, string after = null, RequestOptions options = null);
7152+
}
7153+
}
71257154
namespace Primitives {
71267155
public abstract class JsonModel<T> : IJsonModel<T>, IPersistableModel<T> {
71277156
protected abstract T CreateCore(ref Text.Json.Utf8JsonReader reader, ModelReaderWriterOptions options);

api/OpenAI.netstandard2.0.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public class OpenAIClient {
2929
public virtual OpenAIResponseClient GetOpenAIResponseClient(string model);
3030
public virtual RealtimeClient GetRealtimeClient();
3131
public virtual VectorStoreClient GetVectorStoreClient();
32+
public virtual VideoClient GetVideoClient();
3233
}
3334
public class OpenAIClientOptions : ClientPipelineOptions {
3435
public Uri Endpoint { get; set; }
@@ -6277,6 +6278,31 @@ public enum VectorStoreStatus {
62776278
Expired = 3
62786279
}
62796280
}
6281+
namespace OpenAI.Videos {
6282+
public class VideoClient {
6283+
protected VideoClient();
6284+
public VideoClient(ApiKeyCredential credential, OpenAIClientOptions options);
6285+
public VideoClient(ApiKeyCredential credential);
6286+
public VideoClient(AuthenticationPolicy authenticationPolicy, OpenAIClientOptions options);
6287+
public VideoClient(AuthenticationPolicy authenticationPolicy);
6288+
protected internal VideoClient(ClientPipeline pipeline, OpenAIClientOptions options);
6289+
public VideoClient(string apiKey);
6290+
public Uri Endpoint { get; }
6291+
public ClientPipeline Pipeline { get; }
6292+
public virtual ClientResult CreateVideo(BinaryContent content, string contentType, RequestOptions options = null);
6293+
public virtual Task<ClientResult> CreateVideoAsync(BinaryContent content, string contentType, RequestOptions options = null);
6294+
public virtual ClientResult CreateVideoRemix(string videoId, BinaryContent content, string contentType, RequestOptions options = null);
6295+
public virtual Task<ClientResult> CreateVideoRemixAsync(string videoId, BinaryContent content, string contentType, RequestOptions options = null);
6296+
public virtual ClientResult DeleteVideo(string videoId, RequestOptions options = null);
6297+
public virtual Task<ClientResult> DeleteVideoAsync(string videoId, RequestOptions options = null);
6298+
public virtual ClientResult DownloadVideo(string videoId, string variant = null, RequestOptions options = null);
6299+
public virtual Task<ClientResult> DownloadVideoAsync(string videoId, string variant = null, RequestOptions options = null);
6300+
public virtual ClientResult GetVideo(string videoId, RequestOptions options = null);
6301+
public virtual Task<ClientResult> GetVideoAsync(string videoId, RequestOptions options = null);
6302+
public virtual ClientResult GetVideos(long? limit = null, string order = null, string after = null, RequestOptions options = null);
6303+
public virtual Task<ClientResult> GetVideosAsync(long? limit = null, string order = null, string after = null, RequestOptions options = null);
6304+
}
6305+
}
62806306
namespace Primitives {
62816307
public abstract class JsonModel<T> : IJsonModel<T>, IPersistableModel<T> {
62826308
protected abstract T CreateCore(ref Text.Json.Utf8JsonReader reader, ModelReaderWriterOptions options);

examples/OpenAI.Examples.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<TargetFramework>net9.0</TargetFramework>
44

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using NUnit.Framework;
2+
using NUnit.Framework.Internal;
3+
using OpenAI.Videos;
4+
using System;
5+
using System.ClientModel;
6+
using System.Net.Http;
7+
using System.Text;
8+
using System.Text.Json;
9+
10+
namespace OpenAI.Examples;
11+
12+
// This example uses experimental APIs which are subject to change. To use experimental APIs,
13+
// please acknowledge their experimental status by suppressing the corresponding warning.
14+
#pragma warning disable OPENAI001
15+
16+
public partial class VideoExamples
17+
{
18+
[Test]
19+
public void Example01_VideoCreation()
20+
{
21+
// 1) Create the client
22+
VideoClient client = new(new ApiKeyCredential(Environment.GetEnvironmentVariable("OPENAI_API_KEY")));
23+
24+
// 2) Build the multipart/form-data payload with an explicit boundary
25+
var boundary = Guid.NewGuid().ToString();
26+
var contentType = $"multipart/form-data; boundary=\"{boundary}\"";
27+
using var multipart = new MultipartFormDataContent(boundary);
28+
29+
multipart.Add(new StringContent("sora-2", Encoding.UTF8, "text/plain"), "model");
30+
multipart.Add(new StringContent("A calico cat playing a piano on stage", Encoding.UTF8, "text/plain"), "prompt");
31+
32+
// 3) Get a stream for the multipart body
33+
using var bodyStream = multipart.ReadAsStream();
34+
35+
// 4) Send the request
36+
var createResult = client.CreateVideo(BinaryContent.Create(bodyStream), contentType);
37+
var createRaw = createResult.GetRawResponse().Content;
38+
39+
// 5) Parse the JSON response
40+
using var createdDoc = JsonDocument.Parse(createRaw);
41+
var id = createdDoc.RootElement.GetProperty("id").GetString();
42+
var status = createdDoc.RootElement.GetProperty("status").GetString();
43+
44+
Console.WriteLine($"CreateVideo => id: {id}, status: {status}");
45+
}
46+
}
47+
48+
#pragma warning restore OPENAI001
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
using NUnit.Framework;
2+
using NUnit.Framework.Internal;
3+
using OpenAI.Videos;
4+
using System;
5+
using System.ClientModel;
6+
using System.Net.Http;
7+
using System.Text;
8+
using System.Text.Json;
9+
using System.Threading.Tasks;
10+
11+
namespace OpenAI.Examples;
12+
13+
// This example uses experimental APIs which are subject to change. To use experimental APIs,
14+
// please acknowledge their experimental status by suppressing the corresponding warning.
15+
#pragma warning disable OPENAI001
16+
17+
public partial class VideoExamples
18+
{
19+
[Test]
20+
public async Task Example01_VideoCreationAsync()
21+
{
22+
// 1) Create the client
23+
VideoClient client = new(new ApiKeyCredential(Environment.GetEnvironmentVariable("OPENAI_API_KEY")));
24+
25+
// 2) Build the multipart/form-data payload with an explicit boundary
26+
var boundary = Guid.NewGuid().ToString();
27+
var contentType = $"multipart/form-data; boundary=\"{boundary}\"";
28+
using var multipart = new MultipartFormDataContent(boundary);
29+
30+
multipart.Add(new StringContent("sora-2", Encoding.UTF8, "text/plain"), "model");
31+
multipart.Add(new StringContent("A calico cat playing a piano on stage", Encoding.UTF8, "text/plain"), "prompt");
32+
33+
// 3) Get a stream for the multipart body
34+
using var bodyStream = await multipart.ReadAsStreamAsync();
35+
36+
// 4) Send the request
37+
var createResult = await client.CreateVideoAsync(BinaryContent.Create(bodyStream), contentType);
38+
var createRaw = createResult.GetRawResponse().Content;
39+
40+
// 5) Parse the JSON response
41+
using var createdDoc = JsonDocument.Parse(createRaw);
42+
var id = createdDoc.RootElement.GetProperty("id").GetString();
43+
var status = createdDoc.RootElement.GetProperty("status").GetString();
44+
45+
Console.WriteLine($"CreateVideo => id: {id}, status: {status}");
46+
}
47+
}
48+
49+
#pragma warning restore OPENAI001

scripts/Export-Api.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ function Invoke-GenAPI {
272272
$content = $content -creplace "Realtime\.", ""
273273
$content = $content -creplace "Responses\.", ""
274274
$content = $content -creplace "VectorStores\.", ""
275+
$content = $content -creplace "Videos\.", ""
275276

276277
# Remove Diagnostics.DebuggerStepThrough attribute.
277278
$content = $content -creplace ".*Diagnostics.DebuggerStepThrough.*\n", ""

scripts/Invoke-CodeGen.ps1

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ param(
1616
[string]$LocalRepositoryPath,
1717

1818
[Parameter(Mandatory = $false)]
19-
[switch]$Force
19+
[switch]$Force,
20+
21+
[Parameter(Mandatory = $false)]
22+
[switch]$Clean
2023
)
2124

2225
function Invoke-ScriptWithLogging {
@@ -293,6 +296,14 @@ try {
293296

294297
Write-ElapsedTime "npm ci complete"
295298

299+
if ($Clean) {
300+
Invoke-ScriptWithLogging { npm run clean -w $codegenFolderPath }
301+
if ($LASTEXITCODE -ne 0) {
302+
exit $LASTEXITCODE
303+
}
304+
Write-ElapsedTime "npm run clean complete"
305+
}
306+
296307
Invoke-ScriptWithLogging { npm run build -w $codegenFolderPath }
297308
if ($LASTEXITCODE -ne 0) {
298309
exit $LASTEXITCODE

specification/base/typespec/common/models.tsp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,3 +468,12 @@ union ServiceTier {
468468
"flex",
469469
"scale",
470470
}
471+
472+
#suppress "@azure-tools/typespec-azure-core/no-enum" "Auto-suppressed warnings non-applicable rules during import."
473+
#suppress "@azure-tools/typespec-azure-core/documentation-required" "Auto-suppressed warnings non-applicable rules during import."
474+
enum OrderEnum {
475+
#suppress "@azure-tools/typespec-azure-core/documentation-required" "Auto-suppressed warnings non-applicable rules during import."
476+
asc,
477+
#suppress "@azure-tools/typespec-azure-core/documentation-required" "Auto-suppressed warnings non-applicable rules during import."
478+
desc,
479+
}

specification/base/typespec/main.tsp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ import "./runs";
1919
import "./threads";
2020
import "./responses";
2121
import "./vector-stores";
22+
import "./videos";
2223
import "./uploads";

0 commit comments

Comments
 (0)