Skip to content

Instantly share code, notes, and snippets.

View ftnext's full-sized avatar

nikkie ftnext

View GitHub Profile
# https://github.com/ftnext/fastapi-playground/blob/1908d81cde87f27c495cbcffa4c5142777118f9c/opentelemetry/client.rb
require 'bundler/setup'
Bundler.require
ENV['OTEL_TRACES_EXPORTER'] = 'console'
OpenTelemetry::SDK.configure do |c|
c.use 'OpenTelemetry::Instrumentation::Faraday'
end
@ftnext
ftnext / app.py
Last active February 26, 2026 13:54
# /// script
# requires-python = ">=3.13"
# dependencies = [
# "a2wsgi>=1.10.10",
# "django>=6.0.2",
# "fastapi>=0.133.1",
# "uvicorn>=0.41.0",
# ]
# ///
@ftnext
ftnext / test_tool_call_by_deepeval.py
Created February 22, 2026 14:04
OPENAI_API_KEY=dummy uvx --python 3.13 deepeval test run test_tool_call_by_deepeval.py
# https://deepeval.com/docs/metrics-tool-correctness#usage
from deepeval import evaluate
from deepeval.metrics import ToolCorrectnessMetric
from deepeval.test_case import LLMTestCase, ToolCall
tool_correctness = ToolCorrectnessMetric()
def test_agent_tool_choice():
test_case = LLMTestCase(
# https://github.com/ftnext/2026-slides/blob/ef721a71a3dec9a414e5e05de1def3448f0f1272/samplecode/deep-research-otel/gemini.rb
require "faraday"
require "json"
require "opentelemetry/sdk"
require "opentelemetry/instrumentation/faraday"
ENV["OTEL_TRACES_EXPORTER"] = "console"
OpenTelemetry::SDK.configure do |c|
c.use 'OpenTelemetry::Instrumentation::Faraday'
end
# https://github.com/ftnext/kotoha-python-linter/blob/66566f6e3f3a528e3a4d9c11d59738c6cdb859ee/kotoha/first_linter.py
import argparse
import ast
import importlib
from collections.abc import Iterable
from pathlib import Path
def _load_rule(rule_spec: str) -> type[ast.NodeVisitor]:
"""Load a rule class from MODULE:CLASS specification."""
from astroid import nodes
from pylint.checkers import BaseChecker
class ArgumentListTypeHintChecker(BaseChecker):
name = "kotoha-checker"
priority = -1
msgs = {
"W9999": (
"Avoid concrete list type in argument '%s'; use Sequence or Iterable instead",
import logging
import sys
import time
import uuid
from pathlib import Path
from typing import Any, Optional
import uvicorn
from typing_extensions import override
require "faraday"
require "json"
api_key = ENV["GEMINI_API_KEY"]
conn = Faraday.new(
url: "https://generativelanguage.googleapis.com"
)
response = conn.post(
"/v1beta/models/gemini-3-flash-preview:generateContent"
) do |req|
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "anthropic>=0.79.0",
# ]
# ///
import anthropic
client = anthropic.Anthropic()
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "anthropic>=0.79.0",
# ]
# ///
from pathlib import Path
import anthropic