8ddee0f621
Change the required parameter name from 'filePath' to 'path' in the read_multi_modal tool's JSON schema to match the property definition and the ReadFileToolParams struct field name.
42 lines
1.1 KiB
C++
42 lines
1.1 KiB
C++
#include "tool.hpp"
|
|
#include "read_multi_modal.hpp"
|
|
#include "json_types.hpp"
|
|
#include "base64_util.hpp"
|
|
|
|
|
|
|
|
Tool make_read_multi_modal() {
|
|
return Tool{
|
|
.name = "read_multi_modal",
|
|
.description = ""
|
|
"Reads multi modal files (images, audio, etc)\n",
|
|
|
|
.parameters_schema = {
|
|
{"type", "object"},
|
|
{"properties", {
|
|
{"path", {
|
|
{"type", "string"},
|
|
{"description", "Absolute or relative path to multi modal file to read"}
|
|
}},
|
|
}},
|
|
{"required", {"path"}}
|
|
},
|
|
.execute = create_tool_execute<ReadFileToolParams>([](const ReadFileToolParams& params) -> Content {
|
|
std::vector<ContentPart> ret{};
|
|
|
|
ContentPart image_part;
|
|
image_part.type = "image_url";
|
|
ImageUrl img_url;
|
|
auto uri = read_image_as_data_uri(params.path);
|
|
if (!uri)
|
|
return "Failed to read image " + uri.error();
|
|
|
|
img_url.url = *uri;
|
|
image_part.image_url = img_url;
|
|
ret.push_back(image_part);
|
|
|
|
return ret;
|
|
})
|
|
};
|
|
}
|