@arizeai/phoenix-client
Version:
A client for the Phoenix API
69 lines • 2.44 kB
JavaScript
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.openAIToolDefinitionSchema = void 0;
exports.createOpenAIToolDefinition = createOpenAIToolDefinition;
const jsonSchema_1 = require("../../jsonSchema");
const zod_1 = __importDefault(require("zod"));
/**
* The schema for an OpenAI tool definition
* @see https://platform.openai.com/docs/guides/structured-outputs/supported-schemas
*
* Note: The nested passThrough's are used to allow for extra keys in JSON schema, however, they do not actually
* allow for extra keys when the zod schema is used for parsing. This is to allow more flexibility for users
* to define their own tools according
*/
exports.openAIToolDefinitionSchema = zod_1.default
.object({
type: zod_1.default.literal("function").describe("The type of the tool"),
function: zod_1.default
.object({
name: zod_1.default.string().describe("The name of the function"),
description: zod_1.default
.string()
.optional()
.describe("A description of the function"),
parameters: jsonSchema_1.jsonSchemaZodSchema
.extend({
strict: zod_1.default
.boolean()
.optional()
.describe("Whether or not the arguments should exactly match the function definition, only supported for OpenAI models"),
})
.describe("The parameters that the function accepts"),
})
.passthrough()
.describe("The function definition"),
})
.passthrough();
/*
*
* Conversion Helpers
*
*/
/**
* Creates an OpenAI tool definition
* @param toolNumber the number of the tool in that instance for example instance.tools.length + 1 to be used to fill in the name
* @returns an OpenAI tool definition
*/
function createOpenAIToolDefinition(toolNumber) {
return {
type: "function",
function: {
name: `new_function_${toolNumber}`,
description: "",
parameters: {
type: "object",
properties: {
new_arg: {
type: "string",
},
},
required: [],
},
},
};
}
//# sourceMappingURL=toolSchemas.js.map