Commit Graph
161 Commits
Author SHA1 Message Date
科林_Cyril Pilgrim 8eea73f574 feat(nodes): add dedicated reasoning output pin for deepseek models
Motivation: Expose the parsed reasoning_content to downstream ComfyUI nodes so users can route or display the internal thoughts of models like DeepSeek.

Implementation: Appended 'reasoning' to RETURN_TYPES and RETURN_NAMES in openai_compatible.py. Updated _success and _error_result standard return tuple length from 3 to 4.
2026-03-01 23:18:39 +08:00
科林_Cyril Pilgrim 8d66620e59 feat(nodes): integrate o1/o3 role downgrade and deepseek reasoning extraction
Motivation: Absorbing robust API handling strategies from comfyui_LLM_party to enhance compatibility with newer models (o1/o3) and models that return internal thought processes (DeepSeek/R1).

Implementation: 1. o1/o3 Compatibility: Intercept payload building to convert unsupported 'system' roles to 'user' roles and spoof an 'assistant' acknowledgment. 2. DeepSeek Readiness: Parse official 'reasoning_content' or fallback to regex extraction of 'think' blocks, stripping them from the main ComfyUI text output to keep prompts clean.
2026-03-01 23:06:15 +08:00
科林_Cyril Pilgrim a35f9cc67e fix(nodes): append assistant response to conversation history to enable true multi-turn memory
Motivation:
The enable_memory feature was incomplete because it only stored the user's prompts in the history array without appending the assistant's previous replies. This resulted in context-blind multi-turn interactions.

Implementation:
Added logic to append the assistant's response to self._conversation_history right before returning the success result, completing the conversational loop.
2026-03-01 22:45:16 +08:00
科林_Cyril Pilgrim 26ed2a055c fix(ui): move token usage display below the node's bottom boundary to prevent overlapping with existing bottom widgets 2026-03-01 17:04:41 +08:00
科林_Cyril Pilgrim 2832338a9a chore(git): remove task_plan.md and untrack test_api.py
Motivation:
Internal planning files and temporary test scripts should not be part of the public repository.

Implementation:
1. Deleted task_plan.md and removed from git tracking.
2. Untracked test_api.py (keeping local copy) and added both to .gitignore.
2026-03-01 16:45:13 +08:00
科林_Cyril Pilgrim 7ec2e455cb feat(ui): migrate token display to native canvas rendering on the right side to completely avoid widget serialization issues 2026-03-01 16:16:08 +08:00
科林_Cyril Pilgrim bfecfe5f81 style(ui): increase token display widget height for better readability 2026-03-01 16:06:42 +08:00
科林_Cyril Pilgrim 162d65e239 fix(ui): prevent dynamically added token display widget from corrupting node parameter serialization indices 2026-03-01 14:36:39 +08:00
科林_Cyril Pilgrim 8a983d1e2b fix(nodes): fix json combine and seed payload compliance
Motivation:
JSONCombine was failing with 'dict' has no attribute 'strip' when receiving dictionary inputs, and strict APIs (like Qwen) returned 400 Errors when receiving the non-standard 'seed' field in the payload.

Implementation:
Updated JSONCombine in json_builder.py to handle both string and dict types safely. Removed the seed field from the API payload in openai_compatible.py to strictly follow CONTRIBUTING.md Rule 3.1 and ensure standard OpenAI compatibility.
2026-02-28 22:30:22 +08:00
科林_Cyril Pilgrim c418732d4c fix(nodes): cast seed to int to satisfy strict API provider type checks 2026-02-28 20:57:17 +08:00
科林_Cyril Pilgrim bd5d3f0e6d feat(nodes): restore seed parameter to enable generation diversity and ComfyUI cache bypassing 2026-02-28 20:28:24 +08:00
科林_Cyril Pilgrim 1a15c8d129 refactor(nodes): optimize OpenAI compatible adapter and translator
Motivation:
LLM API calls frequently failed with HTTP 429 and 50x errors, crashing the workflow. Code redundancy existed between different LLM nodes. Non-standard payload fields caused 400 errors with some providers.

