get-convex / get-convex/rag

RAG component does not expose providerMetadata to usageHandler

Open
#60 3 comments 1 reaction 0 assignees View on GitHub
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.