text
stringlengths
185
73.3k
repo
stringlengths
7
100
path
stringlengths
4
146
language
stringclasses
7 values
hash
stringlengths
16
16
score
float64
7
8.5
stars
int64
0
237k
"""Shared Ollama HTTP transport with readable failures. Ollama returns real explanations in the body of a 500 response ("model requires more system memory...", "error loading model..."). ``urllib`` only exposes the status line, so every caller used to log a bare "HTTP Error 500: Internal Server Error" with no cause. E...
protocorn/clippy-vision
core/ollama_client.py
.py
6286cfa574fe4142
7.56
12
"""Resolve writable data paths for Clippy Vision. Dev (default): <repo>/core/data/ Packaged: set CLIPPY_DATA_DIR to %APPDATA%/Clippy Vision/data (Electron main.js sets this when spawning Python). """ from __future__ import annotations import os from pathlib import Path _CORE_DIR = Path(__file_...
protocorn/clippy-vision
core/paths.py
.py
33a7659d1aa816b6
7.56
12
"""Small platform adapters used by the capture process. The original capture loop was tightly coupled to Win32 APIs. Keeping the platform-specific work here lets the event pipeline stay the same on Windows, macOS, and Linux while still allowing optional integrations where the host doesn't provide them. """ from __fut...
protocorn/clippy-vision
core/platform_support.py
.py
4b0b972d3202b9aa
7.56
12
"""Privacy / access-control settings for screenshot redaction. When a target is enabled, matching windows are blacked out in captures (same path as always-redacting the Clippy Vision window). """ from __future__ import annotations import json import time from typing import Optional try: from core.storage import ...
protocorn/clippy-vision
core/privacy_settings.py
.py
037f36fcf2685a21
7.56
12
import json from dataclasses import asdict, dataclass from pathlib import Path from typing import Optional import torch @dataclass(frozen=True) class D3PMConfig: num_classes: int num_timesteps: int = 1000 beta_start: float = 1e-4 beta_end: float = 0.02 class D3PMScheduler: """ Multinomial /...
Buddhi19/SyntheticGen
src/models/d3pm.py
.py
3243c1e73e136fea
7.56
12
#!/usr/bin/env python # coding=utf-8 # Copyright 2025 The HuggingFace Inc. team. All rights reserved. # # 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/LI...
Buddhi19/SyntheticGen
src/scripts/generate_joint_image_mask_diffusion.py
.py
f2dcb76eec3c53e8
7.56
12
from __future__ import annotations import json import re import uuid from pathlib import Path from typing import Annotated, Any, Literal import keyring from pydantic import BaseModel, Field from .platforms import APP_NAME, get_platform KEYRING_SERVICE = "ai-gauge" KEYRING_GITHUB_PAT = "github-pat" KEYRING_OPENROUTE...
jpajak/ai-gauge
src/aigauge/config.py
.py
f34d7b4dbb1e09d2
7.63
17
from __future__ import annotations import json import logging from dataclasses import asdict, dataclass from datetime import datetime, timedelta from pathlib import Path from typing import Iterable from .config import app_data_dir from .models import SnapshotStatus, UsageSnapshot log = logging.getLogger("aigauge.his...
jpajak/ai-gauge
src/aigauge/history.py
.py
14da87d538dcb159
7.63
17
from __future__ import annotations from pathlib import Path from PyQt6.QtGui import QIcon def app_icon_path(extension: str = "png") -> Path: """Return the packaged AI Gauge application-icon asset.""" return Path(__file__).resolve().parent / "assets" / f"aigaugeicon.{extension}" def app_icon() -> QIcon: ...
jpajak/ai-gauge
src/aigauge/icons.py
.py
93b7fcfe30af5190
7.13
17
from __future__ import annotations import logging from logging.handlers import RotatingFileHandler from pathlib import Path from .config import app_data_dir LOGGER_NAME = "aigauge" _LOG_FILENAME = "ai-gauge.log" def log_path() -> Path: return app_data_dir() / _LOG_FILENAME def setup_logging() -> logging.Logg...
jpajak/ai-gauge
src/aigauge/logging_setup.py
.py
4d4a105a5fb716ea
7.63
17
"""macOS menu-bar rendering. Qt's ``QSystemTrayIcon`` is icon-first on macOS. Wide text pixmaps get squeezed into the menu-bar icon slot on some builds, which makes percent labels unreadable. Render a fixed-size provider-dot icon instead and keep readable numbers in the popover. The pixmap is rendered at ``device_pix...
jpajak/ai-gauge
src/aigauge/menubar.py
.py
b1ba8c0d6386684a
7.63
17
from dataclasses import dataclass, field from datetime import datetime, timedelta from enum import Enum from typing import Any class SnapshotStatus(str, Enum): OK = "ok" AUTH_REQUIRED = "auth_required" ERROR = "error" @dataclass class UsageMetric: """A single percent-used reading with a reset time."...
jpajak/ai-gauge
src/aigauge/models.py
.py
f163aac44b0557f6
7.63
17
"""Platform abstraction seam. The app talks to one of three concrete subclasses depending on the host OS. This module owns: - the abstract :class:`Platform` interface, - shared helpers that don't differ by OS (e.g. building the auto-start command from ``sys.executable``), - the ``APP_DATA_DIR_OVERRIDE_ENV`` env-var ...
jpajak/ai-gauge
src/aigauge/platforms/base.py
.py
92dfbf0dba805b87
7.63
17
"""macOS implementation of the platform seam. - App data lives under ``~/Library/Application Support/ai-gauge``. - Secrets (cookies + PAT) go through ``keyring`` (login Keychain). Keychain has no meaningful per-item size limit, so the DPAPI-style encrypted-file workaround used on Windows isn't needed. - Auto-start...
jpajak/ai-gauge
src/aigauge/platforms/macos.py
.py
93d2a51bb882d7ad
7.63
17
"""Windows implementation of the platform seam. - App data lives under ``%APPDATA%/ai-gauge``. - Cookies are stored DPAPI-encrypted via the existing ``secret_storage`` module (Windows Credential Manager caps blobs at ~2.5KB, which Codex JWTs blow past). - Auto-start uses a named Task Scheduler entry instead of a Run...
jpajak/ai-gauge
src/aigauge/platforms/windows.py
.py
e34678cccf98f281
7.63
17
from __future__ import annotations import logging from typing import Any, Callable from PyQt6.QtCore import QObject from ..models import SnapshotStatus, UsageSnapshot from ..webview import runtime as webengine # Resolved on first scrape rather than imported at module scope: ..webview # .scraper pulls in QtWebEngine...
jpajak/ai-gauge
src/aigauge/providers/_scrape_runner.py
.py
c43529f903fb6871
7.63
17
from __future__ import annotations from abc import ABC, abstractmethod from typing import Callable from ..models import UsageSnapshot class Provider(ABC): """Base class for a usage data source. Implementations may either return a snapshot synchronously (for plain HTTP providers like Copilot) or invoke ...
jpajak/ai-gauge
src/aigauge/providers/base.py
.py
54cce24503a4fa82
7.63
17
"""Auto-start at login. Thin wrapper around the platform seam. The actual per-OS work (registry on Windows, LaunchAgent plist on macOS, .desktop file on Linux) lives in ``aigauge.platforms``. """ from __future__ import annotations from .platforms import autostart_command, get_platform def _startup_command() -> str:...
jpajak/ai-gauge
src/aigauge/startup.py
.py
2ae07f30c2e58b3c
7.63
17
from __future__ import annotations from datetime import datetime import json import os from pathlib import Path import tempfile import time from .config import app_data_dir from .models import UsageSnapshot CACHE_SCHEMA_VERSION = 1 _MAX_CACHE_BYTES = 1024 * 1024 def usage_cache_path() -> Path: return app_data...
jpajak/ai-gauge
src/aigauge/usage_cache.py
.py
53267f319004d20e
7.63
17
from __future__ import annotations import logging from http.cookies import SimpleCookie from PyQt6.QtCore import QByteArray, QDateTime, QUrl from PyQt6.QtNetwork import QNetworkCookie from ..config import ( COOKIE_DOMAINS, COOKIE_NAME_ALIASES, COOKIE_NAMES, Config, browser_accounts, get_provi...
jpajak/ai-gauge
src/aigauge/webview/cookies.py
.py
e2c634bd2fe45815
7.63
17
from __future__ import annotations import logging from PyQt6.QtCore import QUrl from PyQt6.QtWebEngineCore import QWebEnginePage log = logging.getLogger("aigauge.webview.page") # JS console fragments that are pure third-party telemetry/analytics chatter # and never useful when diagnosing AI Gauge issues. Matched a...
jpajak/ai-gauge
src/aigauge/webview/page.py
.py
51adff8a355f73fa
7.63
17
"""Lazy, guarded access to QtWebEngine. QtWebEngine is Chromium, and it wants a GL context the moment it initialises. On a machine with no GLX/EGL — a headless X11 display, an XRDP session, a VM with no GPU — that initialisation fails hard and takes the process with it (issue #7). The gauge itself is plain QtWidgets ...
jpajak/ai-gauge
src/aigauge/webview/runtime.py
.py
99cdd267d3363278
7.63
17
"""VideoToNo MCP Server:把「视频链接 → Markdown 笔记」能力暴露为 MCP 工具。 接入方式(两种传输,工具完全相同): - stdio:`python -m backend.mcp_server`,供 Codex CLI、Cherry Studio 等以本地命令方式接入; - SSE:挂载在 FastAPI 的 `/mcp/sse`(见 main.py),Cherry Studio 以远程 URL 方式接入, 无需本机 Python 环境(便携版 exe 用户推荐此方式)。 任务实际由本地后端进程执行,MCP 只是访问通道,因此从 UI、Cherry Studio 还是 Codex 提交,...
like-attract/video-to-note
backend/mcp_server.py
.py
4fd030577d79c284
7.65
19
# Suite-wide guards added in the 2026-08 super-cycle (pattern from sam-gov r10). # When live tests run, anything named *live* waits before each test so a full # live pass can never burst-hammer the API or burn a keyed quota. import os import random import time import pytest LIVE = os.environ.get("BLS_LIVE_TESTS") == ...
1102tools-dev/federal-contracting-mcps
servers/bls-oews-mcp/tests/conftest.py
.py
2d0176dae603997c
7.16
20
# SPDX-License-Identifier: MIT """Credential-readiness contract for BLS access.""" from __future__ import annotations import asyncio import pytest from bls_oews_mcp.server import mcp def _payload(result): return result.structured_content if hasattr(result, "structured_content") else result[1] @pytest.mark.p...
1102tools-dev/federal-contracting-mcps
servers/bls-oews-mcp/tests/test_access_status.py
.py
4827b366ea839f20
8.16
20
# Round 8 (2026-08-18 super-cycle): live contract anchors, one call per test. # The cross-foot canary is the guard for the round-7 money bug (hourly # percentile labels shifted one slot, inflating Hourly Median 26%). import asyncio import json import os import re import pytest from .test_audit_r7 import _call, _paylo...
1102tools-dev/federal-contracting-mcps
servers/bls-oews-mcp/tests/test_audit_r8.py
.py
d92cb50466351cf7
7.16
20
# Suite-wide guards added in the 2026-08 super-cycle (pattern from sam-gov r10). # When live tests run, anything named *live* waits before each test so a full # live pass can never burst-hammer the API or burn a keyed quota. import os import random import time import pytest LIVE = os.environ.get("ECFR_LIVE_TESTS") ==...
1102tools-dev/federal-contracting-mcps
servers/ecfr-mcp/tests/conftest.py
.py
906e67a3104a2857
7.16
20
"""Round 2: adversarial edge case test. Try to break ecfr-mcp with extreme inputs, injection payloads, and boundary probes.""" from __future__ import annotations import asyncio, sys from ecfr_mcp.server import ( get_latest_date, get_cfr_content, get_cfr_structure, get_version_history, get_ancestry, search_cfr, ...
1102tools-dev/federal-contracting-mcps
servers/ecfr-mcp/tests/scenarios/stress_test_r2.py
.py
ee35274fa3b75e17
8.16
20
"""Round 3: creative chaos. Real-world edge cases a 1102 would actually hit, combined with edge cases an LLM might hallucinate as inputs.""" from __future__ import annotations import asyncio, sys, time from ecfr_mcp.server import ( get_latest_date, get_cfr_content, get_cfr_structure, get_version_history, get_an...
1102tools-dev/federal-contracting-mcps
servers/ecfr-mcp/tests/scenarios/stress_test_r3.py
.py
a2298ad639bc78a8
8.16
20
# Suite-wide guards added in the 2026-08 super-cycle (pattern from sam-gov r10). # When live tests run, anything named *live* waits before each test so a full # live pass can never burst-hammer the API or burn a keyed quota. import os import random import time import pytest LIVE = os.environ.get("FR_LIVE_TESTS") == "...
1102tools-dev/federal-contracting-mcps
servers/federal-register-mcp/tests/conftest.py
.py
aee8ca57d35af2b9
7.16
20
# Round 7 (2026-08-18 super-cycle): live contract anchors, one call per test. # Re-stamps the 1.0.1-wave headliners (pre-2011 lockout, soonest-closing # comment periods, FAR case completeness) through the real tool pipeline. import asyncio import json import os import pytest from .test_round_6 import _call, _payload ...
1102tools-dev/federal-contracting-mcps
servers/federal-register-mcp/tests/test_audit_r7.py
.py
3f0bff5c01ad47a3
7.16
20
import dataclasses import typing as t import psycopg.sql from django.apps.registry import Apps from django.db import connections, models, transaction from django.db.utils import OperationalError, ProgrammingError from django_absurd.choices import TaskState from django_absurd.exceptions import ( ADMIN_VIEW_READONL...
lincolnloop/django-absurd
django_absurd/admin_views.py
.py
55b91099f9034321
7.54
11
import datetime as dt import typing as t import uuid from collections.abc import Mapping import psycopg.errors from absurd_sdk import CreateQueueOptions, JsonObject, JsonValue from django.apps import apps from django.core.exceptions import ImproperlyConfigured from django.db import transaction from django.db.utils imp...
lincolnloop/django-absurd
django_absurd/backends.py
.py
7f1da6203058a35b
7.54
11
import typing as t from collections.abc import Mapping, Sequence import croniter from absurd_sdk import CreateQueueOptions, QueueStorageMode from django.apps import AppConfig, apps from django.conf import settings from django.contrib.admin.sites import AdminSite from django.core.checks import CheckMessage, Error, regi...
lincolnloop/django-absurd
django_absurd/checks.py
.py
d5d629f943656dd8
7.54
11
"""Deferred enqueue: the wrapper's name, and the handler that runs it. A deferred enqueue spawns a wrapper row rather than the caller's task, so the caller's task is never claimed before its work exists. ``backends`` spawns that row and ``worker`` dispatches it, so the name they agree on lives here — importable by bot...
lincolnloop/django-absurd
django_absurd/deferred.py
.py
4746609a61dbb148
7.54
11
"""Shared flush logic for tearing down Absurd state between tests. Backs both the automatic test cleanup (``django_absurd.test.install_absurd_cleanup``, which wraps ``TransactionTestCase._post_teardown``) and the ``absurd_flush`` management command — a plain, always-Django-dependent module. Both in-function imports b...
lincolnloop/django-absurd
django_absurd/flush.py
.py
6636701890c28c7d
7.54
11
"""Hooks handed to the Absurd clients, where Absurd's own lifecycle becomes visible. The async client takes both; the sync client takes only ``log_before_spawn``, because its ``_execute_task`` never awaits a hook's return value. Every hook body is contained, for a different reason each: - ``wrap_task_execution`` run...
lincolnloop/django-absurd
django_absurd/hooks.py
.py
f5fc493fcc437c2e
7.54
11
"""A default destination for django-absurd's own log lines. The worker and beat commands run in the foreground and their whole job is to report what Absurd is doing, so they should not be silent out of the box. Django's default configuration covers the ``django`` logger only, and the root logger's default level is WAR...
lincolnloop/django-absurd
django_absurd/logging.py
.py
dd05c1ea6b3ab955
7.54
11
import typing as t from django.core.exceptions import ImproperlyConfigured from django.core.management.base import BaseCommand, CommandError from django_absurd.backends import AbsurdBackend, get_absurd_backends from django_absurd.exceptions import ( BackendNotConfiguredError, MultipleBackendsConfiguredError, ...
lincolnloop/django-absurd
django_absurd/management/base.py
.py
66cba72378ddac7c
7.54
11
"""The absurd_params factory: a task decorator and a per-invocation enqueue channel.""" import dataclasses import enum import typing as t from absurd_sdk import CancellationPolicy, JsonObject, RetryStrategy from django.tasks import Task from django_absurd.tasks import AbsurdTask, SpawnKwargs, build_merged_spawn_opti...
lincolnloop/django-absurd
django_absurd/params.py
.py
34a88481a5c02e1d
7.54
11
"""Writable Django admin for pg_cron ScheduledTask rows (registered at import). The admin lane (``source="admin"``) is fully writable; settings-declared rows (``source="settings"``, owned by reconcile) stay read-only, gated per object. """ import contextlib import typing as t from django import forms from django.con...
lincolnloop/django-absurd
django_absurd/pg_cron/admin.py
.py
3a7b8f5d2b3f61b5
7.54
11
"""The single seam every ``cron.*`` write for django-absurd schedules routes through. Each verb opens the CENTRAL pg_cron connection (auto-discovered via ``open_central_connection``), applies the inert test gate, and schedules jobs cross-database with ``cron.schedule_in_database`` — binding each job to the LIVE app da...
lincolnloop/django-absurd
django_absurd/pg_cron/catalog.py
.py
b70579431b9d0962
7.54
11
"""System checks for the pg_cron scheduler app (registered via PgCronConfig.ready).""" import typing as t from collections.abc import Mapping, Sequence import psycopg from django.apps import AppConfig from django.core.checks import CheckMessage, Error, Tags, register from django.core.exceptions import ImproperlyConfi...
lincolnloop/django-absurd
django_absurd/pg_cron/checks.py
.py
24513e818f241f14
7.54
11
import logging import typing as t from django.core.exceptions import ValidationError from django.core.validators import MinValueValidator from django.db import connections, models if t.TYPE_CHECKING: from django_absurd.backends import AbsurdBackend from django_absurd.backends import get_declared_queues from djan...
lincolnloop/django-absurd
django_absurd/pg_cron/models.py
.py
455866201907f44f
7.54
11
"""pg_cron reconcile engine: materialize declared SCHEDULE entries into ScheduledTask rows (the rows' post_save signal emits the pg_cron jobs), prune undeclared ones, and tear down via the explicit ``--teardown`` command — plus the spawn-option resolution they depend on. Per-row pg_cron job emission lives on the Schedu...
lincolnloop/django-absurd
django_absurd/pg_cron/reconcile.py
.py
9e333e5fe87d0389
7.54
11
"""(Un)schedule a pg_cron job whenever a ScheduledTask row is saved or deleted. The single emission path for `.save()`/`.delete()`: settings reconcile upserts, admin authoring, direct ORM save/delete, AND loaddata all flow through here, so pg_cron matches the rows — the row is the source of truth, so a loaded/restored...
lincolnloop/django-absurd
django_absurd/pg_cron/signals.py
.py
faaee1e84e2d5f4b
7.54
11
"""Shared schedule validators — the single source of rule truth. Each raises `django.core.exceptions.ValidationError`. `ScheduledTask.clean()` + field `validators=[...]` enforce them model-first; the system checks call the same callables and wrap failures into `absurd.E007`. All of them are pure — `validate_declared_q...
lincolnloop/django-absurd
django_absurd/pg_cron/validators.py
.py
0f579cc608cc748d
7.54
11
"""django-absurd's ``pytest11`` plugin: auto Absurd cleanup plus the ``dj_absurd`` fixture. ``pytest_configure`` installs ``django_absurd.test.install_absurd_cleanup``, which patches ``TransactionTestCase._post_teardown`` so every DB-backed test flushes leftover Absurd state after it runs — no per-test fixture or mark...
lincolnloop/django-absurd
django_absurd/pytest_plugin.py
.py
ed1f80190752f144
8.04
11
import contextlib import datetime as dt import logging import re import typing as t import zlib from dataclasses import dataclass, field import psycopg.errors from absurd_sdk import Absurd, CreateQueueOptions, QueuePolicyOptions from django.db import connections, transaction from django_absurd import backends from dj...
lincolnloop/django-absurd
django_absurd/queues.py
.py
9c4cae633ea3b915
7.54
11
import dataclasses import datetime as dt import functools import hashlib import logging import threading import typing as t import croniter from django.db import close_old_connections from django.utils import timezone from django.utils.module_loading import import_string from django_absurd.backends import AbsurdBacke...
lincolnloop/django-absurd
django_absurd/scheduler.py
.py
f6f464a5b399d4ac
7.54
11
"""Preprocess all datasets for PortBench.""" import json from datetime import datetime from pathlib import Path import pandas as pd from portbench.data_preprocess import ( PreprocessConfig, TimeAligner, get_all_preprocessors, ) def main(): """Run complete data preprocessing pipeline.""" print("...
AgenticFinLab/portbench
examples/data_preprocess/preprocess_all.py
.py
a1318d16e94c339a
7.48
8
""" Unified PortBench evaluation entry point. Two evaluation tiers: qa — Tier 1: static QA dataset accuracy (T1-T7 templates) sandbox — Tier 2: stateful Sandbox × 3 Profiles (stress gate + normal backtest) Usage: # Both tiers, mock agent (no API keys needed) python examples/run_all_eval.py # Spe...
AgenticFinLab/portbench
examples/run_all_eval.py
.py
de1fa9b92e2b8061
7.48
8
""" Regenerate paper-facing PNGs into the EMNLP paper figures/ directory. Usage (from portbench repo root): python examples/visualization/export_paper_figures.py \ --experiments-dir EXPERIMENTS_rebuttal_lookback/monthly \ --out-dir D:/GitHub/yuxuan-emnlp26-portbench/figures """ from __future__ import an...
AgenticFinLab/portbench
examples/visualization/export_paper_figures.py
.py
1900810a265591a8
7.48
8
""" Export polished NAV figures into the paper figures/ directory (NAV-only, no CEPS panel). Usage: python examples/visualization/gen_paper_nav_figures.py """ from __future__ import annotations import sys from pathlib import Path import pandas as pd ROOT = Path(__file__).resolve().parents[2] sys.path.insert(0, s...
AgenticFinLab/portbench
examples/visualization/gen_paper_nav_figures.py
.py
17cd43c6e5147a24
7.48
8
""" Generate Figure for Section 5.4 — Profile Adaptation as LLM Value. Scatter design (aligned with analysis_normal_vs_stress): X = AdaptScore, Y = PAS. Each model contributes three independent points (one per investor profile). Encoding: - profile → colour (solid fill, uniform white edge) - model → ma...
AgenticFinLab/portbench
examples/visualization/gen_profile_adaptation.py
.py
df8024551c1029b4
7.48
8
""" Generate QA dataset visualizations into datasets/visualization/. Produces: datasets/visualization/ fig_dataset_overview.png — 3×2 comprehensive stats panel fig_dataset_regime_heatmap.png — template × regime count heatmap fig_qa_samples.png — 4×2 card grid (one example per templat...
AgenticFinLab/portbench
examples/visualization/generate_dataset_figures.py
.py
b482c6a152cfb78c
7.48
8
"""Canonical serialization and stage cache-key construction.""" from __future__ import annotations import dataclasses import hashlib import json import math import struct from enum import Enum from typing import Any, Mapping def _stable_float(value: float) -> str: """Serialize a binary64 value independently of ...
AgenticFinLab/portbench
portbench/agent_eval/canonical.py
.py
02171ce5b2294f8b
7.48
8
"""Explicit multi-agent collaboration for portfolio weight optimization.""" from __future__ import annotations from dataclasses import asdict from typing import Any, Dict from portbench.agent_eval.base import MarketSnapshot, S2Output, S3Output from portbench.agent_eval.canonical import canonical_json from portbench....
AgenticFinLab/portbench
portbench/agent_eval/collaboration.py
.py
d10c40d8ab230a9a
7.48
8
"""Frozen contracts for PortBench paper-upgrade scaffolding. Implements plan steps 1–3 contract surface: schema versions, result protocols, architecture IDs, and shared dataclasses. """ from __future__ import annotations import math from dataclasses import dataclass, field from enum import Enum from typing import An...
AgenticFinLab/portbench
portbench/agent_eval/contracts.py
.py
3dde82f53118c80b
7.48
8
"""Prompt-exact reuse of archived S1-S3 single-agent responses.""" from __future__ import annotations import hashlib import json from dataclasses import dataclass, field from pathlib import Path from typing import Any import yaml from .base import MarketSnapshot, S1Output, S2Output, S3Output, StageID from .prompts ...
AgenticFinLab/portbench
portbench/agent_eval/legacy_stage_reuse.py
.py
adfdd80c775e75aa
7.48
8
""" Mock agent adapter for development and unit testing. The mock agent does not call any LLM. Instead it returns rule-based outputs that are intentionally slightly noisy (not perfect) so that CEPS scores are non-trivial and the pipeline can be tested end-to-end. Noise level controls how far the mock deviates from gr...
AgenticFinLab/portbench
portbench/agent_eval/mock_agent.py
.py
d193f2358b655f45
7.48
8
"""Deterministic Point-in-Time repair operators for the five stages.""" from __future__ import annotations import dataclasses from collections.abc import Mapping, Sequence from typing import Any, Dict, Optional import numpy as np import pandas as pd VERSION = "pit_repair_v2" _FUTURE_KEYS = frozenset( {"future_...
AgenticFinLab/portbench
portbench/agent_eval/pit_repair.py
.py
f10dc5ed6fe88631
7.48
8
"""Persistent factual and intervention stage cache.""" from __future__ import annotations import json import os import threading from dataclasses import asdict, is_dataclass from pathlib import Path from typing import Any, Callable, Dict, Optional, Tuple from portbench.agent_eval.contracts import CachedStageResult, ...
AgenticFinLab/portbench
portbench/agent_eval/replay_adapter.py
.py
5f5f20089fc6c4de
7.48
8
"""Protocol / provenance validators and ranking schema guards.""" from __future__ import annotations from typing import Any, Dict, Iterable, List, Mapping, Optional, Sequence from portbench.agent_eval.contracts import ( STEP_REPLAY_FORBIDDEN_METRICS, ProvenanceSource, ResultProvenance, ) from portbench.m...
AgenticFinLab/portbench
portbench/agent_eval/result_gates.py
.py
46361d7ad1462117
7.48
8
""" Front-door passwords, stored as salted PBKDF2 hashes — never plaintext. Two independent levels, because they protect different things: ADMIN the settings panel, the keys, the test endpoints. Whoever holds this controls the application and can spend your API keys. GUEST the call itself — the Call bu...
mrain1p/Talk-Wave
agent-worker/admin_auth.py
.py
7501ff263cc0d0eb
7.45
7
"""Where a stored secret is allowed to travel. Its own module because it is a rule, not a helper: both the settings panel's option lookups and every test endpoint have to obey it, and the failure it prevents is silent. """ from __future__ import annotations import logging log = logging.getLogger("callin.token") #...
mrain1p/Talk-Wave
agent-worker/api/credentials.py
.py
ac3e26609e5f1fe1
7.45
7
"""What the card LOOKS like — the answer to "how should this widget dress", independent of who is asking. Split from api/live.py at 0.10.131, when the now-playing rail's two new fields pushed that file over the ceiling. The seam is real and one-way: nothing here touches a request, a session or the station client. Thes...
mrain1p/Talk-Wave
agent-worker/api/look.py
.py
1f42978bd4d1ddc7
7.45
7
"""The mixer's fetch leg for live-call clips. The relay (worker process) pushes `voice_queue.push <url>` at the mixer; the mixer then curls the clip from HERE (web process) — the two containers share `data/onair/`, which is the whole hand-off. Public by design, like /vm-air: the mixer is curl on another network, so th...
mrain1p/Talk-Wave
agent-worker/api/onair.py
.py
e67ae0ddb63872fb
7.45
7
"""The station player's listener actions: the heart and the request box. The player is a LISTENER surface, and the station already answers listeners without credentials — POST /like and POST /request are public on the station by design, rate-limited per IP, refusing in plain words ("Requests are temporarily closed.")....
mrain1p/Talk-Wave
agent-worker/api/player.py
.py
14fab29af2fd7ea4
7.45
7
"""The panel's activity data: the concurrent-listener series, sampled. The rest of the ACTIVITY strip — doors, ratings, time-to-first-word — is derived client-side from /calls, because the records already carry their timestamps, kinds, problems and ratings. The listener curve is the one series nothing stores: the stat...
mrain1p/Talk-Wave
agent-worker/api/stats.py
.py
1286de91c575ddb7
7.45
7
"""Serving web-widget/ — the call page, and how long a browser may keep it. The html is never cached, so an image update is picked up immediately. The 100KB of js and css behind it is cached for a year, because its URL carries a tag that changes exactly when the file does. """ from __future__ import annotations impo...
mrain1p/Talk-Wave
agent-worker/api/widget.py
.py
8bf60d7771ffd0e0
7.45
7
"""The HTTP edge: what we send back, and who we believe sent it. Both answers are policy rather than plumbing. Which origins may talk to this service decides who can spend the operator's API budget, and which address a request is attributed to decides whose cooldown and whose lockout counter it lands on — so neither m...
mrain1p/Talk-Wave
agent-worker/api/wire.py
.py
a86f8c25b2d9e355
7.45
7
"""How the DJ behaves in a TYPED chat. The spoken conduct is written for a phone call — dead-air rules, TTS-length turns, the can't-be-in-two-places hold — and typing has different physics: silence isn't awkward, replies can breathe a little, and the DJ can keep typing while the broadcast talks. What is medium-indepen...
mrain1p/Talk-Wave
agent-worker/brain/conduct_chat.py
.py
1f59788255bad02f
7.45
7
"""Per-call record of what the caller actually made happen.""" from __future__ import annotations import json import logging import time from .background import spawn log = logging.getLogger("callin.agent") class CallActions: """Per-call record of what the caller actually made happen. Two jobs, both of w...
mrain1p/Talk-Wave
agent-worker/call/actions.py
.py
b5490957856ef2c4
7.45
7
"""Whether this call is already over, and the word that stops it restarting. The two failures this owns, both recorded on one live harness call (2026-08-25, against the deployed stack): the DJ said goodbye TWICE — a full farewell, then a second full farewell on the next turn — and when an on-air hold interrupted the E...
mrain1p/Talk-Wave
agent-worker/call/arc.py
.py
e257700e7fed80dd
7.45
7
"""What the caller asked for, and whether anything ever happened about it. The gap this fills, named in the master plan and left open through three reviews: **nothing pairs an ask to an outcome.** A record holds turns, tools and problems. It does not hold "the caller asked for a shoutout and no shoutout was ever sent"...
mrain1p/Talk-Wave
agent-worker/call/asks.py
.py
ac19a563bd908ef0
7.45
7
"""Fire-and-forget tasks that actually survive. `asyncio.create_task` alone is not enough: the event loop keeps only a weak reference, so a task with no other reference can be garbage-collected mid-execution. For us that meant an action card or an on-air state change going missing at random — worse than one that never...
mrain1p/Talk-Wave
agent-worker/call/background.py
.py
cf1c519c887cbebd
7.45
7
"""Whether the DJ just showed the caller the door, and one word in its ear. The failure, in the operator's own words: a caller who asked for one song was shown the door three times on the way out. `conduct.CLOSING` has four paragraphs against it and they do not hold — measured 2026-08-14 with SCENARIO_SET=closing, one...
mrain1p/Talk-Wave
agent-worker/call/door.py
.py
28fa98a26ad2be83
7.45
7
"""Who has the floor — so two of the DJ's own turns never start at once. Ten things can make the DJ speak and they were added one incident at a time, each checking whatever the incident was about. Reading them against each other (docs/the-call.md has the table) shows most of that is already covered: * the greeting ...
mrain1p/Talk-Wave
agent-worker/call/floor.py
.py
0a5d77be8d1fd0ef
7.45
7
"""After the call: reading the conversation back, and the back-to-air mention. Split out of lifecycle.py, which was over the length ceiling and had exactly this seam recorded against it: everything here runs AFTER the call, only reads the session, and nothing during-call reads it back. `transcript` is the one honest ...
mrain1p/Talk-Wave
agent-worker/call/handoff.py
.py
522f807864da6832
7.45
7
import logging import secrets import time from mcp.server.auth.middleware.auth_context import get_access_token from mcp.server.auth.provider import ( AccessToken, AuthorizationCode, AuthorizationParams, OAuthAuthorizationServerProvider, RefreshToken, construct_redirect_uri, ) from mcp.server.au...
dmm-com/mcp-pagoda
src/mcp_server/lib/auth/azure.py
.py
4c0767e96baba9bf
7.45
7
import logging from typing import Literal from mcp.server.auth.provider import AccessToken, TokenVerifier from mcp.server.auth.settings import AuthSettings from mcp.server.fastmcp.server import FastMCP from mcp_server.lib.auth.azure import get_azure_mcp_server from mcp_server.lib.auth.common import ServerSettings fro...
dmm-com/mcp-pagoda
src/mcp_server/server_sse.py
.py
991f8c3f540c36e7
7.45
7
"""CI verdict for a PR head, used to disprove predicted build failures. Models routinely predict compile errors that the real compiler disagrees with — on deepiri-topolsea#21 Gemini claimed a missing import and a broken route definition on a commit whose Rust job was green. GitHub already ran the actual toolchain on t...
Team-Deepiri/deepiri-sorge
bot/build_status.py
.py
ad862b5f4c45087a
7.42
6
"""Assemble PR diffs when GitHub rejects the monolithic diff (406 too_large). GitHub caps ``Accept: application/vnd.github.v3.diff`` at ~20k lines. ``GET /pulls/{n}/files`` still returns per-file ``patch`` fields (paginated), so we stitch those into a reviewable unified-diff-like text. """ from __future__ import anno...
Team-Deepiri/deepiri-sorge
bot/diff_assembler.py
.py
6f3226fafbf11555
7.42
6
"""GitHub App installation token helpers.""" from __future__ import annotations import os import time import requests from ghapi.all import GhApi from loguru import logger def _load_private_key(pem: str | None) -> str: if pem: # Handle both actual \n chars and literal "\\n" strings pem = pem.re...
Team-Deepiri/deepiri-sorge
bot/github_app.py
.py
aa99b6ba82ed1093
7.42
6
"""PR-HEAD dependency evidence for the review prompt. Gives the model objective facts about packages imported in the DIFF vs manifests on the checked-out tip — so it does not guess from hunks alone. ClaimVerifier remains the post-condition safety net for the same class of claims. """ from __future__ import annotation...
Team-Deepiri/deepiri-sorge
bot/manifest_evidence.py
.py
b8267245809e30e4
7.42
6
"""Prompt templates for review runners.""" from pathlib import Path _DIR = Path(__file__).parent _TEMPLATE_PATH = _DIR / "review_template.txt" _GROQ_BUG_DETECTOR_PATH = _DIR / "groq_bug_detector.txt" def load_review_template() -> str: if _TEMPLATE_PATH.exists(): return _TEMPLATE_PATH.read_text(encoding=...
Team-Deepiri/deepiri-sorge
bot/prompts/__init__.py
.py
82f37433865653d2
7.42
6
"""Build enabled providers from config.""" from __future__ import annotations from bot.config import CacheConfig, Config from bot.providers.base import Provider from bot.providers.gemini import GeminiProvider from bot.providers.groq import GroqProvider from bot.providers.openrouter import OpenRouterProvider def bui...
Team-Deepiri/deepiri-sorge
bot/providers/__init__.py
.py
340d99b1fcfad4b3
7.42
6
"""Helpers shared by provider adapters.""" from __future__ import annotations import time import requests from bot.file_splitter import ReviewChunk from bot.scheduling.run_context import RunContext from bot.scheduling.types import MAX_PARTIAL_CHARS, ProviderResult from bot.schemas import ReviewResult # A fragment...
Team-Deepiri/deepiri-sorge
bot/providers/_runner_adapter.py
.py
53ad4a669ca53632
7.42
6
"""Provider Protocol — execution backends for the review scheduler.""" from __future__ import annotations from typing import TYPE_CHECKING, Protocol, runtime_checkable from bot.file_splitter import ReviewChunk from bot.scheduling.types import ProviderResult, ProviderStatus if TYPE_CHECKING: from bot.scheduling....
Team-Deepiri/deepiri-sorge
bot/providers/base.py
.py
9df76ce6dbb9391a
7.42
6
"""Base runner class for model runners""" from __future__ import annotations from abc import ABC, abstractmethod from loguru import logger from bot.diff_parser import ParsedDiff from bot.prompts import load_review_template from bot.schemas import ReviewIssue, ReviewResult, issues_from_parsed, result_from_parsed fro...
Team-Deepiri/deepiri-sorge
bot/runners/base.py
.py
c3fd333a33f9e841
7.42
6
"""Groq runner using the OpenAI-compatible chat completions API.""" from __future__ import annotations import os import time import requests from loguru import logger from bot.config import CacheConfig from bot.diff_parser import ParsedDiff from bot.prompts import load_groq_bug_detector_template from bot.runners.ba...
Team-Deepiri/deepiri-sorge
bot/runners/groq_runner.py
.py
09409b788f5e3fef
7.42
6
"""Shared JSON Schema definitions for structured output enforcement across all runners. Both Gemini (responseSchema) and OpenAI-compatible APIs (response_format: json_schema) support structured output schemas. This module provides a single source of truth for the review output schema to keep all runners in sync. The ...
Team-Deepiri/deepiri-sorge
bot/runners/json_schema.py
.py
a6aac5d9872375d1
7.42
6
"""Review complexity scoring for quality-aware provider routing. Returns a score in [0, 1]. Used by the scheduler market score (live path) and ContextRouter (size/quota plan) so both share one definition. """ from __future__ import annotations import re from pathlib import Path from bot.file_splitter import ReviewC...
Team-Deepiri/deepiri-sorge
bot/scheduling/complexity.py
.py
6a7967ffdda0e1c6
7.42
6
"""Market-style provider scoring for a chunk. Includes soft **lane affinity**: size + complexity/security bias so simple PRs prefer Groq and auth/complex PRs prefer Gemini without hardcoding a winner. """ from __future__ import annotations from bot.scheduling.complexity import ( COMPLEXITY_ESCALATE, SECURITY...
Team-Deepiri/deepiri-sorge
bot/scheduling/market_score.py
.py
512c93fb35129dfd
7.42
6
"""Assign review-chunk priority from path keywords (higher = review first).""" from __future__ import annotations from bot.file_splitter import ReviewChunk # (substrings matched against lowercased paths, priority weight) # First matching rule wins per file; chunk takes the max across its files. _PATH_RULES: tuple[tu...
Team-Deepiri/deepiri-sorge
bot/scheduling/priority.py
.py
fadd24290555fffd
7.42
6
"""Shared mutable state for one review run.""" from __future__ import annotations import threading import time from collections.abc import Callable from dataclasses import dataclass, field from typing import Any from bot.quota_tracker import QuotaTracker from bot.scheduling.health import HealthTracker from bot.sched...
Team-Deepiri/deepiri-sorge
bot/scheduling/run_context.py
.py
2899563cf1e9f61b
7.42
6
"""Structured results for provider-backed review execution.""" from __future__ import annotations from dataclasses import dataclass, field from typing import Any from bot.file_splitter import ReviewChunk from bot.schemas import ReviewResult @dataclass class ProviderResult: """Outcome of a single provider.revie...
Team-Deepiri/deepiri-sorge
bot/scheduling/types.py
.py
b1b0953a0787010e
7.42
6
"""Shared review result types.""" from __future__ import annotations from dataclasses import dataclass from bot.utils.response_parser import normalize_review_payload # Review types meaning "zero chunks were successfully reviewed". A quality # score is never defensible for these: there is no evidence behind it, and...
Team-Deepiri/deepiri-sorge
bot/schemas.py
.py
9665a80e54af6125
7.42
6
"""Disk-backed cache for review results, keyed by diff + model hash.""" from __future__ import annotations import hashlib import json import time from pathlib import Path from loguru import logger CACHE_DIR = Path.home() / ".cache" / "sorge" / "reviews" # Provider-agnostic key used by the scheduler so a hit skips ...
Team-Deepiri/deepiri-sorge
bot/utils/cache.py
.py
2113da3886b9ae54
7.42
6