mirror of
https://github.com/primedigitaltech/market-assistant.git
synced 2026-07-21 23:41:39 +08:00
新增 providers 包:协议、Crawler 网关适配器、output 去围栏、token 启发式与工厂;llm_client 与 keyword_suggest 走统一入口。未改各 generate_* 提示词。补充 MA_LLM_TEXT_PROVIDER 说明至 .env.example。 Made-with: Cursor
11 lines
439 B
Python
11 lines
439 B
Python
"""
|
||
与 `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
|