Skip to content

Instantly share code, notes, and snippets.

@yoyu777
yoyu777 / validate_input.py
Created December 5, 2025 09:42
Task 3.5: Call the agent upon user input
# This is a utility module for ADK data structures
from google.genai import types
# This function needs to be **asynchronous** (`async def`),
# as we need to **await** the responses to be produced.
async def validate_input(user_input: str):
try:
@yoyu777
yoyu777 / validation_agent_runner.py
Created December 5, 2025 09:31
Task 3.3: Create the validation agent runner
from google.adk.runners import Runner
validation_agent_runner = Runner(
agent=validation_agent, # We will reference the previous agent we created here
session_service=session_service, # reference the session service we are going to use
app_name=app_name
)
@yoyu777
yoyu777 / validation_agent.py
Last active December 5, 2025 09:28
Task 3.1: Define the validation agent
# 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.")
@yoyu777
yoyu777 / create_validation_session.py
Last active December 5, 2025 09:30
Task 3.2: Create the validation session
# We will use the InMemorySessionService for this session
# It means the session data only lives in the computer's memory
# while the program is running.
from google.adk.sessions import InMemorySessionService
session_service = InMemorySessionService()
app_name = "ValidationAgent"
user_id="test_user"
@yoyu777
yoyu777 / http_server.js
Created October 17, 2021 19:33
http_server.js
/*
//it is necessary to start a web server,
//so App Engine is happy
*/
const http = require('http');
const hostname = '0.0.0.0';
const port = process.env.PORT;
@yoyu777
yoyu777 / sheetreader.cs
Last active September 26, 2024 07:24
sheetreader for Unity (Sheets API v4)
using System;
using System.Collections.Generic;
using Google.Apis.Services;
using Google.Apis.Auth.OAuth2;
using Google.Apis.Sheets.v4;
using Google.Apis.Sheets.v4.Data;
using UnityEngine;