41 lines
1.6 KiB
Rust
41 lines
1.6 KiB
Rust
//! On a host that answers `ai.complete` itself, an unanswered ask produces nothing.
|
|
//!
|
|
//! The local completer exists so a graph runs headless — the CLI, an agent session — with
|
|
//! no model attached. In the editor page it was wrong: with no model loaded, the front
|
|
//! panel showed its stand-in (`answer: <the prompt's words>`) as the node's reply while
|
|
//! the page's own Local AI panel said the same node was waiting for a model.
|
|
|
|
use flowrs_core::graph::runtime::Runtime;
|
|
use flowrs_core::graph::widget::{ExecContext, WidgetRegistry};
|
|
use std::collections::HashMap;
|
|
|
|
/// The editor page answers `ai.complete` itself, so an ask it has not answered yet must
|
|
/// produce nothing there — not the local completer's stand-in, shown as the node's reply
|
|
/// while the page's own panel says the node is waiting for a model.
|
|
#[test]
|
|
fn a_host_that_answers_completions_gets_no_stand_in_reply() {
|
|
let reg = WidgetRegistry::with_builtins();
|
|
let complete = reg.get("ai.complete").unwrap();
|
|
let props = HashMap::from([("prompt".to_string(), "Reply with one word: ready".into())]);
|
|
|
|
let headless = Runtime::new();
|
|
let out = complete.execute(
|
|
&ExecContext::for_widget(complete, &props).with_runtime(headless),
|
|
HashMap::new(),
|
|
);
|
|
assert!(
|
|
out.contains_key("text"),
|
|
"headless, the local completer answers"
|
|
);
|
|
|
|
let page = Runtime::new();
|
|
page.set_answers_completions(true);
|
|
let out = complete.execute(
|
|
&ExecContext::for_widget(complete, &props).with_runtime(page),
|
|
HashMap::new(),
|
|
);
|
|
assert!(
|
|
out.is_empty(),
|
|
"an unanswered ask waits for the host: {out:?}"
|
|
);
|
|
}
|