Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leaving method unspecified in LLMGraphTransformer triggers Pydantic parsing errors #38

Open
pbrady opened this issue Jan 31, 2025 · 0 comments · May be fixed by #39
Open

Leaving method unspecified in LLMGraphTransformer triggers Pydantic parsing errors #38

pbrady opened this issue Jan 31, 2025 · 0 comments · May be fixed by #39

Comments

@pbrady
Copy link

pbrady commented Jan 31, 2025

I opened an issue on the main repo first (langchain-ai/langchain#29515) since I wasn't aware the experimental utilities had their own repo.

I won't bother reproducing the text of the issue but my problem boiled down to this line:

structured_llm = llm.with_structured_output(schema, include_raw=True)

The default "method" parameter is "json_schema" for ChatOpenAI and this results in success. However, for ChatOllama, it is "function_calling" which results in the parsing errors mentioned in the issue.

To get ChatOllama working with constrained nodes, I needed to change the indicated line to:

structured_llm = llm.with_structured_output(
    schema, method="json_schema", include_raw=True
)

I'm not sure what the general correct fix is. Perhaps the method should be passed into the LLMGraphTransformer constructor?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant