mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-05 10:53:59 +00:00
feat: share the tool catalog with voice
This commit is contained in:
1 parent
0953ebb026
commit
1a03e7483d
19 files changed
+288
-15
No files matched your search
@@ -0,0 +1,28 @@
|
||||
/** Function-calling adapter for a tool catalog: tool records and results. */
|
||||
|
||||
/** Tools as `{ type: 'function', name, description, parameters }` records. */
|
||||
export function toFunctionTools(tools, { exclude = [] } = {}) {
|
||||
const skipped = new Set(exclude);
|
||||
return tools
|
||||
.filter((tool) => !skipped.has(tool.name))
|
||||
.map((tool) => ({
|
||||
type: 'function',
|
||||
name: tool.name,
|
||||
description: tool.description,
|
||||
parameters: structuredClone(tool.inputSchema),
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* A tool result as one JSON function output. Images are counted rather than
|
||||
* sent, since function outputs carry text.
|
||||
*/
|
||||
export function toFunctionOutput(name, result) {
|
||||
return {
|
||||
ok: true,
|
||||
tool: name,
|
||||
summary: result.summary,
|
||||
data: result.data,
|
||||
...(result.images?.length ? { images_omitted: result.images.length } : {}),
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user