use futures::{future::BoxFuture, stream::BoxStream};
use crate::_prelude::*;
pub trait ToolT
where
Self: Send + Sync,
{
fn name(&self) -> &str;
fn description(&self) -> &str;
fn schema(&self) -> Value;
fn call(&self, params: Value) -> BoxFuture<'static, Result<Value>>;
fn call_stream(
&self,
#[allow(unused)] params: Value,
) -> BoxFuture<'static, Result<BoxStream<'static, String>>> {
let tool = self.name().to_owned();
Box::pin(async move { Err(ToolError::StreamingNotSupported(tool))? })
}
fn supports_stream(&self) -> bool {
false
}
}
#[derive(Clone, Debug)]
pub struct ToolCall {
pub name: String,
pub args: Value,
}
#[derive(Clone, Debug)]
pub struct ToolCallResult {
pub tool_call: ToolCall,
pub outcome: ToolCallOutcome,
}
#[derive(Clone, Debug)]
pub enum ToolCallOutcome {
Success { result: Value },
Error { message: String },
}