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)