Skip to content

Commit

Permalink
added test
Browse files Browse the repository at this point in the history
  • Loading branch information
erhant committed Nov 16, 2024
1 parent b0c91d7 commit 89075e9
Showing 1 changed file with 105 additions and 0 deletions.
105 changes: 105 additions & 0 deletions workflows/tests/parse_test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
use dkn_workflows::Workflow;

#[test]
fn test_parse_example() -> eyre::Result<()> {
let object = serde_json::json!({
"config":{
"max_steps":50,
"max_time":50,
"tools":[
"ALL"
],
"custom_tools":null,
"max_tokens":null
},
"external_memory":{
"topic":"Machine Learning",
"n_subtopics":"10"
},
"tasks":[
{
"id":"generate_subtopics",
"name":"Task",
"description":"Task Description",
"messages":[
{
"role":"user",
"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"
}
],
"schema":null,
"inputs":[
{
"name":"n_subtopics",
"value":{
"type":"read",
"index":null,
"search_query":null,
"key":"n_subtopics"
},
"required":true
},
{
"name":"topic",
"value":{
"type":"read",
"index":null,
"search_query":null,
"key":"topic"
},
"required":true
}
],
"operator":"generation",
"outputs":[
{
"type":"write",
"key":"subtopics",
"value":"__result"
}
]
},
{
"id":"_end",
"name":"Task",
"description":"Task Description",
"messages":[
{
"role":"user",
"content":""
}
],
"schema":null,
"inputs":[

],
"operator":"end",
"outputs":[

]
}
],
"steps":[
{
"source":"generate_subtopics",
"target":"_end",
"condition":null,
"fallback":null
}
],
"return_value":{
"input":{
"type":"read",
"index":null,
"search_query":null,
"key":"subtopics"
},
"to_json":false,
"post_process":null
}
});

serde_json::from_value::<Workflow>(object)?;

Ok(())
}

0 comments on commit 89075e9

Please sign in to comment.