From 2bf11a8572ebe85cb088bf4ef9111ef725574da1 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 23 Dec 2024 11:24:48 -0500 Subject: [PATCH 1/5] chore: Update mypy requirement from ==1.13.0 to ==1.14.0 (#35) --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 4225b10..d3634d3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,7 +36,7 @@ chevron = "=0.14.0" pytest = ">=2.8" pytest-cov = ">=2.4.0" pytest-mypy = "==0.10.3" -mypy = "==1.13.0" +mypy = "==1.14.0" pycodestyle = "^2.12.1" isort = "^5.13.2" From 95abb8b5c73bfeba9f13468526e5a40f0f4a191d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 23 Dec 2024 11:53:58 -0500 Subject: [PATCH 2/5] chore: Update jinja2 requirement from 3.1.4 to 3.1.5 (#34) --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index d3634d3..f5c44ba 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -53,7 +53,7 @@ pyrfc3339 = ">=1.0" jsonpickle = ">1.4.1" semver = ">=2.7.9" urllib3 = ">=1.26.0" -jinja2 = "3.1.4" +jinja2 = "3.1.5" [tool.mypy] python_version = "3.8" From a3b402509c5a147a16d7c5df6c7578c13a544eb5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 2 Jan 2025 09:36:39 -0500 Subject: [PATCH 3/5] chore: Update mypy requirement from ==1.14.0 to ==1.14.1 (#36) --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index f5c44ba..6795ccc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,7 +36,7 @@ chevron = "=0.14.0" pytest = ">=2.8" pytest-cov = ">=2.4.0" pytest-mypy = "==0.10.3" -mypy = "==1.14.0" +mypy = "==1.14.1" pycodestyle = "^2.12.1" isort = "^5.13.2" From b4a5757ab7a1a8149891977cdfc25bdd4f7bba09 Mon Sep 17 00:00:00 2001 From: Mori Bellamy Date: Thu, 23 Jan 2025 09:54:14 -0800 Subject: [PATCH 4/5] feat: Add ability to track time to first token for LDAIConfigTracker (#37) --- ldai/testing/test_tracker.py | 15 +++++++++++++++ ldai/tracker.py | 16 ++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/ldai/testing/test_tracker.py b/ldai/testing/test_tracker.py index 3196bfb..14215a9 100644 --- a/ldai/testing/test_tracker.py +++ b/ldai/testing/test_tracker.py @@ -75,6 +75,21 @@ def test_tracks_duration_of(client: LDClient): assert calls[0].args[3] == pytest.approx(10, rel=10) +def test_tracks_time_to_first_token(client: LDClient): + context = Context.create('user-key') + tracker = LDAIConfigTracker(client, "variation-key", "config-key", context) + tracker.track_time_to_first_token(100) + + client.track.assert_called_with( # type: ignore + '$ld:ai:tokens:ttf', + context, + {'variationKey': 'variation-key', 'configKey': 'config-key'}, + 100 + ) + + assert tracker.get_summary().time_to_first_token == 100 + + def test_tracks_duration_of_with_exception(client: LDClient): context = Context.create('user-key') tracker = LDAIConfigTracker(client, "variation-key", "config-key", context) diff --git a/ldai/tracker.py b/ldai/tracker.py index 8f3c15c..b29ec6f 100644 --- a/ldai/tracker.py +++ b/ldai/tracker.py @@ -40,6 +40,7 @@ def __init__(self): self._success = None self._feedback = None self._usage = None + self._time_to_first_token = None @property def duration(self) -> Optional[int]: @@ -57,6 +58,10 @@ def feedback(self) -> Optional[Dict[str, FeedbackKind]]: def usage(self) -> Optional[TokenUsage]: return self._usage + @property + def time_to_first_token(self) -> Optional[int]: + return self._time_to_first_token + class LDAIConfigTracker: """ @@ -102,6 +107,17 @@ def track_duration(self, duration: int) -> None: '$ld:ai:duration:total', self._context, self.__get_track_data(), duration ) + def track_time_to_first_token(self, time_to_first_token: int) -> None: + """ + Manually track the time to first token of an AI operation. + + :param time_to_first_token: Time to first token in milliseconds. + """ + self._summary._time_to_first_token = time_to_first_token + self._ld_client.track( + '$ld:ai:tokens:ttf', self._context, self.__get_track_data(), time_to_first_token + ) + def track_duration_of(self, func): """ Automatically track the duration of an AI operation. From f065fd0a490e40cf227174e99c1503b8cabe0412 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 23 Jan 2025 15:43:27 -0500 Subject: [PATCH 5/5] chore(main): release 0.7.0 (#38) :robot: I have created a release *beep* *boop* --- ## [0.7.0](https://github.com/launchdarkly/python-server-sdk-ai/compare/0.6.0...0.7.0) (2025-01-23) ### Features * Add ability to track time to first token for LDAIConfigTracker ([#37](https://github.com/launchdarkly/python-server-sdk-ai/issues/37)) ([b4a5757](https://github.com/launchdarkly/python-server-sdk-ai/commit/b4a5757ab7a1a8149891977cdfc25bdd4f7bba09)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> --- .release-please-manifest.json | 2 +- CHANGELOG.md | 7 +++++++ PROVENANCE.md | 2 +- ldai/__init__.py | 2 +- pyproject.toml | 2 +- 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index bcd0522..e7ca613 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.6.0" + ".": "0.7.0" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 6294c77..babe57b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to the LaunchDarkly Python AI package will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org). +## [0.7.0](https://github.com/launchdarkly/python-server-sdk-ai/compare/0.6.0...0.7.0) (2025-01-23) + + +### Features + +* Add ability to track time to first token for LDAIConfigTracker ([#37](https://github.com/launchdarkly/python-server-sdk-ai/issues/37)) ([b4a5757](https://github.com/launchdarkly/python-server-sdk-ai/commit/b4a5757ab7a1a8149891977cdfc25bdd4f7bba09)) + ## [0.6.0](https://github.com/launchdarkly/python-server-sdk-ai/compare/0.5.0...0.6.0) (2024-12-17) diff --git a/PROVENANCE.md b/PROVENANCE.md index 097c4ab..83049af 100644 --- a/PROVENANCE.md +++ b/PROVENANCE.md @@ -10,7 +10,7 @@ To verify SLSA provenance attestations, we recommend using [slsa-verifier](https ``` # Set the version of the library to verify -VERSION=0.6.0 +VERSION=0.7.0 ``` diff --git a/ldai/__init__.py b/ldai/__init__.py index 42c2d87..ebe38f1 100644 --- a/ldai/__init__.py +++ b/ldai/__init__.py @@ -1 +1 @@ -__version__ = "0.6.0" # x-release-please-version +__version__ = "0.7.0" # x-release-please-version diff --git a/pyproject.toml b/pyproject.toml index 6795ccc..d462edf 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "launchdarkly-server-sdk-ai" -version = "0.6.0" +version = "0.7.0" description = "LaunchDarkly SDK for AI" authors = ["LaunchDarkly "] license = "Apache-2.0"