Skip to content
Open
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
88 changes: 65 additions & 23 deletions .github/workflows/publish-release-from-tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ jobs:
dotnet build --no-restore --configuration Release
dotnet test --no-build --configuration Release --verbosity normal

- name: Pack NuGet package
- name: Pack NuGet packages
run: |
VERSION="${{ steps.validate-tag.outputs.version }}"
dotnet pack src/Braintrust.Sdk/Braintrust.Sdk.csproj \
Expand All @@ -100,26 +100,58 @@ jobs:
-p:PackageVersion="$VERSION" \
-p:Version="$VERSION" \
--output ./artifacts
dotnet pack src/Braintrust.Sdk.OpenAI/Braintrust.Sdk.OpenAI.csproj \
--configuration Release \
--no-build \
-p:PackageVersion="$VERSION" \
-p:Version="$VERSION" \
--output ./artifacts
dotnet pack src/Braintrust.Sdk.Anthropic/Braintrust.Sdk.Anthropic.csproj \
--configuration Release \
--no-build \
-p:PackageVersion="$VERSION" \
-p:Version="$VERSION" \
--output ./artifacts

- name: Find built artifacts
id: find-artifacts
run: |
VERSION="${{ steps.validate-tag.outputs.version }}"

# Find the built NuGet package
# Find the built NuGet packages
NUPKG=$(find ./artifacts -name "Braintrust.Sdk.${VERSION}.nupkg" | head -1)
SNUPKG=$(find ./artifacts -name "Braintrust.Sdk.${VERSION}.snupkg" | head -1)
OPENAI_NUPKG=$(find ./artifacts -name "Braintrust.Sdk.OpenAI.${VERSION}.nupkg" | head -1)
OPENAI_SNUPKG=$(find ./artifacts -name "Braintrust.Sdk.OpenAI.${VERSION}.snupkg" | head -1)
ANTHROPIC_NUPKG=$(find ./artifacts -name "Braintrust.Sdk.Anthropic.${VERSION}.nupkg" | head -1)
ANTHROPIC_SNUPKG=$(find ./artifacts -name "Braintrust.Sdk.Anthropic.${VERSION}.snupkg" | head -1)

echo "nupkg=$NUPKG" >> $GITHUB_OUTPUT
if [[ -n "$SNUPKG" ]]; then
echo "snupkg=$SNUPKG" >> $GITHUB_OUTPUT
fi
echo "openai_nupkg=$OPENAI_NUPKG" >> $GITHUB_OUTPUT
if [[ -n "$OPENAI_SNUPKG" ]]; then
echo "openai_snupkg=$OPENAI_SNUPKG" >> $GITHUB_OUTPUT
fi
echo "anthropic_nupkg=$ANTHROPIC_NUPKG" >> $GITHUB_OUTPUT
if [[ -n "$ANTHROPIC_SNUPKG" ]]; then
echo "anthropic_snupkg=$ANTHROPIC_SNUPKG" >> $GITHUB_OUTPUT
fi

echo "Found artifacts:"
echo " NuGet package: $NUPKG"
if [[ -n "$SNUPKG" ]]; then
echo " Symbols package: $SNUPKG"
fi
echo " OpenAI NuGet package: $OPENAI_NUPKG"
if [[ -n "$OPENAI_SNUPKG" ]]; then
echo " OpenAI symbols package: $OPENAI_SNUPKG"
fi
echo " Anthropic NuGet package: $ANTHROPIC_NUPKG"
if [[ -n "$ANTHROPIC_SNUPKG" ]]; then
echo " Anthropic symbols package: $ANTHROPIC_SNUPKG"
fi

- name: Create GitHub Release
run: |
Expand All @@ -131,13 +163,17 @@ jobs:
--title "Release $TAG"

# Upload artifacts if they exist
if [[ -n "${{ steps.find-artifacts.outputs.nupkg }}" && -f "${{ steps.find-artifacts.outputs.nupkg }}" ]]; then
gh release upload "$TAG" "${{ steps.find-artifacts.outputs.nupkg }}"
fi

if [[ -n "${{ steps.find-artifacts.outputs.snupkg }}" && -f "${{ steps.find-artifacts.outputs.snupkg }}" ]]; then
gh release upload "$TAG" "${{ steps.find-artifacts.outputs.snupkg }}"
fi
for artifact in \
"${{ steps.find-artifacts.outputs.nupkg }}" \
"${{ steps.find-artifacts.outputs.snupkg }}" \
"${{ steps.find-artifacts.outputs.openai_nupkg }}" \
"${{ steps.find-artifacts.outputs.openai_snupkg }}" \
"${{ steps.find-artifacts.outputs.anthropic_nupkg }}" \
"${{ steps.find-artifacts.outputs.anthropic_snupkg }}"; do
if [[ -n "$artifact" && -f "$artifact" ]]; then
gh release upload "$TAG" "$artifact"
fi
done
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Expand All @@ -149,21 +185,27 @@ jobs:

