@hfyjq/crannia 1.1.2 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -201
- package/NOTICE +48 -45
- package/README.md +1 -1
- package/THIRD-PARTY-FRONTEND.md +5266 -5266
- package/THIRD-PARTY-PYTHON-linux.md +174 -0
- package/THIRD-PARTY-PYTHON.md +176 -162
- package/THIRD-PARTY.md +323 -316
- package/apps/desktop/quotes.txt +56 -56
- package/bus/core.py +677 -671
- package/bus/loaders/channel_loader.py +64 -64
- package/bus/loaders/provider_loader.py +4 -7
- package/bus/loaders/skill_loader.py +46 -27
- package/bus/loaders/skill_md.py +9 -9
- package/bus/mcp_disabled.py +4 -6
- package/bus/quarantine.py +10 -13
- package/bus/registry.py +2315 -2284
- package/bus/skill_state.py +124 -124
- package/channels/cli_channel/handler.py +3 -3
- package/channels/cli_channel/manifest.yaml +5 -5
- package/channels/dingtalk_channel/handler.py +32 -32
- package/channels/dingtalk_channel/manifest.yaml +12 -12
- package/channels/feishu_channel/handler.py +33 -33
- package/channels/feishu_channel/manifest.yaml +12 -12
- package/channels/qq_bot_channel/__init__.py +1 -1
- package/channels/qq_bot_channel/handler.py +24 -24
- package/channels/qq_bot_channel/manifest.yaml +4 -4
- package/channels/telegram_channel/__init__.py +1 -1
- package/channels/telegram_channel/handler.py +21 -21
- package/channels/telegram_channel/manifest.yaml +4 -4
- package/channels/telegram_channel/media.py +231 -231
- package/channels/textfmt.py +58 -58
- package/channels/wechat_channel/__init__.py +1 -1
- package/channels/wechat_channel/converter.py +1 -1
- package/channels/wechat_channel/handler.py +8 -8
- package/channels/wechat_channel/manifest.yaml +5 -5
- package/channels/wechat_channel/media.py +178 -178
- package/core/activity.py +753 -709
- package/core/agent_loop.py +7673 -7522
- package/core/allowlist.py +2 -3
- package/core/approval.py +34 -24
- package/core/approval_timeout.py +256 -228
- package/core/artifacts.py +3 -3
- package/core/attachment_gc.py +21 -0
- package/core/auto_review.py +2 -2
- package/core/browser/cdp.py +5 -2
- package/core/browser/discover.py +55 -19
- package/core/browser/session.py +4 -4
- package/core/cache_break_detector.py +97 -0
- package/core/cache_breakpoints.py +103 -0
- package/core/cache_policies.py +255 -0
- package/core/cancellation.py +3 -3
- package/core/channel_configs.py +3 -3
- package/core/channel_turns.py +13 -13
- package/core/child_approval.py +2 -3
- package/core/code_intel.py +11 -11
- package/core/command_policy.py +13 -7
- package/core/computer/annotate.py +231 -11
- package/core/computer/capture.py +140 -1
- package/core/computer/guard.py +7 -4
- package/core/computer/input.py +452 -26
- package/core/computer/session.py +563 -381
- package/core/computer/tools.py +2170 -928
- package/core/computer/uia.py +100 -1
- package/core/computer/watch.py +1 -1
- package/core/computer/win32.py +302 -7
- package/core/config_requirements.py +205 -205
- package/core/cron/runner.py +4 -4
- package/core/daily_log.py +2 -2
- package/core/dedup.py +2 -2
- package/core/egress_channels.py +326 -0
- package/core/egress_gate.py +96 -8
- package/core/egress_preapproved.py +59 -3
- package/core/endpoint.py +141 -141
- package/core/events.py +17 -8
- package/core/extension.py +2 -2
- package/core/file_history.py +10 -10
- package/core/file_tools.py +3 -3
- package/core/github_config.py +1 -1
- package/core/group_digest.py +3 -4
- package/core/group_minutes.py +5 -5
- package/core/group_reply.py +24 -0
- package/core/groups.py +5 -9
- package/core/hooks.py +15 -15
- package/core/i18n.py +2 -2
- package/core/ice/canary.py +3 -3
- package/core/ice/net_heuristics.py +2 -2
- package/core/im_routing.py +2 -2
- package/core/image_input.py +183 -43
- package/core/inbound.py +3 -3
- package/core/jobs.py +6 -6
- package/core/last_good.py +150 -150
- package/core/leaf_md.py +3 -3
- package/core/llm_errors.py +36 -27
- package/core/mail_config.py +2 -2
- package/core/memory/compressor.py +8 -8
- package/core/memory/manager.py +30 -45
- package/core/memory/session_memory.py +1 -2
- package/core/memory/short_term.py +4 -4
- package/core/memory_extract.py +1 -1
- package/core/memory_organize.py +8 -8
- package/core/memory_store.py +7 -9
- package/core/memory_transfer.py +2 -2
- package/core/model_capabilities.py +2 -2
- package/core/model_configs.py +219 -68
- package/core/model_profiles.py +333 -0
- package/core/modes.py +12 -11
- package/core/net_proxy.py +3 -3
- package/core/pipeline/scheduler.py +48 -43
- package/core/pipeline/stage.py +3 -0
- package/core/pipeline/stages/agent_loop.py +36 -15
- package/core/pipeline/stages/group_reply.py +22 -20
- package/core/pipeline/stages/post_process.py +7 -7
- package/core/pipeline/stages/pre_process.py +360 -68
- package/core/prompt_assembler.py +13 -4
- package/core/recycle.py +227 -16
- package/core/response_language.py +1 -1
- package/core/retention.py +2 -2
- package/core/rg.py +4 -3
- package/core/security.py +26 -8
- package/core/services.py +8 -8
- package/core/session_model.py +3 -5
- package/core/session_pool.py +35 -5
- package/core/session_recap.py +40 -3
- package/core/session_workspace.py +2 -3
- package/core/settings_baseline.py +2 -2
- package/core/settings_transfer.py +25 -1
- package/core/shell.py +52 -20
- package/core/side_call.py +3 -3
- package/core/skill_config.py +164 -0
- package/core/skill_factory.py +2 -2
- package/core/skill_guidance.py +2 -4
- package/core/skill_index.py +3 -4
- package/core/skill_settings.py +1 -1
- package/core/skill_sources.py +7 -7
- package/core/ssh_config.py +129 -0
- package/core/state_registry.py +67 -5
- package/core/subagent.py +28 -5
- package/core/subagent_defs.py +3 -3
- package/core/summarizer.py +4 -5
- package/core/tasks_notify.py +6 -6
- package/core/tiers.py +2 -2
- package/core/todos.py +1 -1
- package/core/token_calibrator.py +1 -4
- package/core/tool_outcome.py +108 -108
- package/core/touched_files.py +1 -1
- package/core/trace.py +12 -3
- package/core/unlock.py +4 -4
- package/core/update_tui.py +184 -158
- package/core/updater.py +5 -3
- package/core/version.py +14 -14
- package/core/vision_budget.py +235 -0
- package/core/web_cache.py +152 -152
- package/core/web_request.py +474 -0
- package/core/window_estimate.py +1 -1
- package/core/workspace.py +56 -26
- package/crannia_tray.py +278 -278
- package/licenses/GPL-3.0.txt +619 -619
- package/licenses/LGPL-2.1.txt +502 -502
- package/licenses/LGPL-3.0.txt +165 -165
- package/licenses/MIT-chat-on-wechat.txt +18 -18
- package/licenses/MIT-deepseek-harness.txt +21 -21
- package/licenses/Molio-LICENSE.txt +44 -44
- package/locales/en.json +1876 -1755
- package/main.py +154 -154
- package/mcpx/client.py +12 -1
- package/mcpx/manager.py +530 -522
- package/mcpx/servers/web_search.py +5 -13
- package/package.json +15 -23
- package/providers/anthropic/client.py +35 -33
- package/providers/base.py +13 -13
- package/providers/cache_policies.json +294 -0
- package/providers/cost_table.json +3779 -3779
- package/providers/lmstudio/client.py +2 -2
- package/providers/model_capabilities.json +6665 -6665
- package/providers/model_profiles.json +629 -0
- package/providers/ollama/client.py +2 -2
- package/providers/openai_compat.py +37 -16
- package/providers/openrouter/client.py +2 -2
- package/providers/qwen/__init__.py +1 -1
- package/providers/qwen/client.py +2 -2
- package/providers/qwen/manifest.yaml +16 -16
- package/providers/rate_limiter.py +2 -2
- package/providers/siliconflow/client.py +2 -2
- package/providers/validation.py +171 -171
- package/providers/vision_profiles.json +89 -0
- package/providers/window_table.json +8909 -8909
- package/requirements.txt +59 -51
- package/sbom-linux-x64.json +4580 -0
- package/sbom.json +4600 -4413
- package/skills/diagram/SKILL.md +47 -0
- package/skills/diagram/__init__.py +1 -0
- package/skills/diagram/handler.py +294 -0
- package/skills/diagram/layout.py +174 -0
- package/skills/diagram/manifest.yaml +106 -0
- package/skills/diagram/mermaid.py +170 -0
- package/skills/diagram/svg.py +223 -0
- package/skills/entertainment/SKILL.md +35 -35
- package/skills/entertainment/__init__.py +1 -1
- package/skills/entertainment/handler.py +91 -91
- package/skills/entertainment/manifest.yaml +26 -26
- package/skills/file_parser/GUIDANCE.md +10 -10
- package/skills/file_parser/handler.py +33 -11
- package/skills/github/SKILL.md +32 -32
- package/skills/github/__init__.py +1 -1
- package/skills/mail_parser/SKILL.md +68 -68
- package/skills/mail_parser/__init__.py +1 -1
- package/skills/mail_parser/handler.py +1 -1
- package/skills/media_gen/GUIDANCE.md +19 -19
- package/skills/media_gen/SKILL.md +43 -43
- package/skills/media_gen/__init__.py +1 -1
- package/skills/media_gen/handler.py +1 -1
- package/skills/media_gen/manifest.yaml +93 -93
- package/skills/netops/SKILL.md +45 -0
- package/skills/netops/__init__.py +1 -0
- package/skills/netops/handler.py +418 -0
- package/skills/netops/manifest.yaml +118 -0
- package/skills/office_parser/_excel_io.py +3 -3
- package/skills/office_parser/handler.py +2 -2
- package/skills/office_parser/ppt_tools.py +1 -1
- package/skills/office_parser/pptx_export/console_encoding.py +27 -27
- package/skills/office_parser/pptx_export/resource_paths.py +88 -88
- package/skills/office_parser/pptx_export/svg_finalize/__init__.py +12 -12
- package/skills/office_parser/pptx_export/svg_finalize/crop_images.py +366 -366
- package/skills/office_parser/pptx_export/svg_finalize/embed_images.py +288 -288
- package/skills/office_parser/pptx_export/svg_finalize/fix_image_aspect.py +388 -388
- package/skills/office_parser/pptx_export/svg_finalize/flatten_tspan.py +818 -818
- package/skills/office_parser/pptx_export/svg_finalize/svg_rect_to_path.py +345 -345
- package/skills/office_parser/pptx_export/svg_to_pptx/__init__.py +14 -14
- package/skills/office_parser/pptx_export/svg_to_pptx/drawingml/__init__.py +1 -1
- package/skills/office_parser/pptx_export/svg_to_pptx/drawingml/context.py +186 -186
- package/skills/office_parser/pptx_export/svg_to_pptx/drawingml/converter.py +781 -781
- package/skills/office_parser/pptx_export/svg_to_pptx/drawingml/paths.py +429 -429
- package/skills/office_parser/pptx_export/svg_to_pptx/drawingml/utils.py +40 -21
- package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/__init__.py +1 -1
- package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/builder.py +1267 -1267
- package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/dimensions.py +155 -155
- package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/discovery.py +101 -101
- package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/narration.py +236 -236
- package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/notes.py +257 -257
- package/skills/office_parser/pptx_export/svg_to_pptx/pptx_package/slide_xml.py +136 -136
- package/skills/office_parser/pptx_export/svg_to_pptx/tspan_flattener.py +44 -44
- package/skills/office_parser/pptx_export/svg_to_pptx/use_expander.py +129 -129
- package/skills/office_parser/references/LICENSE-Office-Word-MCP-Server.txt +20 -20
- package/skills/office_parser/references/LICENSE-excel-mcp-server.txt +21 -21
- package/skills/office_parser/references/layout_library.md +816 -816
- package/skills/office_parser/references/ppt-master/LICENSE +21 -21
- package/skills/office_parser/references/ppt-master/references/executor-base.md +474 -474
- package/skills/office_parser/references/ppt-master/references/shared-standards.md +1002 -1002
- package/skills/office_parser/references/ppt-master/references/strategist.md +880 -880
- package/skills/office_parser/references/ppt-master/references/template-designer.md +402 -402
- package/skills/office_parser/references/ppt-master/references/visual-review.md +240 -240
- package/skills/office_parser/references/ppt-master/references/visual-styles/_index.md +106 -106
- package/skills/office_parser/references/ppt-master/references/visual-styles/blueprint.md +37 -37
- package/skills/office_parser/references/ppt-master/references/visual-styles/brutalist.md +38 -38
- package/skills/office_parser/references/ppt-master/references/visual-styles/chalkboard.md +36 -36
- package/skills/office_parser/references/ppt-master/references/visual-styles/dark-tech.md +37 -37
- package/skills/office_parser/references/ppt-master/references/visual-styles/data-journalism.md +36 -36
- package/skills/office_parser/references/ppt-master/references/visual-styles/editorial.md +38 -38
- package/skills/office_parser/references/ppt-master/references/visual-styles/glassmorphism.md +36 -36
- package/skills/office_parser/references/ppt-master/references/visual-styles/ink-notes.md +37 -37
- package/skills/office_parser/references/ppt-master/references/visual-styles/ink-wash.md +36 -36
- package/skills/office_parser/references/ppt-master/references/visual-styles/memphis.md +37 -37
- package/skills/office_parser/references/ppt-master/references/visual-styles/paper-cut.md +36 -36
- package/skills/office_parser/references/ppt-master/references/visual-styles/photo-editorial.md +38 -38
- package/skills/office_parser/references/ppt-master/references/visual-styles/pixel-art.md +36 -36
- package/skills/office_parser/references/ppt-master/references/visual-styles/sketch-notes.md +36 -36
- package/skills/office_parser/references/ppt-master/references/visual-styles/soft-rounded.md +37 -37
- package/skills/office_parser/references/ppt-master/references/visual-styles/swiss-minimal.md +38 -38
- package/skills/office_parser/references/ppt-master/references/visual-styles/vintage-poster.md +36 -36
- package/skills/office_parser/references/ppt-master/references/visual-styles/zine.md +37 -37
- package/skills/office_parser/references/spec_lock.md +235 -235
- package/skills/office_parser/soffice.py +68 -68
- package/skills/office_parser/word_tools.py +3 -3
- package/skills/ssh/SKILL.md +81 -0
- package/skills/ssh/__init__.py +1 -0
- package/skills/ssh/handler.py +609 -0
- package/skills/ssh/manifest.yaml +182 -0
- package/tui/crannia.cmd +134 -134
- package/tui/crannia.sh +82 -0
- package/tui/crannia_tui/__init__.py +1 -1
- package/tui/crannia_tui/app.py +240 -17
- package/tui/crannia_tui/app.tcss +21 -0
- package/tui/crannia_tui/clipboard.py +78 -10
- package/tui/crannia_tui/commands.py +37 -0
- package/tui/crannia_tui/events.py +6 -0
- package/tui/crannia_tui/i18n.py +164 -164
- package/tui/crannia_tui/locales/en.json +31 -6
- package/tui/crannia_tui/paths.py +4 -1
- package/tui/crannia_tui/profile.py +178 -169
- package/tui/crannia_tui/settings.py +134 -134
- package/tui/crannia_tui/setup.py +44 -5
- package/tui/crannia_tui/ui.py +156 -16
- package/tui/crannia_tui/update.py +393 -389
- package/vendor/ripgrep/COPYING.txt +3 -3
- package/vendor/ripgrep/LICENSE-MIT.txt +21 -21
- package/vendor/ripgrep/NOTICE-vscode-ripgrep.txt +13 -13
- package/vendor/ripgrep/README.md +30 -14
- package/vendor/ripgrep/UNLICENSE.txt +24 -24
- package/vendor/ripgrep/linux-x64/rg +0 -0
- package/vendor/ripgrep/package-source.json +15 -16
- package/web/__main__.py +12 -15
- package/web/server.py +8481 -8594
- package/web/static/img/channel-telegram.svg +1 -1
- package/web/static/img/channel-wechat.svg +1 -1
- package/web/templates/logs.html +49 -49
- package/web/templates/models.html +46 -46
|
@@ -536,25 +536,17 @@ def _http_get_once(url: str, timeout: int = 15, max_bytes=None):
|
|
|
536
536
|
def _same_site(a: str, b: str) -> bool:
|
|
537
537
|
"""两个 URL 是不是同一个站(scheme + 端口 + host,host 忽略 `www.` 前缀)。
|
|
538
538
|
|
|
539
|
-
|
|
539
|
+
判据与实现都在 `core.egress_gate.same_site`(唯一一处)——
|
|
540
|
+
`web_request` 用的是同一个函数,两处各写一份必然漂。
|
|
541
|
+
|
|
540
542
|
跨 host 的跳转不跟随,而是交回模型
|
|
541
543
|
—— 模型要重新调一次 `web_fetch`,于是重新走一遍判定。
|
|
542
544
|
|
|
543
545
|
忽略 `www.` 是有代价的取舍:多跟一跳同名站(`example.com` → `www.example.com`
|
|
544
546
|
很常见),换掉的是大量正常抓取被退回给模型。
|
|
545
547
|
"""
|
|
546
|
-
from
|
|
547
|
-
|
|
548
|
-
pa, pb = urlsplit(a), urlsplit(b)
|
|
549
|
-
|
|
550
|
-
def norm(p):
|
|
551
|
-
host = (p.hostname or "").lower()
|
|
552
|
-
if host.startswith("www."):
|
|
553
|
-
host = host[4:]
|
|
554
|
-
port = p.port or (443 if p.scheme == "https" else 80)
|
|
555
|
-
return (p.scheme.lower(), host, port)
|
|
556
|
-
|
|
557
|
-
return norm(pa) == norm(pb)
|
|
548
|
+
from core.egress_gate import same_site
|
|
549
|
+
return same_site(a, b)
|
|
558
550
|
|
|
559
551
|
|
|
560
552
|
#: 单次抓取的内容上限。年报这类文件常见几十 MB(英文版尤其大),
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hfyjq/crannia",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Crannia application code pack for automatic updates",
|
|
5
|
-
"license": "
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "git+https://github.com/hfyjq/Crannia.git"
|
|
@@ -11,37 +11,29 @@
|
|
|
11
11
|
"access": "public"
|
|
12
12
|
},
|
|
13
13
|
"crannia": {
|
|
14
|
-
"version": "1.
|
|
14
|
+
"version": "1.2.0",
|
|
15
15
|
"channel": "stable",
|
|
16
|
-
"published_at": "2026-11-
|
|
17
|
-
"release_notes_url": "https://github.com/hfyjq/Crannia/releases/tag/v1.
|
|
16
|
+
"published_at": "2026-11-28T16:54:08Z",
|
|
17
|
+
"release_notes_url": "https://github.com/hfyjq/Crannia/releases/tag/v1.2.0",
|
|
18
18
|
"minimum_client_version": null,
|
|
19
19
|
"mandatory": false,
|
|
20
20
|
"changelog": {},
|
|
21
21
|
"artifacts": {
|
|
22
22
|
"windows-exe": {
|
|
23
|
-
"url": "https://
|
|
24
|
-
"sha256": "
|
|
25
|
-
"size_bytes":
|
|
26
|
-
"urls": [
|
|
27
|
-
"https://gitcode.com/KanocRain/crannia-release/releases/download/v1.1.2/crannia-1.1.2-win-x64.exe",
|
|
28
|
-
"https://github.com/hfyjq/Crannia/releases/download/v1.1.2/crannia-1.1.2-win-x64.exe"
|
|
29
|
-
]
|
|
23
|
+
"url": "https://github.com/hfyjq/Crannia/releases/download/v1.2.0/crannia-1.2.0-win-x64.exe",
|
|
24
|
+
"sha256": "ead2d4e1e33dce2bd75ad159c3cb4f5a8f7fb59bf4cbc6b7a0a794cd4a2cc9ec",
|
|
25
|
+
"size_bytes": 268220335
|
|
30
26
|
},
|
|
31
27
|
"codepack": {
|
|
32
|
-
"app_version": "1.
|
|
33
|
-
"runtime": "
|
|
34
|
-
"shell_sha256": "
|
|
35
|
-
"shell_sig": "
|
|
28
|
+
"app_version": "1.2.0",
|
|
29
|
+
"runtime": "bcce5f46b9fe05ab0d72c75dae96e8dc30fed50163629cfa8ec88160245d528a",
|
|
30
|
+
"shell_sha256": "1d7c703d2a4be4f2e67b0c0ff9e72d703ea9731b9828943b5f81237018337266",
|
|
31
|
+
"shell_sig": "a718700e0a3607882d239c1d30911ac35c2c5e71119fe69784f6f6f10ebe0092"
|
|
36
32
|
},
|
|
37
33
|
"tui": {
|
|
38
|
-
"url": "https://
|
|
39
|
-
"sha256": "
|
|
40
|
-
"size_bytes":
|
|
41
|
-
"urls": [
|
|
42
|
-
"https://gitcode.com/KanocRain/crannia-release/releases/download/v1.1.2/crannia-tui-1.1.2-code.zip",
|
|
43
|
-
"https://github.com/hfyjq/Crannia/releases/download/v1.1.2/crannia-tui-1.1.2-code.zip"
|
|
44
|
-
]
|
|
34
|
+
"url": "https://github.com/hfyjq/Crannia/releases/download/v1.2.0/crannia-tui-1.2.0-code.zip",
|
|
35
|
+
"sha256": "22db9d849398013a09f819981d90aa9b3921aba9976404ab7be089b8db3cb6e3",
|
|
36
|
+
"size_bytes": 7539293
|
|
45
37
|
}
|
|
46
38
|
}
|
|
47
39
|
}
|
|
@@ -57,8 +57,8 @@ def _create_with_retry(client, kwargs):
|
|
|
57
57
|
else int(rstate.get("retry") or 0)
|
|
58
58
|
llm_retry.note(_session_key(), n, kind=kind,
|
|
59
59
|
text=headline(e, kind=kind), phase=action)
|
|
60
|
-
print(f"[llm] {kind or 'unknown'}
|
|
61
|
-
f"
|
|
60
|
+
print(f"[llm] {kind or 'unknown'} -- retrying in {delay}ms"
|
|
61
|
+
f" ({action} {n})")
|
|
62
62
|
#: 可打断 —— 用户按了打断就立刻把原异常抛回。
|
|
63
63
|
if not llm_retry.wait(_session_key(), delay):
|
|
64
64
|
raise
|
|
@@ -113,8 +113,8 @@ def _to_anthropic_content(content):
|
|
|
113
113
|
if block is not None:
|
|
114
114
|
out.append(block)
|
|
115
115
|
else:
|
|
116
|
-
print(f"[anthropic]
|
|
117
|
-
f"
|
|
116
|
+
print(f"[anthropic] unrecognized content block type={kind!r} -- "
|
|
117
|
+
f"replaced with a visible note")
|
|
118
118
|
out.append({"type": "text",
|
|
119
119
|
"text": f"[这块内容({kind})Anthropic 这条线不支持]"})
|
|
120
120
|
# 空列表上游会 400(content 不能是空数组),补一个空文本块。
|
|
@@ -134,13 +134,13 @@ def _image_block(part: dict) -> Optional[dict]:
|
|
|
134
134
|
|
|
135
135
|
url = (part.get("image_url") or {}).get("url") or ""
|
|
136
136
|
if not url.startswith("data:"):
|
|
137
|
-
print(f"[anthropic]
|
|
138
|
-
f"
|
|
137
|
+
print(f"[anthropic] image block is not a data: URL ({url[:40]!r}) -- "
|
|
138
|
+
f"dropped")
|
|
139
139
|
return None
|
|
140
140
|
head, _, payload = url.partition(",")
|
|
141
141
|
media = head[5:].split(";")[0].strip().lower() or "image/png"
|
|
142
142
|
if not payload:
|
|
143
|
-
print("[anthropic]
|
|
143
|
+
print("[anthropic] image data: URL has no payload -- dropped")
|
|
144
144
|
return None
|
|
145
145
|
# 重编码成 base64 一次(`data:` 里本来就是 base64,但别假设 ——
|
|
146
146
|
# 一个 `;base64,` 都没有的 data URL 是百分号编码的)。
|
|
@@ -171,8 +171,7 @@ def _image_block_media(block) -> list:
|
|
|
171
171
|
getattr(src, "media_type", "image/png"), src.data),
|
|
172
172
|
"name": "image",
|
|
173
173
|
}]
|
|
174
|
-
print("[media]
|
|
175
|
-
"(url 来源不下载,绕开出网闸)")
|
|
174
|
+
print("[media] ignoring non-base64 image block")
|
|
176
175
|
return []
|
|
177
176
|
|
|
178
177
|
|
|
@@ -288,8 +287,8 @@ class AnthropicProvider(BaseProvider):
|
|
|
288
287
|
self.supports_vision = bool(supports_vision)
|
|
289
288
|
# 这条路没有音频部件 —— 永远 False,声明了也要出声。
|
|
290
289
|
if supports_audio:
|
|
291
|
-
print("[anthropic] config
|
|
292
|
-
"
|
|
290
|
+
print("[anthropic] config declares supports_audio but this path has no audio parts "
|
|
291
|
+
"-- treating as unsupported")
|
|
293
292
|
self.supports_audio = False
|
|
294
293
|
self._temperature = temperature
|
|
295
294
|
self._max_tokens = max_tokens
|
|
@@ -359,11 +358,11 @@ class AnthropicProvider(BaseProvider):
|
|
|
359
358
|
return
|
|
360
359
|
self._window_claim_warned = True
|
|
361
360
|
print(
|
|
362
|
-
f"[window] prompt={prompt_tokens:,}
|
|
363
|
-
f"{self._context_window:,}
|
|
364
|
-
f"
|
|
365
|
-
f"
|
|
366
|
-
f"
|
|
361
|
+
f"[window] prompt={prompt_tokens:,} exceeds declared window "
|
|
362
|
+
f"{self._context_window:,} -- declared value is wrong"
|
|
363
|
+
f" (source={self._window_source}, model={self._model})."
|
|
364
|
+
f" compression gate uses the declared value"
|
|
365
|
+
f" ({int(self._context_window * 0.85):,})"
|
|
367
366
|
)
|
|
368
367
|
|
|
369
368
|
# ------------------------------------------------------------------
|
|
@@ -435,23 +434,21 @@ class AnthropicProvider(BaseProvider):
|
|
|
435
434
|
budget = 0
|
|
436
435
|
if self._thinking_budget > 0 and not self._tier_supersede_warned:
|
|
437
436
|
self._tier_supersede_warned = True
|
|
438
|
-
print(f"[thinking]
|
|
439
|
-
f"anthropic.thinking_budget={self._thinking_budget}
|
|
440
|
-
f"(档位是唯一来源)")
|
|
437
|
+
print(f"[thinking] effort tier disables thinking -- config.yaml "
|
|
438
|
+
f"anthropic.thinking_budget={self._thinking_budget} superseded")
|
|
441
439
|
if budget <= 0:
|
|
442
440
|
return {}
|
|
443
441
|
if budget < _MIN_THINKING_BUDGET:
|
|
444
|
-
print(f"[thinking]
|
|
445
|
-
f"{_MIN_THINKING_BUDGET}
|
|
442
|
+
print(f"[thinking] budget {budget} below Anthropic minimum "
|
|
443
|
+
f"{_MIN_THINKING_BUDGET} -- sending {_MIN_THINKING_BUDGET}")
|
|
446
444
|
budget = _MIN_THINKING_BUDGET
|
|
447
445
|
if budget >= self._max_tokens:
|
|
448
446
|
if self._max_tokens <= _MIN_THINKING_BUDGET:
|
|
449
|
-
print(f"[thinking] max_tokens={self._max_tokens}
|
|
450
|
-
f"
|
|
451
|
-
f"(硬发会被上游 400,整轮都没了)")
|
|
447
|
+
print(f"[thinking] max_tokens={self._max_tokens} cannot fit thinking budget "
|
|
448
|
+
f"(needs >{_MIN_THINKING_BUDGET}) -- omitting thinking this time")
|
|
452
449
|
return {}
|
|
453
|
-
print(f"[thinking]
|
|
454
|
-
f"
|
|
450
|
+
print(f"[thinking] budget {budget} >= max_tokens {self._max_tokens} "
|
|
451
|
+
f"-- clamped to {self._max_tokens - 1}")
|
|
455
452
|
budget = self._max_tokens - 1
|
|
456
453
|
return {"thinking": {"type": "enabled", "budget_tokens": budget}}
|
|
457
454
|
|
|
@@ -464,6 +461,9 @@ class AnthropicProvider(BaseProvider):
|
|
|
464
461
|
temperature: "float | None" = None,
|
|
465
462
|
) -> ChatResponse:
|
|
466
463
|
"""向 Claude 发一条同步消息。"""
|
|
464
|
+
from core import model_profiles as _profiles
|
|
465
|
+
messages = _profiles.sanitize_for_wire(
|
|
466
|
+
messages, self._provider_name, self._model)
|
|
467
467
|
system_prompt, api_messages = self._to_anthropic_messages(
|
|
468
468
|
messages, system=system
|
|
469
469
|
)
|
|
@@ -569,6 +569,9 @@ class AnthropicProvider(BaseProvider):
|
|
|
569
569
|
temperature: "float | None" = None,
|
|
570
570
|
) -> AsyncIterator[StreamChunk]:
|
|
571
571
|
"""流式接收 Claude 的回复。"""
|
|
572
|
+
from core import model_profiles as _profiles
|
|
573
|
+
messages = _profiles.sanitize_for_wire(
|
|
574
|
+
messages, self._provider_name, self._model)
|
|
572
575
|
system_prompt, api_messages = self._to_anthropic_messages(
|
|
573
576
|
messages, system=system
|
|
574
577
|
)
|
|
@@ -619,8 +622,8 @@ class AnthropicProvider(BaseProvider):
|
|
|
619
622
|
else int(rstate.get("retry") or 0)
|
|
620
623
|
llm_retry.note(_session_key(), n, kind=kind,
|
|
621
624
|
text=headline(e, kind=kind), phase=action)
|
|
622
|
-
print(f"[llm] {kind or 'unknown'}
|
|
623
|
-
f"
|
|
625
|
+
print(f"[llm] {kind or 'unknown'} -- retrying in {delay}ms"
|
|
626
|
+
f" ({action} {n})")
|
|
624
627
|
#: 可打断(同 OpenAI 兼容那条)。
|
|
625
628
|
if not await llm_retry.wait_async(_session_key(), delay):
|
|
626
629
|
llm_retry.clear(_session_key())
|
|
@@ -629,8 +632,8 @@ class AnthropicProvider(BaseProvider):
|
|
|
629
632
|
continue
|
|
630
633
|
#: 与 OpenAI 兼容那条同一条诊断口径 —— 错误类别跟着 chunk 走
|
|
631
634
|
#: (用户面 `core/llm_errors.explain` 要用),并且出声。
|
|
632
|
-
print(f"[llm]
|
|
633
|
-
f"
|
|
635
|
+
print(f"[llm] stream failed ({type(e).__name__}: {str(e)[:200]})"
|
|
636
|
+
f" -- model={self._model}")
|
|
634
637
|
llm_retry.fail(_session_key(), kind=kind,
|
|
635
638
|
text=headline(e, kind=kind))
|
|
636
639
|
yield StreamChunk(
|
|
@@ -727,9 +730,8 @@ class AnthropicProvider(BaseProvider):
|
|
|
727
730
|
args = json.loads(raw_args)
|
|
728
731
|
except (json.JSONDecodeError, TypeError) as exc:
|
|
729
732
|
args = {}
|
|
730
|
-
print(f"[anthropic]
|
|
731
|
-
f"JSON
|
|
732
|
-
f"(历史本身不动)")
|
|
733
|
+
print(f"[anthropic] arguments for '{name}' in history are not valid "
|
|
734
|
+
f"JSON ({type(exc).__name__}: {exc}) -- backfilled with no args")
|
|
733
735
|
tool_blocks.append({
|
|
734
736
|
"type": "tool_use",
|
|
735
737
|
"id": tc.get("id", ""),
|
package/providers/base.py
CHANGED
|
@@ -163,7 +163,7 @@ def _load_cost_table() -> tuple[dict, dict]:
|
|
|
163
163
|
if isinstance(row, dict):
|
|
164
164
|
lookup[(str(prov), str(name))] = row
|
|
165
165
|
except Exception as exc: # noqa: BLE001 —— 见上:坏掉只是"一律未定价"
|
|
166
|
-
print(f"[cost]
|
|
166
|
+
print(f"[cost] failed to read price table (treating all as unpriced): {type(exc).__name__}: {exc}")
|
|
167
167
|
table, lookup = {}, {}
|
|
168
168
|
_cost_table, _cost_lookup = table, lookup
|
|
169
169
|
return table, lookup
|
|
@@ -291,20 +291,20 @@ def record_token_usage(prompt: int, completion: int,
|
|
|
291
291
|
calls = _token_counter["api_calls"]
|
|
292
292
|
if not _cache_probe_done and cache_hit is not None:
|
|
293
293
|
_cache_probe_done = True
|
|
294
|
-
print(f"[cache]
|
|
295
|
-
f"
|
|
294
|
+
print(f"[cache] upstream reported cache fields: this hit {cache_hit} / input {prompt}"
|
|
295
|
+
f" -- hit-rate metric available")
|
|
296
296
|
if calls % _CACHE_REPORT_EVERY == 0:
|
|
297
297
|
_rp = _token_counter["cache_reported_prompt_tokens"]
|
|
298
298
|
if _rp > 0:
|
|
299
299
|
_ht = _token_counter["cache_hit_tokens"]
|
|
300
|
-
print(f"[cache]
|
|
300
|
+
print(f"[cache] call #{calls} · this input {prompt:,} · cumulative hit "
|
|
301
301
|
f"{_ht:,}/{_rp:,} = {_ht / _rp:.1%}"
|
|
302
|
-
f"
|
|
302
|
+
f" ({_token_counter['cache_reported_calls']}/{calls} calls reported)")
|
|
303
303
|
else:
|
|
304
|
-
print(f"[cache]
|
|
305
|
-
"
|
|
306
|
-
" cache_read_input_tokens
|
|
307
|
-
"
|
|
304
|
+
print(f"[cache] call #{calls} · this input {prompt:,} · upstream never reported cache fields"
|
|
305
|
+
" (none of prompt_tokens_details.cached_tokens / prompt_cache_hit_tokens /"
|
|
306
|
+
" cache_read_input_tokens)"
|
|
307
|
+
" -> this provider cannot measure hit rate, NOT a hit of 0")
|
|
308
308
|
|
|
309
309
|
if _token_counter_started == 0.0:
|
|
310
310
|
_token_counter_started = time.time()
|
|
@@ -746,10 +746,10 @@ def log_context_overflow(model: str, err: object, *, where: str = "") -> None:
|
|
|
746
746
|
与 `[cache]` / `[calibrator]` 同款,走 `print`,只到 stdout
|
|
747
747
|
(落盘属于另一层的工作,不在这里顺手做)。
|
|
748
748
|
"""
|
|
749
|
-
print(f"[overflow]
|
|
750
|
-
f"{', ' + where if where else ''}
|
|
751
|
-
f"
|
|
752
|
-
f"
|
|
749
|
+
print(f"[overflow] upstream reports request too long (model={model}"
|
|
750
|
+
f"{', ' + where if where else ''}) -- "
|
|
751
|
+
f"retry / switch key will not help, need compression or trimming."
|
|
752
|
+
f" raw: {str(err)[:300]}")
|
|
753
753
|
|
|
754
754
|
|
|
755
755
|
def _reply_side_tokens(m: dict, count_tokens) -> int:
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schema": 2,
|
|
3
|
+
"fetched": "2026-11-24",
|
|
4
|
+
"source": "official provider docs, see 电脑接管-性能考察-2026-11-24.md 12/13/16",
|
|
5
|
+
"note": "缓存与回收策略。16 家 provider 全部列出(含端配置里没有单独卡片、归到「其他」那几类),未查实的数字一律不填、在 note 里写明缺口,不按相似厂商推断。端配置的「其他」卡映射到 openai 目录,所以走 openai 那行;但它的上游可能是任意中转,缓存是否命中要用 usage 读数验证,读不到就写「没量到」。模型级覆盖优先于 provider 行,config.yaml 的显式声明优先于整张表。",
|
|
6
|
+
"_default": {
|
|
7
|
+
"strategy": "unknown",
|
|
8
|
+
"cache_mode": "unknown",
|
|
9
|
+
"cache_format": "none",
|
|
10
|
+
"explicit_enabled": false,
|
|
11
|
+
"eviction": "batch",
|
|
12
|
+
"batch_every": 25,
|
|
13
|
+
"keep_images": 3,
|
|
14
|
+
"max_inline_images": 12,
|
|
15
|
+
"min_prefix_tokens": 0,
|
|
16
|
+
"max_breakpoints": 0,
|
|
17
|
+
"ttl_seconds": 0,
|
|
18
|
+
"lookback_blocks": 0,
|
|
19
|
+
"tools_must_be_stable": false,
|
|
20
|
+
"note": "没有单独策略的供应商按现状做批量淘汰(最近 3 张图受保护、25 次观察边界、12 张硬上限),不加任何标记。保守之处:缺关掉客户端淘汰的能力位,那一族模型可能有害。"
|
|
21
|
+
},
|
|
22
|
+
"anthropic": {
|
|
23
|
+
"strategy": "explicit_blocks",
|
|
24
|
+
"cache_mode": "explicit",
|
|
25
|
+
"cache_format": "anthropic",
|
|
26
|
+
"explicit_enabled": false,
|
|
27
|
+
"eviction": "batch",
|
|
28
|
+
"batch_every": 25,
|
|
29
|
+
"keep_images": 3,
|
|
30
|
+
"max_inline_images": 12,
|
|
31
|
+
"min_prefix_tokens": 1024,
|
|
32
|
+
"min_prefix_by_model": {
|
|
33
|
+
"claude-fable-5": 512,
|
|
34
|
+
"claude-mythos-5": 512,
|
|
35
|
+
"claude-opus-5-5": 512,
|
|
36
|
+
"claude-sonnet-5-5": 512,
|
|
37
|
+
"claude-haiku-5-5": 512,
|
|
38
|
+
"claude-mythos-preview": 2048,
|
|
39
|
+
"claude-opus-4-7": 2048,
|
|
40
|
+
"claude-opus-4-6": 4096,
|
|
41
|
+
"claude-opus-4-5": 4096,
|
|
42
|
+
"claude-haiku-4-5": 4096,
|
|
43
|
+
"claude-opus-4-8": 1024,
|
|
44
|
+
"claude-sonnet-5": 1024,
|
|
45
|
+
"claude-sonnet-4-6": 1024,
|
|
46
|
+
"claude-sonnet-4-5": 1024
|
|
47
|
+
},
|
|
48
|
+
"max_breakpoints": 4,
|
|
49
|
+
"ttl_seconds": 300,
|
|
50
|
+
"lookback_blocks": 20,
|
|
51
|
+
"tools_must_be_stable": true,
|
|
52
|
+
"note": "缓存层级 tools → system → messages,改一层则该层及之后全失效。最小前缀按模型分四档,逐条列在 min_prefix_by_model,匹配不到的用 min_prefix_tokens 兜底、不猜。ttl 300 是默认 ephemeral,另有付费 1 小时档未启用。thinking 块不能单独打点。"
|
|
53
|
+
},
|
|
54
|
+
"openai": {
|
|
55
|
+
"strategy": "implicit",
|
|
56
|
+
"cache_mode": "implicit",
|
|
57
|
+
"cache_format": "openai_native",
|
|
58
|
+
"explicit_enabled": false,
|
|
59
|
+
"eviction": "batch",
|
|
60
|
+
"batch_every": 25,
|
|
61
|
+
"keep_images": 3,
|
|
62
|
+
"max_inline_images": 12,
|
|
63
|
+
"min_prefix_tokens": 2048,
|
|
64
|
+
"max_breakpoints": 4,
|
|
65
|
+
"ttl_seconds": 1800,
|
|
66
|
+
"lookback_blocks": 50,
|
|
67
|
+
"tools_must_be_stable": true,
|
|
68
|
+
"note": "支持的模型默认开缓存。旧模型隐式、最小 2048 token;新代际可用 prompt_cache_options 切显式、最小 1024 token,这里保守取 2048。字段是 prompt_cache_key / prompt_cache_breakpoint / prompt_cache_options,不是 cache_control。工具定义参与缓存,改了就断。ttl 1800 是新代际默认值,老模型另有 in_memory / 24h 两档。端配置的「其他」卡也走这一行,但上游可能不是 OpenAI,命中必须看 usage。"
|
|
69
|
+
},
|
|
70
|
+
"azure": {
|
|
71
|
+
"strategy": "implicit",
|
|
72
|
+
"cache_mode": "implicit",
|
|
73
|
+
"cache_format": "openai_native",
|
|
74
|
+
"explicit_enabled": false,
|
|
75
|
+
"eviction": "batch",
|
|
76
|
+
"batch_every": 25,
|
|
77
|
+
"keep_images": 3,
|
|
78
|
+
"max_inline_images": 12,
|
|
79
|
+
"min_prefix_tokens": 1024,
|
|
80
|
+
"max_breakpoints": 3,
|
|
81
|
+
"ttl_seconds": 1800,
|
|
82
|
+
"lookback_blocks": 50,
|
|
83
|
+
"tools_must_be_stable": true,
|
|
84
|
+
"note": "与 OpenAI 同族但数字不同:最小 1024 token 且开头 1024 必须逐字相同;隐式模式下最新消息占一个写入槽,所以显式断点只剩 3 个。新代际可用 prompt_cache_options 切显式。工具定义明确参与缓存。"
|
|
85
|
+
},
|
|
86
|
+
"deepseek": {
|
|
87
|
+
"strategy": "implicit",
|
|
88
|
+
"cache_mode": "implicit",
|
|
89
|
+
"cache_format": "none",
|
|
90
|
+
"explicit_enabled": false,
|
|
91
|
+
"eviction": "batch",
|
|
92
|
+
"batch_every": 25,
|
|
93
|
+
"keep_images": 3,
|
|
94
|
+
"max_inline_images": 12,
|
|
95
|
+
"min_prefix_tokens": 0,
|
|
96
|
+
"max_breakpoints": 0,
|
|
97
|
+
"ttl_seconds": 0,
|
|
98
|
+
"lookback_blocks": 0,
|
|
99
|
+
"tools_must_be_stable": false,
|
|
100
|
+
"note": "自动前缀缓存、无开关,wire 不加任何标记。官方没有给统一的最小可缓存 token 数,第三方那个很小的存储单位证据不足,所以不填数字、不拿它做闸门。缓存命中与未命中价差很大,分高峰与非高峰。"
|
|
101
|
+
},
|
|
102
|
+
"qwen": {
|
|
103
|
+
"strategy": "explicit_blocks",
|
|
104
|
+
"cache_mode": "mutually_exclusive",
|
|
105
|
+
"cache_format": "alibaba",
|
|
106
|
+
"explicit_enabled": false,
|
|
107
|
+
"eviction": "batch",
|
|
108
|
+
"batch_every": 25,
|
|
109
|
+
"keep_images": 3,
|
|
110
|
+
"max_inline_images": 12,
|
|
111
|
+
"min_prefix_tokens": 1024,
|
|
112
|
+
"max_breakpoints": 4,
|
|
113
|
+
"ttl_seconds": 300,
|
|
114
|
+
"lookback_blocks": 20,
|
|
115
|
+
"tools_must_be_stable": true,
|
|
116
|
+
"note": "隐式恒开且关不掉,显式要标记,两者在同一个请求里互斥。先 explicit_enabled=false 走隐式零风险,等 wire 测试证明兼容层能透传块键再开。显式规则:最小 1024 token、最多 4 个 ephemeral 标记、5 分钟命中刷新、从后向前只回溯 20 个 content 块。工具定义不能独立打点,且 tools 的顺序、字段顺序、字段结构必须逐次一致。并行 tool 调用建议合并成一条消息的多个 content 块。"
|
|
117
|
+
},
|
|
118
|
+
"zhipu": {
|
|
119
|
+
"strategy": "implicit",
|
|
120
|
+
"cache_mode": "implicit",
|
|
121
|
+
"cache_format": "none",
|
|
122
|
+
"explicit_enabled": false,
|
|
123
|
+
"eviction": "batch",
|
|
124
|
+
"batch_every": 25,
|
|
125
|
+
"keep_images": 3,
|
|
126
|
+
"max_inline_images": 12,
|
|
127
|
+
"min_prefix_tokens": 512,
|
|
128
|
+
"max_breakpoints": 0,
|
|
129
|
+
"ttl_seconds": 0,
|
|
130
|
+
"lookback_blocks": 0,
|
|
131
|
+
"tools_must_be_stable": false,
|
|
132
|
+
"note": "自动缓存、无需配置,重复前缀建议 500 token 以上;公开文档的部署说明给 GLM 的隐式最小前缀是 512,取 512。TTL 未公开,不依赖缓存时效,只靠批量淘汰降低断前缀频率。"
|
|
133
|
+
},
|
|
134
|
+
"moonshot": {
|
|
135
|
+
"strategy": "implicit",
|
|
136
|
+
"cache_mode": "implicit",
|
|
137
|
+
"cache_format": "none",
|
|
138
|
+
"explicit_enabled": false,
|
|
139
|
+
"eviction": "batch",
|
|
140
|
+
"batch_every": 25,
|
|
141
|
+
"keep_images": 3,
|
|
142
|
+
"max_inline_images": 12,
|
|
143
|
+
"min_prefix_tokens": 0,
|
|
144
|
+
"max_breakpoints": 0,
|
|
145
|
+
"ttl_seconds": 300,
|
|
146
|
+
"lookback_blocks": 0,
|
|
147
|
+
"tools_must_be_stable": false,
|
|
148
|
+
"note": "只有隐式。默认 5 分钟档,另有 1 小时档且首次写入后锁定。显式断点会被拒(HTTP 400),所以 max_breakpoints=0,不要尝试打点。工具定义明确列入可缓存内容。最小可缓存长度只说「小于一个完整 block 无法写入」,block 大小未公开,所以不填数字。"
|
|
149
|
+
},
|
|
150
|
+
"gemini": {
|
|
151
|
+
"strategy": "implicit",
|
|
152
|
+
"cache_mode": "implicit",
|
|
153
|
+
"cache_format": "cached_content",
|
|
154
|
+
"explicit_enabled": false,
|
|
155
|
+
"eviction": "batch",
|
|
156
|
+
"batch_every": 25,
|
|
157
|
+
"keep_images": 3,
|
|
158
|
+
"max_inline_images": 12,
|
|
159
|
+
"min_prefix_tokens": 4096,
|
|
160
|
+
"max_breakpoints": 1,
|
|
161
|
+
"ttl_seconds": 3600,
|
|
162
|
+
"lookback_blocks": 0,
|
|
163
|
+
"tools_must_be_stable": true,
|
|
164
|
+
"note": "2.5 及更新模型隐式缓存默认开、没有关闭开关。显式缓存用单个 cached_content 引用(每请求一个),Beta 能力且部分新代际不支持,所以 explicit_enabled=false。最小前缀:2.5 那代 2048,3.x 及以后 4096,取更保守的 4096。TTL 默认 1 小时。工具定义参与缓存。图像按固定分块计 token,没有长边硬上限。"
|
|
165
|
+
},
|
|
166
|
+
"grok": {
|
|
167
|
+
"strategy": "routing_key",
|
|
168
|
+
"cache_mode": "implicit",
|
|
169
|
+
"cache_format": "routing_only",
|
|
170
|
+
"explicit_enabled": false,
|
|
171
|
+
"eviction": "batch",
|
|
172
|
+
"batch_every": 25,
|
|
173
|
+
"keep_images": 3,
|
|
174
|
+
"max_inline_images": 12,
|
|
175
|
+
"min_prefix_tokens": 0,
|
|
176
|
+
"max_breakpoints": 0,
|
|
177
|
+
"ttl_seconds": 0,
|
|
178
|
+
"lookback_blocks": 0,
|
|
179
|
+
"tools_must_be_stable": false,
|
|
180
|
+
"note": "自动缓存、不可关闭,官方明确说命中不保证(可能被挤出、可能路由到不同服务器)。只提供把请求路由到同一服务器的键(会话头或请求体字段),没有断点概念。最小 token、TTL、工具定义是否参与都没找到官方口径,一律不填。"
|
|
181
|
+
},
|
|
182
|
+
"minimax": {
|
|
183
|
+
"strategy": "implicit",
|
|
184
|
+
"cache_mode": "implicit",
|
|
185
|
+
"cache_format": "none",
|
|
186
|
+
"explicit_enabled": false,
|
|
187
|
+
"eviction": "batch",
|
|
188
|
+
"batch_every": 25,
|
|
189
|
+
"keep_images": 3,
|
|
190
|
+
"max_inline_images": 12,
|
|
191
|
+
"min_prefix_tokens": 0,
|
|
192
|
+
"max_breakpoints": 0,
|
|
193
|
+
"ttl_seconds": 0,
|
|
194
|
+
"lookback_blocks": 0,
|
|
195
|
+
"tools_must_be_stable": false,
|
|
196
|
+
"note": "官方写全自动缓存、无需配置;兼容接口的参数表里没有缓存标记字段。最小 token、TTL 未公开,不填数字。"
|
|
197
|
+
},
|
|
198
|
+
"hunyuan": {
|
|
199
|
+
"strategy": "routing_key",
|
|
200
|
+
"cache_mode": "implicit",
|
|
201
|
+
"cache_format": "routing_only",
|
|
202
|
+
"explicit_enabled": false,
|
|
203
|
+
"eviction": "batch",
|
|
204
|
+
"batch_every": 25,
|
|
205
|
+
"keep_images": 3,
|
|
206
|
+
"max_inline_images": 12,
|
|
207
|
+
"min_prefix_tokens": 0,
|
|
208
|
+
"max_breakpoints": 0,
|
|
209
|
+
"ttl_seconds": 0,
|
|
210
|
+
"lookback_blocks": 0,
|
|
211
|
+
"tools_must_be_stable": false,
|
|
212
|
+
"note": "隐式 KV Cache,没有显式缓存对象。有两个用于复用缓存的标识:请求体里的缓存键与会话头。TTL 机制存在但官方没给秒数;最小可缓存长度、能否关闭都没找到口径。接入指南提到系统提示词与工具定义的排列会影响命中,但没有独立标记。"
|
|
213
|
+
},
|
|
214
|
+
"volcengine": {
|
|
215
|
+
"strategy": "unknown",
|
|
216
|
+
"cache_mode": "unknown",
|
|
217
|
+
"cache_format": "none",
|
|
218
|
+
"explicit_enabled": false,
|
|
219
|
+
"eviction": "batch",
|
|
220
|
+
"batch_every": 25,
|
|
221
|
+
"keep_images": 3,
|
|
222
|
+
"max_inline_images": 12,
|
|
223
|
+
"min_prefix_tokens": 0,
|
|
224
|
+
"max_breakpoints": 0,
|
|
225
|
+
"ttl_seconds": 0,
|
|
226
|
+
"lookback_blocks": 0,
|
|
227
|
+
"tools_must_be_stable": false,
|
|
228
|
+
"note": "官方按模型区分隐式与显式缓存,另有旧版上下文缓存接口(待下线,且不支持 tools)。最小 token、TTL、显式标记字段名都没找到公开数字,所以不猜策略,落 unknown。命中与否只能用 usage 读数判断。"
|
|
229
|
+
},
|
|
230
|
+
"siliconflow": {
|
|
231
|
+
"strategy": "unknown",
|
|
232
|
+
"cache_mode": "unknown",
|
|
233
|
+
"cache_format": "none",
|
|
234
|
+
"explicit_enabled": false,
|
|
235
|
+
"eviction": "batch",
|
|
236
|
+
"batch_every": 25,
|
|
237
|
+
"keep_images": 3,
|
|
238
|
+
"max_inline_images": 12,
|
|
239
|
+
"min_prefix_tokens": 0,
|
|
240
|
+
"max_breakpoints": 0,
|
|
241
|
+
"ttl_seconds": 0,
|
|
242
|
+
"lookback_blocks": 0,
|
|
243
|
+
"tools_must_be_stable": false,
|
|
244
|
+
"note": "聚合平台,按缓存命中计费,说明隐式缓存存在。但没有公开是否透传上游的缓存标记,也没有最小 token、TTL 口径,所以落 unknown,不加任何标记。图像尺寸随底层模型差异很大,图预算表里单独写。"
|
|
245
|
+
},
|
|
246
|
+
"openrouter": {
|
|
247
|
+
"strategy": "routing_key",
|
|
248
|
+
"cache_mode": "implicit",
|
|
249
|
+
"cache_format": "none",
|
|
250
|
+
"explicit_enabled": false,
|
|
251
|
+
"eviction": "batch",
|
|
252
|
+
"batch_every": 25,
|
|
253
|
+
"keep_images": 3,
|
|
254
|
+
"max_inline_images": 12,
|
|
255
|
+
"min_prefix_tokens": 0,
|
|
256
|
+
"max_breakpoints": 0,
|
|
257
|
+
"ttl_seconds": 0,
|
|
258
|
+
"lookback_blocks": 0,
|
|
259
|
+
"tools_must_be_stable": false,
|
|
260
|
+
"note": "聚合平台,规则随底层模型。有会话键做粘性路由,空闲 60 分钟过期;会把某家的缓存标记翻译成另一家的形状,但 TTL 不翻译。最小 token 与 TTL 全部随底层,这里不填数字、不加标记。"
|
|
261
|
+
},
|
|
262
|
+
"ollama": {
|
|
263
|
+
"strategy": "implicit",
|
|
264
|
+
"cache_mode": "implicit",
|
|
265
|
+
"cache_format": "none",
|
|
266
|
+
"explicit_enabled": false,
|
|
267
|
+
"eviction": "batch",
|
|
268
|
+
"batch_every": 25,
|
|
269
|
+
"keep_images": 3,
|
|
270
|
+
"max_inline_images": 12,
|
|
271
|
+
"min_prefix_tokens": 0,
|
|
272
|
+
"max_breakpoints": 0,
|
|
273
|
+
"ttl_seconds": 0,
|
|
274
|
+
"lookback_blocks": 0,
|
|
275
|
+
"tools_must_be_stable": false,
|
|
276
|
+
"note": "本地运行时,服务端自动做前缀缓存,但没有可打的标记;兼容接口明确不支持缓存块。上下文窗口默认值有两套公开说法(固定 4096,或按显存给更大),本表不改窗口决议,只说明这里没有缓存策略可调。"
|
|
277
|
+
},
|
|
278
|
+
"lmstudio": {
|
|
279
|
+
"strategy": "implicit",
|
|
280
|
+
"cache_mode": "implicit",
|
|
281
|
+
"cache_format": "none",
|
|
282
|
+
"explicit_enabled": false,
|
|
283
|
+
"eviction": "batch",
|
|
284
|
+
"batch_every": 25,
|
|
285
|
+
"keep_images": 3,
|
|
286
|
+
"max_inline_images": 12,
|
|
287
|
+
"min_prefix_tokens": 0,
|
|
288
|
+
"max_breakpoints": 0,
|
|
289
|
+
"ttl_seconds": 0,
|
|
290
|
+
"lookback_blocks": 0,
|
|
291
|
+
"tools_must_be_stable": false,
|
|
292
|
+
"note": "本地运行时,token 缓存默认开且总在响应里报数,用上一次响应 id 复用。最小 token、TTL 未公开,不填数字、不打标记。图像输入默认长边 2048,可在设置里改,图预算表里按这个默认值写。"
|
|
293
|
+
}
|
|
294
|
+
}
|