Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 56 additions & 1 deletion api/OpenAI.net8.0.cs

Large diffs are not rendered by default.

56 changes: 56 additions & 0 deletions api/OpenAI.netstandard2.0.cs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion codegen/generator/src/OpenAI.Library.Plugin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.TypeSpec.Generator.ClientModel" Version="1.0.0-alpha.20250626.7" />
<PackageReference Include="Microsoft.TypeSpec.Generator.ClientModel" Version="1.0.0-alpha.20250722.1" />
</ItemGroup>

<!-- Copy output to package dist path for local execution and -->
Expand Down
27 changes: 24 additions & 3 deletions codegen/generator/src/Visitors/OmittedTypesVisitor.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using Microsoft.TypeSpec.Generator.ClientModel;
using Microsoft.TypeSpec.Generator.Expressions;
using Microsoft.TypeSpec.Generator.Providers;
using Microsoft.TypeSpec.Generator.Statements;
using System.Collections.Generic;
using System.Linq;

Expand All @@ -20,10 +22,29 @@ public class OmittedTypesVisitor : ScmLibraryVisitor

protected override TypeProvider? VisitType(TypeProvider type)
{
if (TypeNamesToOmit.Any(typeName => type.Name == typeName))
// Strip buildable attributes for omitted types from OpenAIContext
if (type.Name == "OpenAIContext")
{
return null;
var filtered = new List<AttributeStatement>(type.Attributes.Count);
foreach (var a in type.Attributes)
{
bool drop =
a.Type.Name == "ModelReaderWriterBuildableAttribute" &&
a.Arguments.Count == 1 &&
a.Arguments[0] is TypeOfExpression tof &&
TypeNamesToOmit.Contains(tof.Type.Name);

if (!drop) filtered.Add(a);
}

if (filtered.Count != type.Attributes.Count)
type.Update(attributes: filtered);
}
return type;

// Omit the types themselves
if (TypeNamesToOmit.Contains(type.Name))
return null;

return base.VisitType(type);
}
}
7 changes: 5 additions & 2 deletions codegen/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,11 @@
],
"dependencies": {
"@open-ai/plugin": "file:",
"@azure-tools/typespec-client-generator-core": "~0.57.0",
"@typespec/http-client-csharp": "1.0.0-alpha.20250626.7"
"@azure-tools/typespec-client-generator-core": "0.57.2",
"@azure-tools/typespec-azure-core": "0.57.0",
"@typespec/http-client-csharp": "1.0.0-alpha.20250722.1",
"@typespec/http": "1.1.0",
"@typespec/openapi": "1.1.0"
},
"devDependencies": {
"@types/node": "^22.8.1",
Expand Down
Loading