- name: Publish to NuGet.org
run: |
NUPKG="${{ steps.find-artifacts.outputs.nupkg }}"

if [[ -z "$NUPKG" || ! -f "$NUPKG" ]]; then
echo "Error: NuGet package not found"
exit 1
fi

echo "Publishing $NUPKG to NuGet.org..."
dotnet nuget push "$NUPKG" \
--api-key "${{ steps.nuget-login.outputs.NUGET_API_KEY }}" \
--source https://api.nuget.org/v3/index.json \
--skip-duplicate
for NUPKG in \
"${{ steps.find-artifacts.outputs.nupkg }}" \
"${{ steps.find-artifacts.outputs.openai_nupkg }}" \
"${{ steps.find-artifacts.outputs.anthropic_nupkg }}"; do
if [[ -z "$NUPKG" || ! -f "$NUPKG" ]]; then
echo "Error: NuGet package not found: $NUPKG"
exit 1
fi

echo "Publishing $NUPKG to NuGet.org..."
dotnet nuget push "$NUPKG" \
--api-key "${{ steps.nuget-login.outputs.NUGET_API_KEY }}" \
--source https://api.nuget.org/v3/index.json \
--skip-duplicate
done

- name: Wait for NuGet.org indexing
run: |
VERSION="${{ steps.validate-tag.outputs.version }}"
echo "Package published! It may take a few minutes to appear on NuGet.org"
echo "Check status at: https://www.nuget.org/packages/Braintrust.Sdk/$VERSION"
echo "Packages published! It may take a few minutes to appear on NuGet.org"
echo "Check status at:"
echo " https://www.nuget.org/packages/Braintrust.Sdk/$VERSION"
echo " https://www.nuget.org/packages/Braintrust.Sdk.OpenAI/$VERSION"
echo " https://www.nuget.org/packages/Braintrust.Sdk.Anthropic/$VERSION"
14 changes: 14 additions & 0 deletions Braintrust.Sdk.sln
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenAIInstrumentation", "ex
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EvalExample", "examples\EvalExample\EvalExample.csproj", "{DFAA25AA-72B1-4246-BAB9-A10CCF115406}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Braintrust.Sdk.OpenAI", "src\Braintrust.Sdk.OpenAI\Braintrust.Sdk.OpenAI.csproj", "{B3C7D1A2-4E5F-6789-ABCD-EF0123456789}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Braintrust.Sdk.Anthropic", "src\Braintrust.Sdk.Anthropic\Braintrust.Sdk.Anthropic.csproj", "{A8A1C23E-7D6F-47FE-9959-B90E9CEF7B2C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AnthropicInstrumentation", "examples\AnthropicInstrumentation\AnthropicInstrumentation.csproj", "{446D2C4A-41D6-4E4F-AC4C-6809E2416A98}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Braintrust.Sdk.OpenAI.Tests", "tests\Braintrust.Sdk.OpenAI.Tests\Braintrust.Sdk.OpenAI.Tests.csproj", "{C4D8E2B3-5F6A-7890-BCDE-F01234567890}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Braintrust.Sdk.Anthropic.Tests", "tests\Braintrust.Sdk.Anthropic.Tests\Braintrust.Sdk.Anthropic.Tests.csproj", "{5346F038-36B5-4914-8AB0-D5BF360A5178}"
EndProject
Global
Expand Down Expand Up @@ -62,6 +66,14 @@ Global
{446D2C4A-41D6-4E4F-AC4C-6809E2416A98}.Debug|Any CPU.Build.0 = Debug|Any CPU
{446D2C4A-41D6-4E4F-AC4C-6809E2416A98}.Release|Any CPU.ActiveCfg = Release|Any CPU
{446D2C4A-41D6-4E4F-AC4C-6809E2416A98}.Release|Any CPU.Build.0 = Release|Any CPU
{B3C7D1A2-4E5F-6789-ABCD-EF0123456789}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B3C7D1A2-4E5F-6789-ABCD-EF0123456789}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B3C7D1A2-4E5F-6789-ABCD-EF0123456789}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B3C7D1A2-4E5F-6789-ABCD-EF0123456789}.Release|Any CPU.Build.0 = Release|Any CPU
{C4D8E2B3-5F6A-7890-BCDE-F01234567890}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C4D8E2B3-5F6A-7890-BCDE-F01234567890}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C4D8E2B3-5F6A-7890-BCDE-F01234567890}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C4D8E2B3-5F6A-7890-BCDE-F01234567890}.Release|Any CPU.Build.0 = Release|Any CPU
{5346F038-36B5-4914-8AB0-D5BF360A5178}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5346F038-36B5-4914-8AB0-D5BF360A5178}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5346F038-36B5-4914-8AB0-D5BF360A5178}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand All @@ -75,6 +87,8 @@ Global
{DFAA25AA-72B1-4246-BAB9-A10CCF115406} = {A1BDA853-65BE-4CC8-8070-CCBA22069A7A}
{A8A1C23E-7D6F-47FE-9959-B90E9CEF7B2C} = {6530DEC3-1D19-4854-80AC-2D6D02BEAECC}
{446D2C4A-41D6-4E4F-AC4C-6809E2416A98} = {A1BDA853-65BE-4CC8-8070-CCBA22069A7A}
{B3C7D1A2-4E5F-6789-ABCD-EF0123456789} = {6530DEC3-1D19-4854-80AC-2D6D02BEAECC}
{C4D8E2B3-5F6A-7890-BCDE-F01234567890} = {638AA92E-E6F9-4619-846C-6E12610D5AAE}
{5346F038-36B5-4914-8AB0-D5BF360A5178} = {638AA92E-E6F9-4619-846C-6E12610D5AAE}
EndGlobalSection
EndGlobal
2 changes: 1 addition & 1 deletion Directory.Build.targets
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
<Message Text="Generated Braintrust SDK version: $(BraintrustSdkVersion)" Importance="high" />

