Skip to content

Commit 8b0aa04

Browse files
committed
feat: add support for tool calling to beeai compiler
Signed-off-by: Nick Mitchell <[email protected]>
1 parent abd6233 commit 8b0aa04

File tree

8 files changed

+575
-56
lines changed

8 files changed

+575
-56
lines changed

pdl-live-react/src-tauri/src/cli/setup.rs

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use ::std::path::Path;
33
use serde_json::Value;
44
use urlencoding::encode;
55

6-
use tauri_plugin_cli::CliExt;
6+
use tauri_plugin_cli::{ArgData, CliExt};
77

88
use crate::cli::run;
99
use crate::compile;
@@ -18,7 +18,9 @@ pub fn cli(app: &mut tauri::App) -> Result<(), Box<dyn ::std::error::Error>> {
1818
// `subcommand` is `Option<Box<SubcommandMatches>>` where `SubcommandMatches` is a struct with { name, matches }.
1919
let Some(subcommand_matches) = app.cli().matches()?.subcommand else {
2020
if let Some(help) = app.cli().matches()?.args.get("help") {
21-
return Err(Box::from(help.value.as_str().or(Some("Internal Error")).unwrap()));
21+
return Err(Box::from(
22+
help.value.as_str().or(Some("Internal Error")).unwrap(),
23+
));
2224
} else {
2325
return Err(Box::from("Internal Error"));
2426
}
@@ -32,19 +34,29 @@ pub fn cli(app: &mut tauri::App) -> Result<(), Box<dyn ::std::error::Error>> {
3234

3335
match compile_subcommand_matches.name.as_str() {
3436
"beeai" => {
35-
let Some(source) = compile_subcommand_matches.matches.args.get("source") else {
36-
return Err(Box::from("Missing source file"));
37+
// TODO this probably fails if the source is a number??
38+
let Some(ArgData {
39+
value: Value::String(source_file_path),
40+
..
41+
}) = compile_subcommand_matches.matches.args.get("source")
42+
else {
43+
return Err(Box::from("Invalid source file"));
3744
};
38-
let Value::String(source_file_path) = &source.value else {
39-
return Err(Box::from("Invalid source file argument"));
45+
let Some(ArgData {
46+
value: Value::String(output_file_path),
47+
..
48+
}) = compile_subcommand_matches.matches.args.get("output")
49+
else {
50+
return Err(Box::from("Invalid output argument"));
4051
};
41-
let Some(output) = compile_subcommand_matches.matches.args.get("output") else {
42-
return Err(Box::from("Missing output argument"));
52+
let Some(ArgData {
53+
value: Value::Bool(debug),
54+
..
55+
}) = compile_subcommand_matches.matches.args.get("debug")
56+
else {
57+
return Err(Box::from("Invalid debug argument"));
4358
};
44-
let Value::String(output_file_path) = &output.value else {
45-
return Err(Box::from("Invalid output file argument"));
46-
};
47-
return compile::beeai::compile(source_file_path, output_file_path);
59+
return compile::beeai::compile(source_file_path, output_file_path, debug);
4860
}
4961
_ => {}
5062
}

0 commit comments

Comments
 (0)