Ai Tip From Hwchase17
Provides AI learning tips by demonstrating how to create custom LangChain agents with structured outputs using Pydantic models.
AI Tip from @hwchase17
Description
Automatically generated AI learning skill from curated web and social media sources.
Steps
- New in LangChain: You can now easily create custom agents with structured outputs!
- from langchain_core.pydantic_v1 import BaseModel, Field
- class Joke(BaseModel):
- setup: str = Field(description="question to set up a joke")
- punchline: str = Field(description="answer to resolve the joke")
- llm.with_structured_output(Joke)
Code Examples
from langchain_core.pydantic_v1 import BaseModel, Field
class Joke(BaseModel):
setup: str = Field(description="question to set up a joke")
punchline: str = Field(description="answer to resolve the joke")
llm.with_structured_output(Joke)
Dependencies
- Python 3.8+
- Relevant libraries (see code examples)
- Downloads
- 954All time
- Security audit
- Pass
- Last updated
- 6mo ago
- Current version
- v1.0.0
- License
- MIT-0