<!-- Set the Version property for NuGet packaging -->
<PropertyGroup Condition="'$(MSBuildProjectName)' == 'Braintrust.Sdk'">
<PropertyGroup Condition="'$(MSBuildProjectName)' == 'Braintrust.Sdk' or '$(MSBuildProjectName)' == 'Braintrust.Sdk.OpenAI' or '$(MSBuildProjectName)' == 'Braintrust.Sdk.Anthropic'">
<Version>$(BraintrustSdkVersion)</Version>
<PackageVersion>$(BraintrustSdkVersion)</PackageVersion>
</PropertyGroup>
Comment on lines 77 to 81
Copy link

Copilot AI Feb 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ComputeBraintrustVersion now sets Version/PackageVersion for the new Braintrust.Sdk.OpenAI and Braintrust.Sdk.Anthropic packages, but the later VerifyAssemblyVersion target still only runs for Braintrust.Sdk. This means the new packages won’t get the same safeguard against version mismatches (e.g., if Version is overridden or the embedded version resource diverges). Consider expanding the VerifyAssemblyVersion target condition to include the new package projects as well, or factoring the condition into a shared property so all packable SDK packages are verified consistently.

Copilot uses AI. Check for mistakes.
Expand Down
5 changes: 1 addition & 4 deletions examples/EvalExample/EvalExample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

<ItemGroup>
<ProjectReference Include="..\..\src\Braintrust.Sdk\Braintrust.Sdk.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="OpenAI" Version="2.6.0" />
<ProjectReference Include="..\..\src\Braintrust.Sdk.OpenAI\Braintrust.Sdk.OpenAI.csproj" />
</ItemGroup>

<PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion examples/EvalExample/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Braintrust.Sdk.Eval;
using Braintrust.Sdk.Instrumentation.OpenAI;
using Braintrust.Sdk.OpenAI;
using OpenAI;
using OpenAI.Chat;

Expand Down
5 changes: 1 addition & 4 deletions examples/OpenAIInstrumentation/OpenAIInstrumentation.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@

<ItemGroup>
<ProjectReference Include="..\..\src\Braintrust.Sdk\Braintrust.Sdk.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="OpenAI" Version="2.6.0" />
<ProjectReference Include="..\..\src\Braintrust.Sdk.OpenAI\Braintrust.Sdk.OpenAI.csproj" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion examples/OpenAIInstrumentation/Program.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Threading.Tasks;
using Braintrust.Sdk;
using Braintrust.Sdk.Instrumentation.OpenAI;
using Braintrust.Sdk.OpenAI;
using OpenAI;
using OpenAI.Chat;

Expand Down
5 changes: 5 additions & 0 deletions src/Braintrust.Sdk.Anthropic/Braintrust.Sdk.Anthropic.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,17 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<!-- Version is determined dynamically from git state in Directory.Build.targets -->
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>

<ItemGroup>
<InternalsVisibleTo Include="Braintrust.Sdk.Anthropic.Tests" />
</ItemGroup>

