From 706061cdde24fda57abd9d4847fbc0743fdf30bc Mon Sep 17 00:00:00 2001 From: dino Date: Thu, 30 Oct 2025 17:02:10 +0000 Subject: [PATCH] feat: parse llm response into vector of actions Co-authored-by: Gaauwe Rombouts --- crates/magic_palette/src/magic_palette.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/crates/magic_palette/src/magic_palette.rs b/crates/magic_palette/src/magic_palette.rs index 2d32e4ada022e43bddd8d5d220f5fb49c94c432d..51633d8b8215e8d4e77ba606c922fcf23d45bfc1 100644 --- a/crates/magic_palette/src/magic_palette.rs +++ b/crates/magic_palette/src/magic_palette.rs @@ -222,7 +222,26 @@ Format your response as a simple list of action names, one per line, with no add buffer.push_str(&message); } - dbg!(buffer); + dbg!(&buffer); + + // Split result by ';` and for each string, call `cx.build_action`. + let _ = cx.update(move |_window, cx| { + let mut actions: Vec> = vec![]; + + for line in buffer.lines() { + dbg!(line); + + let action = cx.build_action(line, None); + match action { + Ok(action) => actions.push(action), + Err(err) => { + log::error!("Failed to build action: {}", err); + } + } + } + + dbg!(&actions); + }); // Ok(()) });