langchain - ✅(Solved) Fix [langchain_huggingface] Pydantic schema is not supported for function calling [1 pull requests, 1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
langchain-ai/langchain#36441Fetched 2026-04-08 02:22:24
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Author
Participants
Timeline (top)
labeled ×3commented ×1cross-referenced ×1issue_type_added ×1

PR fix notes

PR #36527: fix(huggingface): support pydantic structured output for function calling

Description (problem / solution / changelog)

Fixes #36441

Enable Pydantic schemas in ChatHuggingFace.with_structured_output(..., method="function_calling") by using PydanticToolsParser instead of raising NotImplementedError. Add unit coverage for parsed and include_raw=True behavior and remove outdated xfails for Pydantic structured output.

How did you verify your code works?

I verified the change with: uv run pytest tests/unit_tests/test_chat_models.py -k 'structured_output_pydantic_function_calling' -q

AI Disclosure

This contribution was developed with assistance from an AI coding agent and reviewed manually.

Changed files

  • libs/partners/huggingface/langchain_huggingface/chat_models/huggingface.py (modified, +8/-6)
  • libs/partners/huggingface/tests/integration_tests/test_standard.py (modified, +2/-10)
  • libs/partners/huggingface/tests/unit_tests/test_chat_models.py (modified, +78/-0)
RAW_BUFFERClick to expand / collapse

Checked other resources

  • This is a feature request, not a bug report or usage question.
  • I added a clear and descriptive title that summarizes the feature request.
  • I used the GitHub search to find a similar feature request and didn't find it.
  • I checked the LangChain documentation and API reference to see if this feature already exists.
  • This is not related to the langchain-community package.

Package (Required)

  • langchain
  • langchain-openai
  • langchain-anthropic
  • langchain-classic
  • langchain-core
  • langchain-model-profiles
  • langchain-tests
  • langchain-text-splitters
  • langchain-chroma
  • langchain-deepseek
  • langchain-exa
  • langchain-fireworks
  • langchain-groq
  • langchain-huggingface
  • langchain-mistralai
  • langchain-nomic
  • langchain-ollama
  • langchain-openrouter
  • langchain-perplexity
  • langchain-qdrant
  • langchain-xai
  • Other / not sure / general

Feature Description

langchain_huggingface/chat_models/huggingface.py", line 1174, in with_structured_output raise NotImplementedError(msg) NotImplementedError: Pydantic schema is not supported for function calling

langchain-huggingface version is 1.2.1

Use Case

The langchain open tutorial

Proposed Solution

No response

Alternatives Considered

No response

Additional Context

No response

extent analysis

TL;DR

The NotImplementedError exception indicates that the Pydantic schema is not supported for function calling in the langchain-huggingface package, suggesting a potential limitation or missing implementation in the current version.

Guidance

  • The error occurs in the with_structured_output method of huggingface.py, which may require additional implementation or configuration to support Pydantic schema.
  • Verify the langchain-huggingface version (currently 1.2.1) and check the documentation or release notes for any known issues or updates related to Pydantic schema support.
  • Consider searching for open issues or pull requests in the langchain-huggingface repository that may address this limitation or provide a workaround.
  • If possible, try updating to a newer version of langchain-huggingface to see if the issue is resolved, although no specific version is mentioned as a fix.

Notes

The provided information does not include a clear solution or workaround, and the langchain-huggingface version may not be the latest. Without further details or updates, it's challenging to provide a definitive fix.

Recommendation

Apply workaround: Since there is no clear indication of a fixed version, and without more information on potential workarounds or fixes, the best course of action is to explore workarounds such as modifying the code to avoid using Pydantic schema for function calling or waiting for an update to the langchain-huggingface package that addresses this limitation.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING