Add eval runner and tool orchestration
This commit is contained in:
1 parent
4294f3c92e
commit
5579db54da
66 files changed
+6162
-242
No files matched your search
@@ -0,0 +1,42 @@
|
||||
import { z } from "zod";
|
||||
import type { Tool } from "./tool.js";
|
||||
|
||||
export interface OpenAiToolDefinition {
|
||||
type: "function";
|
||||
function: {
|
||||
name: string;
|
||||
description: string;
|
||||
parameters: unknown;
|
||||
};
|
||||
}
|
||||
|
||||
function toToolDescriptor(tool: Tool<unknown, unknown>): {
|
||||
name: string;
|
||||
description: string;
|
||||
parameters: unknown;
|
||||
} {
|
||||
return {
|
||||
name: tool.name,
|
||||
description: tool.description,
|
||||
parameters: z.toJSONSchema(tool.argsSchema),
|
||||
};
|
||||
}
|
||||
|
||||
export function serializeToolsForHermes(
|
||||
tools: readonly Tool<unknown, unknown>[],
|
||||
): string {
|
||||
const descriptors = tools.map(toToolDescriptor);
|
||||
return `<tools>\n${JSON.stringify(descriptors, null, 2)}\n</tools>`;
|
||||
}
|
||||
|
||||
export function serializeToolsForOpenAi(
|
||||
tools: readonly Tool<unknown, unknown>[],
|
||||
): OpenAiToolDefinition[] {
|
||||
return tools.map((tool) => {
|
||||
const descriptor = toToolDescriptor(tool);
|
||||
return {
|
||||
type: "function",
|
||||
function: descriptor,
|
||||
};
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user