Callback handleLLMEnd Called Twice – Is It Doubling Token Usage? #7675
juanmanuelarze
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi everyone,
I'm working on a project where I'm using both a history retriever and a source retriever. This is my code:
`const { model, modelOptions, dbSource, botPhone, metadata } = assistant;
const { from, text } = message;
I've noticed that the handleLLMEnd callback is being called twice.
I'm wondering if the second call is simply adding the tokens from the first call plus the response, or if the request itself is actually being made twice.
If it's the latter, that would be a problem because it would double my token usage, which directly impacts costs.
Could someone clarify this for me? Also, if I'm unintentionally causing duplicate requests and there's a way to fix it, I would really appreciate your guidance.
Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions