@@ -64,12 +64,6 @@ def __init__(
6464 self .max_async = config .llm .max_async
6565 self .vlm_timeout = config .llm .vlm_timeout
6666
67- # Token 估算配置
68- self .llm_estimated_output_tokens = config .llm .estimated_output_tokens
69- self .vlm_estimated_output_tokens = config .llm .vlm_estimated_output_tokens
70- self .vlm_max_tokens = config .llm .vlm_max_tokens
71- self .vlm_image_tokens_estimate = config .llm .vlm_image_tokens_estimate
72-
7367 # 存储配置
7468 self .use_external_storage = config .storage .use_external
7569 self .kv_storage = config .storage .kv_storage
@@ -112,14 +106,11 @@ def _create_llm_func(self, llm_config: Dict):
112106 # 获取 rate_limiter 实际使用的并发数(将用于 LightRAG)
113107 actual_max_concurrent = rate_limiter .max_concurrent
114108
115- # 获取 token 估算配置(支持租户覆盖)
116- llm_estimated_output = llm_config .get ("estimated_output_tokens" , self .llm_estimated_output_tokens )
117-
118109 def llm_model_func (prompt , ** kwargs ):
119110 # 精确计算输入 tokens(使用 tiktoken)
120111 input_tokens = count_tokens (prompt , model = "cl100k_base" )
121112 # 保守估算输出 tokens(实体提取通常输出较长)
122- estimated_output = llm_estimated_output # 从配置读取
113+ estimated_output = 3000 # 50 entities + 46 relations ≈ 3000 tokens
123114 estimated_tokens = input_tokens + estimated_output
124115
125116 # Debug: 输出 token 计数
@@ -304,11 +295,6 @@ def _create_vision_model_func(self, llm_config: Dict):
304295 tokens_per_minute = tokens_per_minute
305296 )
306297
307- # 获取 VLM token 估算配置(支持租户覆盖)
308- vlm_image_tokens = llm_config .get ("vlm_image_tokens_estimate" , self .vlm_image_tokens_estimate )
309- vlm_estimated_output = llm_config .get ("vlm_estimated_output_tokens" , self .vlm_estimated_output_tokens )
310- vlm_max_tokens = llm_config .get ("vlm_max_tokens" , self .vlm_max_tokens )
311-
312298 async def seed_vision_model_func (prompt : str , image_data : str , system_prompt : str ) -> str :
313299 """
314300 使用 VLM 理解图片内容(带速率限制)
@@ -323,8 +309,8 @@ async def seed_vision_model_func(prompt: str, image_data: str, system_prompt: st
323309 """
324310 # 精确计算 tokens(使用 tiktoken)
325311 prompt_tokens = count_tokens (prompt , model = "cl100k_base" )
326- image_tokens = vlm_image_tokens # 从配置读取
327- estimated_output = vlm_estimated_output # 从配置读取
312+ image_tokens = 200 # 图片约 200 tokens(固定估算)
313+ estimated_output = 500 # VLM 输出通常较短
328314 estimated_tokens = prompt_tokens + image_tokens + estimated_output
329315
330316 # Debug: 输出 token 计数
@@ -350,7 +336,7 @@ async def seed_vision_model_func(prompt: str, image_data: str, system_prompt: st
350336 ]
351337 }
352338 ],
353- "max_tokens" : vlm_max_tokens , # 从配置读取
339+ "max_tokens" : 500 ,
354340 "temperature" : 0.1
355341 }
356342
0 commit comments