Implementation:
1. Extracted api_client.py for centralized HTTP handling with smart retries (Retry-After, backoff, jitter) and structured error logging.
2. Implemented graceful degradation to return error text instead of raising exceptions.
3. Cleaned up non-standard OpenAI payload fields.
4. Added input validation to fail fast on empty prompts or API keys.
5. Refactored both openai_compatible.py and llm_translator.py to reuse LLMClient.
6. Handled dual import registration in __init__.py for robust dynamic loading.
2026-02-28 16:31:06 +08:00
科林_Cyril Pilgrim 739324c58b fix(openai-adapter): handle SSL TLS compatibility errors
Motivation:
部分国内 API 服务商(如 iFlow)TLS 握手时提前关闭连接,触发 UNEXPECTED_EOF_WHILE_READING

Implementation:
创建宽松 SSL context:禁用 hostname/cert 校验,启用 OP_LEGACY_SERVER_CONNECT 兼容旧服务器 TLS 版本
2026-02-28 11:02:23 +08:00
科林_Cyril Pilgrim fe9a0a1721 fix(openai-adapter): resolve HTTP 403, token display, and provider routing bugs
Motivation:
- WAF拦截:urllib默认User-Agent被API网关识别为爬虫,触发1010/403
- Token显示失效:前端JS import路径层级错误、缺少OUTPUT_NODE声明
- Provider路由错误:用base_url匹配ProviderRegistry导致适配逻辑永远失效

Implementation:
- 添加浏览器User-Agent到HTTP请求头,绕过WAF反爬拦截
- 修复display_tokens.js import路径(../../→../../../),改用find-or-create widget策略
- 添加OUTPUT_NODE=True,对齐ComfyUI UI反馈节点标准
- 修正provider查找逻辑:用provider_name匹配配置,用base_url发起API调用
- max_tokens默认值从512调整为2048
2026-02-28 10:43:25 +08:00
科林_Cyril Pilgrim 73fdbf6ac0 fix(ui): use ComfyWidgets for token display compatibility 2026-02-28 00:14:24 +08:00
科林_Cyril Pilgrim 52b8e5e68a feat(ui): display Token Usage directly on nodes & enhance request size logs 2026-02-28 00:04:04 +08:00
科林_Cyril Pilgrim 67c499bbfd feat(llm_loader): add ModelScope/魔搭 provider 2026-02-27 21:06:39 +08:00
科林_Cyril Pilgrim d46e3df8a4 fix(translator): add SSL context and retry for transient errors
Motivation:
urllib.request.urlopen without explicit SSL context causes UNEXPECTED_EOF_WHILE_READING on some Python/env combos. Transient network errors also need graceful handling.

Implementation:
Added ssl.create_default_context() and 3-attempt retry loop for SSL/URLError/ConnectionError/TimeoutError in _call_api. Also added iFlow/心流 provider to LLM_Loader.
2026-02-17 13:59:08 +08:00
科林_Cyril Pilgrim b58e134c05 refactor(translator): move LLMTranslator to Utility category
Motivation:
Translation node better fits under the Utility category for grouping practical helper nodes.

Implementation:
Changed CATEGORY from Translation to Utility in llm_translator.py.
2026-02-17 10:14:32 +08:00
科林_Cyril Pilgrim 0b2bd1dd13 fix(llm_loader): restore self-contained URL mapping
Motivation:
from nodes.openai_compatible import ProviderRegistry clashed with ComfyUI's own nodes module, causing the LLM_Loader node to fail loading entirely.

Implementation:
Reverted to a local _BASE_URL_MAPPING dict, keeping the dead import cleanup from the previous refactor. The mapping is now self-contained with no cross-module dependencies.
2026-02-17 10:12:05 +08:00
科林_Cyril Pilgrim 156243f035 refactor(nodes): fix critical bugs and optimize architecture
Motivation:
Fix NameError in json_fixer, remove dangerous dead imports (aiohttp), eliminate duplicated provider URL mappings and repeated build logic across multiple node files.

