lean_ctx_proxy/
compress_shared.rs1use serde_json::Value;
5
6use super::tool_kind::{self, ToolResultKind};
7
8#[derive(Debug, Clone, Copy, PartialEq, Eq)]
10pub enum ToolKind {
11 ToolUse,
12 ToolResult,
13 Text,
14 Image,
15 Other,
16}
17
18pub fn classify_tool_kind(content: &Value) -> ToolKind {
20 match content.get("type").and_then(Value::as_str) {
21 Some("tool_use" | "function_call") => ToolKind::ToolUse,
22 Some("tool_result" | "function_call_output") => ToolKind::ToolResult,
23 Some("text" | "input_text" | "output_text") => ToolKind::Text,
24 Some("image" | "image_url" | "input_image") => ToolKind::Image,
25 _ => ToolKind::Other,
26 }
27}
28
29pub const fn should_compress_content(kind: ToolKind) -> bool {
31 matches!(kind, ToolKind::Text)
32}
33
34pub fn tool_result_kind(tool_name: Option<&str>) -> ToolResultKind {
36 tool_name.map_or(ToolResultKind::Other, tool_kind::classify_tool_name)
37}