first commit
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* LangSmith dataset write-back utilities.
|
||||
*
|
||||
* Provides functions to update examples in a LangSmith dataset
|
||||
* with regenerated state.
|
||||
*/
|
||||
|
||||
import type { Client as LangsmithClient } from 'langsmith/client';
|
||||
|
||||
import type { CoordinationLogEntry } from '@/types/coordination';
|
||||
import type { SimpleWorkflow } from '@/types/workflow';
|
||||
|
||||
import type { EvalLogger } from './logger';
|
||||
import type { SerializedMessage } from './workflow-regenerator';
|
||||
|
||||
/** Entry for LangSmith write-back operations */
|
||||
export interface LangSmithWriteBackEntry {
|
||||
exampleId: string;
|
||||
messages: SerializedMessage[];
|
||||
coordinationLog: CoordinationLogEntry[];
|
||||
workflowJSON: SimpleWorkflow;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write regenerated state back to a LangSmith dataset.
|
||||
* Updates the inputs field of each example while preserving other fields.
|
||||
*/
|
||||
export async function writeBackToLangSmithDataset(
|
||||
client: LangsmithClient,
|
||||
updates: LangSmithWriteBackEntry[],
|
||||
logger?: EvalLogger,
|
||||
): Promise<void> {
|
||||
if (updates.length === 0) {
|
||||
logger?.verbose('No updates to write back to LangSmith');
|
||||
return;
|
||||
}
|
||||
|
||||
logger?.info(`Writing back ${updates.length} examples to LangSmith dataset...`);
|
||||
|
||||
// Use batch update for efficiency
|
||||
const exampleUpdates = updates.map((update) => ({
|
||||
id: update.exampleId,
|
||||
inputs: {
|
||||
messages: update.messages,
|
||||
coordinationLog: update.coordinationLog,
|
||||
workflowJSON: update.workflowJSON,
|
||||
},
|
||||
}));
|
||||
|
||||
await client.updateExamples(exampleUpdates);
|
||||
|
||||
logger?.info(`Successfully updated ${updates.length} examples in LangSmith`);
|
||||
}
|
||||
Reference in New Issue
Block a user