@maximai/maxim-js
Version:
Maxim AI JS SDK. Visit https://getmaxim.ai for more info.
91 lines (90 loc) • 6.62 kB
TypeScript
import { HumanEvaluationConfig, MaximAPIEvaluatorFetchResponse } from "../models/evaluator";
import { MaximAPICreateTestRunResponse, MaximAPITestRunEntryCreatePayload, MaximAPITestRunEntryCreateResponse, MaximAPITestRunEntryExecutePromptChainForDataPayload, MaximAPITestRunEntryExecutePromptChainForDataResponse, MaximAPITestRunEntryExecutePromptForDataPayload, MaximAPITestRunEntryExecutePromptForDataResponse, MaximAPITestRunEntryExecuteSimulationPromptGetResponse, MaximAPITestRunEntryExecuteSimulationPromptPayload, MaximAPITestRunEntryExecuteSimulationPromptPostResponse, MaximAPITestRunEntryExecuteSimulationWorkflowGetResponse, MaximAPITestRunEntryExecuteSimulationWorkflowPayload, MaximAPITestRunEntryExecuteSimulationWorkflowPostResponse, MaximAPITestRunEntryExecuteWorkflowForDataPayload, MaximAPITestRunEntryExecuteWorkflowForDataResponse, MaximAPITestRunEntryPushPayload, MaximAPITestRunSimulationLocalExecutionPayload, MaximAPITestRunSimulationLocalExecutionPostResponse, TestRunConfig, TestRunResult } from "../models/testRun";
import { ExtractAPIDataType } from "../utils/utils";
import { MaximAPI } from "./maxim";
export declare class MaximTestRunAPI extends MaximAPI {
constructor(baseUrl: string, apiKey: string, isDebug?: boolean);
createTestRun(name: string, workspaceId: string, runType: "SINGLE" | "COMPARISON", evaluatorConfig: ExtractAPIDataType<MaximAPIEvaluatorFetchResponse>[], requiresLocalRun: boolean, workflowId?: string, promptVersionId?: string, promptChainVersionId?: string, humanEvaluationConfig?: HumanEvaluationConfig, tags?: string[], simulationConfig?: TestRunConfig["simulationConfig"], connectedRepoId?: string): Promise<ExtractAPIDataType<MaximAPICreateTestRunResponse>>;
markTestRunFailed(testRunId: string): Promise<void>;
updateSimulationStatus(testRunEntryId: string, status: "FAILED"): Promise<void>;
attachDatasetToTestRun(testRunId: string, datasetId: string): Promise<void>;
/**
* Checks if a value is already in Variable format.
*/
private isVariable;
/**
* Converts dataEntry values from string/string[] to Variable type format.
* - string -> { type: "text", payload: string }
* - string[] -> { type: "file", payload: UrlAttachment[] }
* - null/undefined -> undefined (skipped)
*/
private convertDataEntryToVariables;
/**
* Normalizes raw dataEntry to Variable format. If any value is a plain string/array,
* converts via convertDataEntryToVariables; otherwise returns the entry as-is (already Variable).
*/
private normalizeDataEntryToVariables;
/**
* Signed upload URL for log-repository attachments (same service as {@link MaximAttachmentAPI}).
*/
private getLogAttachmentUploadUrl;
private uploadBufferToSignedUrl;
private readFileOrFileDataAttachment;
/**
* Resolves a remotely fetchable URL for push payloads: URL attachments pass through;
* local file / in-memory fileData attachments are uploaded via the log attachment pipeline.
*/
private resolveAttachmentUrlForPush;
/**
* Converts Variable format to API format for dataEntry (TEXT / JSON only).
*/
private convertNonFileVariableToAPIFormat;
/**
* Converts a FILE variable to API format, uploading local/fileData attachments first.
*/
private convertFileVariableToAPIFormat;
/**
* Converts dataEntry from Variable format to API format.
* FILE variables upload non-URL attachments before building the payload.
*/
private convertDataEntryToAPIFormat;
createTestRunEntry({ testRun, }: MaximAPITestRunEntryCreatePayload): Promise<ExtractAPIDataType<MaximAPITestRunEntryCreateResponse>>;
pushTestRunEntry({ testRun, runConfig, entry, localSimulation }: MaximAPITestRunEntryPushPayload): Promise<void>;
markTestRunProcessed(testRunId: string): Promise<void>;
getTestRunStatus(testRunId: string): Promise<{
entryStatus: {
total: number;
running: number;
completed: number;
failed: number;
queued: number;
stopped: number;
};
testRunStatus: "QUEUED" | "RUNNING" | "FAILED" | "COMPLETE" | "STOPPED";
}>;
getTestRunFinalResult(testRunId: string): Promise<TestRunResult>;
executeWorkflowForData({ dataEntry, workflowId, contextToEvaluate, }: MaximAPITestRunEntryExecuteWorkflowForDataPayload): Promise<ExtractAPIDataType<MaximAPITestRunEntryExecuteWorkflowForDataResponse>>;
executePromptForData({ promptVersionId, input, dataEntry, contextToEvaluate, simulationConfig, }: MaximAPITestRunEntryExecutePromptForDataPayload): Promise<ExtractAPIDataType<MaximAPITestRunEntryExecutePromptForDataResponse>>;
executePromptChainForData({ promptChainVersionId, input, dataEntry, contextToEvaluate, }: MaximAPITestRunEntryExecutePromptChainForDataPayload): Promise<ExtractAPIDataType<MaximAPITestRunEntryExecutePromptChainForDataResponse>>;
executeSimulationPromptForData({ testRunId, promptVersionId, workspaceId, datasetEntryId, entry, simulationConfig, }: MaximAPITestRunEntryExecuteSimulationPromptPayload): Promise<ExtractAPIDataType<MaximAPITestRunEntryExecuteSimulationPromptPostResponse>>;
getSimulationPromptStatus({ workspaceId, testRunEntryId, }: {
workspaceId: string;
testRunEntryId: string;
}): Promise<ExtractAPIDataType<MaximAPITestRunEntryExecuteSimulationPromptGetResponse>>;
executeSimulationWorkflowForData({ testRunId, workflowId, workspaceId, datasetEntryId, entry, simulationConfig, }: MaximAPITestRunEntryExecuteSimulationWorkflowPayload): Promise<ExtractAPIDataType<MaximAPITestRunEntryExecuteSimulationWorkflowPostResponse>>;
getSimulationWorkflowStatus({ workspaceId, testRunEntryId, }: {
workspaceId: string;
testRunEntryId: string;
}): Promise<ExtractAPIDataType<MaximAPITestRunEntryExecuteSimulationWorkflowGetResponse>>;
executeSimulationLocalExecution({ testRunId, workspaceId, datasetEntryId, entry, simulationConfig, conversationHistory, testRunEntryId, }: MaximAPITestRunSimulationLocalExecutionPayload): Promise<ExtractAPIDataType<MaximAPITestRunSimulationLocalExecutionPostResponse>>;
/**
* Normalize userInput from backend (string|null) to Record<string, unknown>|null.
* Backend returns plain string; SDK consumers expect {input: string}.
*/
private normalizeUserInput;
/**
* Serialize simulationConfig for the backend API.
* Flattens customSimulator fields to top level (matching backend's flat schema).
*/
private serializeSimulationConfig;
}