@langchain/azure-openai
Version:
Azure SDK for OpenAI integrations for LangChain.js
44 lines (43 loc) • 996 B
TypeScript
/**
* Formatting function definitions for calculating openai function defination token usage.
*
* https://github.com/hmarr/openai-chat-tokens/blob/main/src/functions.ts
* (c) 2023 Harry Marr
* MIT license
*/
import { FunctionDefinition } from "@azure/openai";
export interface FunctionDef extends Omit<FunctionDefinition, "parameters"> {
name: string;
description?: string;
parameters: ObjectProp;
}
interface ObjectProp {
type: "object";
properties?: {
[key: string]: Prop;
};
required?: string[];
}
interface AnyOfProp {
anyOf: Prop[];
}
type Prop = {
description?: string;
} & (AnyOfProp | ObjectProp | {
type: "string";
enum?: string[];
} | {
type: "number" | "integer";
minimum?: number;
maximum?: number;
enum?: number[];
} | {
type: "boolean";
} | {
type: "null";
} | {
type: "array";
items?: Prop;
});
export declare function formatFunctionDefinitions(functions: FunctionDef[]): string;
export {};