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
# ref: https://github.com/ftnext/fastapi-playground/blob/d57513e38ce92f932c151935605b693cc91c32de/apiroute/app.py | |
# uvx --with fastapi uvicorn app:app --log-level info --reload | |
import json | |
import logging | |
from fastapi import APIRouter, Body, FastAPI, Request, Response | |
from fastapi.routing import APIRoute | |
logger = logging.getLogger("uvicorn.myapp") # hack to easy logging |
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
# /// script | |
# requires-python = ">=3.11" | |
# dependencies = [ | |
# "browser-use", | |
# "langchain-google-vertexai", | |
# "pillow", | |
# "playwright==1.51.0", | |
# ] | |
# /// |
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
# https://github.com/ftnext/agent-practice/blob/4b7e992018a3a558eb38f05d5038bde82c18663c/adk/refine-loop/agent.py | |
from collections.abc import AsyncGenerator | |
from google.adk.agents import BaseAgent, LlmAgent, LoopAgent | |
from google.adk.agents.invocation_context import InvocationContext | |
from google.adk.events import Event | |
from google.genai import types | |
class HumanAsAgent(BaseAgent): |
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
# /// script | |
# requires-python = ">=3.12" | |
# dependencies = [ | |
# "gradio[mcp]", | |
# "httpx", | |
# ] | |
# /// | |
# https://github.com/ftnext/mcp-practice/blob/95bf6faf63d0e5853eac0481dc71a919c2a3a675/sse/frameworks/gradio_mcp_server.py |
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
# https://github.com/ftnext/agent-practice/blob/bf5c290886bb4a4ecf9407485e25dc90ae92258e/adk/stop-loop/agent.py | |
# ref: https://deepwiki.com/search/loopagentmaxiterationssubagent_2b7c8989-9c8b-4349-95d9-7a3be391c165 | |
from collections.abc import AsyncGenerator | |
from google.adk.agents import BaseAgent, LoopAgent | |
from google.adk.agents.invocation_context import InvocationContext | |
from google.adk.events import Event, EventActions | |
from google.genai import types |
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
# Shows how to call all the sub-agents using the LLM's reasoning ability. Run this with "adk run" or "adk web" | |
from pathlib import Path | |
from google.adk.agents import LlmAgent | |
from google.adk.tools import google_search | |
from google.adk.tools.agent_tool import AgentTool | |
def load_instruction_from_file(filename: str) -> str: | |
"""Reads instruction text from a file relative to this script.""" |
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
# Copyright 2025 ftnext | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, |
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
# /// script | |
# requires-python = ">=3.12" | |
# dependencies = [ | |
# "google-cloud-aiplatform[evaluation]", | |
# ] | |
# /// | |
# ref: https://github.com/googleapis/python-aiplatform/blob/v1.89.0/tests/system/vertexai/test_evaluation.py | |
from datetime import datetime |
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
# /// script | |
# requires-python = ">=3.12" | |
# dependencies = [ | |
# "inspect-ai", | |
# "openai", | |
# ] | |
# /// | |
# ref: https://github.com/UKGovernmentBEIS/inspect_ai/blob/0.3.88/examples/hello_world.py | |
from inspect_ai import Task, task | |
from inspect_ai.dataset import Sample |
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
import os | |
from typing import Literal | |
import llm | |
from google.genai import Client, types | |
@llm.hookimpl | |
def register_models(register): | |
register(GeminiYouTube()) |