Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
be1b13a
Update TypeSpec
joseharriaga Feb 6, 2024
587222b
Add Assistants API
joseharriaga Feb 7, 2024
dd840f7
Re-generate OpenAPI spec with a few fixes
joseharriaga Feb 7, 2024
9733bb9
Remove duplicate readme
joseharriaga Feb 8, 2024
a952d41
Rename README
joseharriaga Feb 8, 2024
8eb95a0
Edit a couple of comments
joseharriaga Feb 8, 2024
b6bfedf
Fix listAssistants name
joseharriaga Feb 8, 2024
11bb01f
Fix listRuns path
joseharriaga Feb 9, 2024
4e9e7aa
Add initial .NET generated library
joseharriaga Feb 15, 2024
43dd97b
Fix fine-tuning operations.tsp
joseharriaga Feb 20, 2024
b16017a
Update System.ClientModel
joseharriaga Feb 20, 2024
a1ba42c
Fix Update-ClientModel.ps1 script
joseharriaga Feb 20, 2024
54851e2
Add embeddings example
joseharriaga Feb 20, 2024
03664d5
Fix Update-ClientModel.ps1 script: DefaultRequestContext and URI path…
joseharriaga Feb 21, 2024
c398c45
Fix SubmitToolOutputsRunRequest, remove Embeddings customizations, ed…
joseharriaga Feb 28, 2024
4decb12
Fix Update-ClientModel.ps1 script: Convenience methods with a single …
joseharriaga Feb 28, 2024
8c0f76d
Add ConvertTo-Internal.ps1 script
joseharriaga Feb 28, 2024
f1198ad
Port over custom code
joseharriaga Feb 29, 2024
48f0c6a
Update TypeSpec and add unbranded .NET library
joseharriaga Feb 29, 2024
d01aefa
Add samples and README (#3)
joseharriaga Feb 29, 2024
6604f76
Add CONTRIBUTING guide, fix Add-Customizations.ps1 script (#4)
joseharriaga Feb 29, 2024
9b3a87f
Improve function calling samples (#5)
joseharriaga Feb 29, 2024
2e44859
Refactor codegen scripts for eventual removal (#7)
joseharriaga Mar 4, 2024
36718a7
fix toolcalls serialization issue (#8)
trrwilson Mar 5, 2024
6ee5281
Update the fine-tuning TypeSpec and generated code (#9)
joseharriaga Mar 7, 2024
a7abb18
Expose protocol methods publicly (#10)
joseharriaga Mar 9, 2024
6e2d84b
Add convenience methods for image edits and variations (#11)
joseharriaga Mar 11, 2024
c056a8e
Update chat's function calling sample (#14)
joseharriaga Mar 12, 2024
0a209e4
Temporarily rename FineTuningClient for codegen (#15)
joseharriaga Mar 13, 2024
78b4d1b
migrate to int instead of long on custom surface (#16)
trrwilson Mar 13, 2024
9507223
Add client builds to the main workflow (#12)
hallipr Mar 13, 2024
ae2b80c
Update generated OpenAPIv3 spec (#18)
joseharriaga Mar 14, 2024
ae52661
Add version properties to allow for action based package naming (#19)
hallipr Mar 14, 2024
4c0740e
Remove validation job from workflow (#20)
hallipr Mar 14, 2024
f49feeb
Remove no-PR condition on package upload (#21)
hallipr Mar 15, 2024
5da30e9
Update CodeGen to version 3.0.0-beta.20240312.2 (#22)
joseharriaga Mar 15, 2024
21bd3c9
Fix protocol method sample (#24)
joseharriaga Mar 15, 2024
6d6ea78
Add unit tests with secrets (#23)
hallipr Mar 15, 2024
c25a062
Add release workflow (#25)
hallipr Mar 15, 2024
1d447d9
When building a release, upload nuget package as a release asset (#27)
hallipr Mar 18, 2024
3957379
Add release url to nuget package (#28)
hallipr Mar 18, 2024
bc4d02f
Use major version 0 (#29)
hallipr Mar 18, 2024
ddbba58
Use better package urls (#30)
hallipr Mar 18, 2024
fed67d6
Add ModifyMessage methods to AssistantClient (#31)
joseharriaga Mar 18, 2024
6374f6d
Move OpenAI to use latest multipart/form-data proposal (#32)
annelo-msft Mar 20, 2024
7b8ea02
Update System.ClientModel to version 1.1.0-alpha.20240319.1 (#35)
joseharriaga Mar 20, 2024
b5032d5
Add Directory.Build.targets to test project to copy assets to output …
joseharriaga Mar 20, 2024
bab92c7
Apply EditorBrowsableState.Never to multipart/form-data protocol meth…
joseharriaga Mar 20, 2024
2f84947
client constructor feedback (#34)
trrwilson Mar 20, 2024
cf3b7c0
Polyfill the C#12 "ExperimentalAttribute" and use it for AssistantCli…
trrwilson Mar 20, 2024
e1d8bfa
Initial implementation
annelo-msft Mar 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
16 changes: 16 additions & 0 deletions .dotnet/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# CONTRIBUTING

## How to run code generation

1. Run the following command to install the necessary tools:
`npm install`
1. Regenerate the OpenAPI spec by running the following command:
`npx tsp compile .\openai-in-typespec\main.tsp --emit @typespec/openapi3`
1. Regenerate the library by running the following command:
`npx tsp compile .\openai-in-typespec\main.tsp --emit @azure-tools/typespec-csharp --option @azure-tools/typespec-csharp.emitter-output-dir=.\openai-in-typespec\.dotnet`
1. Run the following script:
`.\openai-in-typespec\.dotnet\scripts\Update-ClientModel.ps1`
1. Run the following script:
`.\openai-in-typespec\.dotnet\scripts\ConvertTo-Internal.ps1`
1. Run the following script:
`.\openai-in-typespec\.dotnet\scripts\Add-Customizations.ps1`
36 changes: 36 additions & 0 deletions .dotnet/OpenAI.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.9.34701.34
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenAI", "src\OpenAI.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenAI.Tests", "tests\OpenAI.Tests.csproj", "{1F1CD1D4-9932-4B73-99D8-C252A67D4B46}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "System.ClientModel", "..\..\azure-sdk-for-net\sdk\core\System.ClientModel\src\System.ClientModel.csproj", "{297DA5FF-1CD7-4183-8C13-45987286D33F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{28FF4005-4467-4E36-92E7-DEA27DEB1519}.Debug|Any CPU.Build.0 = Debug|Any CPU
{28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.ActiveCfg = Release|Any CPU
{28FF4005-4467-4E36-92E7-DEA27DEB1519}.Release|Any CPU.Build.0 = Release|Any CPU
{1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1F1CD1D4-9932-4B73-99D8-C252A67D4B46}.Release|Any CPU.Build.0 = Release|Any CPU
{297DA5FF-1CD7-4183-8C13-45987286D33F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{297DA5FF-1CD7-4183-8C13-45987286D33F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{297DA5FF-1CD7-4183-8C13-45987286D33F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{297DA5FF-1CD7-4183-8C13-45987286D33F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A97F4B90-2591-4689-B1F8-5F21FE6D6CAE}
EndGlobalSection
EndGlobal
584 changes: 584 additions & 0 deletions .dotnet/README.md

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions .dotnet/nuget.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<!--To inherit the global NuGet package sources remove the <clear/> line below -->
<clear />
<add key="nuget" value="https://api.nuget.org/v3/index.json" />
<add key="DevelopmentFeed" value="https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-net/nuget/v3/index.json" />
</packageSources>
</configuration>
62 changes: 62 additions & 0 deletions .dotnet/scripts/Add-Customizations.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
function Update-SystemTextJsonPackage {
$current = Get-Location
$root = Split-Path $PSScriptRoot -Parent

# Update System.Text.Json package to 8.0.2 in OpenAI.csproj
$directory = Join-Path -Path $root -ChildPath "src"
Set-Location -Path $directory
dotnet remove "OpenAI.csproj" package "System.Text.Json"
dotnet add "OpenAI.csproj" package "System.Text.Json" --version "8.0.2"

Set-Location -Path $current
}

function Update-MicrosoftBclAsyncInterfacesPackage {
$current = Get-Location
$root = Split-Path $PSScriptRoot -Parent

# Update Microsoft.Bcl.AsyncInterfaces package to 8.0.0 in OpenAI.Tests.csproj
$directory = Join-Path -Path $root -ChildPath "tests"
Set-Location -Path $directory
dotnet remove "OpenAI.Tests.csproj" package "Microsoft.Bcl.AsyncInterfaces"
dotnet add "OpenAI.Tests.csproj" package "Microsoft.Bcl.AsyncInterfaces" --version "8.0.0"

Set-Location -Path $current
}

function Set-LangVersionToLatest {
$root = Split-Path $PSScriptRoot -Parent
$filePath = Join-Path -Path $root -ChildPath "tests\OpenAI.Tests.csproj"
$xml = [xml](Get-Content -Path $filePath)

$xml.Project.PropertyGroup.TargetFramework = "net8.0"

$element = $xml.CreateElement("LangVersion")
$element.InnerText = "latest"
$xml.Project.PropertyGroup.AppendChild($element) | Out-Null

$xml.Save($filePath)
}

function Edit-RunObjectSerialization {
$root = Split-Path $PSScriptRoot -Parent
$directory = Join-Path -Path $root -ChildPath "src\Generated\Models"

$file = Get-ChildItem -Path $directory -Filter "RunObject.Serialization.cs"
$content = Get-Content -Path $file -Raw

Write-Output "Editing $($file.FullName)"

$content = $content -creplace "expiresAt = property\.Value\.GetDateTimeOffset\(`"O`"\);", "// BUG: https://github.com/Azure/autorest.csharp/issues/4296`r`n // expiresAt = property.Value.GetDateTimeOffset(`"O`");`r`n expiresAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64());"
$content = $content -creplace "startedAt = property\.Value\.GetDateTimeOffset\(`"O`"\);", "// BUG: https://github.com/Azure/autorest.csharp/issues/4296`r`n // startedAt = property.Value.GetDateTimeOffset(`"O`");`r`n startedAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64());"
$content = $content -creplace "cancelledAt = property\.Value\.GetDateTimeOffset\(`"O`"\);", "// BUG: https://github.com/Azure/autorest.csharp/issues/4296`r`n // cancelledAt = property.Value.GetDateTimeOffset(`"O`");`r`n cancelledAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64());"
$content = $content -creplace "failedAt = property\.Value\.GetDateTimeOffset\(`"O`"\);", "// BUG: https://github.com/Azure/autorest.csharp/issues/4296`r`n // failedAt = property.Value.GetDateTimeOffset(`"O`");`r`n failedAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64());"
$content = $content -creplace "completedAt = property\.Value\.GetDateTimeOffset\(`"O`"\);", "// BUG: https://github.com/Azure/autorest.csharp/issues/4296`r`n // completedAt = property.Value.GetDateTimeOffset(`"O`");`r`n completedAt = DateTimeOffset.FromUnixTimeSeconds(property.Value.GetInt64());"

$content | Set-Content -Path $file.FullName -NoNewline
}

Update-SystemTextJsonPackage
Update-MicrosoftBclAsyncInterfacesPackage
Set-LangVersionToLatest
Edit-RunObjectSerialization
75 changes: 75 additions & 0 deletions .dotnet/scripts/ConvertTo-Internal.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
function Edit-GeneratedOpenAIClient {
$root = Split-Path $PSScriptRoot -Parent

$directory = Join-Path -Path $root -ChildPath "src\Generated"
$file = Get-ChildItem -Path $directory -Filter "OpenAIClient.cs"

$content = Get-Content -Path $file -Raw

Write-Output "Editing $($file.FullName)"

$content = $content -creplace "public partial class", "internal partial class"
$content = $content -creplace "public readonly partial struct", "internal readonly partial struct"
$content = $content -creplace "public static partial class", "internal static partial class"
$content = $content -creplace "namespace OpenAI", "namespace OpenAI.Internal"
$content = $content -creplace "using OpenAI.Models;", "using OpenAI.Internal.Models;"
$content = $content -creplace "private (OpenAI.)?(?<var>\w+) _cached(\w+);", "private OpenAI.Internal.`${var} _cached`${var};"
$content = $content -creplace "public virtual (OpenAI.)?(?<var>\w+) Get(\w+)Client", "public virtual OpenAI.Internal.`${var} Get`${var}Client"
$content = $content -creplace "ref _cached(\w+), new (OpenAI.)?(?<var>\w+)", "ref _cached`${var}, new OpenAI.Internal.`${var}"

$content | Set-Content -Path $file.FullName -NoNewline
}

function Edit-GeneratedSubclients {
$root = Split-Path $PSScriptRoot -Parent

$directory = Join-Path -Path $root -ChildPath "src\Generated"
$files = Get-ChildItem -Path $($directory + "\*") -Include "*.cs" -Exclude "OpenAIClient.cs"

foreach ($file in $files) {
$content = Get-Content -Path $file -Raw

Write-Output "Editing $($file.FullName)"

$content = $content -creplace "public partial class", "internal partial class"
$content = $content -creplace "public readonly partial struct", "internal readonly partial struct"
$content = $content -creplace "public static partial class", "internal static partial class"
$content = $content -creplace "namespace OpenAI", "namespace OpenAI.Internal"
$content = $content -creplace "using OpenAI.Models;", "using OpenAI.Internal.Models;"

$content | Set-Content -Path $file.FullName -NoNewline
}
}

function Edit-GeneratedModels {
$root = Split-Path $PSScriptRoot -Parent

$directory = Join-Path -Path $root -ChildPath "src\Generated\Models"
$files = Get-ChildItem -Path $($directory + "\*") -Include "*.cs"

foreach ($file in $files) {
$content = Get-Content -Path $file -Raw

Write-Output "Editing $($file.FullName)"

$content = $content -creplace "public partial class", "internal partial class"
$content = $content -creplace "public readonly partial struct", "internal readonly partial struct"
$content = $content -creplace "public static partial class", "internal static partial class"
$content = $content -creplace "namespace OpenAI", "namespace OpenAI.Internal"
$content = $content -creplace "using OpenAI.Models;", "using OpenAI.Internal.Models;"

$content | Set-Content -Path $file.FullName -NoNewline
}
}

function Remove-GeneratedTests {
$root = Split-Path $PSScriptRoot -Parent

$directory = Join-Path -Path $root -ChildPath "tests\Generated"
Remove-Item -LiteralPath $directory -Recurse -Force
}

Edit-GeneratedOpenAIClient
Edit-GeneratedSubclients
Edit-GeneratedModels
Remove-GeneratedTests
21 changes: 21 additions & 0 deletions .dotnet/scripts/Update-Client.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
$repoRoot = Join-Path $PSScriptRoot .. .. -Resolve
$dotnetFolder = Join-Path $repoRoot .dotnet

function Invoke([scriptblock]$script) {
$scriptString = $script | Out-String
Write-Host "--------------------------------------------------------------------------------`n> $scriptString"
& $script
}

Push-Location $repoRoot
try {
Invoke { npm ci }
Invoke { npm exec --no -- tsp compile main.tsp --emit @typespec/openapi3 }
Invoke { npm exec --no -- tsp compile main.tsp --emit @azure-tools/typespec-csharp --option @azure-tools/typespec-csharp.emitter-output-dir="$dotnetFolder" }
Invoke { .dotnet\scripts\Update-ClientModel.ps1 }
Invoke { .dotnet\scripts\ConvertTo-Internal.ps1 }
Invoke { .dotnet\scripts\Add-Customizations.ps1 }
}
finally {
Pop-Location
}
Loading