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 |
|---|---|---|---|---|---|---|
"""add_issues_table_and_feedback_issue_fk
Revision ID: bc0838c50bec
Revises: 88eae8d7e7a6
Create Date: 2026-02-10 17:54:54.362389
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
import sqlmodel
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.... | agencyenterprise/draft-detective | alembic/versions/bc0838c50bec_add_issues_table_and_feedback_issue_fk.py | .py | 2d0a3ee406e784b7 | 7.65 | 19 |
"""remove_unneeded_workflow_run_columns
Revision ID: c3fa401e821b
Revises: 67ccc59315f1
Create Date: 2025-11-27 15:55:18.861270
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
import sqlmodel
# revision identifiers, used by Alembic.
revision: str = 'c3fa401e821b'
down_revision... | agencyenterprise/draft-detective | alembic/versions/c3fa401e821b_remove_unneeded_workflow_run_columns.py | .py | 374918642203fc05 | 7.65 | 19 |
"""add_user_connections
Revision ID: c6b3cc257d3c
Revises: 1e1b703e2340
Create Date: 2025-11-10 14:25:59.590419
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
import sqlmodel
# revision identifiers, used by Alembic.
revision: str = 'c6b3cc257d3c'
down_revision: Union[str, Non... | agencyenterprise/draft-detective | alembic/versions/c6b3cc257d3c_add_user_connections.py | .py | 0e98e7696cbb603e | 7.65 | 19 |
"""add_file_artifact_columns
Revision ID: cbd53440b56f
Revises: aef5202a5521
Create Date: 2026-01-19 18:09:46.526257
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
import sqlmodel
from sqlalchemy.dialects import postgresql
# revision identifiers, used by Alembic.
revision: st... | agencyenterprise/draft-detective | alembic/versions/cbd53440b56f_add_file_artifact_columns.py | .py | dec42f82b83c2c79 | 7.65 | 19 |
"""create_files_table
Revision ID: cdfa040a0771
Revises: dc6d4f17b026
Create Date: 2025-12-09 15:07:54.041817
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
import sqlmodel
# revision identifiers, used by Alembic.
revision: str = 'cdfa040a0771'
down_revision: Union[str, None]... | agencyenterprise/draft-detective | alembic/versions/cdfa040a0771_create_files_table.py | .py | da9ac8263054cb12 | 7.65 | 19 |
"""remove domain and target_audience from projects
Revision ID: dbe72628c304
Revises: ab0512d13ef0
Create Date: 2026-08-24 10:55:50.049351
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
import sqlmodel
# revision identifiers, used by Alembic.
revision: str = 'dbe72628c304'
do... | agencyenterprise/draft-detective | alembic/versions/dbe72628c304_remove_domain_and_target_audience_from_.py | .py | c60f55f4e202b32d | 7.65 | 19 |
"""make_workflow_project_optional
Revision ID: dc6d4f17b026
Revises: 90b84d00bfda
Create Date: 2025-12-04 22:28:05.217998
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
import sqlmodel
# revision identifiers, used by Alembic.
revision: str = 'dc6d4f17b026'
down_revision: Unio... | agencyenterprise/draft-detective | alembic/versions/dc6d4f17b026_make_workflow_project_optional.py | .py | 0d7bcf8a60179fa5 | 7.65 | 19 |
"""add encrypted_openai_api_key to users
Revision ID: ddaeb39ae83a
Revises: 8b28e2a42549
Create Date: 2026-04-03 09:56:50.662498
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
import sqlmodel
# revision identifiers, used by Alembic.
revision: str = 'ddaeb39ae83a'
down_revisio... | agencyenterprise/draft-detective | alembic/versions/ddaeb39ae83a_add_encrypted_openai_api_key_to_users.py | .py | acaeb11e1efaf8b8 | 7.65 | 19 |
"""add_pgvector_extension
Revision ID: e02d6d007602
Revises: 98b0e22e71a6
Create Date: 2025-10-17 10:11:39.306576
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
import sqlmodel
# revision identifiers, used by Alembic.
revision: str = "e02d6d007602"
down_revision: Union[str, ... | agencyenterprise/draft-detective | alembic/versions/e02d6d007602_add_pgvector_extension.py | .py | 1230347b03ed955b | 7.65 | 19 |
"""Initial migration: create agents, workflows, workflow_runs, chats tables
Revision ID: e8cd4f1f7766
Revises:
Create Date: 2025-09-09 16:55:43.302893
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
# revision identifiers, used by A... | agencyenterprise/draft-detective | alembic/versions/e8cd4f1f7766_initial_migration_create_agents_.py | .py | 3f9d0423b9127272 | 7.65 | 19 |
"""add suggested_action to issues
Revision ID: f4ef6e0d9708
Revises: 1d6c512c344f
Create Date: 2026-04-28 17:23:34.132767
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
import sqlmodel
# revision identifiers, used by Alembic.
revision: str = 'f4ef6e0d9708'
down_revision: Unio... | agencyenterprise/draft-detective | alembic/versions/f4ef6e0d9708_add_suggested_action_to_issues.py | .py | e3665cd2b01c7d0a | 7.65 | 19 |
"""add_index_to_workflow_run_project_id
Revision ID: f6c0d2582e72
Revises: cbd53440b56f
Create Date: 2026-01-22 19:31:23.309901
"""
from typing import Sequence, Union
from alembic import op
import sqlalchemy as sa
import sqlmodel
# revision identifiers, used by Alembic.
revision: str = 'f6c0d2582e72'
down_revision... | agencyenterprise/draft-detective | alembic/versions/f6c0d2582e72_add_index_to_workflow_run_project_id.py | .py | 279afd4ea5922e5b | 7.65 | 19 |
"""Hello World Litestar MCP Plugin Example.
This example demonstrates the simplest possible integration of the Litestar MCP Plugin.
It shows how to add MCP capabilities to any Litestar application with just 3 lines of code.
The MCP plugin exposes your application's metadata through the MCP Streamable HTTP
transport s... | cofin/litestar-mcp | docs/examples/hello_world/main.py | .py | cf23988ce25e0363 | 7.56 | 12 |
"""Pytest companion for ``docs/examples/hello_world/main.py``.
Exercises the marked snippet (``build_app``) end-to-end via
``litestar.testing.TestClient`` and the project-standard JSON-RPC helper.
"""
from typing import Any
from litestar.testing import TestClient
from docs.examples.hello_world.main import build_app... | cofin/litestar-mcp | docs/examples/hello_world/test_hello_world.py | .py | dcab25fee105a155 | 8.06 | 12 |
"""Shared Advanced Alchemy model and service for the reference notes examples."""
from advanced_alchemy.base import UUIDAuditBase
from advanced_alchemy.repository import SQLAlchemyAsyncRepository
from advanced_alchemy.service import SQLAlchemyAsyncRepositoryService
from sqlalchemy.orm import Mapped, mapped_column
cl... | cofin/litestar-mcp | docs/examples/notes/advanced_alchemy/common.py | .py | 1a4f53f011aa1049 | 7.56 | 12 |
"""JWT-authenticated Advanced Alchemy reference notes example."""
# /// script
# requires-python = ">=3.10"
# dependencies = [
# "litestar[standard]>=2.0",
# "litestar-mcp",
# "advanced-alchemy[litestar]>=1.0",
# "aiosqlite",
# "python-jose[cryptography]",
# "uvicorn",
# ]
# ///
from pathlib import Path
f... | cofin/litestar-mcp | docs/examples/notes/advanced_alchemy/jwt_auth.py | .py | f7d37da2900c5094 | 7.56 | 12 |
"""JWT-authenticated Advanced Alchemy + Dishka reference notes example."""
# /// script
# requires-python = ">=3.10"
# dependencies = [
# "litestar[standard]>=2.0",
# "litestar-mcp",
# "advanced-alchemy[litestar]>=1.0",
# "aiosqlite",
# "dishka",
# "python-jose[cryptography]",
# "uvicorn",
# ]
# ///
fro... | cofin/litestar-mcp | docs/examples/notes/advanced_alchemy/jwt_auth_dishka.py | .py | e64f47e7a462a69b | 7.56 | 12 |
"""No-auth Advanced Alchemy reference notes example."""
# /// script
# requires-python = ">=3.10"
# dependencies = [
# "litestar[standard]>=2.0",
# "litestar-mcp",
# "advanced-alchemy[litestar]>=1.0",
# "aiosqlite",
# "uvicorn",
# ]
# ///
from pathlib import Path
from typing import Any
from uuid import UUID... | cofin/litestar-mcp | docs/examples/notes/advanced_alchemy/no_auth.py | .py | ddb6d6f62bfe15c1 | 7.56 | 12 |
"""No-auth Advanced Alchemy + Dishka reference notes example.
Mirrors :mod:`docs.examples.notes.advanced_alchemy.no_auth` but resolves the
:class:`NoteService` through a Dishka container rather than Litestar's
built-in DI. The public MCP surface (tool and resource names, payload shapes)
is identical to the plain varia... | cofin/litestar-mcp | docs/examples/notes/advanced_alchemy/no_auth_dishka.py | .py | 04ad61573ddcb62b | 7.56 | 12 |
"""Shared contracts for the reference notes examples."""
from typing import Final
from uuid import UUID
import msgspec
LIST_NOTES_TOOL_NAME: "Final" = "list_notes"
CREATE_NOTE_TOOL_NAME: "Final" = "create_note"
DELETE_NOTE_TOOL_NAME: "Final" = "delete_note"
NOTES_SCHEMA_RESOURCE_NAME: "Final" = "notes_schema"
APP_IN... | cofin/litestar-mcp | docs/examples/notes/shared/contracts.py | .py | e7d5188b086ce204 | 7.56 | 12 |
"""Cloud Run-shaped SQLSpec reference notes example (app-managed JWT)."""
# /// script
# requires-python = ">=3.10"
# dependencies = [
# "litestar[standard]>=2.0",
# "litestar-mcp",
# "sqlspec[aiosqlite]>=0.43",
# "python-jose[cryptography]",
# "uvicorn",
# ]
# ///
import os
from collections.abc import Asyn... | cofin/litestar-mcp | docs/examples/notes/sqlspec/cloud_run_jwt.py | .py | edc18f0e2034d7b0 | 8.06 | 12 |
"""Shared SQLSpec wiring for the reference notes examples.
This module owns the SQLSpec adapter configuration, the typed row mapping,
the schema bootstrap SQL, and the :class:`SQLSpecNoteService` used by every
variant in the family. Variant files never redeclare SQL or row shapes —
they compose this module's service w... | cofin/litestar-mcp | docs/examples/notes/sqlspec/common.py | .py | 16ec8cad4f7213d0 | 8.06 | 12 |
"""Google IAP-authenticated SQLSpec reference notes example (BYO middleware pattern).
Uses ``MCPAuthBackend`` with ``build_iap_token_validator`` as the ``token_validator``.
The ``build_iap_header_alias_middleware`` aliases ``x-goog-iap-jwt-assertion``
into ``Authorization: Bearer`` at the ASGI layer so the bearer-toke... | cofin/litestar-mcp | docs/examples/notes/sqlspec/google_iap.py | .py | 107df4f1db68c81b | 8.06 | 12 |
"""JWT-authenticated SQLSpec reference notes example."""
# /// script
# requires-python = ">=3.10"
# dependencies = [
# "litestar[standard]>=2.0",
# "litestar-mcp",
# "sqlspec[aiosqlite]>=0.43",
# "python-jose[cryptography]",
# "uvicorn",
# ]
# ///
from collections.abc import AsyncIterator
from pathlib impo... | cofin/litestar-mcp | docs/examples/notes/sqlspec/jwt_auth.py | .py | b1d8a38fcca43a16 | 8.06 | 12 |
"""JWT-authenticated SQLSpec + Dishka reference notes example."""
# /// script
# requires-python = ">=3.10"
# dependencies = [
# "litestar[standard]>=2.0",
# "litestar-mcp",
# "sqlspec[aiosqlite]>=0.43",
# "dishka",
# "python-jose[cryptography]",
# "uvicorn",
# ]
# ///
from collections.abc import AsyncIte... | cofin/litestar-mcp | docs/examples/notes/sqlspec/jwt_auth_dishka.py | .py | e5b42e4b8c6bea84 | 8.06 | 12 |
"""No-auth SQLSpec reference notes example.
Mirrors :mod:`docs.examples.notes.advanced_alchemy.no_auth` but backs the
notes domain with an explicit SQLSpec async SQLite adapter. Parameters are
bound, results are mapped into :class:`NoteRow` via ``schema_type``, and the
HTTP/MCP surface is handed the shared public :cla... | cofin/litestar-mcp | docs/examples/notes/sqlspec/no_auth.py | .py | bc977154e7d44322 | 8.06 | 12 |
"""No-auth SQLSpec + Dishka reference notes example.
Mirrors :mod:`docs.examples.notes.sqlspec.no_auth` but resolves the
:class:`SQLSpecNoteService` through a Dishka container. The public MCP
surface (tool/resource names and payload shapes) is identical to the plain
variant — Dishka is a pure DI swap.
"""
# /// scrip... | cofin/litestar-mcp | docs/examples/notes/sqlspec/no_auth_dishka.py | .py | 08785d47fd7ae2bb | 8.06 | 12 |
"""Snippets for Google ADK client integration."""
from google.adk.tools.mcp_tool import McpToolset
from google.adk.tools.mcp_tool.mcp_session_manager import StreamableHTTPConnectionParams
def connect_simple() -> "McpToolset":
"""Connect to the Litestar MCP server without authentication."""
toolset = McpTools... | cofin/litestar-mcp | docs/examples/snippets/adk_snippets.py | .py | 3adbdf620127bdbb | 7.56 | 12 |
"""Snippet: MCPAuthBackend with a custom token validator. Referenced from docs/usage/auth.rst."""
from typing import Any
from litestar import Litestar
from litestar.middleware import DefineMiddleware
from litestar_mcp import LitestarMCP, MCPAuthBackend, MCPConfig
from litestar_mcp.auth import MCPAuthConfig
async d... | cofin/litestar-mcp | docs/examples/snippets/auth_bearer_validator.py | .py | 7ce2d9359ba3dd4a | 7.56 | 12 |
"""Authorize MCP tool dispatch with a Litestar Guard.
Scopes declared on ``@mcp_tool(scopes=[...])`` are discovery-only metadata
since v0.5.0. Attach a Guard to enforce access control — the same guard
protects HTTP and MCP paths.
"""
from typing import TYPE_CHECKING, Any
# start-example
from litestar import Controll... | cofin/litestar-mcp | docs/examples/snippets/authorization_guard.py | .py | d9bf788bdd59d2eb | 7.56 | 12 |
"""Snippet: register standalone prompts. Referenced from docs/usage/configuration.rst."""
from litestar import Litestar
from litestar_mcp import LitestarMCP, MCPConfig, mcp_prompt
@mcp_prompt(name="greet", description="Greet a user by name.")
async def greet(name: "str") -> "str":
"""Build a greeting prompt.
... | cofin/litestar-mcp | docs/examples/snippets/configuration_prompts.py | .py | dc56d3716bc0805a | 7.56 | 12 |
"""Snippet: MCP tool-call callback configuration."""
from typing import Any
from litestar import Litestar, Request
from litestar_mcp import LitestarMCP, MCPConfig
# start-example
async def after_tool_call(
tool_name: "str",
arguments: "dict[str, Any]",
request: "Request[Any, Any, Any]",
*,
resu... | cofin/litestar-mcp | docs/examples/snippets/configuration_tool_callbacks.py | .py | 3d0e6e301c8a3f34 | 7.56 | 12 |
"""Snippet: using the mcp_tool/mcp_resource decorators. Referenced from docs/usage/marking_routes.rst."""
from litestar import Litestar, get
from litestar_mcp import LitestarMCP
from litestar_mcp.utils import mcp_tool
def build() -> "Litestar":
# start-example
@mcp_tool(name="get_user")
@get("/users/{us... | cofin/litestar-mcp | docs/examples/snippets/marking_decorator.py | .py | 4876afb99a6120ff | 7.56 | 12 |
"""Snippet: request-scoped dependency injection. Referenced from docs/usage/dependencies.rst."""
from typing import Any
from litestar import Litestar, get
from litestar.di import Provide
from litestar_mcp import LitestarMCP
async def provide_current_user() -> "dict[str, str]":
return {"id": "u-1", "role": "adm... | cofin/litestar-mcp | docs/examples/snippets/marking_dependencies.py | .py | ef13585cf7f5553b | 7.56 | 12 |
"""Snippet: marking and registering MCP prompts. Referenced from docs/usage/marking_routes.rst."""
from litestar import Litestar, get
from litestar_mcp import LitestarMCP, mcp_prompt
def build() -> "Litestar":
# start-example
@mcp_prompt(name="summarize", description="Summarise a document in a chosen style.... | cofin/litestar-mcp | docs/examples/snippets/marking_prompts.py | .py | afa5bc6d1402b6b5 | 7.56 | 12 |
"""Snippet: marking a route as an MCP resource. Referenced from docs/usage/marking.rst."""
from typing import Any
from litestar import Litestar, get
from litestar_mcp import LitestarMCP
def build() -> "Litestar":
# start-example
@get("/api/schema", mcp_resource="api_schema")
async def get_schema() -> "... | cofin/litestar-mcp | docs/examples/snippets/marking_resources.py | .py | 8c4412b61e1d939e | 7.56 | 12 |
"""Snippet: marking a route as an MCP tool. Referenced from docs/usage/marking.rst."""
from litestar import Litestar, get
from litestar_mcp import LitestarMCP
def build() -> "Litestar":
# start-example
@get("/users/{user_id:int}", mcp_tool="get_user")
async def get_user(user_id: "int") -> "dict[str, int... | cofin/litestar-mcp | docs/examples/snippets/marking_tools.py | .py | 943c19f48e07749a | 7.56 | 12 |
"""Snippet: binary MCP resources with MIME metadata."""
from litestar import Litestar, Response, get
from litestar_mcp import LitestarMCP, mcp_resource
def build() -> "Litestar":
# start-route-example
@get(
"/reports/latest",
mcp_resource="latest_report",
mcp_resource_mime_type="appl... | cofin/litestar-mcp | docs/examples/snippets/resource_binary.py | .py | 0f3b6fb1527be66e | 7.56 | 12 |
from pathlib import Path
from platformdirs import user_data_dir
from danmaku_sender._version import __version__
from danmaku_sender.utils.path_utils import find_assets_dir
# 应用数据目录(import 时计算,运行时不变)
_DATA_DIR = Path(user_data_dir("BiliDanmakuSender", "Miku_oso"))
_DATA_DIR.mkdir(parents=True, exist_ok=True)
class... | TouhouGleaners/danmaku-sender | src/danmaku_sender/config/app_meta.py | .py | 26a6d6a33b7b6389 | 7.66 | 20 |
from pydantic import ConfigDict, Field, model_validator
from danmaku_sender.types.models.evented_model import EventedModel
class SenderConfig(EventedModel):
"""发送器的配置数据"""
model_config = ConfigDict(validate_assignment=True)
# 延迟设置
min_delay: float = Field(default=8.0, ge=0.1)
max_delay: float = ... | TouhouGleaners/danmaku-sender | src/danmaku_sender/config/sender_config.py | .py | 9410ca940e07c272 | 7.66 | 20 |
"""账号管理控制器:封装账号验证与用户信息获取的异步 API 调用"""
import logging
from PySide6.QtCore import QObject, Signal
from .concurrency import PoolTask
from danmaku_sender.types.models.account import AccountCredential
from danmaku_sender.types.models.user import UserProfile
from danmaku_sender.config import ApiAuthConfig
from danmaku_sen... | TouhouGleaners/danmaku-sender | src/danmaku_sender/controller/account_controller.py | .py | a78ee2b472639034 | 7.66 | 20 |
import logging
import threading
from PySide6.QtCore import QObject, Signal, Slot
from .concurrency import WorkerThread, PoolTask
from danmaku_sender.config import ApiAuthConfig
from danmaku_sender.types.models.user import UserProfile
from danmaku_sender.service.auth_service import AuthService
logger = logging.getL... | TouhouGleaners/danmaku-sender | src/danmaku_sender/controller/auth_controller.py | .py | 951c2cb43fd07823 | 7.66 | 20 |
import logging
import threading
import traceback
from typing import Callable
from abc import abstractmethod
from PySide6.QtCore import QThread, QObject, Signal, QRunnable, Slot, QThreadPool
logger = logging.getLogger(__name__)
class WorkerThread(QThread):
"""
所有长驻/重型 Worker 线程的抽象基类。
提供了线程管理、信号定义和日志记录等... | TouhouGleaners/danmaku-sender | src/danmaku_sender/controller/concurrency.py | .py | c6392cf16676db60 | 7.66 | 20 |
import logging
from typing import Callable
from PySide6.QtCore import QObject, Signal
from .concurrency import PoolTask
from danmaku_sender.service.editor_session import EditorSession
from danmaku_sender.runtime.state.app_state import AppState
from danmaku_sender.types.models.danmaku import Danmaku
from danmaku_sende... | TouhouGleaners/danmaku-sender | src/danmaku_sender/controller/editor_controller.py | .py | 14d12d1615febd07 | 7.66 | 20 |
import logging
from PySide6.QtCore import QObject, Signal
from .concurrency import PoolTask
from danmaku_sender.repo.history_manager import HistoryManager
from danmaku_sender.service.bili_monitor import BiliDanmakuMonitor
from danmaku_sender.config import ApiAuthConfig
logger = logging.getLogger(__name__)
class ... | TouhouGleaners/danmaku-sender | src/danmaku_sender/controller/history_controller.py | .py | 935cae4cae50906c | 7.66 | 20 |
import logging
import threading
from PySide6.QtCore import QObject, Signal, Slot
from .concurrency import WorkerThread
from .system_utils import KeepSystemAwake
from danmaku_sender.repo.history_manager import HistoryManager
from danmaku_sender.types.models.common import VideoTarget
from danmaku_sender.config import ... | TouhouGleaners/danmaku-sender | src/danmaku_sender/controller/monitor_controller.py | .py | a32b708a860fab35 | 7.66 | 20 |
import logging
from PySide6.QtCore import QObject, Signal, Slot
from .concurrency import PoolTask
from danmaku_sender.repo.github_client import UpdateChecker, UpdateInfo
from danmaku_sender.config.app_meta import AppInfo
logger = logging.getLogger(__name__)
def _check_update(use_proxy: bool):
"""纯业务逻辑:连接 GitH... | TouhouGleaners/danmaku-sender | src/danmaku_sender/controller/system_controller.py | .py | 41755b62e43f061a | 7.66 | 20 |
import ctypes
import logging
import platform
import threading
logger = logging.getLogger(__name__)
IS_WINDOWS = platform.system() == "Windows"
class PowerManagement:
"""系统电源管理工具类 (仅限 Windows)"""
# Windows API 常量
ES_CONTINUOUS = 0x80000000
ES_SYSTEM_REQUIRED = 0x00000001
ES_DISPLAY_REQUIRED = 0x... | TouhouGleaners/danmaku-sender | src/danmaku_sender/controller/system_utils.py | .py | 20a3aa2da45a536e | 7.66 | 20 |
import logging
from PySide6.QtCore import QObject, Signal, QThreadPool, Slot
from danmaku_sender.types.models.video import VideoInfo
from danmaku_sender.config import ApiAuthConfig
from danmaku_sender.service.video_fetcher import VideoFetcher
from .concurrency import PoolTask
logger = logging.getLogger(__name__)
... | TouhouGleaners/danmaku-sender | src/danmaku_sender/controller/video_controller.py | .py | c4ad31e5ec76b92f | 7.66 | 20 |
import logging
from typing import Any, Generator, Protocol
from contextlib import contextmanager
import requests
from requests.exceptions import ConnectionError, HTTPError, RequestException, Timeout
from .wbi_signer import WbiSigner
from danmaku_sender.types.exceptions.exceptions import BiliNetworkError, BiliApiErro... | TouhouGleaners/danmaku-sender | src/danmaku_sender/repo/bili_api_client.py | .py | 046d1aaf02e8d007 | 7.66 | 20 |
import logging
import time
from pathlib import Path
from peewee import SqliteDatabase, fn, Case
from playhouse.migrate import SqliteMigrator, migrate
from .orm_models import db, SentDanmaku
from danmaku_sender.types.models.danmaku import Danmaku
from danmaku_sender.types.models.common import DanmakuStatus, VideoTarg... | TouhouGleaners/danmaku-sender | src/danmaku_sender/repo/history_manager.py | .py | 3093a2fcf9016d1a | 7.66 | 20 |
import time
import logging
import threading
import urllib.parse
from functools import reduce
from hashlib import md5
import requests
logger = logging.getLogger(__name__)
class WbiSigner:
"""WBI 签名类,用于对 B 站 API 请求参数进行签名 (来源BAC)"""
mixin_key_enc_tab = [
46, 47, 18, 2, 53, 8, 23, 32, 15, 50, 10, 31, 5... | TouhouGleaners/danmaku-sender | src/danmaku_sender/repo/wbi_signer.py | .py | 9ee3859e6e9ebe14 | 7.66 | 20 |
import sys
import logging
import logging.handlers
from pathlib import Path
from datetime import datetime, timezone
from PySide6.QtCore import SignalInstance
from danmaku_sender.config.app_meta import AppInfo
class LogNamespace:
"""日志命名空间契约(基于模块路径)"""
SENDER_PREFIXES = ("danmaku_sender.service.sender", "danm... | TouhouGleaners/danmaku-sender | src/danmaku_sender/runtime/infra/log_utils.py | .py | b81fb4bd3f97cdd0 | 7.66 | 20 |
import os
import json
import logging
import keyring
from pathlib import Path
from cryptography.fernet import Fernet, InvalidToken
from ..state.app_state import AppState
from danmaku_sender.config.app_meta import AppInfo
from danmaku_sender.types.models.account import AccountCredential
KEYRING_SERVICE_NAME = f"{AppI... | TouhouGleaners/danmaku-sender | src/danmaku_sender/runtime/managers/account_manager.py | .py | 43cf46f83ff63c83 | 7.66 | 20 |
import json
import logging
from pydantic import ValidationError, BaseModel
from ..state.app_state import AppState
from danmaku_sender.config.app_meta import AppInfo
from danmaku_sender.config import SenderConfig, MonitorConfig, ValidationConfig
logger = logging.getLogger(__name__)
CONFIG_PATH = AppInfo.Paths.CONF... | TouhouGleaners/danmaku-sender | src/danmaku_sender/runtime/managers/config_manager.py | .py | ad7d531d1f2b123c | 7.66 | 20 |
import logging
from dataclasses import dataclass
from PySide6.QtGui import QGuiApplication
from PySide6.QtCore import Qt, QObject, Signal, Slot
logger = logging.getLogger(__name__)
@dataclass
class Palette:
"""双色调色板"""
bg_base: str # 最底层背景 (主窗口)
bg_surface: str # 表面背景 (侧边栏)
bg_ho... | TouhouGleaners/danmaku-sender | src/danmaku_sender/runtime/managers/theme_manager.py | .py | 1c3e12073df038b4 | 7.66 | 20 |
import logging
from .infra.resources import AppResources
from .state.app_state import AppState
from .managers.config_manager import ConfigManager
from .managers.account_manager import AccountManager
from danmaku_sender.config.app_meta import AppInfo
from danmaku_sender.repo.history_manager import HistoryManager
log... | TouhouGleaners/danmaku-sender | src/danmaku_sender/runtime/runtime.py | .py | ffecd346ac96b180 | 7.66 | 20 |
import time
from PySide6.QtCore import QObject, Signal
from .video_state import VideoState
from .queue_state import QueueState
from danmaku_sender.config import ApiAuthConfig, SenderConfig, MonitorConfig, ValidationConfig
from danmaku_sender.types.models.account import AccountCredential
class AppState(QObject):
... | TouhouGleaners/danmaku-sender | src/danmaku_sender/runtime/state/app_state.py | .py | c1137ae29c0bc697 | 7.66 | 20 |
import logging
from PySide6.QtCore import QObject, Signal
from danmaku_sender.types.models.queue import QueueTask, TaskStatus
logger = logging.getLogger(__name__)
class QueueState(QObject):
"""发送任务队列状态管理"""
tasksChanged = Signal() # 队列列表变更
taskStatusChanged = Signal(str, str) # (task_i... | TouhouGleaners/danmaku-sender | src/danmaku_sender/runtime/state/queue_state.py | .py | e015c57fd72c9c66 | 7.66 | 20 |
"""
认证服务层
封装 B 站用户认证相关的 API 操作,controller 层不直接接触 BiliApiClient。
"""
import logging
from contextlib import contextmanager
from danmaku_sender.repo.bili_api_client import BiliApiClient
from danmaku_sender.types.exceptions.exceptions import BiliApiError
from danmaku_sender.types.models.user import UserProfile
from danm... | TouhouGleaners/danmaku-sender | src/danmaku_sender/service/auth_service.py | .py | 2b343c36717c3998 | 7.66 | 20 |
import logging
from contextlib import contextmanager
from .danmaku_parser import DanmakuParser
from danmaku_sender.repo.bili_api_client import BiliApiClient
from danmaku_sender.types.exceptions.exceptions import BiliApiError, BiliNetworkError
from danmaku_sender.repo.history_manager import HistoryManager
from danmaku... | TouhouGleaners/danmaku-sender | src/danmaku_sender/service/bili_monitor.py | .py | 5a0f78da1af3ec66 | 7.66 | 20 |
import logging
import xml.etree.ElementTree as ET
from xml.dom import minidom
from danmaku_sender.types.models.danmaku import Danmaku
from danmaku_sender.types.models.common import UnsentDanmakusRecord
logger = logging.getLogger(__name__)
def create_xml_from_danmakus(danmakus: list[UnsentDanmakusRecord], filepath:... | TouhouGleaners/danmaku-sender | src/danmaku_sender/service/danmaku_exporter.py | .py | 0217cfcddd5bcbd1 | 7.66 | 20 |
import logging
import xml.etree.ElementTree as ET
from danmaku_sender.types.models.danmaku import Danmaku
class DanmakuParser:
"""
Bilibili 弹幕解析器
用于解析Bilibili XML格式的弹幕数据,支持本地文件和在线内容的解析。
"""
def __init__(self):
self.logger = logging.getLogger(__name__)
def parse_xml_file(self, xml_pa... | TouhouGleaners/danmaku-sender | src/danmaku_sender/service/danmaku_parser.py | .py | 7ca808a749c186b6 | 7.66 | 20 |
from typing import TypedDict
from danmaku_sender.types.models.danmaku import Danmaku
from danmaku_sender.config import ValidationConfig
FORBIDDEN_SYMBOLS = "☢⚠☣☠⚡💣⚔🔥"
class ValidationIssue(TypedDict):
original_index: int
danmaku: Danmaku
reason: str
def validate_danmaku_list(
danmaku_list: ... | TouhouGleaners/danmaku-sender | src/danmaku_sender/service/danmaku_validator.py | .py | 8ac24dd0eb579a28 | 7.66 | 20 |
import copy
import logging
import colorsys
from typing import Any, Callable
from danmaku_sender.config import ValidationConfig
from danmaku_sender.types.models.danmaku import Danmaku
from danmaku_sender.types.models.editor_types import EditorItem, EditorField, AtomicChange, ViewItem, InsertPosition
from .danmaku_valid... | TouhouGleaners/danmaku-sender | src/danmaku_sender/service/editor_session.py | .py | ac8995064f7811b4 | 7.66 | 20 |
import time
from threading import Event
from typing import Callable
from dataclasses import dataclass, field
from danmaku_sender.types.models.danmaku import Danmaku
from danmaku_sender.types.models.result import DanmakuSendResult
from danmaku_sender.types.models.common import VideoTarget, UnsentDanmakusRecord
from dan... | TouhouGleaners/danmaku-sender | src/danmaku_sender/service/sender/context.py | .py | e4fdd4ecee887752 | 7.66 | 20 |
"""ENG-16: render the dual-reader README still + docs GIF from the real pipeline.
Run from the repo root: ``python assets/render_dual_scanpath.py``.
The previous assets were hand-made and didn't correspond to any real reading.
These build the actual figures the app draws — two readers of the same bundled
demo paragra... | lacclab/scanpath-studio | assets/render_dual_scanpath.py | .py | 14a81f6cf542af9d | 7.48 | 8 |
"""Desktop-bundle entry point (ENG-15).
PyInstaller freezes this script (see ``scanpath_studio.spec``) into the
standalone Scanpath Studio app: it starts the Streamlit server on a free
localhost port with the branded theme, then opens the user's default browser
once the server answers its health check.
Environment ov... | lacclab/scanpath-studio | desktop/launcher.py | .py | 675a7ff28997718c | 7.48 | 8 |
"""Generate the desktop app icons (ENG-15).
Draws a scanpath motif — four fixation dots joined across compact word blocks,
including a return sweep — on a rounded dark tile, then writes the
committed icon files:
desktop/icons/icon.png 512x512 master (also the Linux icon)
desktop/icons/icon.ico Windows (... | lacclab/scanpath-studio | desktop/make_icons.py | .py | bb5b4e6887a279a9 | 7.48 | 8 |
from collections.abc import Sequence
from typing import List
import matplotlib
import matplotlib.cm
import matplotlib.colors as mcolors
import numpy as np
class MidpointNormalizer(mcolors.Normalize):
"""
Custom normalization class to shift the midpoint of a colormap.
"""
def __init__(self, vmin=None... | lacclab/scanpath-studio | other_vis/viz_text_heatmap_from_text_metrics.py | .py | 63c663e465c16368 | 7.48 | 8 |
"""Render the corpus-level analysis figure (fig_corpus) for the manuscript.
A three-panel montage from the *Per text* view of Corpus Analysis, run on the
full OneStop corpus (ordinary reading regime) rather than the 3-reader demo, so
the cohort views are populated:
A word x reader heatmap of total dwell time (AN-2... | lacclab/scanpath-studio | paper/paper_fig_corpus.py | .py | 455e162d60d29f68 | 7.48 | 8 |
"""Render the MultiplEYE case-study figure (fig_multipleye) for the manuscript.
One page of a Chinese MultiplEYE session (Zurich pilot release), with the
scanpath drawn over the authoritative stimulus-page image at its true on-screen
position on the 1920x1080 presentation monitor. Word boxes come from the
loader's agg... | lacclab/scanpath-studio | paper/paper_fig_multipleye.py | .py | 417d4f6b18d853ae | 7.48 | 8 |
"""Render the PoTeC case-study figure for the manuscript (fig_potec).
Loads one reader's reading of one PoTeC textbook text from a local PoTeC clone
(pass download=True on first use to fetch ~45 MB), computes the reading
measures from raw fixations, and renders the scanpath over the German text at
PoTeC's 1680x1050 pr... | lacclab/scanpath-studio | paper/paper_fig_potec.py | .py | eb107e5693c62f11 | 7.48 | 8 |
"""Descriptive statistics + measure validation for the manuscript (Section: Case studies).
Computes, over the bundled 3-participant OneStop demo subset that ships with
scanpath-studio:
1. Dataset counts (participants, texts, trials, word tokens, fixations).
2. Descriptive reading statistics (skipping rate, regression... | lacclab/scanpath-studio | paper/paper_stats.py | .py | c02121e82ad342fb | 7.48 | 8 |
"""Streamlit workbench + headless API for scanpath visualization."""
from __future__ import annotations
__all__ = [
"__version__",
"alignment_sensitivity",
"analysis_tables",
"animate_scanpath",
"build_authored_scanpath",
"cache_status",
"clear_cache",
"compare_scanpaths",
"compute... | lacclab/scanpath-studio | scanpath_studio/__init__.py | .py | 5b57a11aa68f30f3 | 7.48 | 8 |
"""Render a Plotly scanpath animation to a shareable GIF or MP4 clip.
The **Animate** toggle (in the Scanpath Visualization control rail) builds a Plotly
``go.Figure`` with one frame per fixation onset (see
:func:`scanpath_studio.plots.make_scanpath_animation`). The
interactive **HTML** export keeps that figure verbat... | lacclab/scanpath-studio | scanpath_studio/animation_export.py | .py | a4b633a7220c9278 | 7.48 | 8 |
"""Bidirectional browser canvas for the VIZ-33 authoring document."""
from __future__ import annotations
from typing import Any
import pandas as pd
import streamlit as st
_HTML = """
<div class="authoring-toolbar">
<span>Click empty space to add · drag a fixation to move · click to select</span>
<button type="b... | lacclab/scanpath-studio | scanpath_studio/authoring_component.py | .py | 66569103d4e43506 | 7.48 | 8 |
"""The *second* dataset a comparison can draw scanpath B from (CMP-8 §2).
Compare mode used to pick B out of the same loaded corpus as A. This module is
what lets it reach a different one — a PoTeC reader beside a OneStop reader, or
the same text read under two corpora.
**The one hard constraint: nothing here may ren... | lacclab/scanpath-studio | scanpath_studio/compare_source.py | .py | 4162678b7b14ff9c | 7.48 | 8 |
"""In-app debug log + state inspector.
Streamlit reruns the script top-to-bottom on every interaction, and plain
``logging`` / ``print`` output only reaches the *server* terminal — never the
browser. This module bridges that gap: a :class:`logging.Handler` captures log
records into a capped buffer in ``st.session_stat... | lacclab/scanpath-studio | scanpath_studio/debug_log.py | .py | fcedc4ce3bc5c652 | 7.48 | 8 |
"""UX-39 — the app's one easter egg: triple-click the title and eyes pop up.
Triple-click the "Scanpath Studio" heading and a pair of oversized googly eyes
pops up beside it, blinks once, follows the cursor for a few seconds, and fades
out on its own. That is all it does.
It lives entirely in the browser because it i... | lacclab/scanpath-studio | scanpath_studio/easter_egg.py | .py | ce63f321541ffa0d | 7.48 | 8 |
"""Shared, honest progress vocabulary for static, animation, and bulk exports."""
from __future__ import annotations
import hashlib
import math
import time
from collections.abc import Callable
from dataclasses import dataclass
from enum import Enum
from typing import Any
EXPORTER_VERSION = "exp6-v1"
class ExportSt... | lacclab/scanpath-studio | scanpath_studio/export_status.py | .py | dfb01548ab6ae6ce | 7.48 | 8 |
"""Loader for a local bundle of harmonised reading corpora.
EyeGenBench (https://github.com/EyeBench/EyeGenBench) harmonises many public
eye-tracking-while-reading corpora into one schema, but discards screen
geometry. `scripts/prepare_eyegenbench.py` runs their pipeline, recovers the
geometry, and writes the bundle t... | lacclab/scanpath-studio | scanpath_studio/eyegenbench.py | .py | 157fb139b6d692a4 | 7.48 | 8 |
"""The ``label | field`` row — one primitive, shared by every panel that has one.
UX-51 built this for the Scanpath rail's plot controls and UX-53 spread it over
the upload wizard, but both kept it private to :mod:`controls`. UX-69 needs the
same row in the Scanpath subtabs, and :mod:`controls` cannot supply it there:... | lacclab/scanpath-studio | scanpath_studio/fields.py | .py | f49ca8bf06fff1ba | 7.48 | 8 |
"""Detection policy for schematic/altered scanpath labels (VIZ-22)."""
from __future__ import annotations
import math
from collections.abc import Sequence
def illustration_reasons(
settings: dict,
*,
data_source: str | None = None,
fix_index_range: Sequence[int] | None = None,
full_fixation_rang... | lacclab/scanpath-studio | scanpath_studio/illustration.py | .py | 0369422c6d7be61b | 7.48 | 8 |
"""The app's top menu bar — the horizontal replacement for the former sidebar.
Every group that used to be an ``st.sidebar`` section is now a **popover** in one
row directly under the header, and nothing in the app writes to ``st.sidebar``
any more (so Streamlit draws no sidebar chrome at all and the main content gets... | lacclab/scanpath-studio | scanpath_studio/menu.py | .py | 6eba19d343d84a68 | 7.48 | 8 |
#!/usr/bin/env python
"""Bounded readiness gate for the systemd service."""
from __future__ import annotations
import contextlib
import io
import math
import sys
import time
from collections.abc import Callable
from healthcheck import check_health
READINESS_TIMEOUT_SECONDS = 60.0
RETRY_INTERVAL_SECONDS = 1.0
def... | LKosoj/LLMApiGateway | docker/systemd_readiness.py | .py | 5b797dd55da6bf23 | 7.48 | 8 |
"""Admin CRUD endpoints for virtual API keys.
All endpoints here require the master role — that is, the caller must hold the
``GATEWAY_API_KEY`` secret (either via ``Authorization`` header or via a master
session cookie). Virtual key holders cannot create, modify, or delete keys.
"""
from __future__ import annotation... | LKosoj/LLMApiGateway | llm_gateway_core/api/v1/admin_api_keys.py | .py | d9bbda3425177384 | 7.48 | 8 |
"""Detect degenerate ("bad success") non-streaming chat completions.
Some providers answer with HTTP 200 and a syntactically valid body that is
nevertheless useless: an empty assistant message with no tool call, or a
JSON-mode request whose response never contains parseable JSON. Package D
treats these as attempt fail... | LKosoj/LLMApiGateway | llm_gateway_core/api/v1/chat_model_behavior.py | .py | 096a91dd8234a0d6 | 7.48 | 8 |
from __future__ import annotations
import json
import logging
import re
# Package D deliberately widens this from {"json_object"} to also cover
# "json_schema": both response_format types promise the client a parseable
# JSON payload, and Package D's degenerate-response detector (format_ignored)
# needs to recognize... | LKosoj/LLMApiGateway | llm_gateway_core/api/v1/chat_sanitizers.py | .py | f547c284e207296c | 7.48 | 8 |
"""Free-tier LLM catalog page and API.
Serves the filtered freellmapi.co snapshot built by
``llm_gateway_core.services.free_llm_catalog.FreeLlmCatalogService`` to the
`/v1/ui/free-models` page. Accessible to both roles (master and virtual
keys) -- there is nothing account-specific in the catalog.
"""
from __future__ ... | LKosoj/LLMApiGateway | llm_gateway_core/api/v1/free_llm_catalog.py | .py | 6a3b89ca4dae782f | 7.48 | 8 |
"""Quota Dashboard API.
Provides per-virtual-key RPM/TPM snapshot and budget status for the
Quota Dashboard page. Master callers see all keys; virtual-key callers
see only their own card.
"""
from __future__ import annotations
import asyncio
import logging
from typing import TYPE_CHECKING, cast
from fastapi import... | LKosoj/LLMApiGateway | llm_gateway_core/api/v1/quota.py | .py | 9dadd6d605700fb0 | 7.48 | 8 |
#!/usr/bin/env python3
"""
Kestrel Control Panel - Multi-agent orchestrator for power users.
Discovers agents in agent_data/, manages their lifecycle, provides dashboard.
"""
import json
import logging
import os
import secrets
import shutil
import signal
import sqlite3
import subprocess
import sys
from pathlib import... | KestrelSovereignAI/kestrel-sovereign | control-panel/server.py | .py | faf80a5dfd75f79f | 7.48 | 8 |
"""
SimpleTuner API Configuration and Path Management.
Handles runtime path configuration for different environments:
- RunPod: Requires network volume at /workspace
- Vertex AI: Uses standard container paths
"""
import logging
import os
from typing import Optional
logger = logging.getLogger(__name__)
# RunPod netw... | KestrelSovereignAI/kestrel-sovereign | docker/simpletuner_api/config.py | .py | 268f30f21534ce37 | 7.48 | 8 |
"""
SimpleTuner Inference API Endpoints.
Provides REST API for image generation with trained LoRAs.
"""
import base64
import logging
import os
import uuid
from io import BytesIO
from pathlib import Path
from typing import Optional
from fastapi import APIRouter, BackgroundTasks, Form, HTTPException
from kestrel_sove... | KestrelSovereignAI/kestrel-sovereign | docker/simpletuner_api/endpoints/inference.py | .py | 3f3c4e9eadf24b56 | 7.48 | 8 |
"""Repo-root re-export shim — endpoints/ moved into the package.
The endpoints package now lives at ``kestrel_sovereign.endpoints``;
this stub keeps the documented source-clone forms working
(``from endpoints.X import Y``, ``import endpoints.X``). Pip-installed
users import the in-package path directly.
Implementatio... | KestrelSovereignAI/kestrel-sovereign | endpoints/__init__.py | .py | 7bc0f63acca3ac64 | 7.48 | 8 |
"""The reference feature class.
``get_ui_contributions()`` points the host at this package's OWN ``static/``
directory (resolved relative to this file — never a path in core ``static/``).
The host mounts it at ``/features/ui-slot-example/static/`` and the manifest
advertises ``ui.js``; the frontend boot loader imports... | KestrelSovereignAI/kestrel-sovereign | examples/kestrel-feature-ui-slot-example/kestrel_feature_ui_slot_example/feature.py | .py | 775965b680307715 | 7.48 | 8 |
"""Cancellation-safe ownership of internal asyncio tasks.
Callers that create cleanup, launch, or persistence tasks remain responsible
for reaching a terminal outcome even when their own task is cancelled. This
module provides that host-wide ownership rule without depending on subprocess,
Talon, compute, or training c... | KestrelSovereignAI/kestrel-sovereign | kestrel_sovereign/_async_ownership.py | .py | d4202b5b14d0281c | 7.48 | 8 |
"""Private-group ownership for async subprocess launches.
This module owns the detached-process contract: cancellation-safe launch,
whole-tree termination, and bounded reaping. Captured output and command result
semantics live separately in :mod:`kestrel_sovereign._bounded_subprocess`.
"""
from __future__ import anno... | KestrelSovereignAI/kestrel-sovereign | kestrel_sovereign/_async_process.py | .py | 89d902fca44066fc | 7.48 | 8 |
"""Small cancellation-safe reader/writer synchronization primitives."""
import asyncio
from collections.abc import AsyncIterator
from contextlib import asynccontextmanager
from typing import Self
class _DowngradedReaderLease:
"""A reader lease created by atomically downgrading a held writer."""
def __init__... | KestrelSovereignAI/kestrel-sovereign | kestrel_sovereign/_async_rwlock.py | .py | 7bf7b1173167cbec | 7.48 | 8 |
"""Bounded captured execution for async subprocesses.
The runner retains only the tail of each output stream while continuously
draining both pipes. Process launch and tree cleanup are delegated to the
private-group ownership contract in :mod:`kestrel_sovereign._async_process`.
"""
from __future__ import annotations
... | KestrelSovereignAI/kestrel-sovereign | kestrel_sovereign/_bounded_subprocess.py | .py | bcd1ab52e23c338e | 7.48 | 8 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.