mirror of
https://github.com/primedigitaltech/market-assistant.git
synced 2026-07-22 08:01:34 +08:00
新增 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
11 lines
428 B
Python
11 lines
428 B
Python
"""
|
||
与 `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
|