Skip to content

Commit da20fec

Browse files
committed
add workflow test [skip ci]
1 parent 83a8c1c commit da20fec

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

compute/src/node/diagnostic.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ impl DriaComputeNode {
1111
/// Returns the task count within the channels, `single` and `batch`.
1212
#[inline(always)]
1313
pub fn get_pending_task_count(&self) -> [usize; 2] {
14+
// TODO: return the number of tasks in the channels as well
1415
[
1516
self.pending_tasks_single.len(),
1617
self.pending_tasks_batch.len(),

workflows/tests/workflow_test.rs

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
use dkn_workflows::{Executor, Model, Workflow};
2+
3+
#[tokio::test]
4+
#[ignore = "requires API keys"]
5+
async fn test_workflow() {
6+
dotenvy::dotenv().ok(); // read api key
7+
let workflow = serde_json::from_value::<Workflow>(serde_json::json!({
8+
"steps": [{ "source": "A", "target": "__end" }],
9+
"tasks": [
10+
{
11+
"id": "A",
12+
"name": "",
13+
"outputs": [
14+
{
15+
"key": "result",
16+
"type": "write",
17+
"value": "__result"
18+
}
19+
],
20+
"messages": [
21+
{
22+
"role": "user",
23+
"content": "Hey there."
24+
}
25+
],
26+
"operator": "generation",
27+
"description": ""
28+
},
29+
{
30+
"id": "__end",
31+
"name": "end",
32+
"messages": [
33+
{
34+
"role": "user",
35+
"content": "End of the task"
36+
}
37+
],
38+
"operator": "end",
39+
"description": "End of the task"
40+
}
41+
],
42+
"config": {
43+
"tools": [
44+
"ALL"
45+
],
46+
"max_time": 250,
47+
"max_steps": 10
48+
},
49+
"return_value": {
50+
"input": {
51+
"key": "result",
52+
"type": "read"
53+
}
54+
}
55+
}))
56+
.unwrap();
57+
58+
let executor = Executor::new(Model::GPT4oMini);
59+
let result = executor
60+
.execute(None, &workflow, &mut Default::default())
61+
.await
62+
.unwrap();
63+
println!("Result: {:?}", result);
64+
}

0 commit comments

Comments
 (0)