aidy.v2.plugin.prompt_compressor
Messages
message PromptCompressorLog
请求日志中的 prompt_compressor 扩展字段。
message PromptCompressorLog { // 本次压缩处理状态,例如 compressed / skip / bypass。 string status = 1; // 压缩前的总 token 数。 uint32 original_tokens = 2; // 压缩后的总 token 数。 uint32 compressed_tokens = 3; // 本次请求共节省的 token 数。 uint32 saved_tokens = 4; // 实际生效的目标 token 数;未使用 target_token 覆盖时为 0。 uint32 target_token = 5; // skip 时的原因,例如 below_min_token_threshold / no_compressible_messages。 string skip_reason = 6; // bypass 时的错误信息。 string error = 7;}message PromptCompressorPluginConfig
路由级语义压缩配置。
message PromptCompressorPluginConfig { // 是否启用语义压缩。 // 只有显式设置为 true 时,插件才会在该 route 上进入请求链路。 bool enabled = 1; // 目标压缩率,0.1~0.95;与 target_token 二选一,target_token > 0 时优先。 // 未显式设置时,运行时默认值为 0.5。 float target_ratio = 2; // 目标 token 数;> 0 时覆盖 target_ratio。 // 未显式设置时,运行时默认值为 0,表示不启用该覆盖逻辑。 int32 target_token = 3; // 需要压缩的消息角色。 // 未显式设置时,运行时默认值为 ["system"]。 repeated string compress_roles = 4; // 最小触发阈值(估算 token 数),低于此值时跳过压缩。 // 未显式设置时,运行时默认值为 500。 int32 min_token_threshold = 5; // 保留最近 N 条用户消息不压缩。 // 未显式设置时,运行时默认值为 1。 int32 force_retain_last_n = 6; // 压缩下限安全阀,即使配置更激进也不低于此比例。 // 未显式设置时,运行时默认值为 0.3。 float max_compression_ratio = 7;}