@nevermined-io/payments
    Preparing search index...

    Function withHeliconeLogging

    • Wraps an async operation with Helicone logging

      Type Parameters

      • TInternal = any
      • TExtracted = any

      Parameters

      • agentName: string

        Name of the agent for logging purposes

      • payloadConfig: HeliconePayloadConfig

        Configuration for the Helicone payload

      • operation: () => Promise<TInternal>

        The async operation to execute (returns internal result with extra data)

      • resultExtractor: (internalResult: TInternal) => TExtracted

        Function to extract the user-facing result from internal result

      • usageCalculator: (
            internalResult: TInternal,
        ) => {
            completion_tokens: number;
            completion_tokens_details?: {
                accepted_prediction_tokens: number;
                audio_tokens: number;
                reasoning_tokens: number;
                rejected_prediction_tokens: number;
            };
            prompt_tokens: number;
            prompt_tokens_details?: { audio_tokens: number; cached_tokens: number };
            total_tokens: number;
        }

        Function to calculate usage metrics from the internal result

      • responseIdPrefix: string

        Prefix for the response ID

      • heliconeApiKey: string

        The Helicone API key for logging

      • heliconeManualLoggingUrl: string

        The Helicone manual logging endpoint URL

      • accountAddress: string

        The account address for logging purposes

      • environmentName: EnvironmentName

        The environment name for logging purposes

      • startAgentRequest: StartAgentRequest

        The agent request for logging purposes

      • customProperties: CustomProperties

        Custom properties to add as Helicone headers (should include agentid and sessionid)

      Returns Promise<TExtracted>

      Promise that resolves to the extracted user result