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
"""LLM 辅助优化会议转录(声纹分离之后的增强层)。 声纹负责"谁说的"(它有声音信息,是强项);LLM 负责它擅长、声纹做不到的事: 1. 给说话人起名/角色:把抽象的"发言人1/2"识别成"面试官/应聘者",或从对话里 认出自报的真名(如有人说"我叫小林"),输出 标签→显示名 映射。 2. 纠正 ASR 同音错字 / 人名术语:结合上下文把识别错的字纠回(追蜜→追觅), 只做"等长/近义"的小修,不重写句子。 3. 仅在声纹归属与对话逻辑【明显矛盾】处轻量改归属(不全量重判——声纹通常更准)。 返回结构化结果,各项都做严格校验后由调用方择优应用。无 key/失败返回空结果 (不动声纹结果...
superLin006/LiveBabel
livebabel/meeting/llm_refine.py
.py
e80036cb6097f44d
7.42
6
"""用 ffmpeg 把字幕硬压(烧录)进视频,生成新的视频文件。 硬压 = 字幕变成画面像素,任何播放器/平台都能看到,不依赖外挂字幕文件。 用 ASS 烧录能保留双语配色(原文白、译文青)。 速度说明:字幕叠加(subtitles 滤镜)是 CPU 软件滤镜,无法 GPU 化;但视频「重编码」 这步可以走 GPU(NVENC),比 CPU 的 libx264 快很多。有 N 卡时优先 NVENC,失败回退 CPU 的 libx264 veryfast(比默认 medium 快得多,体积/画质略有取舍)。 """ from __future__ import annotations import os import su...
superLin006/LiveBabel
livebabel/offline/burn.py
.py
2248f6619e7f5b80
7.42
6
"""Windows 下让 CTranslate2 找到并加载 cuBLAS / cuDNN 运行时 DLL。 CTranslate2 4.x 不再自带这些 DLL;它们由 pip 包 nvidia-cublas-cu12 / nvidia-cudnn-cu12 提供,落在 site-packages\\nvidia\\<子包>\\bin\\。仅 os.add_dll_directory() 有时不够 (取决于 CTranslate2 内部用什么方式加载),最稳的是把这些目录全部注册 + 预加载关键 DLL 进进程。本模块在加载模型前调用一次,使源码运行和打包后的 exe 都无需手动配 PATH。 非 Windows(Linux...
superLin006/LiveBabel
livebabel/offline/cuda_dll.py
.py
570557d220e18808
7.42
6
"""把带时间戳的双语句子写成字幕文件。 * SRT:纯文本,最兼容(视频网站、所有播放器)。双语为原文一行 + 译文一行。 * ASS:带样式,原文白色、译文青色,可控字体/描边/位置。双语配色更好看。 输入是 transcribe.Sentence 列表(已填 translation)。 """ from __future__ import annotations from typing import List from livebabel.offline.transcribe import Sentence # ---------- 时间戳格式 ---------- def _srt_ts(sec: f...
superLin006/LiveBabel
livebabel/offline/subtitle_writer.py
.py
caaa9ab8b5e4c0a2
7.42
6
"""离线识别:用 Qwen3-ASR-0.6B 把视频/音频转成带时间戳的句子。 Qwen3-ASR 在 sherpa-onnx 中是离线模型。这里使用同一套 Silero VAD 做句段 切分,再对每个纯语音段进行 Qwen 识别;CPU 使用 INT8,CUDA 使用 FP16。 输出:list[Sentence],每个含 start/end(秒)和 text(原文)。 """ from __future__ import annotations import os import tempfile import wave from dataclasses import dataclass from typing imp...
superLin006/LiveBabel
livebabel/offline/transcribe.py
.py
6e82fdc961c56aa1
7.42
6
"""离线批量翻译:把识别出的句子分批(默认每批 10 句)翻译,带滚动上下文。 逐句翻译会发很多次 HTTP 请求(网络往返是大头),慢。一次发一批让模型整体翻译, 请求数降一个量级,且整体翻译上下文更完整、术语更一致,质量通常更好。 风险是模型返回的行数和输入对不齐 → 用编号约定 + 数量校验,不齐就回退逐句翻译这一批, 保证绝不串轴。复用与实时一致的 DeepSeek 调用方式。 """ from __future__ import annotations import os import re from collections import deque from typing import List, Optiona...
superLin006/LiveBabel
livebabel/offline/translate_batch.py
.py
ba52a4332c0dd8bd
7.42
6
"""统一的资源路径解析,兼容"源码运行"和"PyInstaller 打包后运行"两种情况。 打包后 sys.frozen 为 True,可执行文件目录是 exe 所在目录。模型/历史/设置都放在 exe 旁边(而不是打进 exe),所以以 exe 目录为基准;源码运行则以本文件目录为基准。 模型目录结构(v2.0+): models/ vad/silero_vad.onnx zipformer/{tokens,encoder,decoder,joiner,bpe.*} qwen3-asr/{conv_frontend.onnx,encoder.int8.onnx,decoder.int8.onnx,...
superLin006/LiveBabel
livebabel/paths.py
.py
684d3dbf810c0a44
7.42
6
"""朗读合成结果缓存:按 (文本内容, 音色) 算 key,命中则直接读盘播放, 不重新调用引擎合成。key 里带音色文件内容的 hash,换音色/重新采样声纹后 旧缓存自然失效(不会读到错音色的缓存),不需要额外的失效逻辑。 存储:history/tts_cache/<key>.wav,一个 key 一个完整拼好的 wav 文件。 不做容量上限/过期清理——纪要/字幕文本量级不大,合成产物是纯语音、体积 可控(如 100 字约 1MB),留给用户按需手动清理 history/ 目录即可, 不必增加自动淘汰的复杂度和"缓存突然消失"的意外。 """ from __future__ import annotations imp...
superLin006/LiveBabel
livebabel/tts/cache.py
.py
b7947bf9125d693c
7.42
6
"""ChatTTS 朗读引擎:魔改版 sherpa-onnx(集成 ChatTTS onnx int8)的薄封装。 魔改版 sherpa_onnx 是官方包的超集(同时含 ASR 识别 + ChatTTS 合成能力), 直接 import sherpa_onnx 即可,不需要运行时隔离。环境里只装这一个包 (参见 requirements.txt 注释),不再与官方 sherpa-onnx 共存。 """ from __future__ import annotations import os import threading from typing import Callable, Optional import num...
superLin006/LiveBabel
livebabel/tts/chattts_engine.py
.py
d6c373a106212be5
7.42
6
"""把纪要/字幕文本切成适合朗读的"段"(不是逐句):按目标字数攒够整句再切, 在段内交给 ChatTTS 做一次连续的流式合成(段内音色/韵律连贯、无缝),只在 段与段之间(必要的独立 GPT 调用)才有起势的成本。 为什么不逐句切:ChatTTS 的 GPT 每次独立调用都要重新"起势"(prefill 阶段 的语调状态从头采样),逐句切会让每句话都短促生硬、句间听感割裂。攒到 一定长度再合成,段内部靠真流式(见 chattts_engine.py 的 on_chunk 回调) 边生成边播放,消除人为分句造成的割裂,只保留物理上必要的长文本分段。 """ from __future__ import annotations...
superLin006/LiveBabel
livebabel/tts/text_split.py
.py
3db8021500ed8d8d
7.42
6
"""听写 HUD 浮窗:深色胶囊(参考 macOS 系统听写)。 体验设计: * 按下热键立刻出现「正在聆听…」+ 呼吸红点 —— 即时反馈热键已生效。 * 说话时两段式草稿:已定稿文字白色,未定稿(volatile)灰色,一眼分清。 * 松开后红点变绿、显示最终文本一瞬,再平滑淡出 —— 确认"就是这段话进了输入框"。 * 单行过长时从左侧省略,始终看得到最新说的词。 无边框、置顶、半透明、不抢焦点(否则注入会注到浮窗自己)。 所有方法须在 Qt 主线程调用(由 DictationService 的信号驱动)。 """ from __future__ import annotations import h...
superLin006/LiveBabel
livebabel/ui/dictation_overlay.py
.py
65612b4f2f300127
7.42
6
"""GUI 通用件:统一的浅色「苹果风」主题样式、字体与小组件,供各页面复用。 设计语言参考 macOS 浅色模式:纯净浅灰背景、大圆角柔和卡片、细分隔线、 系统蓝强调、宽松留白。集中放一处,改主题只动这里。 (实时悬浮窗 overlay.py 自管样式,不受本文件影响。) """ from __future__ import annotations # 应用版本(首页页脚显示;发版时与 git tag 同步) APP_VERSION = "1.5.0" # ---- 浅色苹果风色板 ---- BG = "#F5F5F7" # 窗口背景(macOS 经典浅灰) CARD = "#FFFFFF" ...
superLin006/LiveBabel
livebabel/ui/gui_common.py
.py
2874cf469a90680a
7.42
6
"""首次启动:语音模型下载进度窗。 检测到 models/ 缺模型时弹出。在后台线程从 ModelScope 下载(支持断点续传), 进度条 + 日志实时显示。下完返回 Accepted;用户取消 / 关窗返回 Rejected。 """ from __future__ import annotations from PySide6.QtCore import QObject, QThread, Qt, Signal from PySide6.QtWidgets import ( QDialog, QHBoxLayout, QLabel, QProgressBar, QPushButt...
superLin006/LiveBabel
livebabel/ui/model_download_dialog.py
.py
714d2c5f6b69d23c
7.42
6
"""透明置顶双语字幕悬浮窗(PySide6)—— 桌面歌词式体验。 特性: * 紧凑滚动:默认显示最近 N 句(N 可调),新句从下往上,像桌面歌词。 * 双语上下排:原文白色在上,译文青色在下。volatile 未定稿行浅灰斜体。 * 窗口可自由缩放:拖动右下角手柄改大小;按住左键拖动整体移动。 * 右键菜单:切换目标语种 / 字号 / 显示行数 / 是否显示原文 / 锁定位置 / 退出。 * 设置持久化:字号、行数、语种、窗口位置大小存到 settings.json,下次自动恢复。 线程模型:ASR/翻译在后台线程,通过 Qt 信号把文本送到 GUI 线程刷新。 切换语种通过 lang_changed ...
superLin006/LiveBabel
livebabel/ui/overlay.py
.py
52c6a2f72c685296
7.42
6
# SPDX-FileCopyrightText: (c) 2026 Tenstorrent AI ULC # # SPDX-License-Identifier: Apache-2.0 """ AbacusAI Smaug 72B v0.1 model loader implementation. """ import torch from transformers import AutoTokenizer, AutoModelForCausalLM, AutoConfig from typing import Optional from ...base import ForgeModel from ...config imp...
tenstorrent/tt-forge-models
abacusai/pytorch/loader.py
.py
9425d643a08af480
7.59
14
# SPDX-FileCopyrightText: (c) 2025 Tenstorrent AI ULC # # SPDX-License-Identifier: Apache-2.0 """ ALBERT model loader implementation for masked language modeling. """ from transformers import FlaxAlbertForMaskedLM, AlbertTokenizer from typing import Optional from ....base import ForgeModel from ....config import ( ...
tenstorrent/tt-forge-models
albert/masked_lm/jax/loader.py
.py
7d580b271cf2da1c
7.59
14
# SPDX-FileCopyrightText: (c) 2025 Tenstorrent AI ULC # # SPDX-License-Identifier: Apache-2.0 """ ALBERT PaddlePaddle model loader implementation for masked language modeling. """ from typing import Optional, List import paddle from paddlenlp.transformers import AlbertForMaskedLM, AlbertTokenizer from ....config imp...
tenstorrent/tt-forge-models
albert/masked_lm/paddlepaddle/loader.py
.py
5a19e3a8835d8ebc
7.59
14
# SPDX-FileCopyrightText: (c) 2025 Tenstorrent AI ULC # # SPDX-License-Identifier: Apache-2.0 """ ALBERT model loader implementation for masked language modeling. """ import torch from transformers import AlbertForMaskedLM, AlbertTokenizer from typing import Optional from ....base import ForgeModel from ....config imp...
tenstorrent/tt-forge-models
albert/masked_lm/pytorch/loader.py
.py
c30e66aeab98f542
7.59
14
# SPDX-FileCopyrightText: (c) 2025 Tenstorrent AI ULC # # SPDX-License-Identifier: Apache-2.0 """ ALBERT model loader implementation for question answering. """ import torch from transformers import AlbertForQuestionAnswering, AutoTokenizer from typing import Optional from ....base import ForgeModel from ....config im...
tenstorrent/tt-forge-models
albert/question_answering/pytorch/loader.py
.py
daa8cf68e9b0b5fd
7.59
14
# SPDX-FileCopyrightText: (c) 2025 Tenstorrent AI ULC # # SPDX-License-Identifier: Apache-2.0 """ ALBERT model loader implementation for sequence classification. """ import torch from transformers import AlbertForSequenceClassification, AlbertTokenizer from typing import Optional from ....base import ForgeModel from ....
tenstorrent/tt-forge-models
albert/sequence_classification/pytorch/loader.py
.py
9173c9258986e57f
7.59
14
# SPDX-FileCopyrightText: (c) 2025 Tenstorrent AI ULC # # SPDX-License-Identifier: Apache-2.0 """ ALBERT model loader implementation for token classification. """ import torch from transformers import AlbertForTokenClassification, AlbertTokenizer from typing import Optional from ....base import ForgeModel from ....con...
tenstorrent/tt-forge-models
albert/token_classification/pytorch/loader.py
.py
7d9c982e4414bced
7.59
14
# SPDX-FileCopyrightText: (c) 2025 Tenstorrent AI ULC # # SPDX-License-Identifier: Apache-2.0 """ AlexNet model loader implementation for image classification. """ from typing import Optional import jax import jax.numpy as jnp import numpy as np from ....base import ForgeModel from ....config import ( ModelConfig...
tenstorrent/tt-forge-models
alexnet/image_classification/jax/loader.py
.py
da3fb943d3138557
7.59
14
# SPDX-FileCopyrightText: (c) 2026 Tenstorrent AI ULC # # SPDX-License-Identifier: Apache-2.0 """ AlexNet ONNX model loader. """ # Reuse the PyTorch ModelLoader as the base from ...pytorch.loader import ModelLoader as PyTorchModelLoader from ....tools.utils import export_torch_model_to_onnx, print_compiled_model_resul...
tenstorrent/tt-forge-models
alexnet/image_classification/onnx/loader.py
.py
2de6209eb765a62b
7.59
14
# SPDX-FileCopyrightText: (c) 2025 Tenstorrent AI ULC # # SPDX-License-Identifier: Apache-2.0 """ AlexNet PaddlePaddle model loader implementation. """ from typing import Optional import paddle from paddle.vision.models import alexnet from ....config import ( ModelConfig, ModelInfo, ModelGroup, Model...
tenstorrent/tt-forge-models
alexnet/image_classification/paddlepaddle/loader.py
.py
e871aaee4ea980bc
7.59
14
# SPDX-FileCopyrightText: (c) 2025 Tenstorrent AI ULC # # SPDX-License-Identifier: Apache-2.0 """ ALLaM model loader implementation for causal language modeling. """ import torch from transformers import AutoModelForCausalLM, AutoTokenizer from typing import Optional from ....base import ForgeModel from ....config imp...
tenstorrent/tt-forge-models
allam/causal_lm/pytorch/loader.py
.py
5a213535cce427f1
7.59
14
# SPDX-FileCopyrightText: (c) 2026 Tenstorrent AI ULC # # SPDX-License-Identifier: Apache-2.0 """ ARCEE model loader implementation for causal language modeling. """ import torch from transformers import AutoModelForCausalLM, AutoTokenizer, AutoConfig from typing import Optional from ....base import ForgeModel from ....
tenstorrent/tt-forge-models
arcee/text_generation/pytorch/loader.py
.py
167d8fd0d8239449
7.59
14
# SPDX-FileCopyrightText: (c) 2025 Tenstorrent AI ULC # # SPDX-License-Identifier: Apache-2.0 """ Bucketed embedding layer for game variables. """ import torch.nn as nn class BucketedEmbedding(nn.Embedding): """Embedding layer that buckets input indices to reduce vocabulary size.""" def __init__(self, bucket...
tenstorrent/tt-forge-models
arnold/pytorch/src/bucketed_embedding.py
.py
7606dce33de49a67
7.59
14
# SPDX-FileCopyrightText: (c) 2025 Tenstorrent AI ULC # # SPDX-License-Identifier: Apache-2.0 """ DQN Module implementations for Arnold - Deep Q-Network for ViZDoom. """ import torch import torch.nn as nn from logging import getLogger from .model_utils import ( build_CNN_network, build_game_variables_network, ...
tenstorrent/tt-forge-models
arnold/pytorch/src/dqn_module.py
.py
da2b6aae55560e2a
7.59
14
# SPDX-FileCopyrightText: (c) 2025 Tenstorrent AI ULC # # SPDX-License-Identifier: Apache-2.0 """ Model utility functions for building CNN and embedding networks. """ import torch import torch.nn as nn from torch.autograd import Variable from logging import getLogger from .bucketed_embedding import BucketedEmbedding ...
tenstorrent/tt-forge-models
arnold/pytorch/src/model_utils.py
.py
07b2d59c6178b6e9
7.59
14
# SPDX-FileCopyrightText: (c) 2025 Tenstorrent AI ULC # # SPDX-License-Identifier: Apache-2.0 """ Attention DenseUNet model loader implementation """ import torch from typing import Optional from .src.model import AttentionUNet from ...config import ( ModelConfig, ModelInfo, ModelGroup, ModelTask, ...
tenstorrent/tt-forge-models
attention_denseunet/pytorch/loader.py
.py
6f98036288f442b2
7.59
14
# SPDX-FileCopyrightText: (c) 2025 Tenstorrent AI ULC # # SPDX-License-Identifier: Apache-2.0 import torch import torch.nn as nn import torch.nn.functional as F class DoubleConv(nn.Module): """(Conv => BN => ReLU) * 2""" def __init__(self, in_ch, out_ch, mid_ch=None): super().__init__() if no...
tenstorrent/tt-forge-models
attention_denseunet/pytorch/src/model.py
.py
71bfd835914ecce5
7.59
14
# SPDX-FileCopyrightText: (c) 2026 Tenstorrent AI ULC # # SPDX-License-Identifier: Apache-2.0 """ Autoencoder ONNX model loader. """ # Reuse the PyTorch ModelLoader as the base from ...pytorch.loader import ModelLoader as PyTorchModelLoader, ModelVariant from ....tools.utils import export_torch_model_to_onnx class M...
tenstorrent/tt-forge-models
autoencoder/image_classification/onnx/loader.py
.py
c144ec9110eec4c1
7.59
14
# SPDX-FileCopyrightText: (c) 2024 Tenstorrent AI ULC # # SPDX-License-Identifier: Apache-2.0 # Reference: https://github.com/tenstorrent/tt-buda-demos/blob/main/model_demos/cv_demos/linear_autoencoder/pytorch_linear_autoencoder.py """ Autoencoder Linear/Conv model loader implementation """ import os import numpy as np...
tenstorrent/tt-forge-models
autoencoder/pytorch/loader.py
.py
e362056406f998a2
7.59
14
"""被动 turn 的历史读取与 prompt 辅助函数。""" from __future__ import annotations from typing import TYPE_CHECKING, Any from agent.prompting import is_context_frame if TYPE_CHECKING: from agent.core.runtime_support import SessionLike from agent.tools.registry import ToolRegistry def get_history_since_consolidated( ...
YinFengWindy/Shiori-Agent
apps/backend/agent/core/passive_turn/helpers.py
.py
eba4f3d5b12c79cc
7.64
18
"""被动推理的工具事件观测与结果构建逻辑。""" from __future__ import annotations import logging from typing import Any import agent.core.passive_support as support from agent.core.types import LLMToolCall, ReasonerResult from bus.events_lifecycle import ToolCallCompleted, ToolCallStarted logger = logging.getLogger("agent.core.passive_...
YinFengWindy/Shiori-Agent
apps/backend/agent/core/passive_turn/reasoning_result.py
.py
61d4b16272b6102b
7.64
18
"""Official plugin seam for proactive turn admission policies.""" from __future__ import annotations from dataclasses import dataclass, field from datetime import datetime from enum import StrEnum from time import perf_counter from typing import Literal, Mapping, Protocol, Sequence, runtime_checkable class Proactiv...
YinFengWindy/Shiori-Agent
apps/backend/agent/core/proactive_turn/gates.py
.py
ac43e5fe81c60d69
7.64
18
"""主动回复 tick 生命周期与工具步骤日志。""" from __future__ import annotations from datetime import datetime, timezone from typing import Any from agent.turns.result import TurnResult from proactive_v2.context import AgentTickContext def record_tick_log_start( *, state_store: Any, session_key: str, ctx: AgentTick...
YinFengWindy/Shiori-Agent
apps/backend/agent/core/proactive_turn/tick_logging.py
.py
2e5696c0a784bb4f
7.64
18
"""主动回复 pipeline 的共享结果与依赖契约。""" from __future__ import annotations from dataclasses import dataclass, field from datetime import datetime from typing import Any, Awaitable, Callable from ..drift_turn import DriftTurnPipeline from agent.tool_hooks import ToolHook from agent.turns.orchestrator import TurnOrchestrator ...
YinFengWindy/Shiori-Agent
apps/backend/agent/core/proactive_turn/types.py
.py
5aac7fbfa155d183
7.64
18
"""Agent loop 的稳定公共入口。""" import asyncio from .assembly import _AssemblyMixin from .helpers import ( StreamDelta, StreamSink, StreamSinkFactory, StreamSupportPolicy, _MANUAL_CONSOLIDATION_TIMEOUT_SECONDS, _build_resume_content, _is_positive_int, _item_content, _STREAM_SUPPORT_POLIC...
YinFengWindy/Shiori-Agent
apps/backend/agent/looping/core/__init__.py
.py
b4a35b32eac29688
7.64
18
"""AgentLoop 依赖装配与兼容配置属性。""" from __future__ import annotations import asyncio from typing import cast from agent.context import ContextBuilder from agent.core.passive_turn import ( AgentCore, AgentCoreDeps, DefaultContextStore, DefaultReasoner, ) from agent.core.runner import ( CoreRunner, Co...
YinFengWindy/Shiori-Agent
apps/backend/agent/looping/core/assembly.py
.py
2d1bcc59ea7714dd
7.64
18
"""Sync-over-async bridge for authlib's callbacks. authlib's OAuth2 core (``AuthorizationServer``, grant classes, client/token mixins) is entirely synchronous — there is no Starlette/FastAPI integration and no async support. This repo's database access (asyncpg) is entirely async. Rather than adding a second, synchron...
nitin27may/e-commerce-agents
agents/python/auth_server/_bridge.py
.py
088c54a48216716a
7.66
20
"""OAuth2 grant classes for the self-hosted authorization server. ``ClientCredentialsGrant`` needs no customization — authlib's built-in implementation is complete for our purposes and is registered as-is in ``server.py``. The other two grants need user/token lookups against Postgres, bridged from authlib's synchronou...
nitin27may/e-commerce-agents
agents/python/auth_server/grants.py
.py
1ad3eb717614641f
7.66
20
"""RSA signing-key bootstrap and JWKS serving for the self-hosted auth-server. On first boot (no active row in ``oauth_signing_keys``) a new RSA keypair is generated and persisted — the public JWK plus a private PEM, encrypted at rest when ``AUTH_SIGNING_KEY_ENCRYPTION_KEY`` is set (required outside development, see `...
nitin27may/e-commerce-agents
agents/python/auth_server/keys.py
.py
04fec6df0448b232
7.66
20
"""Self-hosted OAuth2 Authorization Server — entry point. Run as HTTP service: uvicorn auth_server.main:app --host 0.0.0.0 --port 8090 Endpoints: GET /health GET /.well-known/jwks.json GET /.well-known/oauth-authorization-server (RFC 8414 metadata) POST /oauth/token POST /oauth/register ...
nitin27may/e-commerce-agents
agents/python/auth_server/main.py
.py
35c8acd81a4ca574
7.66
20
"""RFC 7591 dynamic client registration — the business logic (validation + persistence), separate from the HTTP route wiring in ``main.py``. Gated behind ``settings.AUTH_ALLOW_DYNAMIC_REGISTRATION`` (off by default — this app's client registry is otherwise fixed/seeded, see ``clients.py``'s own module docstring). When...
nitin27may/e-commerce-agents
agents/python/auth_server/register.py
.py
64fb5bc84635d901
7.66
20
"""RFC 9068 JWT access-token generator for the self-hosted OAuth2 AS. Subclasses authlib's own RFC 9068 implementation (``authlib.oauth2.rfc9068.JWTBearerTokenGenerator``) rather than hand-rolling a token generator — the base class already builds a spec-compliant claim set (iss/exp/client_id/iat/jti/scope/sub/aud, ``t...
nitin27may/e-commerce-agents
agents/python/auth_server/token.py
.py
3d17c7375be737d7
7.66
20
"""Stored eval-score baselines and regression detection. A baseline is a snapshot of an ``EvalSummary``'s key scores, committed to ``evals/baselines/<suite>.json``. ``--baseline`` compares a fresh run against it and fails the run if any tracked score dropped by more than ``--max-regression``; ``--update-baseline`` ove...
nitin27may/e-commerce-agents
agents/python/evals/baselines.py
.py
b7631878cd02a638
7.66
20
"""Agent evaluation framework — scores agent responses on groundedness, correctness, and completeness. Loads golden datasets, runs each input through the real production execution path (``evals/harness.py::ProductionRunner``), and produces a scored summary report. Historical note: this used to hand-roll its own OpenA...
nitin27may/e-commerce-agents
agents/python/evals/evaluator.py
.py
c3e91f7436510821
7.66
20
"""Runs eval cases through the real production execution path. Replaces ``evaluator.py``'s old ``_run_agent()``, which hand-rolled its own OpenAI tool-calling loop and called raw undecorated tool functions directly — bypassing every ``AgentMiddleware``/``FunctionMiddleware`` a real request goes through (guardrails, HI...
nitin27may/e-commerce-agents
agents/python/evals/harness.py
.py
a264bd8d82ea885f
7.66
20
"""One-shot migration: re-key committed replay fixtures under the current hash. Every fixture stores its own raw ``request``, so a change to the hashing scheme in ``shared/replay_client.py`` can be applied to the whole corpus *offline* — no API credentials, no re-recording, and the recorded responses are never touched...
nitin27may/e-commerce-agents
agents/python/evals/rehash_fixtures.py
.py
ac30645b5aa5e493
7.66
20
"""Deterministic groundedness scorer, built on Phase 2's grounding verifier. Replaces the old ``AgentEvaluator._score_groundedness`` (evaluator.py), which returned 1.0 whenever any tool was called — never comparing response content to what the tool actually returned, so a fabricated price scored identically to a real ...
nitin27may/e-commerce-agents
agents/python/evals/scorers/db_groundedness.py
.py
6ce0ffdd3f2400c7
7.66
20
"""Inventory & Fulfillment agent definition. When ``settings.MCP_ENABLED`` is True the agent connects to the Inventory MCP server (``ecommerce_mcp_inventory.server``) via ``MCPStreamableHTTPTool`` instead of calling asyncpg directly. Both modes expose the same capabilities. """ from agent_framework import Agent from ...
nitin27may/e-commerce-agents
agents/python/inventory_fulfillment/agent.py
.py
e488c8ea92d95f02
7.66
20
"""Normalized orchestration event protocol. Five orchestration mechanisms will exist behind the mode registry (``orchestrator/modes/``, Phase 1.2): the plain tool router, MAF's ``HandoffBuilder``, MAF ``WorkflowBuilder`` graphs (fan-out/fan-in, declarative YAML), and eventually a magentic manager. Each emits its own n...
nitin27may/e-commerce-agents
agents/python/orchestrator/events.py
.py
2873e958297d0864
7.66
20
"""MAF Handoff workflow for the orchestrator → specialist mesh. This is the ``handoff`` alternative to the ``tool``-mode ``call_specialist_agent`` tool router. ``orchestrator/modes/handoff_mode.py`` wraps :func:`build_orchestrator_handoff_workflow` and is what makes this reachable from a live request — via ``mode="han...
nitin27may/e-commerce-agents
agents/python/orchestrator/handoff.py
.py
3fbffc7c666c93b5
7.66
20
"""Orchestration mode registry. ``/api/chat`` and ``/api/chat/stream`` no longer hardcode "build the tool-router agent and run it" — they resolve a mode name to an :class:`OrchestrationMode` and call its ``run()``. This is what makes the capstone's flagship claim true: the same domain, run through the plain LLM tool r...
nitin27may/e-commerce-agents
agents/python/orchestrator/modes/__init__.py
.py
4385cdad4944580c
7.66
20
"""``OrchestrationMode`` protocol + the request-scoped context every mode's ``run()`` takes. Identity (user email/role/session) is deliberately *not* on ``RunContext`` — this repo's convention is ContextVars (``shared/context.py``), read directly by whatever needs them (tools, ``call_specialist_agent``, A2A header bui...
nitin27may/e-commerce-agents
agents/python/orchestrator/modes/base.py
.py
caff64e4a1df509b
7.66
20
"""``group-chat`` mode: sequential round-table debate over a shared transcript. Wraps ``workflows/group_chat.py``'s ``GroupChatWorkflow`` — per the audit, exercised only with synthetic sync responders in its own tests. This is the first production caller: two agent-backed panelists (a value/pricing perspective and a q...
nitin27may/e-commerce-agents
agents/python/orchestrator/modes/group_chat_mode.py
.py
25507a5929e83870
7.66
20
"""``handoff`` mode: MAF ``HandoffBuilder`` mesh over the same specialists. Wraps ``orchestrator/handoff.py::build_orchestrator_handoff_workflow`` — already built, already tested (``tests/test_handoff_orchestration.py``), never previously reachable from a live request. This is the first thing that reaches it: ``ORCHES...
nitin27may/e-commerce-agents
agents/python/orchestrator/modes/handoff_mode.py
.py
a613274c3d28d680
7.66
20
"""``workflow:pre-purchase`` and ``workflow:return-replace`` modes. Wraps the already-built, already-tested MAF ``WorkflowBuilder`` graphs in ``workflows/pre_purchase.py`` (concurrent fan-out/fan-in) and ``workflows/return_replace.py`` (sequential with an in-workflow HITL gate) — per the audit, previously reachable on...
nitin27may/e-commerce-agents
agents/python/orchestrator/modes/workflow_mode.py
.py
c60abecb87b581d3
7.66
20
"""Orchestration introspection routes — mode listing, graphs, comparison, resume. ``GET /modes`` and ``GET /modes/{name}/graph`` read the real mode registry (``orchestrator/modes/``) — Phase 1.2 wired five modes into it; this route just has to ask, not hardcode a list that drifts out of sync with what ``/api/chat`` ca...
nitin27may/e-commerce-agents
agents/python/orchestrator/routes/orchestration.py
.py
177984935b608fe4
7.66
20
"""JWKS-based token verifier for this server's OAuth 2.1 resource-server mode. Vendored, not shared: ``ecommerce-mcp-inventory`` is an isolated uv workspace member that never imports ``shared/`` (it's independently installable / publishable — see the design doc's correction #7). The main app's identical-in-spirit ``sh...
nitin27may/e-commerce-agents
agents/python/packages/mcp-inventory/src/ecommerce_mcp_inventory/auth.py
.py
cf27fb83667a705c
7.66
20
"""Omni Body App Adapter interface. This module defines the tool-facing adapter contract only. It is not an agent planner and does not decide tasks. Each adapter exposes deterministic actions that omni_body can route to after the adapter is implemented by the host. """ from __future__ import annotations from typing im...
simahanfeng007-lgtm/Tiangongzaowu-V3
app/backend/tiangong-backend/_internal/omni_body_skill/adapters/base.py
.py
51f882c8b9e779c5
7.52
10
"""MCP (Model Context Protocol) client for omni_body actions. v1 设计(2026-08-22,"作 omni_body action 接入"方案): - **安全边界**:服务器进程只能来自用户管理的 ``~/.tiangong/v3/mcp_servers.json``——模型只能引用已配置的服务器名, 绝不能自造命令行。配置文件是唯一的 spawn 授权面。 - **权限链全复用**:mcp.tool.call 注册为 A3,走网关既有确认链; mcp.servers.list / mcp.tools.list 为 A0 只读。 - **进程生命周期...
simahanfeng007-lgtm/Tiangongzaowu-V3
app/backend/tiangong-backend/_internal/omni_body_skill/tools/mcp_client.py
.py
96be58fd93705a20
7.52
10
"""Cross-platform text decoding and newline normalization. The runtime never silently replaces undecodable bytes. It accepts canonical UTF-8 first, explicit Unicode BOM formats second, and a small allowlist of legacy Windows encodings only for subprocess output or imported user files. Every non-UTF-8 decode is report...
simahanfeng007-lgtm/Tiangongzaowu-V3
app/backend/tiangong-backend/_internal/omni_body_skill/tools/portable_text.py
.py
d581889f48afe4af
7.52
10
# SPDX-License-Identifier: MIT # Copyright (c) 2026, Advanced Micro Devices, Inc. All rights reserved. """apt installer: detect packages, PRINT the apt-get line. Never sudo.""" from __future__ import annotations from ..outcome import Outcome from ..recipe import Item, Target from .base import _run_bootstrap, level_fo...
AMD-AGI/Infera
agent_sys/env_mgr/installers/apt.py
.py
051326d5a5c099a5
7.64
18
# SPDX-License-Identifier: MIT # Copyright (c) 2026, Advanced Micro Devices, Inc. All rights reserved. """Installer protocol + shared command/version helpers.""" from __future__ import annotations import re import subprocess from typing import Protocol, runtime_checkable from ..outcome import Outcome from ..recipe i...
AMD-AGI/Infera
agent_sys/env_mgr/installers/base.py
.py
ee22c6f6a4938c74
7.64
18
# SPDX-License-Identifier: MIT # Copyright (c) 2026, Advanced Micro Devices, Inc. All rights reserved. """bin installer: install one executable via a command; probe via check_cmd.""" from __future__ import annotations from ..outcome import Outcome from ..recipe import Item, Target from ..versions import satisfies fro...
AMD-AGI/Infera
agent_sys/env_mgr/installers/bin.py
.py
34408ce6c33f89fc
7.64
18
# SPDX-License-Identifier: MIT # Copyright (c) 2026, Advanced Micro Devices, Inc. All rights reserved. """claude installer: install Claude Code plugins.""" from __future__ import annotations from ..outcome import Outcome from ..recipe import Item, Target from .base import _run_bootstrap, level_for_missing, run_cmd ...
AMD-AGI/Infera
agent_sys/env_mgr/installers/claude.py
.py
d4a8cf72c26a3d87
7.64
18
# SPDX-License-Identifier: MIT # Copyright (c) 2026, Advanced Micro Devices, Inc. All rights reserved. """embed installer: a multi-line script body, optionally gated by check_cmd.""" from __future__ import annotations from ..recipe import Item from .base import ShellInstaller class EmbedInstaller(ShellInstaller): ...
AMD-AGI/Infera
agent_sys/env_mgr/installers/embed.py
.py
b8cb87686c2e6fd0
7.64
18
# SPDX-License-Identifier: MIT # Copyright (c) 2026, Advanced Micro Devices, Inc. All rights reserved. """uv installer: ref form (uv pip install -e) and tool form (uv tool install).""" from __future__ import annotations from pathlib import Path from ..outcome import Outcome from ..recipe import Item, Target from .ba...
AMD-AGI/Infera
agent_sys/env_mgr/installers/uv.py
.py
c69a116d3a396dbc
7.64
18
# SPDX-License-Identifier: MIT # Copyright (c) 2026, Advanced Micro Devices, Inc. All rights reserved. """Outcome — the result of running one stage against one item.""" from __future__ import annotations from collections.abc import Iterable from dataclasses import dataclass, field from typing import Any # Severity a...
AMD-AGI/Infera
agent_sys/env_mgr/outcome.py
.py
5a88b6481d565992
7.64
18
# SPDX-License-Identifier: MIT # Copyright (c) 2026, Advanced Micro Devices, Inc. All rights reserved. """Render Outcomes for humans and machines.""" from __future__ import annotations import json from .outcome import Outcome _ICON = {"ok": "OK ", "info": "INFO", "warn": "WARN", "fail": "FAIL"} def render_human(o...
AMD-AGI/Infera
agent_sys/env_mgr/report.py
.py
fd11ec02c6498ddb
7.64
18
# SPDX-License-Identifier: MIT # Copyright (c) 2026, Advanced Micro Devices, Inc. All rights reserved. """Runner: select items, detect conflicts, dispatch stages, roll up status.""" from __future__ import annotations from collections import defaultdict from dataclasses import dataclass, field from .outcome import Ou...
AMD-AGI/Infera
agent_sys/env_mgr/runner.py
.py
2464285f2bb592c1
7.64
18
# SPDX-License-Identifier: MIT # Copyright (c) 2026, Advanced Micro Devices, Inc. All rights reserved. """Version constraint handling. Thin wrapper over `packaging`.""" from __future__ import annotations from packaging.specifiers import InvalidSpecifier, SpecifierSet from packaging.version import InvalidVersion, Vers...
AMD-AGI/Infera
agent_sys/env_mgr/versions.py
.py
5fdf71019b5ea6e5
7.64
18
"""The agent collection. Two of them: the **spec table** of what kinds of agent exist, and the **instances** of what has been created. Only the instances persist — the spec table is configuration, and restoring it would resurrect a spec the operator has since removed. """ from typing import Any from task_graph.ids i...
AMD-AGI/Infera
agent_sys/task_graph/agent.py
.py
ced0265d307566fd
7.64
18
"""The composition root. The only module that imports every manager. Registration order is free — components resolve at use time, not construction time — so this reads top-down for a human rather than being constrained by dependencies. """ from collections.abc import Sequence from task_graph.agent import AgentMgr fr...
AMD-AGI/Infera
agent_sys/task_graph/bootstrap.py
.py
e16ccca38bd9ac3e
7.64
18
"""The handoff collection. The mgr decides nothing. Version bookkeeping belongs to `Handoff` and the transition belongs to `HandoffVersion`; what is left here is add / get / query and durability. """ from collections.abc import Iterable from task_graph.ids import HandoffId, TaskId from task_graph.models import Hando...
AMD-AGI/Infera
agent_sys/task_graph/handoff.py
.py
0c1da3aa52280960
7.64
18
"""Typed identities. A ``TaskId`` and a ``HandoffId`` built from the same bytes are different values. ``typing.NewType`` would give that statically and erase at runtime, so the two would still compare equal and collide in one dict; subclassing ``uuid.UUID`` gives both, and generation, parsing and formatting come from ...
AMD-AGI/Infera
agent_sys/task_graph/ids.py
.py
4ca8ef6e819da344
7.64
18
"""Ordering the eligible set — the one scheduling decision in the system. No graph algorithm is required: the only graph operation anywhere is asking whether a task's inputs are valid, and that is a query on the handoff. """ from typing import Protocol from task_graph.ids import TaskId from task_graph.models import ...
AMD-AGI/Infera
agent_sys/task_graph/policy.py
.py
f6fd16b521fc2a35
7.64
18
"""Component registry and the recovery protocol. Components are registered by name and resolved at use time, never injected through a constructor. That is what lets a test swap an implementation after the system is wired, and it is what keeps the import graph acyclic: no manager imports another manager. """ from typi...
AMD-AGI/Infera
agent_sys/task_graph/registry.py
.py
76681b2b3417e3b8
7.64
18
"""Resource pools. The one place inheritance appears. Renewable and consumable differ in *three* behaviours — release, persistence, recovery — so a boolean flag would mean three conditionals kept in agreement by hand. """ import logging from abc import ABC, abstractmethod from task_graph.registry import Registry __...
AMD-AGI/Infera
agent_sys/task_graph/resource.py
.py
f384c2230cda15ea
7.64
18
"""The runner seam. What actually executes an agent is harness-specific and out of scope. What this system owes is the interface, and a fake that lets the whole scheduler be tested without one. """ from collections.abc import Callable from typing import Any, Protocol from task_graph.ids import TaskId from task_graph...
AMD-AGI/Infera
agent_sys/task_graph/runner.py
.py
635952f352d2b1db
7.64
18
"""The task collection. Durability and lookup. Transitions are the `Task`'s own, so there is no `set_status` here — a caller does `task.status = X` and then `mgr.persist(tid)`. """ from task_graph.ids import TaskId from task_graph.models import Task, TaskStatus from task_graph.registry import Registry __all__ = ["Ta...
AMD-AGI/Infera
agent_sys/task_graph/task.py
.py
3c49236167433cb8
7.64
18
# SPDX-License-Identifier: MIT # Copyright (c) 2026, Advanced Micro Devices, Inc. All rights reserved. from env_mgr.outcome import Outcome, status_from, worst_level def test_outcome_defaults_empty_details(): o = Outcome("ok", "present") assert o.details == {} def test_status_from_empty_is_ok(): assert s...
AMD-AGI/Infera
agent_sys/tests/env_mgr/test_outcome.py
.py
68e3a5647a7a9d64
7.14
18
# SPDX-License-Identifier: MIT # Copyright (c) 2026, Advanced Micro Devices, Inc. All rights reserved. from env_mgr.versions import constraints_conflict, satisfies def test_no_constraint_is_always_satisfied(): assert satisfies("1.0.0", None) is True assert satisfies(None, None) is True def test_missing_actu...
AMD-AGI/Infera
agent_sys/tests/env_mgr/test_versions.py
.py
2d5f032b56cb7118
7.14
18
"""The authority boundary — criterion 14. The scheduler decides *when*, never *what*. It never writes handoff state. This is the one mechanical check that the boundary has not eroded: a spy HandoffMgr logs every call, `produce` brackets its own writes with a marker, and the assertion is that every write falls inside a...
AMD-AGI/Infera
agent_sys/tests/task_graph/test_authority.py
.py
5535d70f62bb7ced
8.14
18
"""The index invariant — criterion 12. `_move` is the only thing that assigns `task.status` or mutates a pool, so the index cannot disagree with the TaskMgr. This drives a long sequence of operations and re-checks after every one. """ import logging import random from task_graph.models import TaskStatus from task_gr...
AMD-AGI/Infera
agent_sys/tests/task_graph/test_invariants.py
.py
7cadf3d0810eeb5f
8.14
18
import os import json import shutil import base64 def _create_items(items, current_dir): for item in items: item_name = item["name"] item_type = item["type"] item_path = os.path.join(current_dir, item_name) if item_type == "folder": os.makedirs(item_path, exist_ok=True)...
eclipse-autowrx/sdv-runtime
kuksa-syncer/project_utils.py
.py
39e9c3361323a538
7.48
8
# Copyright (c) 2025 Eclipse Foundation. # # This program and the accompanying materials are made available under the # terms of the MIT License which is available at # https://opensource.org/licenses/MIT. # # SPDX-License-Identifier: MIT """ Subprocess wrapper for separate, unbuffered capturing / redirecting of stdo...
eclipse-autowrx/sdv-runtime
kuksa-syncer/subpiper/subpiper.py
.py
052da15ff133e264
7.48
8
from __future__ import annotations import json import os from pathlib import Path from typing import Any class PresetManager: """Manages creation, loading, saving and deletion of parameter presets.""" def __init__(self, preset_dir: str | Path = "C:/SnapdragonAI/presets") -> None: self.preset_dir = P...
Kreuzhofen/snapdragon-ai-studio
app/preset_manager.py
.py
f916d3e33248d100
7.52
10
""" HK NPU STUDIO Application Adapter Created by Holger Kreuzhofen Phoenix UI """ class ApplicationAdapter: """Adapter for application-level operations used by controllers.""" def __init__(self, app): self.app = app def after(self, delay_ms, callback): self.app.after(delay_ms, callback...
Kreuzhofen/snapdragon-ai-studio
controllers/application_adapter.py
.py
54350ecd38119aef
7.52
10
""" HK NPU STUDIO Batch Runtime Adapter Created by Holger Kreuzhofen Phoenix UI """ class BatchRuntimeAdapter: """Adapter for batch runtime operations.""" def __init__(self, app): self.app = app def get_waiting_job_count(self): return self.app.controller.get_waiting_job_count() de...
Kreuzhofen/snapdragon-ai-studio
controllers/batch_runtime_adapter.py
.py
865bfe6944d3eb4f
7.52
10
from __future__ import annotations from app.i18n import tr import time from typing import Any from controllers.generation_job import GenerationJob from controllers.generation_result import GenerationResult from engine.error_diagnostics import diagnose_exception from engine.job_lifecycle import JobStatus, get_job_statu...
Kreuzhofen/snapdragon-ai-studio
controllers/generation_pipeline.py
.py
d389e17ac13f10a6
7.52
10
from __future__ import annotations from uuid import UUID from controllers.generation_job import GenerationJob from engine.job_lifecycle import ( JobStatus, TERMINAL_JOB_STATUSES, cancel_job, get_job_status, set_job_status, ) class GenerationQueue: """ Manages a queue of GenerationJobs in ...
Kreuzhofen/snapdragon-ai-studio
controllers/generation_queue.py
.py
5e4623116ad89bb2
7.52
10
from __future__ import annotations from dataclasses import dataclass, asdict from typing import Any from config import OUTPUT_DIR @dataclass(frozen=True) class PipelineParameters: """Immutable parameter contract shared by CPU, ONNX, and QNN pipelines.""" prompt: str negative_prompt: str model_name: s...
Kreuzhofen/snapdragon-ai-studio
controllers/generation_session.py
.py
59d73fc5e7ef5313
7.52
10
from __future__ import annotations import logging import time from pathlib import Path from typing import Any, Callable import config from controllers.model_manager_model import ModelManagerModel from engine.backends.backend_manager import BackendManager from engine.backends.discovery_result import DiscoveryResult fr...
Kreuzhofen/snapdragon-ai-studio
controllers/model_manager_controller.py
.py
83103c34f80cfcbb
7.52
10
from __future__ import annotations from typing import Any from controllers.model_repository import ModelRepository class ModelManagerModel: """ Model representing the state of the Model Manager. Delegates all metadata storage and retrieval to ModelRepository. """ def __init__(self, repository: M...
Kreuzhofen/snapdragon-ai-studio
controllers/model_manager_model.py
.py
307d477d79ebe5be
7.52
10
from __future__ import annotations import datetime from dataclasses import dataclass from typing import Any from controllers.model_repository import ModelRepository from controllers.generation_result import GenerationResult @dataclass class WorkflowState: """ State representing shared parameters across vario...
Kreuzhofen/snapdragon-ai-studio
controllers/workflow_controller.py
.py
3cac0e3437824420
7.52
10
""" HK NPU STUDIO Help Dialog Created by Holger Kreuzhofen Phoenix UI """ from __future__ import annotations import tkinter as tk from pathlib import Path from app.i18n import get_current_language, tr from dialogs.studio_dialog import StudioDialog from engine.brand_manager import BrandManager from widgets.phoenix....
Kreuzhofen/snapdragon-ai-studio
dialogs/help_dialog.py
.py
7a85d51f2be500a0
7.52
10
from __future__ import annotations import tkinter as tk from tkinter import ttk import threading import subprocess import shutil import os import re import logging from typing import Callable from pathlib import Path from app.i18n import tr from dialogs.studio_dialog import StudioDialog from engine.brand_manager impo...
Kreuzhofen/snapdragon-ai-studio
dialogs/qwen_setup_dialog.py
.py
b08d15fd2aa6b8e6
7.52
10