Member Junction
    Preparing search index...

    Interface AIPromptRunResult<T>

    Result of an AI prompt execution with generic type for the result

    interface AIPromptRunResult<T = unknown> {
        additionalResults?: AIPromptRunResult<T>[];
        cacheInfo?: { cacheHit: boolean; cacheKey?: string; cacheSource?: string };
        cancellationReason?: CancellationReason;
        cancelled?: boolean;
        chatResult: ChatResult;
        combinedCompletionTokens?: number;
        combinedCost?: number;
        combinedPromptTokens?: number;
        combinedTokensUsed?: number;
        completionTokens?: number;
        cost?: number;
        costCurrency?: string;
        errorMessage?: string;
        executionTimeMS?: number;
        judgeMetadata?: JudgeMetadata;
        judgeRationale?: string;
        media?: PromptRunMediaReference[];
        modelInfo?: ModelInfo;
        modelSelectionInfo?: AIModelSelectionInfo;
        promptRun?: MJAIPromptRunEntity;
        promptTokens?: number;
        ranking?: number;
        rawResult?: string;
        result?: T;
        status?: ExecutionStatus;
        success: boolean;
        tokensUsed?: number;
        validationAttempts?: ValidationAttempt[];
        validationResult?: any;
        wasStreamed?: boolean;
    }

    Type Parameters

    • T = unknown
    Index

    Properties

    additionalResults?: AIPromptRunResult<T>[]

    Additional results from parallel execution, ranked by judge Index 0 = second best, Index 1 = third best, etc. (The best result is the main result object itself)

    cacheInfo?: { cacheHit: boolean; cacheKey?: string; cacheSource?: string }

    Cache information if caching was involved

    cancellationReason?: CancellationReason

    Reason for cancellation if applicable

    cancelled?: boolean

    Whether the execution was cancelled

    chatResult: ChatResult

    The ChatResult object containing the full response from the AI model, many of the properties of this object are included in the result object

    combinedCompletionTokens?: number

    For hierarchical prompts: Combined completion tokens including all child prompts. This provides a rollup of all completion tokens generated in the entire execution tree.

    combinedCost?: number

    For hierarchical prompts: Combined cost including all child prompts. This provides a rollup of all costs in the entire execution tree. The currency should match the costCurrency field.

    combinedPromptTokens?: number

    For hierarchical prompts: Combined prompt tokens including all child prompts. This provides a rollup of all prompt tokens used in the entire execution tree.

    combinedTokensUsed?: number

    For hierarchical prompts: Combined total tokens (combinedPromptTokens + combinedCompletionTokens). Note: This is a computed value - when creating objects, you don't need to set this.

    Use combinedPromptTokens and combinedCompletionTokens separately for clarity

    completionTokens?: number

    Number of tokens generated in the completion/output. This follows the ModelUsage convention from @memberjunction/ai

    cost?: number

    Cost of this execution if provided by the AI provider. The currency is specified in the costCurrency field.

    costCurrency?: string

    ISO 4217 currency code for the cost field. Examples: 'USD', 'EUR', 'GBP', 'JPY', etc.

    errorMessage?: string

    Error message if execution failed

    executionTimeMS?: number

    Total execution time in milliseconds

    judgeMetadata?: JudgeMetadata

    Metadata about the judging process (only present on the main result)

    judgeRationale?: string

    Judge's rationale for this ranking

    Media generated during this prompt execution. Contains references to AIPromptRunMedia records with full metadata. This provides complete audit trail of all generated media.

    3.1.0

    modelInfo?: ModelInfo

    Model information for this result

    modelSelectionInfo?: AIModelSelectionInfo

    Model selection information for debugging and analysis

    The AIPromptRun entity that was created for tracking

    promptTokens?: number

    Number of tokens used in the prompt/input. This follows the ModelUsage convention from @memberjunction/ai

    ranking?: number

    Ranking assigned by judge (1 = best, 2 = second best, etc.)

    rawResult?: string

    The raw result from the AI model

    result?: T

    The parsed/validated result based on OutputType

    Current execution status

    success: boolean

    Whether the execution was successful

    tokensUsed?: number

    Total tokens used (promptTokens + completionTokens). Note: This is a computed value - when creating objects, you don't need to set this.

    Use promptTokens and completionTokens separately for clarity

    validationAttempts?: ValidationAttempt[]

    Detailed information about all validation attempts made

    validationResult?: any

    Validation result if output validation was performed

    wasStreamed?: boolean

    Whether streaming was used for this execution