Open MRziyi opened 2 months ago
Same here, the below are not printing out or doing anything inside my customCallbackHandler. This is not expected behavior, as on_chain_start
, on_chain_error
, and on_agent_action
all work like a charm. Are the rest of methods of langchain's BaseCallbackHandler not implemented?. Please kindly advise.
def on_tool_start(
self, serialized: Dict[str, Any], input_str: str, **kwargs: Any
) -> Any:
"""Run when tool starts running."""
print(f"\n\n\033[1m> Running {serialized['name']}...\033[0m") # noqa: T201
print(f"\n\033[1m> Input: {input_str}\033[0m") # noqa: T201
print(input_str)
print(serialized.keys())
def on_tool_end(
self,
output: str,
color: Optional[str] = None,
observation_prefix: Optional[str] = None,
llm_prefix: Optional[str] = None,
**kwargs: Any,
) -> None:
"""If not the final action, print out observation."""
# Remove the tool's response from the conversation history
# context["messages"] = context["messages"][:-1]
# return tool_output
print("<<<<<<<TOOL ENDED OUTPUT")
print()
print(output)
print()
print("TOOL ENDED OUTPUt>>>>>>>")
Hi thanks for raising this, I have raised this internally. Also notice there is an existing PR for this - https://github.com/crewAIInc/crewAI/pull/333/files#diff-61064eabfbcf89548f1d4f5e2e18616dea6e897d06dc0a00bad1eebd634dc9ca
Problem:
I tried to use the
callbacks
parameter (callbacks: List[InstanceOf[BaseCallbackHandler]]
) to achieve some custom display when creating an agent. In the instance ofBaseCallbackHandler
, I implemented all the functions as listed on LangChain. However, I encountered the following issue:Expected Behavior:
All implemented callback functions should be triggered appropriately according to the agent's actions.
Actual Behavior:
Only some of the callback functions are triggered.
Steps to Reproduce:
BaseCallbackHandler
and implement all the functions as documented.callbacks
parameter when creating an agent.Source Code:
Custom callback instance
Driver
File written
Terminal output
Additional Information:
Please let me know if you need any additional information or if there are any workarounds for this issue. Thank you for your assistance.