hub-gif 33bf73e3ba feat(pipeline/llm): OpenAI 官方 ChatGPT 适配器并整理 providers 目录
新增 providers/adapters/openai_official_chatgpt、shared 抽离归一化与 token 启发式;MA_LLM_TEXT_PROVIDER 支持 openai_official/openai_chatgpt/chatgpt。补充单测与 try_openai_official_llm 试跑脚本、.env.example 说明。

Made-with: Cursor
2026-04-27 10:09:26 +08:00

11 lines
428 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` 同口径的保守估算,
供预检、策略档位与各适配器共用(无 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