Content-Length: 312767 | pFad | https://github.com/langchain-ai/langchain/pull/31518

D1 openai[patch]: pass through with_structured_output kwargs by baskaryan · Pull Request #31518 · langchain-ai/langchain · GitHub
Skip to content

openai[patch]: pass through with_structured_output kwargs #31518

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

Merged
merged 2 commits into from
Jun 6, 2025

Conversation

baskaryan
Copy link
Collaborator

Support

from langchain.chat_models import init_chat_model
from pydantic import BaseModel


class ResponseSchema(BaseModel):
    response: str


def get_weather(location: str) -> str:
    """Get weather"""
    pass

llm = init_chat_model("openai:gpt-4o-mini")

structured_llm = llm.with_structured_output(
    ResponseSchema,
    tools=[get_weather],
    strict=True,
    include_raw=True,
    tool_choice="required",
    parallel_tool_calls=False,
)

structured_llm.invoke("whats up?")

@baskaryan baskaryan requested a review from ccurme June 6, 2025 14:55
Copy link

vercel bot commented Jun 6, 2025

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

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
langchain ⬜️ Ignored (Inspect) Visit Preview Jun 6, 2025 2:56pm

@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Jun 6, 2025
Copy link

codspeed-hq bot commented Jun 6, 2025

CodSpeed Walltime Performance Report

Merging #31518 will not alter performance

Comparing bagatur/oai_struct_kwargs (a5bee42) with master (0375848)

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

Summary

✅ 13 untouched benchmarks

@@ -880,6 +880,12 @@ def get_weather(location: str) -> str:

``method`` default changed from "function_calling" to "json_schema".

.. versionchanged:: 0.3.12
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you

@dosubot dosubot bot added the lgtm PR looks good. Use to confirm that a PR is ready for merging. label Jun 6, 2025
Copy link

codspeed-hq bot commented Jun 6, 2025

CodSpeed Instrumentation Performance Report

Merging #31518 will not alter performance

Comparing bagatur/oai_struct_kwargs (a5bee42) with master (0375848)

Summary

✅ 13 untouched benchmarks

@baskaryan baskaryan merged commit 761f8c3 into master Jun 6, 2025
57 checks passed
@baskaryan baskaryan deleted the bagatur/oai_struct_kwargs branch June 6, 2025 15:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm PR looks good. Use to confirm that a PR is ready for merging. size:M This PR changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: https://github.com/langchain-ai/langchain/pull/31518

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy