Skip to content

Commit d75b6a7

Browse files
committed
feat: rust interpreter support for modelResponse, ollama-rs tooling calling, and no-stream
This adds a test for the bee compiler, and that test also runs the compiled code. Signed-off-by: Nick Mitchell <[email protected]>
1 parent 618b838 commit d75b6a7

File tree

8 files changed

+254
-82
lines changed

8 files changed

+254
-82
lines changed

pdl-live-react/src-tauri/Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pdl-live-react/src-tauri/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,16 @@ base64ct = { version = "1.7.1", features = ["alloc"] }
3535
dirs = "6.0.0"
3636
serde_norway = "0.9.42"
3737
minijinja = { version = "2.9.0", features = ["custom_syntax"] }
38-
ollama-rs = { version = "0.3.0", features = ["stream"] }
38+
#ollama-rs = { version = "0.3.0", features = ["stream"] }
39+
ollama-rs = { git = "https://github.com/starpit/ollama-rs.git", branch = "tools-pub-7", features = ["stream"] }
3940
owo-colors = "4.2.0"
4041
rustpython-vm = "0.4.0"
4142
async-recursion = "1.1.1"
4243
tokio-stream = "0.1.17"
4344
tokio = { version = "1.44.1", features = ["io-std"] }
4445
indexmap = { version = "2.9.0", features = ["serde"] }
4546
rustpython-stdlib = { version = "0.4.0", features = ["zlib"] }
47+
schemars = "0.8.22"
4648

4749
[target.'cfg(not(any(target_os = "android", target_os = "ios")))'.dependencies]
4850
tauri-plugin-cli = "2"

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub fn setup(app: &mut tauri::App) -> Result<bool, Box<dyn ::std::error::Error>>
3434
let args = compile_subcommand_matches.matches.args;
3535

3636
match compile_subcommand_matches.name.as_str() {
37-
"beeai" => compile::beeai::compile(
37+
"beeai" => compile::beeai::compile_to_file(
3838
args.get("source")
3939
.and_then(|a| a.value.as_str())
4040
.expect("valid positional source arg"),
@@ -60,6 +60,11 @@ pub fn setup(app: &mut tauri::App) -> Result<bool, Box<dyn ::std::error::Error>>
6060
.and_then(|a| a.value.as_bool())
6161
.or(Some(false))
6262
== Some(true),
63+
subcommand_args
64+
.get("no-stream")
65+
.and_then(|a| a.value.as_bool())
66+
.or(Some(false))
67+
== Some(false),
6368
)
6469
.and_then(|_trace| Ok(true)),
6570
"run" => run_pdl_program(

pdl-live-react/src-tauri/src/compile/beeai.rs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -348,15 +348,7 @@ fn python_source_to_json(source_file_path: &str, debug: bool) -> Result<PathBuf,
348348
Ok(dry_run_file)
349349
}
350350

351-
pub fn compile(
352-
source_file_path: &str,
353-
output_path: &str,
354-
debug: bool,
355-
) -> Result<(), Box<dyn Error>> {
356-
if debug {
357-
eprintln!("Compiling beeai {} to {}", source_file_path, output_path);
358-
}
359-
351+
pub fn compile(source_file_path: &str, debug: bool) -> Result<PdlBlock, Box<dyn Error>> {
360352
let file = match Path::new(source_file_path)
361353
.extension()
362354
.and_then(OsStr::to_str)
@@ -559,6 +551,20 @@ asyncio.run(invoke())
559551
text: body,
560552
});
561553

554+
Ok(pdl)
555+
}
556+
557+
pub fn compile_to_file(
558+
source_file_path: &str,
559+
output_path: &str,
560+
debug: bool,
561+
) -> Result<(), Box<dyn Error>> {
562+
if debug {
563+
eprintln!("Compiling beeai {} to {}", source_file_path, output_path);
564+
}
565+
566+
let pdl = compile(source_file_path, debug)?;
567+
562568
match output_path {
563569
"-" => println!("{}", to_string(&pdl)?),
564570
_ => {

0 commit comments

Comments
 (0)