Compare commits

...

3 Commits

Author SHA1 Message Date
Bagatur
2499c82aff undo 2024-01-09 16:46:14 -05:00
Bagatur
4c00385c25 fmt 2024-01-09 16:45:01 -05:00
Bagatur
4ada30dd40 rfc: add thread info to verbose 2024-01-09 16:41:24 -05:00

View File

@@ -1,6 +1,7 @@
"""Callback Handler that prints to std out."""
from __future__ import annotations
import threading
from typing import TYPE_CHECKING, Any, Dict, Optional
from langchain_core.callbacks.base import BaseCallbackHandler
@@ -22,7 +23,11 @@ class StdOutCallbackHandler(BaseCallbackHandler):
) -> None:
"""Print out that we are entering a chain."""
class_name = serialized.get("name", serialized.get("id", ["<unknown>"])[-1])
print(f"\n\n\033[1m> Entering new {class_name} chain...\033[0m")
current_thread = threading.current_thread().name
print(
f"\n\n\033[1m> Entering new {class_name} chain in thread "
f"{current_thread}...\033[0m"
)
def on_chain_end(self, outputs: Dict[str, Any], **kwargs: Any) -> None:
"""Print out that we finished a chain."""