Last active
December 5, 2025 09:28
-
-
Save yoyu777/6271a099e10683dd783bae8e5a7b81c5 to your computer and use it in GitHub Desktop.
Task 3.1: Define the validation agent
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
| # ADK uses pydantic for json schema validation | |
| # Import a couple of utility classes here | |
| from pydantic import BaseModel, Field | |
| # Import the LlmAgent class from ADK | |
| from google.adk.agents import LlmAgent | |
| # Specify the output schema | |
| class ValidationOutput(BaseModel): | |
| is_valid: bool = Field(..., description="Indicates if the input is a valid object for the game.") | |
| reason: str = Field(..., description="Explanation of why the input is valid or not.") | |
| # Define the validation agent here | |
| validation_agent = LlmAgent( | |
| name="validation_agent", | |
| model=GEMINI_MODEL, # Or your preferred Gemini model | |
| instruction="You are incharge of validate user's initial input", | |
| description="""The user is going to play a game of 20 Questions. | |
| Before starting the game, you need to validate the user's input to ensure it is a valid object for the game. | |
| A valid object should be a noun like the name of an object, an animal, or a concept, and not too obscure. | |
| For example, "cat", "car", "apple" are valid, but "quantum entanglement" or "the number seven" are not. | |
| """, | |
| output_schema=ValidationOutput | |
| ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment