Created
March 11, 2024 02:07
-
-
Save fsndzomga/eb3e745e8f3a5c2f2df21a03e8a2f0db to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from langchain_openai import ChatOpenAI | |
from langchain_core.pydantic_v1 import BaseModel, Field | |
from dotenv import load_dotenv | |
load_dotenv() | |
class NextMove(BaseModel): | |
move: str = Field(..., description="Best next move to win the chess game. It should be in Standard Algebraic Notation") | |
reasoning: str = Field(..., description="Reasoning explaining why the move is the best") | |
model = ChatOpenAI() | |
model_with_structure = model.with_structured_output(NextMove) | |
print(model_with_structure.invoke("Generate a chess move")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment