Fix few more nits

This commit is contained in:
jimmyfraiture
2025-10-01 13:32:18 +01:00
parent 0a75a69ae6
commit 9921a061ed
2 changed files with 16 additions and 1 deletions

View File

@@ -1,5 +1,6 @@
use async_trait::async_trait;
use serde::Deserialize;
use tokio::fs;
use crate::function_tool::FunctionCallError;
use crate::protocol::InputItem;
@@ -47,6 +48,20 @@ impl ToolHandler for ViewImageHandler {
})?;
let abs_path = turn.resolve_path(Some(args.path));
let metadata = fs::metadata(&abs_path).await.map_err(|error| {
FunctionCallError::RespondToModel(format!(
"unable to locate image at `{}`: {error}",
abs_path.display()
))
})?;
if !metadata.is_file() {
return Err(FunctionCallError::RespondToModel(format!(
"image path `{}` is not a file",
abs_path.display()
)));
}
session
.inject_input(vec![InputItem::LocalImage { path: abs_path }])
.await

View File

@@ -31,7 +31,7 @@ pub use router::Router;
use serde::Serialize;
use tracing::trace;
// Model-formatting limits: clients get full streams; oonly content sent to the model is truncated.
// Model-formatting limits: clients get full streams; only content sent to the model is truncated.
pub(crate) const MODEL_FORMAT_MAX_BYTES: usize = 10 * 1024; // 10 KiB
pub(crate) const MODEL_FORMAT_MAX_LINES: usize = 256; // lines
pub(crate) const MODEL_FORMAT_HEAD_LINES: usize = MODEL_FORMAT_MAX_LINES / 2;