Implementation:
1. json_fixer: tracked last_error to prevent NameError, capped brute-force search at 10K chars.
2. llm_loader: removed 6 dead imports, reused ProviderRegistry as single source of truth.
3. openai_compatible: renamed shadowed provider variable to provider_name.
4. json_builder: extracted _parse_value() and _build_from_keys() shared helpers.
5. image_processor: extracted _tensor_to_pil() to deduplicate tensor conversion.
6. Unified all log prefixes to [LLMs_Toolkit], removed redundant WEB_DIRECTORY.
7. Rewrote test_basic.py with 13 test cases (all passing).
2026-02-16 22:16:02 +08:00
科林_Cyril Pilgrim a9bd548045 style(docs): remove emojis from README.md
Motivation:
Ensure a clean, professional, and accessible documentation style by removing decorative emojis.

Implementation:
Removed all emoji characters from headers, lists, and tables in README.md.
2026-02-16 12:38:33 +08:00
科林_Cyril Pilgrim 88eac194c7 feat(all): implement LLMTranslator and internationalize documentation
Motivation:
Introduce a dedicated translation node for simplified workflows, enhance error logging, and make the project accessible to a global audience with a default English README.

Implementation:
1. Implemented LLMTranslator node with auto-language detection and glossary support.
2. Enhanced OpenAICompatibleLoader with request size tracking and detailed error diagnostics.
3. Renamed README.md -> README_CN.md and created a new idiomatic English README.md with language switchers.
4. Added docs/llm_translator_guide.md and removed redundant docs/readme_en.md.
2026-02-15 23:29:01 +08:00
科林_Cyril Pilgrim 7687ee1390 refactor: update OpenAICompatibleLoader to use config dict
- Change generate method signature to accept llm_config dictionary.
- Add logging for provider/model configuration.
- Add documentation for LLM configuration usage.
2026-02-11 15:47:44 +08:00
科林_Cyril Pilgrim 7a4d277d29 perf(image): optimize resizing logic and enhance base64 logging 2026-02-10 17:29:46 +08:00
科林_Cyril Pilgrim 6631e50273 fix(openai): resolve variable naming and sync call logic in loader 2026-02-10 17:29:46 +08:00
科林_Cyril Pilgrim 793fce89cd feat(json): restructure builders to Simple/Medium/Large and add Combine node 2026-02-10 17:29:32 +08:00
科林_Cyril Pilgrim 7f9fc79051 feat: add String Template node & update gitignore
- Add StringTemplate node for variable replacement in strings using JSON context.
- Update .gitignore to recursively exclude __pycache__ directories.
- Fix OpenAICompatibleLoader to use synchronous API calls, preventing event loop errors.
2026-02-10 16:34:02 +08:00
科林_Cyril Pilgrim 984e755158 fix(json-builder): set default keys to empty string to avoid unused keys in output 2026-02-10 15:06:56 +08:00
科林_Cyril Pilgrim aeda7c6085 refactor(json-builder): rename nodes to Basic and Advanced
Updated naming convention per user request:
- JSONBuilderBasic (JSON Builder Basic): 5 key-value pairs
- JSONBuilderAdvanced (JSON Builder Advanced): 10 key-value pairs

Replaces previous static node implementation with improved naming.
2026-02-09 23:46:16 +08:00
科林_Cyril Pilgrim d5f61387ef refactor(json-builder): rename to JSON Build ×5 and JSON Build ×10
Better naming convention:
- JSONBuildCompact → 'JSON Build ×5'
- JSONBuildExtended → 'JSON Build ×10'

More concise and professional display names.
2026-02-09 23:39:33 +08:00
科林_Cyril Pilgrim c28fc8339b feat(json-builder): static nodes - JSON Builder (5) and (10)
Two separate nodes for different use cases:
- JSONBuilder5: 5 key-value pairs
- JSONBuilder10: 10 key-value pairs

