langchain
d5ba5d35 - feat(langchain): improved HITL patterns (#32996)

Commit
215 days ago
feat(langchain): improved HITL patterns (#32996) # Main changes / new features ## Better support for parallel tool calls 1. Support for multiple tool calls requiring human input 2. Support for combination of tool calls requiring human input + those that are auto-approved 3. Support structured output w/ tool calls requiring human input 4. Support structured output w/ standard tool calls ## Shortcut for allowed actions Adds a shortcut where tool config can be specified as a `bool`, meaning "all actions allowed" ```py HumanInTheLoopMiddleware(tool_configs={"expensive_tool": True}) ``` ## A few design decisions here * We only raise one interrupt w/ all `HumanInterrupt`s, currently we won't be able to execute all tools until all of these are resolved. This isn't super blocking bc we can't re-invoke the model until all tools have finished execution. That being said, if you have a long running auto-approved tool, this could slow things down. ## TODOs * Ideally, we would rename `accept` -> `approve` * Ideally, we would rename `respond` -> `reject` * Docs update (@sydney-runkle to own) * In another PR I'd like to refactor testing to have one file for each prebuilt middleware :) Fast follow to https://github.com/langchain-ai/langchain/pull/32962 which was deemed as too breaking
Author
Parents
Loading