Skip to content

Commit 60bd039

Browse files
committed
PdlX -> X
Signed-off-by: Nick Mitchell <[email protected]>
1 parent b0cd0d4 commit 60bd039

File tree

4 files changed

+146
-85
lines changed

4 files changed

+146
-85
lines changed

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

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ use serde_json::{from_reader, json, to_string, Map, Value};
1212
use tempfile::Builder;
1313

1414
use crate::pdl::ast::{
15-
PdlBaseType, PdlBlock, PdlCallBlock, PdlFunctionBlock, PdlListOrString, PdlMessageBlock,
16-
PdlModelBlock, PdlObjectBlock, PdlOptionalType, PdlParser, PdlPythonCodeBlock, PdlRepeatBlock,
17-
PdlTextBlock, PdlType, Role,
15+
CallBlock, FunctionBlock, ListOrString, MessageBlock, ModelBlock, ObjectBlock, PdlBaseType,
16+
PdlBlock, PdlOptionalType, PdlParser, PdlType, PythonCodeBlock, RepeatBlock, Role, TextBlock,
1817
};
1918
use crate::pdl::pip::pip_install_if_needed;
2019
use crate::pdl::requirements::BEEAI_FRAMEWORK;
@@ -190,22 +189,22 @@ fn with_tools(
190189
}
191190

192191
fn call_tools(model: &String, parameters: &HashMap<String, Value>) -> PdlBlock {
193-
let repeat = PdlBlock::Text(PdlTextBlock {
192+
let repeat = PdlBlock::Text(TextBlock {
194193
def: None,
195194
defs: None,
196195
role: None,
197196
parser: None,
198197
description: Some("Calling tool ${ tool.function.name }".to_string()),
199198
text: vec![PdlBlock::Model(
200-
PdlModelBlock::new(model.as_str())
199+
ModelBlock::new(model.as_str())
201200
.parameters(&strip_nulls(parameters))
202201
.input(PdlBlock::Array {
203-
array: vec![PdlBlock::Message(PdlMessageBlock {
202+
array: vec![PdlBlock::Message(MessageBlock {
204203
role: Role::Tool,
205204
description: None,
206205
name: Some("${ tool.function.name }".to_string()),
207206
tool_call_id: Some("${ tool.id }".to_string()),
208-
content: Box::new(PdlBlock::Call(PdlCallBlock {
207+
content: Box::new(PdlBlock::Call(CallBlock {
209208
defs: json_loads(
210209
&"args",
211210
&"pdl__args",
@@ -223,11 +222,11 @@ fn call_tools(model: &String, parameters: &HashMap<String, Value>) -> PdlBlock {
223222
let mut for_ = HashMap::new();
224223
for_.insert(
225224
"tool".to_string(),
226-
PdlListOrString::String("${ response.choices[0].message.tool_calls }".to_string()),
225+
ListOrString::String("${ response.choices[0].message.tool_calls }".to_string()),
227226
);
228227

229228
// response.choices[0].message.tool_calls
230-
PdlBlock::Repeat(PdlRepeatBlock {
229+
PdlBlock::Repeat(RepeatBlock {
231230
for_: for_,
232231
repeat: Box::new(repeat),
233232
})
@@ -242,7 +241,7 @@ fn json_loads(
242241
m.insert(
243242
outer_name.to_owned(),
244243
PdlBlock::Text(
245-
PdlTextBlock::new(vec![PdlBlock::String(format!(
244+
TextBlock::new(vec![PdlBlock::String(format!(
246245
"{{\"{}\": {}}}",
247246
inner_name, value
248247
))])
@@ -404,9 +403,9 @@ pub fn compile(
404403
.map(|((import_from, import_fn), tool_name, schema)| {
405404
(
406405
tool_name.clone(),
407-
PdlBlock::Function(PdlFunctionBlock {
406+
PdlBlock::Function(FunctionBlock {
408407
function: schema,
409-
return_: Box::new(PdlBlock::PythonCode(PdlPythonCodeBlock {
408+
return_: Box::new(PdlBlock::PythonCode(PythonCodeBlock {
410409
// tool function definition
411410
lang: "python".to_string(),
412411
code: format!(
@@ -468,7 +467,7 @@ asyncio.run(invoke())
468467
let model = format!("{}/{}", provider, model);
469468

470469
if let Some(instructions) = instructions {
471-
model_call.push(PdlBlock::Text(PdlTextBlock {
470+
model_call.push(PdlBlock::Text(TextBlock {
472471
role: Some(Role::System),
473472
text: vec![PdlBlock::String(instructions)],
474473
def: None,
@@ -487,7 +486,7 @@ asyncio.run(invoke())
487486
None
488487
};
489488

490-
model_call.push(PdlBlock::Model(PdlModelBlock {
489+
model_call.push(PdlBlock::Model(ModelBlock {
491490
input: None,
492491
description: Some(description),
493492
def: None,
@@ -508,9 +507,9 @@ asyncio.run(invoke())
508507
let mut defs = HashMap::new();
509508
defs.insert(
510509
closure_name.clone(),
511-
PdlBlock::Function(PdlFunctionBlock {
510+
PdlBlock::Function(FunctionBlock {
512511
function: HashMap::new(),
513-
return_: Box::new(PdlBlock::Text(PdlTextBlock {
512+
return_: Box::new(PdlBlock::Text(TextBlock {
514513
def: None,
515514
defs: None,
516515
role: None,
@@ -520,13 +519,13 @@ asyncio.run(invoke())
520519
})),
521520
}),
522521
);
523-
PdlBlock::Text(PdlTextBlock {
522+
PdlBlock::Text(TextBlock {
524523
def: None,
525524
defs: Some(defs),
526525
role: None,
527526
parser: None,
528527
description: Some("Model call wrapper".to_string()),
529-
text: vec![PdlBlock::Call(PdlCallBlock::new(format!(
528+
text: vec![PdlBlock::Call(CallBlock::new(format!(
530529
"${{ {} }}",
531530
closure_name
532531
)))],
@@ -539,15 +538,15 @@ asyncio.run(invoke())
539538
.flat_map(|(a, b)| [a, b])
540539
.collect::<Vec<_>>();
541540

542-
let pdl: PdlBlock = PdlBlock::Text(PdlTextBlock {
541+
let pdl: PdlBlock = PdlBlock::Text(TextBlock {
543542
def: None,
544543
defs: if tool_declarations.len() == 0 {
545544
None
546545
} else {
547546
let mut m = HashMap::new();
548547
m.insert(
549548
"pdl__tools".to_string(),
550-
PdlBlock::Object(PdlObjectBlock {
549+
PdlBlock::Object(ObjectBlock {
551550
object: tool_declarations,
552551
}),
553552
);

0 commit comments

Comments
 (0)