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

rfc: AIMessage.parsed and with_structured_output(..., tools=[]) #27730

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

baskaryan
Copy link
Collaborator

No description provided.

Copy link

vercel bot commented Oct 30, 2024

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 Oct 30, 2024 4:53am

@baskaryan
Copy link
Collaborator Author

baskaryan commented Oct 30, 2024

enables this type of usage

Screenshot 2024-10-29 at 7 54 26 PM

from langchain.chat_models import init_chat_model
from pydantic import BaseModel, Field
from langchain.tools import tool

llm = init_chat_model("gpt-4o")

class ResponseSchema(BaseModel):
    """Respond using this schema."""
    thoughts: list[str]
    answer: strx

@tool
def multiply(x: int, y: int) -> int:
    """return x * y"""
    return x * y

structured_llm = llm.with_structured_output(ResponseSchema, method="json_schema", tools=[multiply], include_raw="raw_only")
structured_llm.invoke("whats 5 * 3").tool_calls

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

Successfully merging this pull request may close these issues.

1 participant