Interface LDAIConfigTracker

The LDAIConfigTracker is used to track various details about AI operations.

Hierarchy

  • LDAIConfigTracker

Methods

  • Track an operation which uses Bedrock.

    This function will track the duration of the operation, the token usage, and the success or error status.

    Type Parameters

    • TRes extends {
          $metadata: {
              httpStatusCode?: number;
          };
          metrics?: {
              latencyMs?: number;
          };
          usage?: {
              inputTokens?: number;
              outputTokens?: number;
              totalTokens?: number;
          };
      }

    Parameters

    • res: TRes

      The result of the Bedrock operation.

    Returns TRes

    The input operation.

  • Track the duration of generation.

    Ideally this would not include overhead time such as network communication.

    Parameters

    • durationMs: number

      The duration in milliseconds.

    Returns void

  • Track the duration of execution of the provided function.

    If the provided function throws, then this method will also throw. In the case the provided function throws, this function will still record the duration.

    This function does not automatically record an error when the function throws.

    Parameters

    • func: (() => Promise<any>)

      The function to track the duration of.

        • (): Promise<any>
        • Returns Promise<any>

    Returns Promise<any>

    The result of the function.

  • Track an OpenAI operation.

    This function will track the duration of the operation, the token usage, and the success or error status.

    If the provided function throws, then this method will also throw. In the case the provided function throws, this function will record the duration and an error. A failed operation will not have any token usage data.

    Type Parameters

    • TRes extends {
          usage?: {
              completion_tokens?: number;
              prompt_tokens?: number;
              total_tokens?: number;
          };
      }

    Parameters

    • func: (() => Promise<TRes>)

      Function which executes the operation.

        • (): Promise<TRes>
        • Returns Promise<TRes>

    Returns Promise<TRes>

    The result of the operation.

  • Track the time to first token for this generation.

    Parameters

    • timeToFirstTokenMs: number

      The duration in milliseconds.

    Returns void

Generated using TypeDoc