-
Notifications
You must be signed in to change notification settings - Fork 37
feat: introduce ManagedResult, RunnerResult, and LDAIMetricSummary #1332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
jsonbailey
wants to merge
1
commit into
jb/aic-2174/server-ai
Choose a base branch
from
jb/aic-2388/js-managed-result
base: jb/aic-2174/server-ai
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export type { LDAIMetricSummary, ManagedResult, RunnerResult } from './types'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| import { LDJudgeResult } from '../judge/types'; | ||
| import { LDAIMetrics } from '../metrics/LDAIMetrics'; | ||
| import { LDTokenUsage } from '../metrics/LDTokenUsage'; | ||
|
|
||
| /** | ||
| * Summary metrics returned in a ManagedResult or ManagedGraphResult. | ||
| * Provides a flat view of the key metrics for the completed operation. | ||
| */ | ||
| export interface LDAIMetricSummary { | ||
| /** | ||
| * Whether the AI operation was successful. | ||
| */ | ||
| success: boolean; | ||
|
|
||
| /** | ||
| * Token usage information, if available. | ||
| */ | ||
| usage?: LDTokenUsage; | ||
|
|
||
| /** | ||
| * List of tool call identifiers made during the operation, if any. | ||
| */ | ||
| toolCalls?: string[]; | ||
|
|
||
| /** | ||
| * Duration of the operation in milliseconds, if tracked. | ||
| */ | ||
| durationMs?: number; | ||
|
|
||
| /** | ||
| * Resumption token for deferred feedback association. | ||
| */ | ||
| resumptionToken?: string; | ||
| } | ||
|
|
||
| /** | ||
| * The result returned by a Runner (provider-level) invocation. | ||
| * Providers implement Runner and return RunnerResult from run(). | ||
| * This type does NOT include evaluations — those are wired in the managed layer. | ||
| */ | ||
| export interface RunnerResult { | ||
| /** | ||
| * The text content of the model's response. | ||
| */ | ||
| content: string; | ||
|
|
||
| /** | ||
| * Metrics information for the operation. | ||
| */ | ||
| metrics: LDAIMetrics; | ||
|
|
||
| /** | ||
| * The raw response object from the provider, if available. | ||
| */ | ||
| raw?: unknown; | ||
|
|
||
| /** | ||
| * Parsed structured output, if the provider returned structured data. | ||
| */ | ||
| parsed?: Record<string, unknown>; | ||
| } | ||
|
|
||
| /** | ||
| * The result returned by a managed model invocation (ManagedModel.run()). | ||
| * Includes a promise for asynchronous judge evaluations. | ||
| */ | ||
| export interface ManagedResult { | ||
| /** | ||
| * The text content of the model's response. | ||
| */ | ||
| content: string; | ||
|
|
||
| /** | ||
| * Summarized metrics for this invocation. | ||
| */ | ||
| metrics: LDAIMetricSummary; | ||
|
|
||
| /** | ||
| * The raw response object from the provider, if available. | ||
| */ | ||
| raw?: unknown; | ||
|
|
||
| /** | ||
| * Parsed structured output, if available. | ||
| */ | ||
| parsed?: Record<string, unknown>; | ||
|
|
||
| /** | ||
| * Promise that resolves to the judge evaluation results. | ||
| * This promise encapsulates both evaluation and tracking | ||
| * (tracker.trackJudgeResult is called when it resolves). | ||
| * Awaiting this promise guarantees both evaluation and tracking are complete. | ||
| */ | ||
| evaluations: Promise<LDJudgeResult[]>; | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need to rename the TrackedChat type to ManagedModel naming. We should also introduce the runner interface as defined in the spec and follow it. This will be a breaking change to move to the .run method and we should drop the old invoke method.