Skip to content

Conversation

@edwinokonkwo
Copy link

@edwinokonkwo edwinokonkwo commented Nov 21, 2025

Part 1: Add server-ai package

We initially reviewed this as a single PR, but decided to align the folder structure with js-core for consistency.
This PR introduces the server-ai package, setting up the foundation for the new structure.

Part 1: Adds the server-ai package (this PR)

Part 2: Adds the LangChain provider ( next )

Part 3: Updates CI and publishing configuration ( next )

@edwinokonkwo edwinokonkwo requested a review from a team as a code owner November 21, 2025 23:13
@edwinokonkwo edwinokonkwo changed the title feat: REL-10772 Added server-ai core packages feat: REL-10772 - Part 1 - Added server-ai core packages Nov 21, 2025
Copy link
Contributor

@jsonbailey jsonbailey left a comment

Choose a reason for hiding this comment

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

This still has the old files in the old location. I would either make these changes to the old file, and then do the move. Or do the move in this pr by deleting the old files. That gives git a chance to recognize the same files and show the proper diff.

Copy link
Contributor

@jsonbailey jsonbailey left a comment

Choose a reason for hiding this comment

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

There are a few changes that need to be made for the project structure. You still may find it easier to separate the reorganization of the package into a separate commit from the addition of the Judges and Chat implementations.

@@ -0,0 +1,573 @@
import asyncio
Copy link
Contributor

Choose a reason for hiding this comment

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

It doesn't look like git is properly tracking this as a moved file, rather it thinks it was deleted and a new file created. We should ensure this shows as moved so that the history still works on the file.

steps:
- name: Build distribution files
shell: bash
working-directory: packages/sdk/server-ai
Copy link
Contributor

Choose a reason for hiding this comment

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

There are a couple options here. The js-core repository passes in the workspace directory and has individual CI build workflows for each project (https://github.com/launchdarkly/js-core/blob/main/.github/workflows/release-please.yml).

The dotnet repository uses shared workflows but sets a github_actions.env file for each package that is loaded during the CI / build process https://github.com/launchdarkly/dotnet-core/tree/main/pkgs/sdk/server-ai.

)

if eval_result and eval_result.success:
self._tracker.track_eval_scores(eval_result.evals)
Copy link
Contributor

Choose a reason for hiding this comment

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

The js-core repo switched to using trackJudgeResponse vs eval scores as it contained information about the judge ai config key. We should make that change here as well.

from ldai.tracker import LDAIConfigTracker


class AIJudge:
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can just call this Judge vs AIJudge to keep it aligned with js-core. Or we might consider updating js-core.

return list(provider_set) # type: ignore[arg-type]

@staticmethod
async def _try_create_provider(
Copy link
Contributor

Choose a reason for hiding this comment

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

This logic is only needed if we cannot do true dynamic imports. JS had issues with that so we needed to use a switch and declare each import so that tree shaking didn't remove the package but python may not have that issue. This code has two approaches and we should test if dynamic works and if so, use it. Otherwise do the direct imports.

This logic for direct imports was simplified in the latest js-core and would likely work here as well. https://github.com/launchdarkly/js-core/blob/main/packages/sdk/server-ai/src/api/providers/AIProviderFactory.ts#L96

)

def track_openai_metrics(self, func):
async def track_openai_metrics(self, func):
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this method being modified?



def test_tracks_openai_metrics(client: LDClient):
@pytest.mark.asyncio
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here, I'm not sure why we made this async. It seems unrelated to the current PR.

@@ -0,0 +1,13 @@
Copyright 2024 Catamorphic, Co.
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this needs to be duplicated and should stay in the root unless we need it for the packaging process.

@@ -0,0 +1,41 @@
# LaunchDarkly Server-side AI library for Python
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here, we have just duplicated this file but left the original at the root. This make sense to move, but we should change the root README in that case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants