hub-gif 9fd32a3f84 refactor(pipeline): OpenAI 网关与配料视觉抽离至 openai_gateway
新增 pipeline/openai_gateway:credentials、text_chat、ingredients_op、ingredients_defaults 等;AI_crawler 仅加载 .env 与重导出。CrawlerOpenAiCompatible 与京东详情/流水线改走 import pipeline.openai_gateway,不再依赖 sys.path 注入爬虫目录。llm/providers/shared 转重导 gateway。详情脚本补充 backend 入 path。

Made-with: Cursor
2026-04-27 10:24:50 +08:00

8 lines
294 B
Python

"""输入 token 保守估算(与历史 AI_crawler 同口径)。"""
from __future__ import annotations
def estimate_chat_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