Skip to content

RAG component does not expose providerMetadata to usageHandler #60

@yantakus

Description

@yantakus

For example, Agent component with the following config:

export const titleAgent = new Agent(components.agent, {
  languageModel: "openai/gpt-4o-mini",
  usageHandler: async (ctx, args) => {
    const gateway = args.providerMetadata?.gateway;
    if (!gateway) {
      throw new Error("Missing providerMetadata.gateway");
    }
    const creditsSpent = costToCredits(gateway.cost);
    ...
  };
});

works just fine.

And RAG component with the same config (it only has an additional textEmbeddingModel: "openai/text-embedding-3-small") throws an error because args.providerMetadata is missing.

Please, add it, otherwise I have to calculate the cost myself. Not a big deal, but still would like not to hardcode input and output token cost.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions