Created
March 11, 2024 20:33
-
-
Save fsndzomga/a03cbfdcb05d0f04152770c881a02ec4 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 | |
import chess | |
import chess.engine | |
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. Always plan 5 moves ahead before deciding the best next move.") | |
reasoning: str = Field(..., description="Reasoning explaining why the move is the best") | |
model = ChatOpenAI(model="gpt-4") | |
chess_agent = model.with_structured_output(NextMove) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment