RAG component does not expose providerMetadata to usageHandler
- Dominant language
- TypeScript
- Stars
- 36
- Forks
- 13
- Avg merge
- 4h 2m
- Merged PRs (30d)
- 2
Description
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.
Contributor guide
Assessment
This issue has not been assessed yet.