All keys are editable text boxes, all values are forceInput.
No dynamic widgets - 100% reliable serialization.
2026-02-09 23:35:28 +08:00
科林_Cyril Pilgrim a4ffc158eb refactor(json-builder): simplify to multiline keys + fixed value inputs
BREAKING CHANGE: Removed dynamic input_count approach entirely

New design:
- keys: multiline text box (one key name per line)
- value_1 ~ value_10: fixed input slots
- Line 1 → value_1, Line 2 → value_2, etc.

Removed frontend JS - no dynamic widgets needed.
This is the most reliable approach since ComfyUI doesn't
support dynamic widget value passing to backend.
2026-02-09 23:30:01 +08:00
科林_Cyril Pilgrim 14c7290a1e feat(json-builder): pure text widgets for keys with custom serialization
Implementation:
- Keys: addWidget('text') with custom serializeValue()
- Values: addInput() for connection slots
- onSerialize: saves dynamic key widget values to node properties
- onConfigure: restores key widgets on workflow load

This allows keys to be pure editable text boxes (not forceInput)
while still being properly serialized and restored.
2026-02-09 23:22:28 +08:00
科林_Cyril Pilgrim 4f9f0581a6 fix(json-builder): rewrite to use proper inputs for dynamic key/value pairs
BREAKING CHANGE: Keys now use forceInput=False (can type OR connect)
- Backend: key_N uses forceInput=False, value_N uses forceInput=True
- Frontend: dynamically adds both as proper inputs (not widgets)
- This ensures ComfyUI correctly serializes dynamic inputs
- Fixes issue where dynamically added keys were not being loaded
2026-02-09 23:14:29 +08:00
科林_Cyril Pilgrim 02cdce34ac style(json-builder): premium styled Update button with gradient design
- Custom draw function for button rendering
- Blue gradient background (#3a6ea5 → #2c5282)
- Rounded corners (6px radius)
- Subtle border and top highlight
- Icon prefix (⟳) for visual appeal
- Follows Google Material Design principles
2026-02-09 23:11:00 +08:00
科林_Cyril Pilgrim d8aee2746a style(json-builder): rename inputcount to input_count, reposition Update button
- Renamed inputcount to input_count for better readability
- Moved Update inputs button to appear right after input_count widget
2026-02-09 23:07:00 +08:00
科林_Cyril Pilgrim 6f349c948d fix(json-builder): remove base_json, make keys manual text inputs
Changes:
- Removed unnecessary base_json parameter
- Keys are now editable text widgets (not forceInput)
- Values remain as input slots for upstream connections
- Frontend JS updated to add text widgets for keys
2026-02-09 23:02:50 +08:00
科林_Cyril Pilgrim 87d9d055e3 feat(json): add frontend JS for dynamic input count refresh
- Created web/js/json_builder.js with Update inputs button handler
- Dynamically adds/removes key_N and value_N input pairs
- Pattern follows KJNodes JoinStringMulti implementation exactly

User can now:
1. Change inputcount value
2. Click Update inputs button
3. Frontend dynamically updates input slots
2026-02-09 22:57:25 +08:00
科林_Cyril Pilgrim 4b5ffd0842 feat(json): upgrade JSON Builder with dynamic inputcount pattern
- Added inputcount parameter for unlimited key-value pairs
- Added base_json input for chaining multiple builders
- Pattern inspired by KJNodes' JoinStringMulti design
- User can adjust inputcount and click Update to add more inputs
2026-02-09 22:50:38 +08:00
科林_Cyril Pilgrim c6d06cfe76 chore: remove tests/ from tracking (already in .gitignore) 2026-02-09 22:10:53 +08:00
科林_Cyril Pilgrim fe293f74c5 feat(json): add JSON Builder and JSON Fixer nodes
JSON Builder:
- Build JSON from up to 5 key-value pairs
- Auto-parse values (string or nested JSON)
- Category: 🚦ComfyUI_LLMs_Toolkit/JSON

JSON Fixer:
- Fix malformed JSON from LLM outputs
- Handle: trailing commas, single quotes, markdown code blocks
- Extract JSON from surrounding text
- Category: 🚦ComfyUI_LLMs_Toolkit/JSON

Also fixed JSON Extractor to use forceInput for upstream connection.
2026-02-09 22:08:44 +08:00
科林_Cyril Pilgrim 3f7a520085 fix(json): align log format with brand identifier standard 2026-02-09 21:57:14 +08:00
科林_Cyril Pilgrim f843bbfe95 refactor: flatten architecture with auto-registration (Google best practices)
- Moved all nodes to flat nodes/ directory:
  - llm_loader.py
  - openai_compatible.py
  - image_processor.py
  - json_extractor.py (NEW)

- Implemented auto-registration in __init__.py:
  - Scans nodes/ directory automatically
  - No need to manually update imports
  - Follows YAGNI principle (4 nodes don't need deep nesting)

- Added JSON Extractor node:
  - Extract values from JSON strings by key
  - Supports nested keys (e.g., 'user.name')
  - Category: 🚦ComfyUI_LLMs_Toolkit/JSON

- Removed src/ multi-level structure for better discoverability
2026-02-09 21:53:02 +08:00
科林_Cyril Pilgrim b1d6fd6a57 chore: standardize environment configuration and clean up legacy config
- Renamed config/env.example to .env.example (following industry standard .env conventions).
- Streamlined .env.example with API key placeholders and pointers to documentation.
- Removed legacy config/ directory.
2026-02-09 15:51:47 +08:00
科林_Cyril Pilgrim d73c0c821a chore: remove tracked __pycache__ from repository 2026-02-09 15:35:18 +08:00
科林_Cyril Pilgrim 056cf7ecc4 refactor: overhaul LLM toolkit architecture and standardize observability
- Core Refactoring: Migrated OpenAICompatibleLoader to a structured class design (ProviderRegistry, MessageBuilder, TokenEstimator) for enhanced maintainability.
- AsyncIO Fix: Resolved 'Event loop is closed' RuntimeError by transitioning to asyncio.run() for robust event loop lifecycle management within ComfyUI's threaded environment.
- Node Enhancements:
    - Added 'seed' parameter for deterministic cache invalidation control.
    - Fixed silent drop of system_prompt in stateless mode (enable_memory=False).
    - Refined category hierarchy: [Generate, Loader, Image] under a unified toolkit brand.
- Observability: Implemented project-wide geek-style logging with [LLMs_Toolkit] branding, execution latency tracking, and high-density token reporting.
- Cleanup: Removed legacy DeepSeek local model vertical, dependencies, and redundant utility nodes.
- Documentation: Simplified README and updated .gitignore for developer hygiene.
2026-02-09 15:26:02 +08:00
科林_Cyril Pilgrim d04fff29e2 refactor: 重构节点分类与清理冗余功能
- 将所有 CATEGORY 从 DeepSeek_Toolkit 改为 🚦ComfyUI_LLMs_Toolkit
- 删除 Video File Uploader 节点 (src/utils/file_uploader.py)
- 移除 OpenAI Compatible 节点的 video_url 入参
2026-02-08 16:31:58 +08:00
科林_Cyril Pilgrim 4762f9be25 refactor: 移除 DeepSeek 本地模型相关代码
- 删除 src/core/model_loader.py (本地模型加载器)
- 删除 src/processors/image_generation.py (Janus Pro 图像生成)
- 删除 src/processors/image_understanding.py (图像分析)
- 移除 requirements.txt 中的 Janus 依赖
- 更新 __init__.py 移除相关导入
- 重写 README.md,精简风格
2026-02-08 16:15:30 +08:00
科林_Cyril Pilgrim eae293833b ✨ 完善安装步骤,突出ComfyUI Manager
🎯 主要优化:
- 将ComfyUI Manager设为首选安装方式
- 优化安装步骤的标题和格式
- 提供清晰的两种安装选择
- 完全聚焦ComfyUI插件生态

📝 格式改进:
- 统一使用'方法一/方法二'的命名方式
- 优化代码块的注释格式
- 提升整体文档的可读性和专业性
2025-06-23 17:42:43 +08:00