UNPKG

@latitude-data/sdk

Version:
1,244 lines (1,233 loc) 165 kB
import { ToolResultPart, LanguageModelUsage, FinishReason, TextStreamPart, ToolContent as ToolContent$1 } from 'ai'; import { z } from 'zod'; import { JSONSchema7 } from 'json-schema'; import { AdapterMessageType, Message as Message$1, ProviderAdapter, Config as Config$1, ToolCallContent } from 'promptl-ai'; export { Adapters, ContentType } from 'promptl-ai'; declare enum MessageRole { system = "system", user = "user", assistant = "assistant", tool = "tool" } type PromptlSourceRef = { start: number; end: number; identifier?: string; }; interface IMessageContent { type: string; _promptlSourceMap?: PromptlSourceRef[]; [key: string]: unknown; } type ReasoningContent = IMessageContent & { type: 'reasoning'; text: string; }; type RedactedReasoningContent = IMessageContent & { type: 'redacted-reasoning'; data: string; }; type TextContent = IMessageContent & { type: 'text'; text: string | undefined; }; type ImageContent = IMessageContent & { type: 'image'; image: string | Uint8Array | Buffer | ArrayBuffer | URL; }; type FileContent = IMessageContent & { type: 'file'; file: string | Uint8Array | Buffer | ArrayBuffer | URL; mimeType: string; }; type ToolContent = { type: 'tool-result'; toolCallId: string; toolName: string; result: unknown; isError?: boolean; }; type ToolRequestContent = { type: 'tool-call'; toolCallId: string; toolName: string; args: Record<string, unknown>; }; type MessageContent = FileContent | ImageContent | ReasoningContent | RedactedReasoningContent | TextContent | ToolContent | ToolRequestContent; interface IMessage { role: MessageRole; content: MessageContent[]; [key: string]: unknown; } type SystemMessage = IMessage & { role: MessageRole.system; }; type UserMessage = IMessage & { role: MessageRole.user; name?: string; }; type AssistantMessage = { role: MessageRole.assistant; toolCalls: ToolCall[]; content: string | ToolRequestContent[] | MessageContent[]; }; type ToolMessage = { role: MessageRole.tool; content: (TextContent | ToolContent | ToolResultPart)[]; [key: string]: unknown; }; type ToolCall = { id: string; name: string; arguments: Record<string, unknown>; }; type Message = AssistantMessage | SystemMessage | ToolMessage | UserMessage; type Config = Record<string, unknown>; declare enum ParameterType { Text = "text", Image = "image", File = "file" } type ComparisonFilter = { key: string; type: 'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte'; value: string | number | boolean; }; type CompoundFilter = { filters: Array<ComparisonFilter | CompoundFilter>; type: 'and' | 'or'; }; type Filter = ComparisonFilter | CompoundFilter; declare function latitudePromptConfigSchema({ providerNames, integrationNames, fullPath, agentToolsMap, noOutputSchemaConfig, }: { providerNames: string[]; integrationNames?: string[]; fullPath?: string; agentToolsMap?: AgentToolsMap; noOutputSchemaConfig?: { message: string; }; }): z.ZodObject<{ provider: z.ZodEffects<z.ZodString, string, string>; model: z.ZodString; temperature: z.ZodOptional<z.ZodNumber>; type: z.ZodOptional<z.ZodEnum<["agent"]>>; disableAgentOptimization: z.ZodOptional<z.ZodBoolean>; parameters: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{ type: z.ZodEnum<["array", "boolean", "integer", "null", "number", "object", "string", ParameterType.Text, ParameterType.Image, ParameterType.File]>; description: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { type: "string" | "number" | "boolean" | "object" | "integer" | "null" | "array" | ParameterType; description?: string | undefined; }, { type: "string" | "number" | "boolean" | "object" | "integer" | "null" | "array" | ParameterType; description?: string | undefined; }>>>; maxSteps: z.ZodOptional<z.ZodNumber>; tools: z.ZodOptional<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodObject<{ description: z.ZodString; parameters: z.ZodOptional<z.ZodObject<{ type: z.ZodLiteral<"object">; properties: z.ZodRecord<z.ZodString, z.ZodType<unknown, z.ZodTypeDef, unknown>>; required: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; additionalProperties: z.ZodOptional<z.ZodBoolean>; }, "strip", z.ZodTypeAny, { type: "object"; properties: Record<string, unknown>; required?: string[] | undefined; additionalProperties?: boolean | undefined; }, { type: "object"; properties: Record<string, unknown>; required?: string[] | undefined; additionalProperties?: boolean | undefined; }>>; }, "strip", z.ZodTypeAny, { description: string; parameters?: { type: "object"; properties: Record<string, unknown>; required?: string[] | undefined; additionalProperties?: boolean | undefined; } | undefined; }, { description: string; parameters?: { type: "object"; properties: Record<string, unknown>; required?: string[] | undefined; additionalProperties?: boolean | undefined; } | undefined; }>>, z.ZodRecord<z.ZodLiteral<"openai">, z.ZodArray<z.ZodUnion<[z.ZodObject<{ type: z.ZodEnum<["web_search_preview", "web_search_preview_2025_03_11"]>; search_context_size: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>; user_location: z.ZodOptional<z.ZodObject<{ type: z.ZodLiteral<"approximate">; city: z.ZodOptional<z.ZodString>; country: z.ZodOptional<z.ZodString>; region: z.ZodOptional<z.ZodString>; timezone: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { type: "approximate"; city?: string | undefined; country?: string | undefined; region?: string | undefined; timezone?: string | undefined; }, { type: "approximate"; city?: string | undefined; country?: string | undefined; region?: string | undefined; timezone?: string | undefined; }>>; }, "strip", z.ZodTypeAny, { type: "web_search_preview" | "web_search_preview_2025_03_11"; search_context_size?: "low" | "medium" | "high" | undefined; user_location?: { type: "approximate"; city?: string | undefined; country?: string | undefined; region?: string | undefined; timezone?: string | undefined; } | undefined; }, { type: "web_search_preview" | "web_search_preview_2025_03_11"; search_context_size?: "low" | "medium" | "high" | undefined; user_location?: { type: "approximate"; city?: string | undefined; country?: string | undefined; region?: string | undefined; timezone?: string | undefined; } | undefined; }>, z.ZodObject<{ type: z.ZodLiteral<"file_search">; vector_store_ids: z.ZodArray<z.ZodString, "many">; filters: z.ZodNullable<z.ZodOptional<z.ZodType<Filter, z.ZodTypeDef, Filter>>>; max_num_results: z.ZodOptional<z.ZodNumber>; ranking_options: z.ZodOptional<z.ZodObject<{ ranker: z.ZodOptional<z.ZodEnum<["auto", "default-2024-11-15"]>>; score_threshold: z.ZodOptional<z.ZodNumber>; }, "strip", z.ZodTypeAny, { ranker?: "auto" | "default-2024-11-15" | undefined; score_threshold?: number | undefined; }, { ranker?: "auto" | "default-2024-11-15" | undefined; score_threshold?: number | undefined; }>>; }, "strip", z.ZodTypeAny, { type: "file_search"; vector_store_ids: string[]; filters?: Filter | null | undefined; max_num_results?: number | undefined; ranking_options?: { ranker?: "auto" | "default-2024-11-15" | undefined; score_threshold?: number | undefined; } | undefined; }, { type: "file_search"; vector_store_ids: string[]; filters?: Filter | null | undefined; max_num_results?: number | undefined; ranking_options?: { ranker?: "auto" | "default-2024-11-15" | undefined; score_threshold?: number | undefined; } | undefined; }>, z.ZodObject<{ type: z.ZodLiteral<"computer_use_preview">; display_height: z.ZodNumber; display_width: z.ZodNumber; environment: z.ZodEnum<["windows", "mac", "linux", "ubuntu", "browser"]>; }, "strip", z.ZodTypeAny, { type: "computer_use_preview"; display_height: number; display_width: number; environment: "windows" | "mac" | "linux" | "ubuntu" | "browser"; }, { type: "computer_use_preview"; display_height: number; display_width: number; environment: "windows" | "mac" | "linux" | "ubuntu" | "browser"; }>]>, "many">>, z.ZodArray<z.ZodUnion<[z.ZodRecord<z.ZodString, z.ZodObject<{ description: z.ZodString; parameters: z.ZodOptional<z.ZodObject<{ type: z.ZodLiteral<"object">; properties: z.ZodRecord<z.ZodString, z.ZodType<unknown, z.ZodTypeDef, unknown>>; required: z.ZodOptional<z.ZodArray<z.ZodString, "many">>; additionalProperties: z.ZodOptional<z.ZodBoolean>; }, "strip", z.ZodTypeAny, { type: "object"; properties: Record<string, unknown>; required?: string[] | undefined; additionalProperties?: boolean | undefined; }, { type: "object"; properties: Record<string, unknown>; required?: string[] | undefined; additionalProperties?: boolean | undefined; }>>; }, "strip", z.ZodTypeAny, { description: string; parameters?: { type: "object"; properties: Record<string, unknown>; required?: string[] | undefined; additionalProperties?: boolean | undefined; } | undefined; }, { description: string; parameters?: { type: "object"; properties: Record<string, unknown>; required?: string[] | undefined; additionalProperties?: boolean | undefined; } | undefined; }>>, z.ZodEffects<z.ZodString, string, string>, z.ZodRecord<z.ZodLiteral<"openai">, z.ZodArray<z.ZodUnion<[z.ZodObject<{ type: z.ZodEnum<["web_search_preview", "web_search_preview_2025_03_11"]>; search_context_size: z.ZodOptional<z.ZodEnum<["low", "medium", "high"]>>; user_location: z.ZodOptional<z.ZodObject<{ type: z.ZodLiteral<"approximate">; city: z.ZodOptional<z.ZodString>; country: z.ZodOptional<z.ZodString>; region: z.ZodOptional<z.ZodString>; timezone: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { type: "approximate"; city?: string | undefined; country?: string | undefined; region?: string | undefined; timezone?: string | undefined; }, { type: "approximate"; city?: string | undefined; country?: string | undefined; region?: string | undefined; timezone?: string | undefined; }>>; }, "strip", z.ZodTypeAny, { type: "web_search_preview" | "web_search_preview_2025_03_11"; search_context_size?: "low" | "medium" | "high" | undefined; user_location?: { type: "approximate"; city?: string | undefined; country?: string | undefined; region?: string | undefined; timezone?: string | undefined; } | undefined; }, { type: "web_search_preview" | "web_search_preview_2025_03_11"; search_context_size?: "low" | "medium" | "high" | undefined; user_location?: { type: "approximate"; city?: string | undefined; country?: string | undefined; region?: string | undefined; timezone?: string | undefined; } | undefined; }>, z.ZodObject<{ type: z.ZodLiteral<"file_search">; vector_store_ids: z.ZodArray<z.ZodString, "many">; filters: z.ZodNullable<z.ZodOptional<z.ZodType<Filter, z.ZodTypeDef, Filter>>>; max_num_results: z.ZodOptional<z.ZodNumber>; ranking_options: z.ZodOptional<z.ZodObject<{ ranker: z.ZodOptional<z.ZodEnum<["auto", "default-2024-11-15"]>>; score_threshold: z.ZodOptional<z.ZodNumber>; }, "strip", z.ZodTypeAny, { ranker?: "auto" | "default-2024-11-15" | undefined; score_threshold?: number | undefined; }, { ranker?: "auto" | "default-2024-11-15" | undefined; score_threshold?: number | undefined; }>>; }, "strip", z.ZodTypeAny, { type: "file_search"; vector_store_ids: string[]; filters?: Filter | null | undefined; max_num_results?: number | undefined; ranking_options?: { ranker?: "auto" | "default-2024-11-15" | undefined; score_threshold?: number | undefined; } | undefined; }, { type: "file_search"; vector_store_ids: string[]; filters?: Filter | null | undefined; max_num_results?: number | undefined; ranking_options?: { ranker?: "auto" | "default-2024-11-15" | undefined; score_threshold?: number | undefined; } | undefined; }>, z.ZodObject<{ type: z.ZodLiteral<"computer_use_preview">; display_height: z.ZodNumber; display_width: z.ZodNumber; environment: z.ZodEnum<["windows", "mac", "linux", "ubuntu", "browser"]>; }, "strip", z.ZodTypeAny, { type: "computer_use_preview"; display_height: number; display_width: number; environment: "windows" | "mac" | "linux" | "ubuntu" | "browser"; }, { type: "computer_use_preview"; display_height: number; display_width: number; environment: "windows" | "mac" | "linux" | "ubuntu" | "browser"; }>]>, "many">>]>, "many">]>>; agents: z.ZodOptional<z.ZodNever> | z.ZodOptional<z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">>; schema: z.ZodOptional<z.ZodType<unknown, z.ZodTypeDef, unknown>>; azure: z.ZodOptional<z.ZodObject<{ resourceName: z.ZodOptional<z.ZodString>; apiKey: z.ZodOptional<z.ZodString>; apiVersion: z.ZodOptional<z.ZodString>; baseUrl: z.ZodOptional<z.ZodString>; headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>; }, "strip", z.ZodTypeAny, { resourceName?: string | undefined; apiKey?: string | undefined; apiVersion?: string | undefined; baseUrl?: string | undefined; headers?: Record<string, string> | undefined; }, { resourceName?: string | undefined; apiKey?: string | undefined; apiVersion?: string | undefined; baseUrl?: string | undefined; headers?: Record<string, string> | undefined; }>>; }, "strip", z.ZodTypeAny, { provider: string; model: string; tools?: Record<string, { description: string; parameters?: { type: "object"; properties: Record<string, unknown>; required?: string[] | undefined; additionalProperties?: boolean | undefined; } | undefined; }> | Partial<Record<"openai", ({ type: "web_search_preview" | "web_search_preview_2025_03_11"; search_context_size?: "low" | "medium" | "high" | undefined; user_location?: { type: "approximate"; city?: string | undefined; country?: string | undefined; region?: string | undefined; timezone?: string | undefined; } | undefined; } | { type: "file_search"; vector_store_ids: string[]; filters?: Filter | null | undefined; max_num_results?: number | undefined; ranking_options?: { ranker?: "auto" | "default-2024-11-15" | undefined; score_threshold?: number | undefined; } | undefined; } | { type: "computer_use_preview"; display_height: number; display_width: number; environment: "windows" | "mac" | "linux" | "ubuntu" | "browser"; })[]>> | (string | Record<string, { description: string; parameters?: { type: "object"; properties: Record<string, unknown>; required?: string[] | undefined; additionalProperties?: boolean | undefined; } | undefined; }> | Partial<Record<"openai", ({ type: "web_search_preview" | "web_search_preview_2025_03_11"; search_context_size?: "low" | "medium" | "high" | undefined; user_location?: { type: "approximate"; city?: string | undefined; country?: string | undefined; region?: string | undefined; timezone?: string | undefined; } | undefined; } | { type: "file_search"; vector_store_ids: string[]; filters?: Filter | null | undefined; max_num_results?: number | undefined; ranking_options?: { ranker?: "auto" | "default-2024-11-15" | undefined; score_threshold?: number | undefined; } | undefined; } | { type: "computer_use_preview"; display_height: number; display_width: number; environment: "windows" | "mac" | "linux" | "ubuntu" | "browser"; })[]>>)[] | undefined; parameters?: Record<string, { type: "string" | "number" | "boolean" | "object" | "integer" | "null" | "array" | ParameterType; description?: string | undefined; }> | undefined; type?: "agent" | undefined; maxSteps?: number | undefined; schema?: unknown; temperature?: number | undefined; disableAgentOptimization?: boolean | undefined; agents?: string[] | undefined; azure?: { resourceName?: string | undefined; apiKey?: string | undefined; apiVersion?: string | undefined; baseUrl?: string | undefined; headers?: Record<string, string> | undefined; } | undefined; }, { provider: string; model: string; tools?: Record<string, { description: string; parameters?: { type: "object"; properties: Record<string, unknown>; required?: string[] | undefined; additionalProperties?: boolean | undefined; } | undefined; }> | Partial<Record<"openai", ({ type: "web_search_preview" | "web_search_preview_2025_03_11"; search_context_size?: "low" | "medium" | "high" | undefined; user_location?: { type: "approximate"; city?: string | undefined; country?: string | undefined; region?: string | undefined; timezone?: string | undefined; } | undefined; } | { type: "file_search"; vector_store_ids: string[]; filters?: Filter | null | undefined; max_num_results?: number | undefined; ranking_options?: { ranker?: "auto" | "default-2024-11-15" | undefined; score_threshold?: number | undefined; } | undefined; } | { type: "computer_use_preview"; display_height: number; display_width: number; environment: "windows" | "mac" | "linux" | "ubuntu" | "browser"; })[]>> | (string | Record<string, { description: string; parameters?: { type: "object"; properties: Record<string, unknown>; required?: string[] | undefined; additionalProperties?: boolean | undefined; } | undefined; }> | Partial<Record<"openai", ({ type: "web_search_preview" | "web_search_preview_2025_03_11"; search_context_size?: "low" | "medium" | "high" | undefined; user_location?: { type: "approximate"; city?: string | undefined; country?: string | undefined; region?: string | undefined; timezone?: string | undefined; } | undefined; } | { type: "file_search"; vector_store_ids: string[]; filters?: Filter | null | undefined; max_num_results?: number | undefined; ranking_options?: { ranker?: "auto" | "default-2024-11-15" | undefined; score_threshold?: number | undefined; } | undefined; } | { type: "computer_use_preview"; display_height: number; display_width: number; environment: "windows" | "mac" | "linux" | "ubuntu" | "browser"; })[]>>)[] | undefined; parameters?: Record<string, { type: "string" | "number" | "boolean" | "object" | "integer" | "null" | "array" | ParameterType; description?: string | undefined; }> | undefined; type?: "agent" | undefined; maxSteps?: number | undefined; schema?: unknown; temperature?: number | undefined; disableAgentOptimization?: boolean | undefined; agents?: string[] | undefined; azure?: { resourceName?: string | undefined; apiKey?: string | undefined; apiVersion?: string | undefined; baseUrl?: string | undefined; headers?: Record<string, string> | undefined; } | undefined; }>; type InferredSchema = z.infer<Omit<ReturnType<typeof latitudePromptConfigSchema>, 'schema'>>; type LatitudePromptConfig = Omit<InferredSchema, 'schema'> & { schema?: JSONSchema7; }; declare enum LatitudeErrorCodes { UnexpectedError = "UnexpectedError", OverloadedError = "OverloadedError", RateLimitError = "RateLimitError", UnauthorizedError = "UnauthorizedError", ForbiddenError = "ForbiddenError", BadRequestError = "BadRequestError", NotFoundError = "NotFoundError", ConflictError = "ConflictError", UnprocessableEntityError = "UnprocessableEntityError", NotImplementedError = "NotImplementedError" } type LatitudeErrorDetails = { [key: string | number | symbol]: string[] | string | undefined; }; declare enum RunErrorCodes { AIProviderConfigError = "ai_provider_config_error", AIRunError = "ai_run_error", ChainCompileError = "chain_compile_error", DefaultProviderExceededQuota = "default_provider_exceeded_quota_error", DefaultProviderInvalidModel = "default_provider_invalid_model_error", DocumentConfigError = "document_config_error", ErrorGeneratingMockToolResult = "error_generating_mock_tool_result", EvaluationRunMissingProviderLogError = "ev_run_missing_provider_log_error",// TODO(evalsv2): Deprecated, remove when v1 evals are migrated EvaluationRunMissingWorkspaceError = "ev_run_missing_workspace_error",// TODO(evalsv2): Deprecated, remove when v1 evals are migrated EvaluationRunResponseJsonFormatError = "ev_run_response_json_format_error",// TODO(evalsv2): Deprecated, remove when v1 evals are migrated EvaluationRunUnsupportedResultTypeError = "ev_run_unsupported_result_type_error",// TODO(evalsv2): Deprecated, remove when v1 evals are migrated FailedToWakeUpIntegrationError = "failed_to_wake_up_integration_error", InvalidResponseFormatError = "invalid_response_format_error", MaxStepCountExceededError = "max_step_count_exceeded_error", MissingProvider = "missing_provider_error", RateLimit = "rate_limit_error", Unknown = "unknown_error", UnsupportedProviderResponseTypeError = "unsupported_provider_response_type_error" } type RunErrorDetails<C extends RunErrorCodes> = C extends RunErrorCodes.ChainCompileError ? { compileCode: string; message: string; } : C extends RunErrorCodes.Unknown ? { stack: string; } : never; declare enum ApiErrorCodes { HTTPException = "http_exception", InternalServerError = "internal_server_error" } type DbErrorRef = { entityUuid: string; entityType: string; }; type ApiResponseCode = RunErrorCodes | ApiErrorCodes | LatitudeErrorCodes; declare class LatitudeError extends Error { statusCode: number; name: string; headers: Record<string, string>; details: LatitudeErrorDetails; constructor(message: string, details?: LatitudeErrorDetails); } declare class UnprocessableEntityError extends LatitudeError { statusCode: number; name: LatitudeErrorCodes; constructor(message: string, details?: LatitudeErrorDetails); } declare class ChainError<T extends RunErrorCodes, RunError = object> extends UnprocessableEntityError { errorCode: T; details: LatitudeErrorDetails; runError?: RunError; constructor({ message, code, details, stack, }: { message: string; code: T; details?: RunErrorDetails<T>; stack?: string; }); get dbError(): RunError | undefined; set dbError(error: RunError); get code(): T; } declare enum ChainEventTypes { ChainCompleted = "chain-completed", ChainError = "chain-error", ChainStarted = "chain-started", IntegrationWakingUp = "integration-waking-up", ProviderCompleted = "provider-completed", ProviderStarted = "provider-started", StepCompleted = "step-completed", StepStarted = "step-started", ToolCompleted = "tool-completed", ToolsRequested = "tools-requested",// TODO(compiler): remove ToolResult = "tool-result", ToolsStarted = "tools-started" } interface GenericLatitudeEventData { type: ChainEventTypes; messages: Message[]; uuid: string; } interface LatitudeChainStartedEventData extends GenericLatitudeEventData { type: ChainEventTypes.ChainStarted; } interface LatitudeStepStartedEventData extends GenericLatitudeEventData { type: ChainEventTypes.StepStarted; } interface LatitudeProviderStartedEventData extends GenericLatitudeEventData { type: ChainEventTypes.ProviderStarted; config: Config; } interface LatitudeProviderCompletedEventData extends GenericLatitudeEventData { type: ChainEventTypes.ProviderCompleted; providerLogUuid: string; tokenUsage: LanguageModelUsage; finishReason: FinishReason; response: ChainStepResponse<StreamType>; } interface LatitudeToolsStartedEventData extends GenericLatitudeEventData { type: ChainEventTypes.ToolsStarted; tools: ToolCall[]; } interface LatitudeToolCompletedEventData extends GenericLatitudeEventData { type: ChainEventTypes.ToolCompleted; } interface LatitudeStepCompletedEventData extends GenericLatitudeEventData { type: ChainEventTypes.StepCompleted; } interface LatitudeChainCompletedEventData extends GenericLatitudeEventData { type: ChainEventTypes.ChainCompleted; tokenUsage: LanguageModelUsage; finishReason: FinishReason; } interface LatitudeChainErrorEventData extends GenericLatitudeEventData { type: ChainEventTypes.ChainError; error: Error | ChainError<RunErrorCodes>; } interface LatitudeIntegrationWakingUpEventData extends GenericLatitudeEventData { type: ChainEventTypes.IntegrationWakingUp; integrationName: string; } type LatitudeEventData = LatitudeChainStartedEventData | LatitudeStepStartedEventData | LatitudeProviderStartedEventData | LatitudeProviderCompletedEventData | LatitudeToolsStartedEventData | LatitudeToolCompletedEventData | LatitudeStepCompletedEventData | LatitudeChainCompletedEventData | LatitudeChainErrorEventData | LatitudeIntegrationWakingUpEventData; declare enum LogSources$1 { API = "api", AgentAsTool = "agent_as_tool", Copilot = "copilot", EmailTrigger = "email_trigger", Evaluation = "evaluation", Experiment = "experiment", IntegrationTrigger = "integration_trigger", Playground = "playground", ScheduledTrigger = "scheduled_trigger", SharedPrompt = "shared_prompt", User = "user" } type DocumentLog = { id: number; uuid: string; documentUuid: string; commitId: number; resolvedContent: string; contentHash: string; parameters: Record<string, unknown>; customIdentifier: string | null; duration: number | null; source: LogSources$1 | null; createdAt: Date; updatedAt: Date; experimentId: number | null; }; type ProviderLog = { id: number; uuid: string; documentLogUuid: string | null; providerId: number | null; model: string | null; finishReason: string | null; config: PartialPromptConfig | null; messages: Message[]; responseObject: unknown | null; responseText: string | null; toolCalls: ToolCall[]; tokens: number | null; costInMillicents: number | null; duration: number | null; source: LogSources$1 | null; apiKeyId: number | null; generatedAt: Date | null; updatedAt: Date; }; type AgentToolsMap = Record<string, string>; type PartialPromptConfig = Omit<LatitudePromptConfig, 'provider'>; type ProviderData = TextStreamPart<any>; type ChainEventDto = ProviderData | LatitudeEventData; type AssertedStreamType = 'text' | Record<string | symbol, unknown>; type ChainCallResponseDto<S extends AssertedStreamType = 'text'> = S extends 'text' ? ChainStepTextResponse : S extends Record<string | symbol, unknown> ? ChainStepObjectResponse<S> : never; type StreamType = 'object' | 'text'; type BaseResponse = { text: string; usage: LanguageModelUsage; documentLogUuid?: string; providerLog?: ProviderLog; output?: (AssistantMessage | { role: 'tool'; content: ToolContent$1; })[]; }; type ChainStepTextResponse = BaseResponse & { streamType: 'text'; reasoning?: string | undefined; toolCalls: ToolCall[]; }; type ChainStepObjectResponse<S extends Record<string, unknown> = any> = BaseResponse & { streamType: 'object'; object: S; }; type ChainStepResponse<T extends StreamType> = T extends 'text' ? ChainStepTextResponse : T extends 'object' ? ChainStepObjectResponse : never; declare enum StreamEventTypes { Latitude = "latitude-event", Provider = "provider-event" } declare const toolCallResponseSchema: z.ZodObject<{ id: z.ZodString; name: z.ZodString; result: z.ZodUnknown; isError: z.ZodOptional<z.ZodBoolean>; text: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { name: string; id: string; result?: unknown; isError?: boolean | undefined; text?: string | undefined; }, { name: string; id: string; result?: unknown; isError?: boolean | undefined; text?: string | undefined; }>; type ToolCallResponse = z.infer<typeof toolCallResponseSchema>; declare const HumanEvaluationBinarySpecification: { readonly name: "Binary"; readonly description: "Judges whether the response meets the criteria. The resulting score is \"passed\" or \"failed\""; readonly configuration: z.ZodObject<z.objectUtil.extendShape<z.objectUtil.extendShape<{ reverseScale: z.ZodBoolean; actualOutput: z.ZodOptional<z.ZodObject<{ messageSelection: z.ZodEnum<["last", "all"]>; contentFilter: z.ZodOptional<z.ZodEnum<["text", "image", "file", "tool_call"]>>; parsingFormat: z.ZodEnum<["string", "json"]>; fieldAccessor: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { messageSelection: "last" | "all"; parsingFormat: "string" | "json"; contentFilter?: "text" | "image" | "file" | "tool_call" | undefined; fieldAccessor?: string | undefined; }, { messageSelection: "last" | "all"; parsingFormat: "string" | "json"; contentFilter?: "text" | "image" | "file" | "tool_call" | undefined; fieldAccessor?: string | undefined; }>>; expectedOutput: z.ZodOptional<z.ZodObject<{ parsingFormat: z.ZodEnum<["string", "json"]>; fieldAccessor: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { parsingFormat: "string" | "json"; fieldAccessor?: string | undefined; }, { parsingFormat: "string" | "json"; fieldAccessor?: string | undefined; }>>; }, { criteria: z.ZodOptional<z.ZodString>; }>, { passDescription: z.ZodOptional<z.ZodString>; failDescription: z.ZodOptional<z.ZodString>; }>, "strip", z.ZodTypeAny, { reverseScale: boolean; actualOutput?: { messageSelection: "last" | "all"; parsingFormat: "string" | "json"; contentFilter?: "text" | "image" | "file" | "tool_call" | undefined; fieldAccessor?: string | undefined; } | undefined; expectedOutput?: { parsingFormat: "string" | "json"; fieldAccessor?: string | undefined; } | undefined; criteria?: string | undefined; passDescription?: string | undefined; failDescription?: string | undefined; }, { reverseScale: boolean; actualOutput?: { messageSelection: "last" | "all"; parsingFormat: "string" | "json"; contentFilter?: "text" | "image" | "file" | "tool_call" | undefined; fieldAccessor?: string | undefined; } | undefined; expectedOutput?: { parsingFormat: "string" | "json"; fieldAccessor?: string | undefined; } | undefined; criteria?: string | undefined; passDescription?: string | undefined; failDescription?: string | undefined; }>; readonly resultMetadata: z.ZodObject<z.objectUtil.extendShape<z.objectUtil.extendShape<{ actualOutput: z.ZodString; expectedOutput: z.ZodOptional<z.ZodString>; datasetLabel: z.ZodOptional<z.ZodString>; }, { reason: z.ZodOptional<z.ZodString>; }>, { configuration: z.ZodObject<z.objectUtil.extendShape<z.objectUtil.extendShape<{ reverseScale: z.ZodBoolean; actualOutput: z.ZodOptional<z.ZodObject<{ messageSelection: z.ZodEnum<["last", "all"]>; contentFilter: z.ZodOptional<z.ZodEnum<["text", "image", "file", "tool_call"]>>; parsingFormat: z.ZodEnum<["string", "json"]>; fieldAccessor: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { messageSelection: "last" | "all"; parsingFormat: "string" | "json"; contentFilter?: "text" | "image" | "file" | "tool_call" | undefined; fieldAccessor?: string | undefined; }, { messageSelection: "last" | "all"; parsingFormat: "string" | "json"; contentFilter?: "text" | "image" | "file" | "tool_call" | undefined; fieldAccessor?: string | undefined; }>>; expectedOutput: z.ZodOptional<z.ZodObject<{ parsingFormat: z.ZodEnum<["string", "json"]>; fieldAccessor: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { parsingFormat: "string" | "json"; fieldAccessor?: string | undefined; }, { parsingFormat: "string" | "json"; fieldAccessor?: string | undefined; }>>; }, { criteria: z.ZodOptional<z.ZodString>; }>, { passDescription: z.ZodOptional<z.ZodString>; failDescription: z.ZodOptional<z.ZodString>; }>, "strip", z.ZodTypeAny, { reverseScale: boolean; actualOutput?: { messageSelection: "last" | "all"; parsingFormat: "string" | "json"; contentFilter?: "text" | "image" | "file" | "tool_call" | undefined; fieldAccessor?: string | undefined; } | undefined; expectedOutput?: { parsingFormat: "string" | "json"; fieldAccessor?: string | undefined; } | undefined; criteria?: string | undefined; passDescription?: string | undefined; failDescription?: string | undefined; }, { reverseScale: boolean; actualOutput?: { messageSelection: "last" | "all"; parsingFormat: "string" | "json"; contentFilter?: "text" | "image" | "file" | "tool_call" | undefined; fieldAccessor?: string | undefined; } | undefined; expectedOutput?: { parsingFormat: "string" | "json"; fieldAccessor?: string | undefined; } | undefined; criteria?: string | undefined; passDescription?: string | undefined; failDescription?: string | undefined; }>; }>, "strip", z.ZodTypeAny, { actualOutput: string; configuration: { reverseScale: boolean; actualOutput?: { messageSelection: "last" | "all"; parsingFormat: "string" | "json"; contentFilter?: "text" | "image" | "file" | "tool_call" | undefined; fieldAccessor?: string | undefined; } | undefined; expectedOutput?: { parsingFormat: "string" | "json"; fieldAccessor?: string | undefined; } | undefined; criteria?: string | undefined; passDescription?: string | undefined; failDescription?: string | undefined; }; expectedOutput?: string | undefined; datasetLabel?: string | undefined; reason?: string | undefined; }, { actualOutput: string; configuration: { reverseScale: boolean; actualOutput?: { messageSelection: "last" | "all"; parsingFormat: "string" | "json"; contentFilter?: "text" | "image" | "file" | "tool_call" | undefined; fieldAccessor?: string | undefined; } | undefined; expectedOutput?: { parsingFormat: "string" | "json"; fieldAccessor?: string | undefined; } | undefined; criteria?: string | undefined; passDescription?: string | undefined; failDescription?: string | undefined; }; expectedOutput?: string | undefined; datasetLabel?: string | undefined; reason?: string | undefined; }>; readonly resultError: z.ZodObject<z.objectUtil.extendShape<z.objectUtil.extendShape<{ message: z.ZodString; }, {}>, {}>, "strip", z.ZodTypeAny, { message: string; }, { message: string; }>; readonly requiresExpectedOutput: false; readonly supportsLiveEvaluation: false; readonly supportsBatchEvaluation: false; readonly supportsManualEvaluation: true; }; type HumanEvaluationBinaryResultMetadata = z.infer<typeof HumanEvaluationBinarySpecification.resultMetadata>; type HumanEvaluationBinaryResultError = z.infer<typeof HumanEvaluationBinarySpecification.resultError>; declare const HumanEvaluationRatingSpecification: { readonly name: "Rating"; readonly description: "Judges the response by rating it under a criteria. The resulting score is the rating"; readonly configuration: z.ZodObject<z.objectUtil.extendShape<z.objectUtil.extendShape<{ reverseScale: z.ZodBoolean; actualOutput: z.ZodOptional<z.ZodObject<{ messageSelection: z.ZodEnum<["last", "all"]>; contentFilter: z.ZodOptional<z.ZodEnum<["text", "image", "file", "tool_call"]>>; parsingFormat: z.ZodEnum<["string", "json"]>; fieldAccessor: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { messageSelection: "last" | "all"; parsingFormat: "string" | "json"; contentFilter?: "text" | "image" | "file" | "tool_call" | undefined; fieldAccessor?: string | undefined; }, { messageSelection: "last" | "all"; parsingFormat: "string" | "json"; contentFilter?: "text" | "image" | "file" | "tool_call" | undefined; fieldAccessor?: string | undefined; }>>; expectedOutput: z.ZodOptional<z.ZodObject<{ parsingFormat: z.ZodEnum<["string", "json"]>; fieldAccessor: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { parsingFormat: "string" | "json"; fieldAccessor?: string | undefined; }, { parsingFormat: "string" | "json"; fieldAccessor?: string | undefined; }>>; }, { criteria: z.ZodOptional<z.ZodString>; }>, { minRating: z.ZodNumber; minRatingDescription: z.ZodOptional<z.ZodString>; maxRating: z.ZodNumber; maxRatingDescription: z.ZodOptional<z.ZodString>; minThreshold: z.ZodOptional<z.ZodNumber>; maxThreshold: z.ZodOptional<z.ZodNumber>; }>, "strip", z.ZodTypeAny, { reverseScale: boolean; minRating: number; maxRating: number; actualOutput?: { messageSelection: "last" | "all"; parsingFormat: "string" | "json"; contentFilter?: "text" | "image" | "file" | "tool_call" | undefined; fieldAccessor?: string | undefined; } | undefined; expectedOutput?: { parsingFormat: "string" | "json"; fieldAccessor?: string | undefined; } | undefined; criteria?: string | undefined; minRatingDescription?: string | undefined; maxRatingDescription?: string | undefined; minThreshold?: number | undefined; maxThreshold?: number | undefined; }, { reverseScale: boolean; minRating: number; maxRating: number; actualOutput?: { messageSelection: "last" | "all"; parsingFormat: "string" | "json"; contentFilter?: "text" | "image" | "file" | "tool_call" | undefined; fieldAccessor?: string | undefined; } | undefined; expectedOutput?: { parsingFormat: "string" | "json"; fieldAccessor?: string | undefined; } | undefined; criteria?: string | undefined; minRatingDescription?: string | undefined; maxRatingDescription?: string | undefined; minThreshold?: number | undefined; maxThreshold?: number | undefined; }>; readonly resultMetadata: z.ZodObject<z.objectUtil.extendShape<z.objectUtil.extendShape<{ actualOutput: z.ZodString; expectedOutput: z.ZodOptional<z.ZodString>; datasetLabel: z.ZodOptional<z.ZodString>; }, { reason: z.ZodOptional<z.ZodString>; }>, { configuration: z.ZodObject<z.objectUtil.extendShape<z.objectUtil.extendShape<{ reverseScale: z.ZodBoolean; actualOutput: z.ZodOptional<z.ZodObject<{ messageSelection: z.ZodEnum<["last", "all"]>; contentFilter: z.ZodOptional<z.ZodEnum<["text", "image", "file", "tool_call"]>>; parsingFormat: z.ZodEnum<["string", "json"]>; fieldAccessor: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { messageSelection: "last" | "all"; parsingFormat: "string" | "json"; contentFilter?: "text" | "image" | "file" | "tool_call" | undefined; fieldAccessor?: string | undefined; }, { messageSelection: "last" | "all"; parsingFormat: "string" | "json"; contentFilter?: "text" | "image" | "file" | "tool_call" | undefined; fieldAccessor?: string | undefined; }>>; expectedOutput: z.ZodOptional<z.ZodObject<{ parsingFormat: z.ZodEnum<["string", "json"]>; fieldAccessor: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { parsingFormat: "string" | "json"; fieldAccessor?: string | undefined; }, { parsingFormat: "string" | "json"; fieldAccessor?: string | undefined; }>>; }, { criteria: z.ZodOptional<z.ZodString>; }>, { minRating: z.ZodNumber; minRatingDescription: z.ZodOptional<z.ZodString>; maxRating: z.ZodNumber; maxRatingDescription: z.ZodOptional<z.ZodString>; minThreshold: z.ZodOptional<z.ZodNumber>; maxThreshold: z.ZodOptional<z.ZodNumber>; }>, "strip", z.ZodTypeAny, { reverseScale: boolean; minRating: number; maxRating: number; actualOutput?: { messageSelection: "last" | "all"; parsingFormat: "string" | "json"; contentFilter?: "text" | "image" | "file" | "tool_call" | undefined; fieldAccessor?: string | undefined; } | undefined; expectedOutput?: { parsingFormat: "string" | "json"; fieldAccessor?: string | undefined; } | undefined; criteria?: string | undefined; minRatingDescription?: string | undefined; maxRatingDescription?: string | undefined; minThreshold?: number | undefined; maxThreshold?: number | undefined; }, { reverseScale: boolean; minRating: number; maxRating: number; actualOutput?: { messageSelection: "last" | "all"; parsingFormat: "string" | "json"; contentFilter?: "text" | "image" | "file" | "tool_call" | undefined; fieldAccessor?: string | undefined; } | undefined; expectedOutput?: { parsingFormat: "string" | "json"; fieldAccessor?: string | undefined; } | undefined; criteria?: string | undefined; minRatingDescription?: string | undefined; maxRatingDescription?: string | undefined; minThreshold?: number | undefined; maxThreshold?: number | undefined; }>; }>, "strip", z.ZodTypeAny, { actualOutput: string; configuration: { reverseScale: boolean; minRating: number; maxRating: number; actualOutput?: { messageSelection: "last" | "all"; parsingFormat: "string" | "json"; contentFilter?: "text" | "image" | "file" | "tool_call" | undefined; fieldAccessor?: string | undefined; } | undefined; expectedOutput?: { parsingFormat: "string" | "json"; fieldAccessor?: string | undefined; } | undefined; criteria?: string | undefined; minRatingDescription?: string | undefined; maxRatingDescription?: string | undefined; minThreshold?: number | undefined; maxThreshold?: number | undefined; }; expectedOutput?: string | undefined; datasetLabel?: string | undefined; reason?: string | undefined; }, { actualOutput: string; configuration: { reverseScale: boolean; minRating: number; maxRating: number; actualOutput?: { messageSelection: "last" | "all"; parsingFormat: "string" | "json"; contentFilter?: "text" | "image" | "file" | "tool_call" | undefined; fieldAccessor?: string | undefined; } | undefined; expectedOutput?: { parsingFormat: "string" | "json"; fieldAccessor?: string | undefined; } | undefined; criteria?: string | undefined; minRatingDescription?: string | undefined; maxRatingDescription?: string | undefined; minThreshold?: number | undefined; maxThreshold?: number | undefined; }; expectedOutput?: string | undefined; datasetLabel?: string | undefined; reason?: string | undefined; }>; readonly resultError: z.ZodObject<z.objectUtil.extendShape<z.objectUtil.extendShape<{ message: z.ZodString; }, {}>, {}>, "strip", z.ZodTypeAny, { message: string; }, { message: string; }>; readonly requiresExpectedOutput: false; readonly supportsLiveEvaluation: false; readonly supportsBatchEvaluation: false; readonly supportsManualEvaluation: true; }; type HumanEvaluationRatingResultMetadata = z.infer<typeof HumanEvaluationRatingSpecification.resultMetadata>; type HumanEvaluationRatingResultError = z.infer<typeof HumanEvaluationRatingSpecification.resultError>; declare enum HumanEvaluationMetric { Binary = "binary", Rating = "rating" } type HumanEvaluationResultMetadata<M extends HumanEvaluationMetric = HumanEvaluationMetric> = M extends HumanEvaluationMetric.Binary ? HumanEvaluationBinaryResultMetadata : M extends HumanEvaluationMetric.Rating ? HumanEvaluationRatingResultMetadata : never; type HumanEvaluationResultError<M extends HumanEvaluationMetric = HumanEvaluationMetric> = M extends HumanEvaluationMetric.Binary ? HumanEvaluationBinaryResultError : M extends HumanEvaluationMetri