langchain
c671d54c - core: make with_alisteners() example workable. (#30059)

Commit
349 days ago
core: make with_alisteners() example workable. (#30059) **Description:** 5 fix of example from function with_alisteners() in libs/core/langchain_core/runnables/base.py Replace incoherent example output with workable example's output. 1. SyntaxError: unterminated string literal print(f"on start callback starts at {format_t(time.time())} correct as print(f"on start callback starts at {format_t(time.time())}") 2. SyntaxError: unterminated string literal print(f"on end callback starts at {format_t(time.time())} correct as print(f"on end callback starts at {format_t(time.time())}") 3. NameError: name 'Runnable' is not defined Fix as from langchain_core.runnables import Runnable 4. NameError: name 'asyncio' is not defined Fix as import asyncio 5. NameError: name 'format_t' is not defined. Implement format_t() as from datetime import datetime, timezone def format_t(timestamp: float) -> str: return datetime.fromtimestamp(timestamp, tz=timezone.utc).isoformat()
Author
Parents
Loading