(
self, input: Input, config: Optional[RunnableConfig] = None, **kwargs: Any
)
| 2477 | ) |
| 2478 | |
| 2479 | def invoke( |
| 2480 | self, input: Input, config: Optional[RunnableConfig] = None, **kwargs: Any |
| 2481 | ) -> Output: |
| 2482 | from langchain_core.beta.runnables.context import config_with_context |
| 2483 | |
| 2484 | # setup callbacks and context |
| 2485 | config = config_with_context(ensure_config(config), self.steps) |
| 2486 | callback_manager = get_callback_manager_for_config(config) |
| 2487 | # start the root run |
| 2488 | run_manager = callback_manager.on_chain_start( |
| 2489 | dumpd(self), |
| 2490 | input, |
| 2491 | name=config.get("run_name") or self.get_name(), |
| 2492 | run_id=config.pop("run_id", None), |
| 2493 | ) |
| 2494 | |
| 2495 | # invoke all steps in sequence |
| 2496 | try: |
| 2497 | for i, step in enumerate(self.steps): |
| 2498 | # mark each step as a child run |
| 2499 | config = patch_config( |
| 2500 | config, callbacks=run_manager.get_child(f"seq:step:{i+1}") |
| 2501 | ) |
| 2502 | if i == 0: |
| 2503 | input = step.invoke(input, config, **kwargs) |
| 2504 | else: |
| 2505 | input = step.invoke(input, config) |
| 2506 | # finish the root run |
| 2507 | except BaseException as e: |
| 2508 | run_manager.on_chain_error(e) |
| 2509 | raise |
| 2510 | else: |
| 2511 | run_manager.on_chain_end(input) |
| 2512 | return cast(Output, input) |
| 2513 | |
| 2514 | async def ainvoke( |
| 2515 | self, |
nothing calls this directly
no test coverage detected