How can i find out that a pair of Callback events correspond to a same LLM call #27232
fernando-torres-blip-ai
announced in
Ask Dosu (Archived)
Replies: 1 comment
-
Hey @fernando-torres-blip-ai! 👋 I'm here to help you with any bugs, questions, or contributions while you wait for a human maintainer. Let's tackle this together! To group Here's a basic implementation suggestion: class CustomCallbackHandler(BaseCallbackHandler):
def __init__(self):
self.llm_calls = {}
def on_llm_start(self, serialized, prompts, *, run_id, **kwargs):
# Store the start event with the run_id
self.llm_calls[run_id] = {'start': {'prompts': prompts}}
def on_llm_end(self, response, *, run_id, **kwargs):
# Retrieve the start event using the run_id and add the end event
if run_id in self.llm_calls:
self.llm_calls[run_id]['end'] = {'response': response} This approach uses the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Im implementing a Custom Callbaback Handler and i want to group the events from
on_llm_start
andon_llm_end
by LLM call. Is there any ID or implementation suggestion to do so ?Beta Was this translation helpful? Give feedback.
All reactions