feat: add cli backend invocation specs
This commit is contained in:
1 parent
3969f12f26
commit
f538fc60bb
4 files changed
+108
-8
No files matched your search
@@ -614,15 +614,40 @@ fn preview_effect(action: &str, detail: Option<&str>) -> String {
|
||||
}
|
||||
|
||||
fn backend_invocation(cli: &Cli) -> BackendInvocation {
|
||||
let preview = execution_preview(
|
||||
cli,
|
||||
&execution_stub(&execution_contract(&plan_command(cli))),
|
||||
);
|
||||
|
||||
match preview {
|
||||
ExecutionPreview::SummaryOnly { command } => BackendInvocation::SummaryOnly { command },
|
||||
match &cli.command {
|
||||
Commands::Status => BackendInvocation::HttpCall {
|
||||
method: "GET",
|
||||
url: format!("{}/health", cli.server.trim_end_matches('/')),
|
||||
api_key_present: cli.api_key.is_some(),
|
||||
body: None,
|
||||
},
|
||||
Commands::Models(models) => match &models.command {
|
||||
ModelsSubcommand::List => BackendInvocation::HttpCall {
|
||||
method: "GET",
|
||||
url: format!("{}/v1/models", cli.server.trim_end_matches('/')),
|
||||
api_key_present: cli.api_key.is_some(),
|
||||
body: None,
|
||||
},
|
||||
_ => BackendInvocation::SummaryOnly {
|
||||
command: command_summary(&cli.command),
|
||||
},
|
||||
},
|
||||
Commands::Bench(bench) => match &bench.command {
|
||||
BenchSubcommand::Throughput(args) => BackendInvocation::HttpCall {
|
||||
method: "POST",
|
||||
url: format!("{}/v1/chat/completions", cli.server.trim_end_matches('/')),
|
||||
api_key_present: cli.api_key.is_some(),
|
||||
body: Some(format!(
|
||||
"model={} samples={} prompt_tokens={} completion_tokens={} stream=false",
|
||||
args.model, args.samples, args.prompt_tokens, args.completion_tokens
|
||||
)),
|
||||
},
|
||||
_ => BackendInvocation::SummaryOnly {
|
||||
command: command_summary(&cli.command),
|
||||
},
|
||||
},
|
||||
_ => BackendInvocation::SummaryOnly {
|
||||
command: "backend-unimplemented".to_owned(),
|
||||
command: command_summary(&cli.command),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user