image.domain\agent_kit\agent_intent.mbt
79.4% · 27 / 34 points · 79 linesBackground color reports the state of each line. Underlined characters mark exact instrumented byte offsets; hover them to inspect the visit count.
- 1
///| - 2
/// # Agent 意图识别 Agent Intent Recognition - 3
/// - 4
/// 自然语言 → 结构化意图 - 5
/// 描述 Natural language → structured intent - 6
// Agent-Kit 意图类型 — 自然语言操作意图 - 7
// Intent: 从自然语言查询中提取的操作意图 - 8
- 9
///| - 10
/// `#non_exhaustive` 表示未来可能添加新构造器 - 11
#derive(Eq, @debug.Debug) - 12
#non_exhaustive - 13
pub(all) enum Intent { - 14
Denoise - 15
EdgeDetect - 16
Blur - 17
Sharpen - 18
Grayscale - 19
Resize(Int32, Int32) - 20
Rotate - 21
FlipH - 22
FlipV - 23
Threshold(Float, Float) - 24
Mask(Float) - 25
Identity - 26
} - 27
- 28
///| - 29
pub extend Intent with Eq::{not_equal, equal} - 30
- 31
///| - 32
pub extend Intent with @debug.Debug::{to_repr} - 33
- 34
///| - 35
pub fn Intent::to_string(self : Intent) -> String { - 36●
match self { - 37●
Denoise => "denoise" - 38●
EdgeDetect => "edge_detect" - 39●
Blur => "blur" - 40●
Sharpen => "sharpen" - 41●
Grayscale => "grayscale" - 42○
Resize(_, _) => "resize" - 43●
Rotate => "rotate" - 44●
FlipH => "flip_horizontal" - 45○
FlipV => "flip_vertical" - 46○
Threshold(_, _) => "threshold" - 47○
Mask(_) => "mask" - 48●
Identity => "identity" - 49
} - 50
} - 51
- 52
///| - 53
pub fn Intent::keyword(self : Intent) -> Array[String] { - 54●
match self { - 55●
Denoise => ["denoise", "noise", "clean", "smooth"] - 56●
EdgeDetect => ["edge", "edges", "contour", "gradient", "outline"] - 57●
Blur => ["blur", "soft", "hazy"] - 58●
Sharpen => ["sharpen", "sharp", "crisp", "enhance"] - 59●
Grayscale => ["gray", "grayscale", "grey", "monochrome"] - 60○
Resize(_, _) => ["resize", "scale", "shrink", "enlarge"] - 61●
Rotate => ["rotate", "turn", "spin"] - 62●
FlipH => ["flip", "mirror", "reflect"] - 63●
FlipV => ["flip_vertical", "upside_down"] - 64○
Threshold(_, _) => ["threshold", "binarize", "binary"] - 65○
Mask(_) => ["mask", "hide", "select"] - 66●
Identity => ["identity", "noop", "pass"] - 67
} - 68
} - 69
- 70
///| - 71
pub fn Intent::matches(self : Intent, word : String) -> Bool { - 72●
let lowered = word.to_lower() - 73●
for kw in self.keyword() { - 74●
if lowered.contains(kw) { - 75●
return true - 76
} - 77
} - 78
false - 79
}