atman_runtime/tools/
llm_call.rs1use crate::error::RuntimeError;
2use crate::eval::llm_args::parse_llm_args_from_toolargs;
3use crate::eval::llm_dispatch::dispatch_llm;
4use crate::tool::{BoxFut, Tier, Tool, ToolArgs, ToolCtx, ToolResult};
5use crate::value::Value;
6
7pub struct LlmCallTool;
8
9impl Tool for LlmCallTool {
10 fn name(&self) -> &str {
11 "llm.call"
12 }
13
14 fn tier(&self) -> Tier {
15 Tier::Zero
16 }
17
18 fn call<'a>(&'a self, args: ToolArgs, ctx: &'a ToolCtx) -> BoxFut<'a, ToolResult> {
19 Box::pin(async move {
20 let Some(registry) = ctx.registry.as_deref() else {
21 return Err(RuntimeError::ToolFailed(
22 "llm.call: no tool registry available".into(),
23 ));
24 };
25 let llm_args = parse_llm_args_from_toolargs(&args, registry)?;
26 let v = dispatch_llm(llm_args, ctx).await;
27 match v {
28 Value::Err(e) => Err(e),
29 other => Ok(other),
30 }
31 })
32 }
33}