<ItemGroup>
<None Include="README.md" Pack="true" PackagePath="\" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Braintrust.Sdk\Braintrust.Sdk.csproj" />
</ItemGroup>
Expand Down
5 changes: 5 additions & 0 deletions src/Braintrust.Sdk.Anthropic/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Braintrust C# SDK - Anthropic Integration

This package provides Anthropic SDK integration for the Braintrust C# tracer, enabling tracing and evaluation of Anthropic API calls.

For full documentation, see: https://github.com/braintrustdata/braintrust-sdk-dotnet
27 changes: 27 additions & 0 deletions src/Braintrust.Sdk.OpenAI/Braintrust.Sdk.OpenAI.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<!-- Version is determined dynamically from git state in Directory.Build.targets -->
<PackageReadmeFile>README.md</PackageReadmeFile>
</PropertyGroup>

<ItemGroup>
<InternalsVisibleTo Include="Braintrust.Sdk.OpenAI.Tests" />
</ItemGroup>

<ItemGroup>
<None Include="README.md" Pack="true" PackagePath="\" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Braintrust.Sdk\Braintrust.Sdk.csproj" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="OpenAI" Version="2.6.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Diagnostics;
using OpenAI;

namespace Braintrust.Sdk.Instrumentation.OpenAI;
namespace Braintrust.Sdk.OpenAI;

/// <summary>
/// Braintrust OpenAI client instrumentation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.ClientModel.Primitives;
using System.Diagnostics;

namespace Braintrust.Sdk.Instrumentation.OpenAI;
namespace Braintrust.Sdk.OpenAI;

/// <summary>
/// Pipeline transport wrapper that captures request and response bodies for telemetry.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using OpenAI.Chat;
using OpenTelemetry.Trace;

namespace Braintrust.Sdk.Instrumentation.OpenAI;
namespace Braintrust.Sdk.OpenAI;

/// <summary>
/// Decorator wrapper for ChatClient that adds telemetry instrumentation.
Expand Down Expand Up @@ -172,4 +172,4 @@ private void TagActivity(Activity activity, double? timeToFirstToken = null)
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
using OpenAI.Images;
using OpenAI.Moderations;

namespace Braintrust.Sdk.Instrumentation.OpenAI;
namespace Braintrust.Sdk.OpenAI;

/// <summary>
/// Decorator wrapper for OpenAIClient that adds telemetry instrumentation.
Expand Down Expand Up @@ -98,4 +98,4 @@ public override ModerationClient GetModerationClient(string model)
// Note: GetAssistantClient, GetVectorStoreClient, and GetBatchClient are experimental APIs
// that may not exist in all versions. They will fall through to the base class if called.
// TODO: Add delegation for experimental APIs if they become stable
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Diagnostics;
using OpenAI;

namespace Braintrust.Sdk.Instrumentation.OpenAI;
namespace Braintrust.Sdk.OpenAI;

/// <summary>
/// Entry point for instrumenting OpenAI clients.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.Diagnostics;

namespace Braintrust.Sdk.Instrumentation.OpenAI;
namespace Braintrust.Sdk.OpenAI;

/// <summary>
/// Builder for configuring OpenAI telemetry instrumentation.
Expand Down
5 changes: 5 additions & 0 deletions src/Braintrust.Sdk.OpenAI/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Braintrust C# SDK - OpenAI Integration

This package provides OpenAI SDK integration for the Braintrust C# tracer, enabling tracing and evaluation of OpenAI API calls.

For full documentation, see: https://github.com/braintrustdata/braintrust-sdk-dotnet
2 changes: 1 addition & 1 deletion src/Braintrust.Sdk/Braintrust.Sdk.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

<ItemGroup>
<InternalsVisibleTo Include="Braintrust.Sdk.Tests" />
<InternalsVisibleTo Include="Braintrust.Sdk.OpenAI.Tests" />
<InternalsVisibleTo Include="Braintrust.Sdk.Anthropic.Tests" />
</ItemGroup>

Expand All @@ -18,7 +19,6 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="OpenAI" Version="2.6.0" />
<PackageReference Include="OpenTelemetry" Version="1.9.0" />
<PackageReference Include="OpenTelemetry.Api" Version="1.9.0" />
<PackageReference Include="OpenTelemetry.Exporter.OpenTelemetryProtocol" Version="1.9.0" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="6.0.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Braintrust.Sdk\Braintrust.Sdk.csproj" />
<ProjectReference Include="..\..\src\Braintrust.Sdk.OpenAI\Braintrust.Sdk.OpenAI.csproj" />
</ItemGroup>

</Project>
Loading