03. Structured output chains(with_structered_output)

Chains using structured output (with_structured_output)

Copy

# Configuration file for managing API keys as environment variables
from dotenv import load_dotenv

# Load API key information
load_dotenv()

Copy

True

Copy

# Set up LangSmith tracking. https://smith.langchain.com
# !pip install langchain-teddynote
from langchain_teddynote import logging

# Enter a project name.
logging.langsmith("Structured-Output-Chain")

Copy

Start tracking LangSmith.
[Project name]
Structured-Output-Chain

Implement a process to generate a 4-option multiple choice quiz on a specific topic.

The Quiz class defines the quiz's question, difficulty, and four choices.

The ChatOpenAI instance performs natural language processing using the GPT-4o model, and the ChatPromptTemplate defines the conversational prompt for quiz generation.

Copy

Copy

Prints the generated quiz.

Copy

Copy

Last updated