Skip to content
Discussion options

You must be logged in to vote

You can't use it with with_structured_output unfortunately. RunnableWithMessageHistroy expects messages on the output of the wrapped runnable. When you use with_structured_output the output is not an AIMessage, but either a dict or a a pydantic object.

Your options are:

  1. Swap to using the bind_tools interface instead -- it'll involve a bit more manual effort
  2. Use with_structured_output with include_raw=False . See API reference, https://python.langchain.com/api_reference/anthropic/chat_models/langchain_anthropic.chat_models.ChatAnthropic.html#langchain_anthropic.chat_models.ChatAnthropic.with_structured_output

In both cases, you'll may need to restructure the LCEL chain a bit to make sure…

Replies: 3 comments 4 replies

Comment options

You must be logged in to vote
2 replies
@segoranov
Comment options

@dosubot
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@Yairama
Comment options

@mlnrt
Comment options

Answer selected by eyurtsev
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants