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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 5 additions & 0 deletions .dotnet/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Project>
<PropertyGroup>
<LangVersion>latest</LangVersion>
</PropertyGroup>
</Project>
50 changes: 50 additions & 0 deletions .dotnet/OpenAI.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29709.97
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenAI", "src\OpenAI.csproj", "{28FF4005-4467-4E36-92E7-DEA27DEB1519}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenAI.Tests", "tests\OpenAI.Tests.csproj", "{1F1CD1D4-9932-4B73-99D8-C252A67D4B46}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B0C276D1-2930-4887-B29A-D1A33E7009A2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B0C276D1-2930-4887-B29A-D1A33E7009A2}.Release|Any CPU.Build.0 = Release|Any CPU
{8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8E9A77AC-792A-4432-8320-ACFD46730401}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8E9A77AC-792A-4432-8320-ACFD46730401}.Release|Any CPU.Build.0 = Release|Any CPU
{A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A4241C1F-A53D-474C-9E4E-075054407E74}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A4241C1F-A53D-474C-9E4E-075054407E74}.Release|Any CPU.Build.0 = Release|Any CPU
{FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FA8BD3F1-8616-47B6-974C-7576CDF4717E}.Release|Any CPU.Build.0 = Release|Any CPU
{85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{85677AD3-C214-42FA-AE6E-49B956CAC8DC}.Release|Any CPU.Build.0 = Release|Any CPU
{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
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {A97F4B90-2591-4689-B1F8-5F21FE6D6CAE}
EndGlobalSection
EndGlobal
28 changes: 28 additions & 0 deletions .dotnet/scripts/Add-Customizations.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
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
}

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

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

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
}

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

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

$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 Remove-GeneratedTests {
$root = Split-Path $PSScriptRoot -Parent

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

Edit-GeneratedSources
Remove-GeneratedTests
Loading