langchain icon indicating copy to clipboard operation
langchain copied to clipboard

core: Add `TypeError` handler into `get_graph` of `Runnable`

Open hmasdev opened this issue 2 years ago • 2 comments

Description

Problem

Runnable.get_graph fails when InputType or OutputType property raises TypeError.

  • https://github.com/langchain-ai/langchain/tree/003c98e5b440a420d8dbd5f9fdea08888a4a5a33/libs/core/langchain_core/runnables/base.py#L250-L274
  • https://github.com/langchain-ai/langchain/tree/003c98e5b440a420d8dbd5f9fdea08888a4a5a33/libs/core/langchain_core/runnables/base.py#L394-L396

This problem prevents getting a graph of Runnable objects whose InputType or OutputType property raises TypeError but whose invoke works well, such as langchain.output_parsers.RegexParser, which I have already pointed out in #19792 that a TypeError would occur.

Solution

  • Add try-except syntax to handle TypeError to the codes which get input_node and output_node.

Issue

  • #19801

Twitter Handle

hmasdev avatar Apr 01 '24 13:04 hmasdev

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
langchain ⬜️ Ignored (Inspect) Visit Preview May 27, 2024 9:30pm

vercel[bot] avatar Apr 01 '24 13:04 vercel[bot]

cc @nfcampos

ccurme avatar Apr 01 '24 20:04 ccurme

@baskaryan @efriis @eyurtsev @ccurme @vbarda @hwchase17 Could anyone review this PR?

hmasdev avatar May 26 '24 09:05 hmasdev