Skip to content

Commit 89075e9

Browse files
committed
added test
1 parent b0c91d7 commit 89075e9

File tree

1 file changed

+105
-0
lines changed

1 file changed

+105
-0
lines changed

workflows/tests/parse_test.rs

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
use dkn_workflows::Workflow;
2+
3+
#[test]
4+
fn test_parse_example() -> eyre::Result<()> {
5+
let object = serde_json::json!({
6+
"config":{
7+
"max_steps":50,
8+
"max_time":50,
9+
"tools":[
10+
"ALL"
11+
],
12+
"custom_tools":null,
13+
"max_tokens":null
14+
},
15+
"external_memory":{
16+
"topic":"Machine Learning",
17+
"n_subtopics":"10"
18+
},
19+
"tasks":[
20+
{
21+
"id":"generate_subtopics",
22+
"name":"Task",
23+
"description":"Task Description",
24+
"messages":[
25+
{
26+
"role":"user",
27+
"content":"Given a topic, generate a list of {{n_subtopics}} subtopics that are related to the topic.\nThe topic is: {{topic}}\nThe list must be without numbers, and without any description of the subtopics. \nThe subtopics should be separated by a comma. There must be no other text than the list.\n"
28+
}
29+
],
30+
"schema":null,
31+
"inputs":[
32+
{
33+
"name":"n_subtopics",
34+
"value":{
35+
"type":"read",
36+
"index":null,
37+
"search_query":null,
38+
"key":"n_subtopics"
39+
},
40+
"required":true
41+
},
42+
{
43+
"name":"topic",
44+
"value":{
45+
"type":"read",
46+
"index":null,
47+
"search_query":null,
48+
"key":"topic"
49+
},
50+
"required":true
51+
}
52+
],
53+
"operator":"generation",
54+
"outputs":[
55+
{
56+
"type":"write",
57+
"key":"subtopics",
58+
"value":"__result"
59+
}
60+
]
61+
},
62+
{
63+
"id":"_end",
64+
"name":"Task",
65+
"description":"Task Description",
66+
"messages":[
67+
{
68+
"role":"user",
69+
"content":""
70+
}
71+
],
72+
"schema":null,
73+
"inputs":[
74+
75+
],
76+
"operator":"end",
77+
"outputs":[
78+
79+
]
80+
}
81+
],
82+
"steps":[
83+
{
84+
"source":"generate_subtopics",
85+
"target":"_end",
86+
"condition":null,
87+
"fallback":null
88+
}
89+
],
90+
"return_value":{
91+
"input":{
92+
"type":"read",
93+
"index":null,
94+
"search_query":null,
95+
"key":"subtopics"
96+
},
97+
"to_json":false,
98+
"post_process":null
99+
}
100+
});
101+
102+
serde_json::from_value::<Workflow>(object)?;
103+
104+
Ok(())
105+
}

0 commit comments

Comments
 (0)