diff --git a/src/functions.ts b/src/functions.ts index 60e9cc7..42d5a5d 100644 --- a/src/functions.ts +++ b/src/functions.ts @@ -56,7 +56,7 @@ export function isAnyOfProp(prop: Prop): prop is AnyOfProp { /** When OpenAI use functions in the prompt, they format them as TypeScript * definitions rather than OpenAPI JSON schemas. This function converts the JSON * schemas into TypeScript definitions. */ -export function formatFunctionDefinitions(functions: FunctionDef[]) { +export function formatFunctionDefinitions(functions: FunctionDef[]): string { const lines = ["namespace functions {", ""] for (const f of functions) { if (f.description) { diff --git a/src/token-counts.ts b/src/token-counts.ts index 6ce790d..70c4fa1 100644 --- a/src/token-counts.ts +++ b/src/token-counts.ts @@ -122,7 +122,7 @@ export function messageTokensEstimate(message: Message): number { * @param funcs An array of OpenAI function definitions * @returns An estimate for the number of tokens the function definitions will use */ -export function functionsTokensEstimate(funcs: FunctionDef[]) { +export function functionsTokensEstimate(funcs: FunctionDef[]): number { const promptDefinitions = formatFunctionDefinitions(funcs) let tokens = stringTokens(promptDefinitions) tokens += 9 // Add nine per completion diff --git a/tsconfig.json b/tsconfig.json index 72366af..7558d28 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -31,6 +31,7 @@ /* Interop Constraints */ "isolatedModules": true, "verbatimModuleSyntax": true, + "isolatedDeclarations": true, "forceConsistentCasingInFileNames": true, /* Type Checking */