Skip to content

Instantly share code, notes, and snippets.

View ftnext's full-sized avatar

nikkie ftnext

View GitHub Profile
# 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
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "browser-use",
# "langchain-google-vertexai",
# "pillow",
# "playwright==1.51.0",
# ]
# ///
# 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):
# /// script
# requires-python = ">=3.12"
# dependencies = [
# "gradio[mcp]",
# "httpx",
# ]
# ///
# https://github.com/ftnext/mcp-practice/blob/95bf6faf63d0e5853eac0481dc71a919c2a3a675/sse/frameworks/gradio_mcp_server.py
# 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
# 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."""
@ftnext
ftnext / agent.py
Created April 25, 2025 13:43
Under youtube-shorts-assistant directory
# 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,
# /// 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
# /// 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
import os
from typing import Literal
import llm
from google.genai import Client, types
@llm.hookimpl
def register_models(register):
register(GeminiYouTube())