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 |
|---|---|---|---|---|---|---|
"""CEC2017 visualization and timing utilities.
Provides surface_plot() for 3D visualization and time_batch() for benchmarking.
Both use the batch (M, N) calling convention.
"""
from __future__ import annotations
from typing import TYPE_CHECKING
import numpy as np
if TYPE_CHECKING:
from collections.abc import C... | MostafaMassoud/DT-GSK | benchmarks/cec_suite_python/cec2017/utils.py | .py | 2089d76bca83bafe | 7 | 0 |
"""Thread-local serial-kernel routing — **cec2020 suite only**.
Why per-suite: a scope must never be able to route a *different* suite's
kernels. Each suite that gets serial twins owns its own thread-local flag; this
mirrors ``cec2017/_kernel_mode.py`` and ``cec2020lsgo/_kernel_mode.py``.
Why thread-local rather than... | MostafaMassoud/DT-GSK | benchmarks/cec_suite_python/cec2020/_kernel_mode.py | .py | d8fe8af55e00af34 | 7 | 0 |
"""CEC2020 entry point — unified interface for all 10 benchmark functions.
Usage::
from benchmarks import cec2020_func
x = np.random.uniform(-100, 100, (100, 10))
fitness = cec2020_func(x, 1) # F1: returns (100,) array
fitness = cec2020_func(1, x) # same — auto-detects argument or... | MostafaMassoud/DT-GSK | benchmarks/cec_suite_python/cec2020/functions.py | .py | 88e450e941366ffa | 7 | 0 |
# Copyright (c) The btclib developers
# Distributed under the MIT software license, see the accompanying
# LICENSE file or https://opensource.org/license/mit for the full text.
"""Re-check every vendored-vector pin against upstream, weekly.
`vectors/README.md` pins each vendored file to an upstream commit and the
git... | btclib-org/btclib-benchmarks | .github/scripts/check_vendored_vectors.py | .py | 69826e3ee7e24332 | 7.15 | 1 |
# Copyright (c) The btclib developers
# Distributed under the MIT software license, see the accompanying
# LICENSE file or https://opensource.org/license/mit for the full text.
"""Count a Cosmic Ray session by outcome, the skipped mutants left out.
`cr-rate` answers the wrong question for a filtered session, and not ... | btclib-org/btclib-benchmarks | .github/scripts/mutation_counts.py | .py | bff028fd8f01a139 | 7.15 | 1 |
# Copyright (c) The btclib developers
# Distributed under the MIT software license, see the accompanying
# LICENSE file or https://opensource.org/license/mit for the full text.
"""What the second signature under the same key costs, and the hundredth.
Nearly every row of the other four benchmarks times one operation o... | btclib-org/btclib-benchmarks | scripts/05-key-reuse.py | .py | 8cf928ca67f889ce | 7.15 | 1 |
# Copyright (c) The btclib developers
# Distributed under the MIT software license, see the accompanying
# LICENSE file or https://opensource.org/license/mit for the full text.
"""Timings of BIP352, which no comparand on any other page here offers.
[ISS 83][iss83] took a census of what `btclib_secp256k1` exports that... | btclib-org/btclib-benchmarks | scripts/06-silentpayments.py | .py | da10b5422c7ffd60 | 7.15 | 1 |
# Copyright (c) The btclib developers
# Distributed under the MIT software license, see the accompanying
# LICENSE file or https://opensource.org/license/mit for the full text.
"""Say which artifact each comparand's install resolved to, measuring nothing.
uv run python scripts/artifacts.py
One line per declared ... | btclib-org/btclib-benchmarks | scripts/artifacts.py | .py | a0f9f7339fc1c491 | 7.15 | 1 |
# Copyright (c) The btclib developers
# Distributed under the MIT software license, see the accompanying
# LICENSE file or https://opensource.org/license/mit for the full text.
"""Write the published pages from the saved runs, measuring nothing.
uv run python scripts/render.py # every page, from its ru... | btclib-org/btclib-benchmarks | scripts/render.py | .py | 3f4df3c9b0046a93 | 7.15 | 1 |
# Copyright (c) The btclib developers
# Distributed under the MIT software license, see the accompanying
# LICENSE file or https://opensource.org/license/mit for the full text.
"""One pool of inputs, shared by every benchmark and built at most once.
Every script here draws from the same `POOL_SIZE` secret keys and th... | btclib-org/btclib-benchmarks | src/btclib_benchmarks/_inputs.py | .py | 72da4fdfd92145e8 | 7.15 | 1 |
# Copyright (c) The btclib developers
# Distributed under the MIT software license, see the accompanying
# LICENSE file or https://opensource.org/license/mit for the full text.
"""Where the packages being timed came from, said above every number.
A released wheel, a git checkout and an editable install of the same
di... | btclib-org/btclib-benchmarks | src/btclib_benchmarks/_provenance.py | .py | 90a29a1afa2a9310 | 7.15 | 1 |
# Copyright (c) The btclib developers
# Distributed under the MIT software license, see the accompanying
# LICENSE file or https://opensource.org/license/mit for the full text.
"""The vendored vectors, read and checked, for the benchmarks and the suite.
Every row of every benchmark runs over a set of published inputs... | btclib-org/btclib-benchmarks | src/btclib_benchmarks/_vectors.py | .py | 3427fb23acdb2fe3 | 7.15 | 1 |
# Copyright (c) The btclib developers
# Distributed under the MIT software license, see the accompanying
# LICENSE file or https://opensource.org/license/mit for the full text.
"""Tests for the command that says which artifact each comparand resolved to.
What is being defended is that the report covers the comparands... | btclib-org/btclib-benchmarks | tests/artifacts_test.py | .py | 7c9cf5a5971c841d | 7.65 | 1 |
# Copyright (c) The btclib developers
# Distributed under the MIT software license, see the accompanying
# LICENSE file or https://opensource.org/license/mit for the full text.
"""The convention-test declaration in tests/README.md is true.
Section 7 of the organization standard lists the conventions a suite can
turn ... | btclib-org/btclib-benchmarks | tests/conventions_test.py | .py | 1bc86db45a39bc1a | 7.65 | 1 |
# Copyright (c) The btclib developers
# Distributed under the MIT software license, see the accompanying
# LICENSE file or https://opensource.org/license/mit for the full text.
"""The pool every benchmark draws from, and the cache that hands it back.
`src/btclib_benchmarks/_inputs.py` is the one place a measurement g... | btclib-org/btclib-benchmarks | tests/inputs_test.py | .py | edef957ae73bcdba | 7.65 | 1 |
# Copyright (c) The btclib developers
# Distributed under the MIT software license, see the accompanying
# LICENSE file or https://opensource.org/license/mit for the full text.
"""Tests for the provenance report every benchmark prints before its numbers.
What is being defended is the one failure this project cannot a... | btclib-org/btclib-benchmarks | tests/provenance_test.py | .py | ac18a213462dfdaa | 7.65 | 1 |
# Copyright (c) The btclib developers
# Distributed under the MIT software license, see the accompanying
# LICENSE file or https://opensource.org/license/mit for the full text.
"""`btclib_benchmarks`'s public surface, declared and empty.
Section 7 of the organization standard asks every module and package to
declare ... | btclib-org/btclib-benchmarks | tests/public_surface_test.py | .py | cbb8d7c8efb529f0 | 7.65 | 1 |
# Copyright (c) The btclib developers
# Distributed under the MIT software license, see the accompanying
# LICENSE file or https://opensource.org/license/mit for the full text.
"""The three things in the renderer that refuse rather than format.
`src/btclib_benchmarks/_results.py` is outside the coverage gate on
purpo... | btclib-org/btclib-benchmarks | tests/results_test.py | .py | 2c7c2b45ff068cd6 | 7.65 | 1 |
# Copyright (c) The btclib developers
# Distributed under the MIT software license, see the accompanying
# LICENSE file or https://opensource.org/license/mit for the full text.
"""What every measured package answers about its own arithmetic.
`vectors_test.py` holds each implementation to what a specification
publishe... | btclib-org/btclib-benchmarks | tests/round_trip_test.py | .py | 92587f587b82b444 | 7.65 | 1 |
# Copyright (c) The btclib developers
# Distributed under the MIT software license, see the accompanying
# LICENSE file or https://opensource.org/license/mit for the full text.
"""Every benchmark loads, and its comparands agree, without timing anything.
This is the whole of what a test can hold a benchmark to. A meas... | btclib-org/btclib-benchmarks | tests/scripts_import_test.py | .py | 4792e2a2bb5758fd | 7.65 | 1 |
"""Autonomous headless bot client for match simulation, AI testing, and stress load testing."""
import random
import time
from typing import Dict, Optional
from shared.enums.game_enums import CharacterClass, WeaponType, AbilityType, PacketOpcode
from shared.protocols.packet import GamePacket, PacketHeader
from shared.m... | Dhanunjay-narra/Multiplayer-Game | client/bot_client/bot_runner.py | .py | 1b7cd3e6d4917b25 | 7 | 0 |
"""Client networking, prediction, reconciliation, and state interpolation engine."""
import asyncio
import time
from typing import Any, Dict, List, Optional
from shared.enums.game_enums import PacketOpcode, CharacterClass, WeaponType, AbilityType
from shared.protocols.packet import GamePacket, PacketHeader, SequenceTra... | Dhanunjay-narra/Multiplayer-Game | client/core/game_client.py | .py | 65a87c4b7d1698a3 | 7 | 0 |
"""Interactive terminal client dashboard with live radar, HUD, and combat log."""
import time
from typing import Dict, List, Optional
from shared.schemas.gameplay_schemas import GameStateSnapshot
try:
from rich.console import Console
from rich.table import Table
RICH_AVAILABLE = True
except ImportError:
... | Dhanunjay-narra/Multiplayer-Game | client/ui/terminal_client.py | .py | 5c29eaef54769e85 | 7 | 0 |
"""Admin Live-Ops remote configuration and immutable audit logging."""
import uuid
import time
from typing import Any, Dict, List, Optional
from shared.schemas.admin_schemas import LiveGameConfig, AuditLogRecord
class AdminService:
"""Manages dynamic hot-reloaded game configuration and administrative audit logs."... | Dhanunjay-narra/Multiplayer-Game | server/admin/admin_service.py | .py | b6d53e4503bd9ac1 | 7 | 0 |
"""预算明细面板(Phase 67)
从已生成的攻略正文抽结构化开销 + 需预约项(LLM)→ 分类归一 → **服务端重算汇总**
→ 写一条 meta.budget 的 assistant 消息供前端渲染成面板。
为什么汇总要服务端算:让模型自己算总额会输出 `"total": 30+54+120=324` 这类非法 JSON
(TripStar 就因此被迫写正则 eval 修复)。这里模型只给单项金额,加法我们自己做。
"""
import asyncio
import json
import logging
from app.agent.context_security import EXTERNAL_POLICY... | 315462438/tongyou-travel-agent | backend/app/agent/budget.py | .py | f8b4273cb59c8c2b | 7.24 | 2 |
"""协作式取消(Phase 16):用户点停止 → 标记 cid,运行中的 agent 在检查点抛出中止。
进程内线程安全集合(BackgroundTask 跑在线程池里)。取消是「协作式」的:
长时间 MCP 调用不会立刻中断,但会在下一个 check 点(每块流式/每次搜索抓取)生效。
"""
import logging
import threading
logger = logging.getLogger(__name__)
_cancelled: set[str] = set()
_lock = threading.Lock()
class TurnCancelled(Exception):
"""本... | 315462438/tongyou-travel-agent | backend/app/agent/cancel.py | .py | e7aea80b65283879 | 7.24 | 2 |
"""对话内确认交互(Phase 7)
后台任务向对话流写「确认卡片」消息(meta.confirm),前端渲染按钮;
用户点击经 POST /api/chat/{cid}/confirm 落一条 role=action 的隐藏消息
(meta.confirm_reply);后台轮询消息表拿决定,超时按默认值处理。
复用消息表做双向通道:无需 WebSocket,且决定有审计记录。
"""
import asyncio
import json
import uuid
from sqlalchemy import select
from sqlalchemy.orm import Session
from app.confi... | 315462438/tongyou-travel-agent | backend/app/agent/confirm.py | .py | 29ae86e1ede2a083 | 7.24 | 2 |
"""独立扫码连接会话(Phase 109 第二期)。
**为什么值得从对话轮次里搬出来** —— 原计划把这件事排到后面,理由是「等待会占住
浏览器池槽位,而 `BROWSER_POOL_MAX=2`」。**这个理由经查是错的**,它只算了新方案的
成本没算现状:
现状:acquire → 导航携程 → 撞登录墙 → 等扫码(≤180s) → 重开页 → 抓取
→ 继续必应搜索 + 最多 8 个页面 → release
占槽 = 采集全程 + 最多 180s
独立:acquire → 导航 → 等扫码(≤90s) → release
占槽 = 最多 ... | 315462438/tongyou-travel-agent | backend/app/agent/connect_session.py | .py | 4f63aa172c4eb5e2 | 7.24 | 2 |
"""连接器清单(Phase 109):把「这个系统连了哪些外部站点、各自能做什么」摊开给用户看。
**为什么需要它**:用户现在完全不知道系统会去携程和小红书取数据,也不知道自己的
携程登录态被记着。更糟的是能力边界不透明——问「我的携程订单」才发现做不到。
清单是**代码常量不是用户数据**,所以不入库;状态复用 `travel_site_login`
(Phase 9/15 已经是 `(user_id, site)` 按用户隔离的)。多一张表就多一处不同步。
⚠️ **不显示「有效期」**:`settings.site_login_ttl_min` 在浏览器池模式下是死代码
(`_expire_stale_logins`... | 315462438/tongyou-travel-agent | backend/app/agent/connectors.py | .py | b2a92f7333cb794a | 7.24 | 2 |
"""上下文清单(Phase 89,借鉴 dsh 的 "Model-visible ⟺ logged" 不变式)
## 要解决什么
`_assemble_history` 是**请求时现算**的派生结果,事后无法回答「那一轮到底喂了
什么进模型」。
> 2026-08-22 订正:此处原本还列了「改 `history_rounds` 会让边界追溯性移动」——
> 那个装配期滑动窗口已随本次改造删除,边界现在只由日志里的 replace 事件决定,
> 不再随配置漂移。清单要解决的仍是「派生结果没被记下来」这一半。
日志本身是完整的(消息从不删除、摘要也只是另存一列),缺的不是**输入**,
而是**那次派生的结果**。今天调... | 315462438/tongyou-travel-agent | backend/app/agent/context_manifest.py | .py | 91be3ecca18464fe | 7.24 | 2 |
"""上下文注入防护(Phase 31):外部内容标记 + 防标签逃逸。
三条标准防线在本项目的落法:
- 来源标记:所有抓取的网页内容进 prompt 前包 <external_content source=… url=…> 标签;
- 结构化角色:guide/direct 生成调用重建为标准 agent 轨迹(assistant.tool_calls →
tool → assistant),外部内容落在 tool 角色上(见 orchestrator);
- 输入清洗:只做最小必要形态——剥掉外部文本里的 external_content 开闭标签字面量,
防止恶意页面用 </external_content> 提前闭... | 315462438/tongyou-travel-agent | backend/app/agent/context_security.py | .py | e961d10d9c0483df | 7.24 | 2 |
"""页面结构化抽取(PRD 6.4/6.5,评审 🔴5:结构化输出)
Phase 69:这里的输入全是抓来的页面文本(不可信),此前是裸拼进 prompt 的。
虽然 parse() 的结构化输出限制了危害形态,但 summarize_page 是自由文本且结果会流回
主上下文,注入可借它跨层传播——统一包 <external_content> 并追加外部内容规则。
"""
from app.agent.context_security import EXTERNAL_POLICY, wrap_external
from app.llm.client import get_llm
from app.schemas.hotel... | 315462438/tongyou-travel-agent | backend/app/agent/extract.py | .py | c083d8472508d693 | 7.24 | 2 |
"""LangGraph 攻略图组装(Phase 14 + 16 checkpoint)
固定采集/生成主干 + critique/research/rewrite 反思循环:
parse → (quick_take 占位+快答先行) → collect → (有料) generate → critique
critique → finalize / research→generate / rewrite→generate
反思关闭或达上限时退化为「生成一次即终稿」。
Phase 16:编译时挂 Postgres checkpointer(AsyncPostgresSaver),每步 state 落 PG,
thre... | 315462438/tongyou-travel-agent | backend/app/agent/graph.py | .py | 068cbe7462d6bfc1 | 7.24 | 2 |
"""图片规格化(Phase 111):把用户上传的图变成视觉模型收得下的形状。
## 为什么需要这一层
DeepSeek 视觉端对图片有**单边 8192 px** 的硬上限,越界返回 400,而报文写的是
「unsupported image,请确认格式是 webp/png/jpeg/gif」——**格式是对的,越界的是尺寸**。
照着报文去查格式会一路走错(2026-08-27 就是这么被误导的)。
实测判据(同一张 1800×25242 的行程长截图,逐档裁切):
1800× 8192 941KB OK
1800× 8500 988KB FAIL
1024×14360 1207K... | 315462438/tongyou-travel-agent | backend/app/agent/image_prep.py | .py | b05c35107ab3c4a8 | 7.24 | 2 |
"""地点导航 deep link(Phase 100)。
行程板上每个地点都有精确坐标,但用户想真去导航时只能自己打开高德手动搜。
这里拼一条 deep link 直接跳到用户自己的地图 App。
**不消耗我们的高德配额**:请求由用户设备发起、落到高德 C 端产品,与开发者 key 无关,
URL 里也不含任何 key(与「静态图后端签名代拉、key 不进前端」是同一条纪律的另一面)。
## 唯一有技术含量的部分:坐标系分流
`travel_trip_stop.location` 混着两套坐标系(国内高德 GCJ-02 / 海外 WGS-84,
见 `models.py`)。这在站内一直是对的——GCJ 偏移只在中国境... | 315462438/tongyou-travel-agent | backend/app/agent/nav_links.py | .py | 2e528ce7d36ffc34 | 7.24 | 2 |
"""LangGraph 攻略图节点(Phase 14)
节点复用 orchestrator 里踩坑踩出来的采集/生成逻辑,只新增 critique/research
反思环节。进度/流式照旧写消息表(前端轮询无需改)。
"""
import logging
import re
from app.agent import orchestrator as orch
from app.agent.graph_state import AgentState
from app.config import settings
from app.llm.client import get_llm
from app.schemas.criti... | 315462438/tongyou-travel-agent | backend/app/agent/nodes.py | .py | fb687daaffbfb904 | 7.24 | 2 |
"""Phase 51 批5:实时数据可信度守卫。
酒店/火车/航班的「实时价格/房态/时刻」在没有出发日期时无法真实查询——弱模型却容易
一本正经地编具体房价和车次。本模块负责(纯函数、可测):
1. `realtime_kind`:判定这轮是否在问「实时价格/时刻」类需求(hotel / transport);
2. `extract_travel_date`:从话里抽出行/入住日期(相对词 + 显式日期);
3. `credibility_directive`:生成注入生成 prompt 的可信度纪律——
无日期 → 标「参考价(非实时)」+ 先追问日期;有日期 → 标注查询日期 + 数据来源。
生成侧只做 prom... | 315462438/tongyou-travel-agent | backend/app/agent/realtime_guard.py | .py | 7f8e9bdeac2ad2a8 | 7.24 | 2 |
"""工具输出按结构裁剪(Phase 96,借鉴 dsh 社区插件 toolshrink)
Phase 90 的 `truncate.py` 解决的是「截断本身要幂等」,没解决「**截哪里**」——
仍然按位置下刀。而按位置下刀在网页上有个要命的后果:**前面全是导航**。
实测维基百科「西湖」词条(生产参数 limit=4000):喂给模型的 4000 字里
**3681 字是导航和目录,正文只有 319 字,有效率 8%**。预算再大也先被 chrome 吃掉。
这里按**结构**下刀:认出内容格式,套一条人写死的规则。注意「语义」不是"理解内容",
而是"**认得这是什么格式**"——判断力是人在写 reducer 时付... | 315462438/tongyou-travel-agent | backend/app/agent/reducers.py | .py | 946ddd2b1e4b7841 | 7.24 | 2 |
"""重复工具调用守卫(Phase 89,借鉴 dsh 的 repeat-tool-reminder)
Phase 28 的**硬配额**治的是「总量超标」(搜 ≤3 次、读 ≤10 个),治不了另一半:
同一个查询被反复调用三次,总数没超但时间和上下文都白烧了。而长上下文里 prompt
纪律必然漂移——模型不会因为你写了「别重复」就不重复。
这里补上另一半:**检测连续重复,注入升级式建议**。刻意不阻断——
合法的重复调用(换了参数的翻页、确实需要重查)一次都不该被拦,
决定权留给模型:换思路、补证据、还是收敛出稿。
## 按调用方分链(Phase 95)
工具闭包是**主 agent 与全部 subagent 共享*... | 315462438/tongyou-travel-agent | backend/app/agent/repeat_guard.py | .py | 36ba41b48e4271da | 7.24 | 2 |
"""深度研究模式的工具集(Phase 21)
资源分工(用户拍板):
- 浏览器(必应搜索/开页面)→ **主 agent**:串行有状态昂贵(池 busy=每用户串行、登录态);
整轮懒加载共享一个 ChromeMCP 会话,首次用到才 acquire,轮末统一关闭。
- 高德 API / fetch_url(纯 HTTP)→ **subagent**:httpx 无状态可并行。
所有工具内打 cancel.check(cid)(停止按钮可用)并写 progress(前端可见进度)。
工具用闭包工厂绑定 cid/user_id,避免全局状态。
"""
import asyncio
import ipaddress
im... | 315462438/tongyou-travel-agent | backend/app/agent/research_tools.py | .py | 1c79d1ae4f1cc33a | 7.24 | 2 |
"""Phase 1 任务执行器:打开 URL → 读取 → 分类 → 抽取 → 落库
Phase 1 用简单顺序调用;LangGraph 编排 + checkpoint 恢复在 Phase 2/3。
"""
import asyncio
import json
import logging
import traceback
from app.agent.extract import extract_hotel, extract_note, summarize_page
from app.db.models import TravelPage, TravelTask
from app.db.session import get... | 315462438/tongyou-travel-agent | backend/app/agent/runner.py | .py | 9133c68b588da15b | 7.24 | 2 |
"""站点路由(Phase 3)—— 按意图把 Agent 浏览器导航到指定站点
酒店/住宿相关 → 携程;路线/行程规划相关 → 小红书。
命中登录墙时向对话流写入 handoff 卡片消息(meta.handoff),提示用户在
Agent 调试 Chrome 窗口中自行登录,后台轮询页面状态直到登录完成或超时。
服务器 headless 模式(settings.is_headless_server)用户看不到浏览器窗口,
无法手动登录,直接跳过等待、回退公开搜索。
"""
import asyncio
import logging
import os
import tempfile
from dataclasses im... | 315462438/tongyou-travel-agent | backend/app/agent/site_router.py | .py | 0fb10f761c99a331 | 7.24 | 2 |
"""用户上传技能的校验(Phase 27)。
复用 deepagents 自带的 SKILL.md frontmatter 解析器(同 Phase 26 内置技能走的是同一套
规范),不重新发明校验规则;这里只加一层「拒绝而不是静默丢弃」——内置技能解析失败只是
少一条技能、日志警告即可,但用户主动上传时必须让用户知道到底哪里错了。
"""
from __future__ import annotations
from app.config import settings
class SkillValidationError(Exception):
"""用户上传的 SKILL.md 内容不合法,携带可展示给用户... | 315462438/tongyou-travel-agent | backend/app/agent/skill_validation.py | .py | 72c49288df5fe005 | 7.24 | 2 |
"""深度研究 agent 的技能库加载器(Phase 26 内置技能 + Phase 27 用户上传技能)。
技能正文以 .md 文件形式存在仓库里(`backend/app/agent/skills/`,方便版本管理/人工维护),
但 deep_research 的 agent 默认用的是 `StateBackend`(ephemeral,per-invoke,不碰真实磁盘——
选型原因见 docs/pitfalls/ 里 FilesystemBackend virtual_mode 默认值的踩坑记录)。所以这里只
负责「读盘一次/查一次库 → 转成 StateBackend 认的 FileData → 每轮 agent.ai... | 315462438/tongyou-travel-agent | backend/app/agent/skills_loader.py | .py | 645f1266e71f1a03 | 7.24 | 2 |
"""采集来源全文的落库与按需重取(Phase 103)。
## 问题
`_search_and_collect_queries` 抓完页面只留 `_excerpt(page.text)` 的 1500 字摘录,全文丢弃;
而 `collect_sources` 的复用分支(`is_revision`)复用的**就是这 1500 字**。用户第二轮追问
「第 3 家酒店的取消政策」时,信息在原页面里有、在我们手上没有——只能重爬(慢)或让模型编。
深度研究链路早就有这个能力(`research_tools._stash_source` + `read_source(id, offset)`),
opencode 则是做到了全局... | 315462438/tongyou-travel-agent | backend/app/agent/source_pages.py | .py | 7bbcc9c9a62838fb | 7.24 | 2 |
"""子代理运行可视化(Phase 88)
深度研究会**并发派多个 `api-researcher`**(RESEARCH_SYSTEM 明确要求一步里一次性发多个),
但用户此前完全看不见:谁在跑、在查什么、跑了多久、烧了多少 token。等待期只有一串
扁平的足迹进度,看不出并行度,也判断不了「是不是卡住了」。
这里挂一个 LangChain callback,跟踪 `task` 工具(deepagents 的子代理派发入口)的
开始/结束,并把子代理内部的 LLM token 归属到对应子任务上,落成一条
`meta.subagents` 的 progress 消息供前端渲染成面板。
**token 归属靠 run 树... | 315462438/tongyou-travel-agent | backend/app/agent/subagent_trace.py | .py | ee1afeeca6a96f3c | 7.24 | 2 |
"""幂等中段截断(Phase 89,借鉴 dsh 的 compaction-tool-result-pruner)
## 为什么要有这个模块
项目里到处在截断长文本(工具结果预览、来源摘录、进度文案摘要),但没有一处保证
**截过一次的东西再截一次不会变**。不幂等的截断有两个真实后果:
1. 同一段内容在链路里被截多次,每次都少一点,最后剩个头尾拼盘;
2. 排查时无法判断「这段是原文还是被截过的」——因为截断痕迹本身也会被截掉。
dsh 的 pruner 在**配置校验期**就用一条数学约束根治了它:
headChars + marker + tailChars <= thresholdChars
于是「任... | 315462438/tongyou-travel-agent | backend/app/agent/truncate.py | .py | cd207f8d965da2b2 | 7.24 | 2 |
"""管理后台(Phase 74):角色管理 / 邀请码 / 公告推送。
设计取舍见 docs/task_plans/管理后台批次-角色邀请码公告图片表情-2026-08-04.md
"""
from __future__ import annotations
import secrets
from fastapi import APIRouter, Depends, HTTPException
from pydantic import BaseModel
from sqlalchemy import func, select, update
from sqlalchemy.orm import Session
from ... | 315462438/tongyou-travel-agent | backend/app/api/admin_api.py | .py | 23bf0e237296786c | 7.24 | 2 |
"""登录 / 注册(Phase 15)"""
import re
from fastapi import APIRouter, Depends, HTTPException
from pydantic import BaseModel
from sqlalchemy import func, select
from sqlalchemy.orm import Session
from app.api.deps import get_current_user, is_online, iso_utc, require_admin
from app.auth import hash_password, new_token, ver... | 315462438/tongyou-travel-agent | backend/app/api/auth_api.py | .py | 804cbf5b307b1950 | 7.24 | 2 |
import json
import os
from datetime import datetime, timedelta, timezone
from fastapi import APIRouter, BackgroundTasks, Depends, HTTPException
from fastapi.responses import FileResponse
from pydantic import BaseModel, Field
from sqlalchemy import select
from sqlalchemy.orm import Session
from app.agent.orchestrator ... | 315462438/tongyou-travel-agent | backend/app/api/chat_api.py | .py | 24ee342fd88ffa90 | 7.24 | 2 |
"""连接管理(Phase 109):查看本系统连了哪些外部站点、各自能做什么、断开。
计划见 docs/task_plans/连接管理页-2026-08-26.md。
本期**不动 orchestrator**:只是把既有状态(`travel_site_login`)暴露出来,
外加一个真正有效的断开。连接仍走原来的路径(查酒店时命中登录墙 → 扫码卡片)。
"""
import os
from fastapi import APIRouter, Depends, HTTPException
from fastapi.responses import FileResponse
from sqlalchemy import ... | 315462438/tongyou-travel-agent | backend/app/api/connectors_api.py | .py | 196d5d6eb905b506 | 7.24 | 2 |
"""鉴权依赖(Phase 15):从 Authorization: Bearer <token> 解析当前用户。"""
import logging
from datetime import datetime, timezone
from fastapi import Depends, Header, HTTPException
from sqlalchemy.orm import Session
from app.config import settings
from app.db.models import TravelSession, TravelUser
from app.db.session import get_... | 315462438/tongyou-travel-agent | backend/app/api/deps.py | .py | 94c9ff9cf0de3538 | 7.24 | 2 |
"""图片代理(Phase 12)
攻略里的景点图/酒店图经此代理:同源加载(避免将来 https 混合内容)、
导出长图时不污染 canvas。仅放行图源白名单域名(防 SSRF 开放代理)。
"""
from urllib.parse import urlparse
import httpx
from fastapi import APIRouter, HTTPException
from fastapi.responses import Response
router = APIRouter(prefix="/api", tags=["img"])
# 图源白名单(host 后缀匹配):高德 + 携程 + 小红书官方... | 315462438/tongyou-travel-agent | backend/app/api/img_api.py | .py | cad1b9557a99babf | 7.24 | 2 |
from fastapi import APIRouter, Depends, HTTPException
from sqlalchemy import select
from sqlalchemy.orm import Session
from app.api.deps import get_current_user
from app.db.models import TravelMemory, TravelUser
from app.db.session import get_db
router = APIRouter(prefix="/api/memory", tags=["memory"])
@router.get(... | 315462438/tongyou-travel-agent | backend/app/api/memory_api.py | .py | 2844812f3df428bc | 7.24 | 2 |
"""新用户空状态数据(Phase 75)。
背景:08-04 那批新用户 12 个里 4 个(33%)注册后一个字没问就走了。
提问的 8 个全部拿到了完整攻略,所以问题不在产出质量,在**第一步的门槛**——
首页示例写死成都,而用户全是合肥/武汉的;空输入框又要求他们一次说清完整需求。
这里只提供「让人敢开口」的素材,不碰生成链路。
"""
from __future__ import annotations
import asyncio
import logging
import time
from datetime import datetime, timedelta, timezone
import httpx... | 315462438/tongyou-travel-agent | backend/app/api/onboarding_api.py | .py | e227d8fd950fc35d | 7.24 | 2 |
"""沙箱产物下载(Phase 27c):深度研究 agent 在 Docker 沙箱里生成的文件(PPT/Word/图表等)。
跟 `/api/img`、handoff-screenshot 同一套信任模型:不鉴权,靠 `batch_key`(服务端生成的
uuid4 hex,不可猜测)做访问控制——这类静态文件本来就无法带 Authorization header 加载
(下载链接/<img> 都一样),项目里已经是既定模式。到期后(`sandbox_artifacts_ttl_min`)
文件被懒清理删除,请求会 404。
"""
import os
import re
from fastapi import APIRo... | 315462438/tongyou-travel-agent | backend/app/api/sandbox_artifacts_api.py | .py | 374b1d6ba1552dda | 7.24 | 2 |
"""高德静态地图代理(Phase 13)
前端只传点位/编号/颜色,后端构造 markers+path、签名、拉图返回,
高德 key/sig 不进前端。仅用于手账海报路线图。
"""
import hashlib
from urllib.parse import urlencode
import httpx
from fastapi import APIRouter, HTTPException
from fastapi.responses import Response
from app.config import settings
from app.tools.amap import sign_params
rou... | 315462438/tongyou-travel-agent | backend/app/api/staticmap_api.py | .py | 663bead3ea52135a | 7.24 | 2 |
"""APDU command / response serialization (port of ``apdu.ts``).
An APDU (Application Protocol Data Unit) is the packet format used to
talk to a smart card, as defined by ISO/IEC 7816-4.
"""
from __future__ import annotations
from dataclasses import dataclass, field
from typing import List, Sequence
# Status word (S... | amandeepsdet/piv-smartcard | src/smartcard_demo/apdu.py | .py | 44197b3f085a6531 | 7 | 0 |
"""Minimal BER-TLV decoder (port of ``ber.ts``).
PIV data objects are encoded as BER-TLV (ISO/IEC 8825-1). We only need
enough of the format to walk the tag/length/value tree returned by a
PIV card, so this is intentionally small.
"""
from __future__ import annotations
from dataclasses import dataclass
from typing i... | amandeepsdet/piv-smartcard | src/smartcard_demo/ber.py | .py | bb0606f73e86060b | 7 | 0 |
"""PIV applet operations (port of ``piv.ts``).
Implements just enough of NIST SP 800-73-4 to select the PIV
application and read an X.509 certificate object off the card, matching
what the web demo does with the Card Authentication certificate.
"""
from __future__ import annotations
import gzip
from dataclasses impo... | amandeepsdet/piv-smartcard | src/smartcard_demo/piv.py | .py | f7c7cdabeaabeaa3 | 7 | 0 |
"""Hex / X.509 helpers and card identification (port of ``util.ts``)."""
from __future__ import annotations
from dataclasses import dataclass
from typing import List, Sequence
from cryptography import x509
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.serialization import Enco... | amandeepsdet/piv-smartcard | src/smartcard_demo/util.py | .py | fe5917668601c6d8 | 7 | 0 |
"""Track 2 risk-suite reflection — methods added to ReflectionAgent.
The nightly reflection loop gains two analyses: return-risk scoring
accuracy against actual return outcomes, and chargeback rebuttal outcomes.
Both run over an injected record list (in production: the outcomes store;
in tests: fake records), so the l... | purvanshh/PayShield | agents/risk_suite_reflection.py | .py | 53fca571477a638f | 7 | 0 |
"""Read-only meta endpoints serving committed measured artifacts.
The dashboard never re-derives its own numbers — it renders what the backend
actually measured and committed under ``models/``:
- ``/v1/meta/return-risk/benchmark`` -> ``models/return_risk_benchmark_results.json``
- ``/v1/meta/return-risk/cost`` ... | purvanshh/PayShield | api/routes/meta.py | .py | c8ada8577fc24c07 | 7 | 0 |
"""Chargeback domain exceptions (Track 02 - Phase 8)."""
from typing import Any
class ChargebackError(Exception):
"""Base error for the evidence responder.
Raised when a rebuttal cannot be assembled or submitted; never causes a
bare 500 - the API maps it to 404/422/502 per the error strategy in
docs... | purvanshh/PayShield | chargeback/exceptions.py | .py | 5c61e139c4f013e3 | 7 | 0 |
"""Realistic Razorpay mock fixtures (Track 02 - Phase 11).
Mock mode must be *realistic*, not optimistic:
- reason codes match actual Visa/Mastercard codes,
- ``respond_by`` timestamps respect per-network windows,
- status transitions follow Razorpay's dispute state machine
(``open -> under_review -> won / lost``).... | purvanshh/PayShield | chargeback/razorpay_mock_fixtures.py | .py | c73b51575c3f1e56 | 7 | 0 |
"""Webhook signature verification (Track 02 - Phase 11).
Razorpay signs webhook payloads with an HMAC-SHA256 of the raw body using
the configured webhook secret; the digest is presented as
``X-Razorpay-Signature``. Kept as a pure function so the verification logic
is unit-testable without an HTTP stack.
"""
import ha... | purvanshh/PayShield | chargeback/signatures.py | .py | 7b4b4664ec0962a7 | 7 | 0 |
"""Centralised Pydantic settings – single source of truth for all config.
Loads *configs/config.yaml* then allows every leaf value to be overridden
via an environment variable of the form PAYSHIELD_{SECTION}_{KEY} (upper,
underscore-separated).
"""
from __future__ import annotations
import os
from pathlib import... | purvanshh/PayShield | configs/config_loader.py | .py | f9c939292f476788 | 7 | 0 |
"""เพิ่มtext Audit Log
Revision ID: 979070a0e887
Revises: b990f5e95503
Create Date: 2026-08-07 11:06:04.085665
"""
from alembic import op
import sqlalchemy as sa
revision = '979070a0e887'
down_revision = 'b990f5e95503'
branch_labels = None
depends_on = None
def upgrade() -> None:
# ### commands auto generated... | b00mc4/YOLO | alembic/versions/20260807_979070a0e887_เพ_มtext_audit_log.py | .py | 29742368e24c82b3 | 7 | 0 |
"""เพิ่มคอลัมใน camera
Revision ID: 243572ed46e7
Revises: 979070a0e887
Create Date: 2026-08-17 14:51:22.681716
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
revision = '243572ed46e7'
down_revision = '979070a0e887'
branch_labels = None
depends_on = None
def upgrade()... | b00mc4/YOLO | alembic/versions/20260817_243572ed46e7_เพ_มคอล_มใน_camera.py | .py | d616018194f9c596 | 7 | 0 |
"""เพิ่ม whitelist
Revision ID: 755fc1911ad0
Revises: 243572ed46e7
Create Date: 2026-08-17 17:12:21.303628
"""
from alembic import op
import sqlalchemy as sa
revision = '755fc1911ad0'
down_revision = '243572ed46e7'
branch_labels = None
depends_on = None
def upgrade() -> None:
# ### commands auto generated by ... | b00mc4/YOLO | alembic/versions/20260817_755fc1911ad0_เพ_ม_whitelist.py | .py | 6a59182aecd3f616 | 7 | 0 |
"""เพิ่ม category และ name ใน whitelist
Revision ID: 1c1e4ae7996b
Revises: 755fc1911ad0
Create Date: 2026-08-18 10:12:22.358267
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
revision = '1c1e4ae7996b'
down_revision = '755fc1911ad0'
branch_labels = None
depends_on = None... | b00mc4/YOLO | alembic/versions/20260818_1c1e4ae7996b_เพ_ม_category_และ_name_ใน_whitelist.py | .py | de3909c3961d2e7a | 7 | 0 |
"""Delete Village
Revision ID: ea7a38f3730c
Revises: 1c1e4ae7996b
Create Date: 2026-08-18 10:42:23.866706
"""
from alembic import op
import sqlalchemy as sa
revision = '8e2a91f4c7b6'
down_revision = '1c1e4ae7996b'
branch_labels = None
depends_on = None
def upgrade() -> None:
op.drop_constraint(
op... | b00mc4/YOLO | alembic/versions/20260818_ea7a38f3730c_delete_village.py | .py | 550b1e2ec429363a | 7 | 0 |
"""Whitelist Category out
Revision ID: 20974ea90985
Revises: c92a6cdf7d3d
Create Date: 2026-08-21 13:14:11.545516
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql
revision = '9d3b1f2a6e7c'
down_revision = 'c92a6cdf7d3d'
branch_labels = None
depends_on = None
def up... | b00mc4/YOLO | alembic/versions/20260821_20974ea90985_whitelist_category_out.py | .py | f16280c59a5235fb | 7 | 0 |
"""column camera
Revision ID: 5ffcf3a95123
Revises: 9d3b1f2a6e7c
Create Date: 2026-08-25 16:23:22.528094
"""
from alembic import op
import sqlalchemy as sa
revision = '5ffcf3a95123'
down_revision = '9d3b1f2a6e7c'
branch_labels = None
depends_on = None
def upgrade() -> None:
# ### commands auto generated by Al... | b00mc4/YOLO | alembic/versions/20260825_5ffcf3a95123_column_camera.py | .py | 05304c9712461132 | 7 | 0 |
"""camera unique
Revision ID: cfe96bd371bb
Revises: 5ffcf3a95123
Create Date: 2026-08-26 09:16:57.672668
"""
from alembic import op
import sqlalchemy as sa
revision = 'cfe96bd371bb'
down_revision = '5ffcf3a95123'
branch_labels = None
depends_on = None
def upgrade() -> None:
op.create_unique_constraint(
... | b00mc4/YOLO | alembic/versions/20260826_cfe96bd371bb_camera_unique.py | .py | 935a0ff6f9313ca1 | 7 | 0 |
"""remember me
Revision ID: 04677021af0d
Revises: aad40b9cf836
Create Date: 2026-08-27 15:14:10.303696
"""
from alembic import op
import sqlalchemy as sa
revision = '04677021af0d'
down_revision = 'aad40b9cf836'
branch_labels = None
depends_on = None
def upgrade() -> None:
op.add_column(
'RefreshTABLE'... | b00mc4/YOLO | alembic/versions/20260827_04677021af0d_remember_me.py | .py | 3ed3b26a158795ef | 7 | 0 |
"""contact
Revision ID: 25bf6331a93a
Revises: cde2bc295a2d
Create Date: 2026-08-27 16:59:06.000109
"""
from alembic import op
import sqlalchemy as sa
revision = '25bf6331a93a'
down_revision = 'cde2bc295a2d'
branch_labels = None
depends_on = None
def upgrade() -> None:
op.create_index(
'ix_contacttable... | b00mc4/YOLO | alembic/versions/20260827_25bf6331a93a_contact.py | .py | ee76da4149f4239f | 7 | 0 |
"""password
Revision ID: aad40b9cf836
Revises: dec0b6cd309e
Create Date: 2026-08-27 14:44:31.428148
"""
from alembic import op
import sqlalchemy as sa
revision = 'aad40b9cf836'
down_revision = 'dec0b6cd309e'
branch_labels = None
depends_on = None
def upgrade() -> None:
op.add_column(
'UserTABLE',
... | b00mc4/YOLO | alembic/versions/20260827_aad40b9cf836_password.py | .py | 722dd55e41a32b61 | 7 | 0 |
"""email
Revision ID: dec0b6cd309e
Revises: fa22800b9348
Create Date: 2026-08-27 14:01:59.574483
"""
from alembic import op
import sqlalchemy as sa
revision = 'dec0b6cd309e'
down_revision = 'fa22800b9348'
branch_labels = None
depends_on = None
def upgrade() -> None:
with op.get_context().autocommit_block():
... | b00mc4/YOLO | alembic/versions/20260827_dec0b6cd309e_email.py | .py | 846094e7482c2e82 | 7 | 0 |
"""Email
Revision ID: fa22800b9348
Revises: cfe96bd371bb
Create Date: 2026-08-27 11:50:34.854331
"""
from alembic import op
import sqlalchemy as sa
revision = 'fa22800b9348'
down_revision = 'cfe96bd371bb'
branch_labels = None
depends_on = None
def upgrade() -> None:
# ### commands auto generated by Alembic - ... | b00mc4/YOLO | alembic/versions/20260827_fa22800b9348_email.py | .py | 5129ad2befa47ca0 | 7 | 0 |
# agent/cal_com.py — Integração com a API do Cal.com para agendamento de chamadas
# Generado por AgentKit
"""
Substitui o cálculo local de horários (agent/agenda.py) pela disponibilidade
real do Cal.com — a fonte da verdade sobre o calendário do consultor passa a
ser o Cal.com (ligado ao iCloud/Google/Outlook), sem pr... | MB-LMBS/reduz-mais-energia | agent/cal_com.py | .py | fa0c1865937d5784 | 7 | 0 |
# agent/calendario.py — Sincronização de chamadas agendadas com o iCloud Calendar
# Generado por AgentKit
"""
Exporta as chamadas marcadas com clientes para o calendário pessoal do
consultor no iCloud (via CalDAV), com lembrete ativado. Quando uma chamada
é cancelada, o evento correspondente é removido do calendário.
... | MB-LMBS/reduz-mais-energia | agent/calendario.py | .py | f2c288c502443cbd | 7 | 0 |
# agent/feriados.py — Feriados nacionais e municipais de Portugal
# Generado por AgentKit
"""
Calcula os feriados nacionais obrigatórios de Portugal para um dado ano,
incluindo os móveis (baseados na Páscoa), e permite consultar os próximos.
Também cruza com os feriados municipais (facultativos) dos concelhos de
Portu... | MB-LMBS/reduz-mais-energia | agent/feriados.py | .py | 0fedeae1bc0ffb5b | 7 | 0 |
# agent/formatacao_whatsapp.py — Formatação de mensagens de sistema para WhatsApp
# Generado por AgentKit
"""
Ajuda a formatar mensagens fixas (não geradas pela IA) para ficarem tão
organizadas no WhatsApp real como ficam no painel /admin: rótulos "Campo:"
em negrito nativo do WhatsApp, e links extraídos para enviar c... | MB-LMBS/reduz-mais-energia | agent/formatacao_whatsapp.py | .py | e883748b9bc2daee | 7 | 0 |
# agent/main.py — Servidor FastAPI + Webhook de WhatsApp
# Generado por AgentKit
"""
Servidor principal del agente de WhatsApp.
Funciona con cualquier proveedor (Meta, Twilio) gracias a la capa de providers.
"""
import os
import uuid
import asyncio
import mimetypes
import logging
from datetime import datetime, time
f... | MB-LMBS/reduz-mais-energia | agent/main.py | .py | f75f52ace68b3bb3 | 7 | 0 |
# agent/meta_templates.py — Gestão de templates de mensagem da Meta (WhatsApp)
# Generado por AgentKit
"""
Consulta e cria templates de mensagem no WhatsApp Business (via Graph API),
usados para o negócio poder iniciar uma conversa fora da janela de 24h —
como as mensagens diárias de motivação à equipa (agent/motivaca... | MB-LMBS/reduz-mais-energia | agent/meta_templates.py | .py | cf538d1e5991cf37 | 7 | 0 |
# agent/motivacao.py — Mensagens diárias de motivação para a equipa comercial
# Generado por AgentKit
"""
Envia mensagens de motivação e espírito de equipa aos consultores/comerciais,
Segunda a Sexta, de manhã e ao final do dia (com destaque à sexta-feira para
o fim de semana). Usa templates pré-aprovados do WhatsApp ... | MB-LMBS/reduz-mais-energia | agent/motivacao.py | .py | 12a06494132d23ba | 7 | 0 |
# agent/notificacoes.py — Encaminhamento de conversas para o consultor humano
# Generado por AgentKit
"""
Envía una conversación completa por WhatsApp al número personal del
consultor. Se usa tanto automáticamente (cuando el bot detecta un pedido
de consultor) como manualmente (botón "Encaminhar para consultor" en /ad... | MB-LMBS/reduz-mais-energia | agent/notificacoes.py | .py | 84b4f776b74af64b | 7 | 0 |
# agent/outlook_calendar.py — Sincronização de chamadas agendadas com o Outlook/Microsoft 365
# Generado por AgentKit
"""
Exporta as chamadas marcadas com clientes para o calendário do Outlook
(Microsoft 365 / Teams) do consultor, via Microsoft Graph API, com lembrete
ativado. Quando uma chamada é cancelada, o evento ... | MB-LMBS/reduz-mais-energia | agent/outlook_calendar.py | .py | 712944b8a46492bd | 7 | 0 |
# agent/providers/base.py — Clase base para proveedores de WhatsApp
# Generado por AgentKit
"""
Define la interfaz común que todos los proveedores de WhatsApp deben implementar.
Esto permite cambiar de proveedor sin modificar el resto del código.
"""
from abc import ABC, abstractmethod
from dataclasses import datacla... | MB-LMBS/reduz-mais-energia | agent/providers/base.py | .py | acecd24cc961aebc | 7 | 0 |
# integrations/attio.py — Sincronização de leads do WhatsApp com o Attio CRM
"""
Regista no Attio (CRM da Reduz+ Energia) os leads que pedem para falar com
um consultor via WhatsApp: garante uma Person (por número de telefone) e um
Deal na etapa QUALIFICADO na primeira vez, e só acrescenta uma nota nas
escaladas segui... | MB-LMBS/reduz-mais-energia | integrations/attio.py | .py | 2a54e7782da4c9a9 | 7 | 0 |
from __future__ import annotations
import logging
import time
from contextlib import asynccontextmanager
from fastapi import FastAPI, WebSocket, Request
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import JSONResponse
from app.api import analytics, auth, categories, detections, diagnosti... | yashdhanani/visionai | apps/api/app/main.py | .py | 106b348d85b84ee8 | 7 | 0 |
from __future__ import annotations
import logging
import cv2
import numpy as np
logger = logging.getLogger("visionai.ml.ocr")
_reader = None
def get_reader(langs: list[str] | None = None, gpu: bool = False):
"""Lazily instantiate the EasyOCR reader (heavy model load)."""
global _reader
if _reader is N... | yashdhanani/visionai | apps/api/app/ml/ocr.py | .py | e6d54ce0530d4c95 | 7 | 0 |
from __future__ import annotations
import logging
from app.ml.inference import Detection
logger = logging.getLogger("visionai.ml.postprocess")
def _iou(a: Detection, b: Detection) -> float:
ax1, ay1, ax2, ay2 = a.x, a.y, a.x + a.width, a.y + a.height
bx1, by1, bx2, by2 = b.x, b.y, b.x + b.width, b.y + b.he... | yashdhanani/visionai | apps/api/app/ml/postprocess.py | .py | e86bec0a9f80feae | 7 | 0 |
import os
import json
import logging
import sys
import uuid
import time
from bedrock_agentcore.memory import MemoryClient
from datetime import datetime, timezone
import re
logging.basicConfig(
level=logging.INFO, # Default to INFO level
format='%(filename)s:%(lineno)d | %(message)s',
handlers=[
l... | kyopark2014/ess-project | application/agentcore_memory.py | .py | ba35a9687bdb1cd5 | 7 | 0 |
"""Application-facing wrappers for graph node embeddings (hybrid document search).
Canonical implementation lives in ``graph/lib/embeddings.py`` so the publish
pipeline and the FastAPI query path share one code path.
"""
from __future__ import annotations
import sys
from pathlib import Path
from typing import Any
_... | kyopark2014/ess-project | application/graph_embeddings.py | .py | 87106bb882644378 | 7 | 0 |
"""
Knowledge Graph memory tool for MCP.
Wraps application.graph_query.query_user_graph — the same BFS/DFS + excerpt
path used by POST /api/graph/query (graph UI document search) — so the agent
can recall past conversation history stored in the user's knowledge graph.
Return shape mirrors mcp_memory.recall_memory(ret... | kyopark2014/ess-project | application/mcp_graph_memory.py | .py | 09f9e0cb65e3b1c5 | 7 | 0 |
"""Anti-Slop skill: serves design rules as system prompt injection for chat."""
from __future__ import annotations
import os
from pathlib import Path
from typing import Any
from fastapi import APIRouter
SKILLS_DIR = Path("/app/skills/anti-slop")
FALLBACK_DIR = Path(__file__).resolve().parent.parent / "skills" / "ant... | pocongtobat008/ai-hub-gateway | api/antislop.py | .py | 96337262f4b5f87a | 7 | 0 |
from __future__ import annotations
import base64
import binascii
import json
import mimetypes
import re
from pathlib import PurePosixPath
from typing import Any, TypeGuard
from urllib.parse import unquote, unquote_to_bytes, urlparse
from curl_cffi import requests
from fastapi import HTTPException, Request
from fastap... | pocongtobat008/ai-hub-gateway | api/image_inputs.py | .py | cfc62fd0c08a2cf3 | 7 | 0 |
"""Local backup management API routes."""
from __future__ import annotations
import json
from typing import Any
from fastapi import APIRouter, Header, HTTPException
from fastapi.responses import FileResponse
from services.local_backup_service import local_backup_service
def create_router() -> APIRouter:
route... | pocongtobat008/ai-hub-gateway | api/local_backup.py | .py | aec40dcdcebdc5d0 | 7 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.