From e0eca1a73549ca8b6c86112af4ae3d8a05ba479a Mon Sep 17 00:00:00 2001 From: Mori Bellamy Date: Wed, 22 Jan 2025 16:28:30 -0800 Subject: [PATCH 1/4] track TimeToFirstToken in LdAiConfigTracker --- .../src/Interfaces/ILdAiConfigTracker.cs | 5 +++++ pkgs/sdk/server-ai/src/LdAiConfigTracker.cs | 5 +++++ .../sdk/server-ai/test/LdAiConfigTrackerTest.cs | 17 +++++++++++++++++ 3 files changed, 27 insertions(+) diff --git a/pkgs/sdk/server-ai/src/Interfaces/ILdAiConfigTracker.cs b/pkgs/sdk/server-ai/src/Interfaces/ILdAiConfigTracker.cs index dce8dd9f..9158b415 100644 --- a/pkgs/sdk/server-ai/src/Interfaces/ILdAiConfigTracker.cs +++ b/pkgs/sdk/server-ai/src/Interfaces/ILdAiConfigTracker.cs @@ -36,6 +36,11 @@ public interface ILdAiConfigTracker /// type of the task's result /// the task public Task TrackDurationOfTask(Task task); + + /// + /// Tracks the time it takes for the first token to be generated. + /// + public void TrackTimeToFirstToken(float timeToFirstTokenMs); /// /// Tracks feedback (positive or negative) related to the output of the model. diff --git a/pkgs/sdk/server-ai/src/LdAiConfigTracker.cs b/pkgs/sdk/server-ai/src/LdAiConfigTracker.cs index bfe7eb0b..b4b4ee1a 100644 --- a/pkgs/sdk/server-ai/src/LdAiConfigTracker.cs +++ b/pkgs/sdk/server-ai/src/LdAiConfigTracker.cs @@ -27,6 +27,7 @@ public class LdAiConfigTracker : ILdAiConfigTracker private const string TokenTotal = "$ld:ai:tokens:total"; private const string TokenInput = "$ld:ai:tokens:input"; private const string TokenOutput = "$ld:ai:tokens:output"; + private const string TimeToFirstToken = "$ld:ai:tokens:ttf"; /// /// Constructs a new AI configuration tracker. The tracker is associated with a configuration, @@ -69,6 +70,10 @@ public async Task TrackDurationOfTask(Task task) TrackDuration(sw.ElapsedMilliseconds); } } + + /// + public void TrackTimeToFirstToken(float timeToFirstTokenMs) => + _client.Track(TimeToFirstToken, _context, _trackData, timeToFirstTokenMs); /// public void TrackFeedback(Feedback feedback) diff --git a/pkgs/sdk/server-ai/test/LdAiConfigTrackerTest.cs b/pkgs/sdk/server-ai/test/LdAiConfigTrackerTest.cs index 4145a332..cbcba1d1 100644 --- a/pkgs/sdk/server-ai/test/LdAiConfigTrackerTest.cs +++ b/pkgs/sdk/server-ai/test/LdAiConfigTrackerTest.cs @@ -51,6 +51,23 @@ public void CanTrackDuration() mockClient.Verify(x => x.Track("$ld:ai:duration:total", context, data, 1.0f), Times.Once); } + [Fact] + public void CanTrackTimeToFirstToken() + { + var mockClient = new Mock(); + var context = Context.New("key"); + const string flagKey = "key"; + var config = LdAiConfig.Disabled; + var data = LdValue.ObjectFrom(new Dictionary + { + { "variationKey", LdValue.Of(config.VariationKey) }, + { "configKey", LdValue.Of(flagKey) } + }); + var tracker = new LdAiConfigTracker(mockClient.Object, flagKey, config, context); + + tracker.TrackTimeToFirstToken(1.0f); + mockClient.Verify(x => x.Track("$ld:ai:tokens:ttf", context, data, 1.0f), Times.Once); + } [Fact] public void CanTrackSuccess() From 04c64d87abb6733912a9de48a576983ec291c79b Mon Sep 17 00:00:00 2001 From: Mori Bellamy Date: Thu, 23 Jan 2025 11:24:05 -0800 Subject: [PATCH 2/4] Update pkgs/sdk/server-ai/src/Interfaces/ILdAiConfigTracker.cs Co-authored-by: Matthew M. Keeler --- pkgs/sdk/server-ai/src/Interfaces/ILdAiConfigTracker.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/sdk/server-ai/src/Interfaces/ILdAiConfigTracker.cs b/pkgs/sdk/server-ai/src/Interfaces/ILdAiConfigTracker.cs index 9158b415..422bb261 100644 --- a/pkgs/sdk/server-ai/src/Interfaces/ILdAiConfigTracker.cs +++ b/pkgs/sdk/server-ai/src/Interfaces/ILdAiConfigTracker.cs @@ -40,6 +40,7 @@ public interface ILdAiConfigTracker /// /// Tracks the time it takes for the first token to be generated. /// + /// the duration in milliseconds public void TrackTimeToFirstToken(float timeToFirstTokenMs); /// From e1400fee41a16504e500a4de84b336d5eb255b4e Mon Sep 17 00:00:00 2001 From: Todd Anderson Date: Tue, 28 Jan 2025 10:03:24 -0600 Subject: [PATCH 3/4] ci: pinning ubuntu to 22.04 --- .github/workflows/publish-docs.yml | 2 +- .github/workflows/release-please.yml | 8 ++++---- .github/workflows/release-sdk-client.yml | 2 +- .github/workflows/release.yml | 2 +- .github/workflows/sdk-server-ai-ci.yml | 2 +- .github/workflows/sdk-server-ci.yml | 2 +- .github/workflows/telemetry-ci.yml | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/publish-docs.yml b/.github/workflows/publish-docs.yml index 21468106..2ee5bd2a 100644 --- a/.github/workflows/publish-docs.yml +++ b/.github/workflows/publish-docs.yml @@ -14,7 +14,7 @@ on: name: Publish Docs jobs: build-publish: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 permissions: id-token: write contents: write diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml index 62c46563..e5589738 100644 --- a/.github/workflows/release-please.yml +++ b/.github/workflows/release-please.yml @@ -7,7 +7,7 @@ on: jobs: release-please: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 outputs: package-sdk-server-released: ${{ steps.release.outputs['pkgs/sdk/server--release_created'] }} @@ -28,7 +28,7 @@ jobs: target-branch: ${{ github.ref_name }} release-sdk-server: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 needs: release-please permissions: id-token: write @@ -57,7 +57,7 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} release-sdk-server-ai: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 needs: release-please permissions: id-token: write @@ -86,7 +86,7 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} release-telemetry: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 needs: release-please permissions: id-token: write diff --git a/.github/workflows/release-sdk-client.yml b/.github/workflows/release-sdk-client.yml index eae5391c..76d28b54 100644 --- a/.github/workflows/release-sdk-client.yml +++ b/.github/workflows/release-sdk-client.yml @@ -73,7 +73,7 @@ jobs: # Signing DLLs is done on Ubuntu due to Digicert tooling compatibility sign-dlls: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 needs: build permissions: id-token: write diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 01557728..92f2ab52 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,7 +25,7 @@ on: jobs: build: - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 permissions: id-token: write contents: write diff --git a/.github/workflows/sdk-server-ai-ci.yml b/.github/workflows/sdk-server-ai-ci.yml index f049b315..0ba01a8a 100644 --- a/.github/workflows/sdk-server-ai-ci.yml +++ b/.github/workflows/sdk-server-ai-ci.yml @@ -13,7 +13,7 @@ jobs: build-and-test: strategy: matrix: - os: [ubuntu-latest, windows-latest, macos-latest] + os: [ubuntu-22.04, windows-latest, macos-latest] fail-fast: false runs-on: ${{ matrix.os }} permissions: diff --git a/.github/workflows/sdk-server-ci.yml b/.github/workflows/sdk-server-ci.yml index a2fd78e5..e2679ef1 100644 --- a/.github/workflows/sdk-server-ci.yml +++ b/.github/workflows/sdk-server-ci.yml @@ -13,7 +13,7 @@ jobs: build-and-test: strategy: matrix: - os: [ubuntu-latest, windows-latest, macos-latest] + os: [ubuntu-22.04, windows-latest, macos-latest] fail-fast: false runs-on: ${{ matrix.os }} permissions: diff --git a/.github/workflows/telemetry-ci.yml b/.github/workflows/telemetry-ci.yml index 64351710..4858dafd 100644 --- a/.github/workflows/telemetry-ci.yml +++ b/.github/workflows/telemetry-ci.yml @@ -13,7 +13,7 @@ jobs: build-and-test: strategy: matrix: - os: [ubuntu-latest, windows-latest, macos-latest] + os: [ubuntu-22.04, windows-latest, macos-latest] fail-fast: false runs-on: ${{ matrix.os }} permissions: From 59af88de176c99d01cf6165023a71a302ee7274f Mon Sep 17 00:00:00 2001 From: Todd Anderson Date: Tue, 28 Jan 2025 10:25:21 -0600 Subject: [PATCH 4/4] ignoring eol workload errors --- pkgs/sdk/client/src/LaunchDarkly.ClientSdk.csproj | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/sdk/client/src/LaunchDarkly.ClientSdk.csproj b/pkgs/sdk/client/src/LaunchDarkly.ClientSdk.csproj index d438a2e1..8c8d6d18 100644 --- a/pkgs/sdk/client/src/LaunchDarkly.ClientSdk.csproj +++ b/pkgs/sdk/client/src/LaunchDarkly.ClientSdk.csproj @@ -36,6 +36,8 @@ 1570,1571,1572,1573,1574,1580,1581,1584,1591,1710,1711,1712 + + false