hub-gif 52c9dc1697 refactor(pipeline/llm): 文本大模型工厂与 OpenAI 兼容适配器
新增 providers 包:协议、Crawler 网关适配器、output 去围栏、token 启发式与工厂;llm_client 与 keyword_suggest 走统一入口。未改各 generate_* 提示词。补充 MA_LLM_TEXT_PROVIDER 说明至 .env.example。

Made-with: Cursor
2026-04-27 09:56:21 +08:00

11 lines
439 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""
与 `crawler_copy/.../AI_crawler` 中 `_estimate_chat_input_tokens` 同口径的保守估算,
供预检、策略档位与 OpenAI 兼容适配器共用(无 tiktoken 时避免 max_tokens 400
"""
from __future__ import annotations
def estimate_crawler_style_input_tokens(system_prompt: str, user_prompt: str) -> int:
total_chars = len(system_prompt or "") + len(user_prompt or "")
return int(total_chars * 0.55) + 512