Skip to content

Commit 4b5b966

Browse files
authored
⚡️ Enable isolatedDeclarations (#39)
1 parent 90f12a6 commit 4b5b966

File tree

3 files changed

+3
-2
lines changed

3 files changed

+3
-2
lines changed

src/functions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export function isAnyOfProp(prop: Prop): prop is AnyOfProp {
5656
/** When OpenAI use functions in the prompt, they format them as TypeScript
5757
* definitions rather than OpenAPI JSON schemas. This function converts the JSON
5858
* schemas into TypeScript definitions. */
59-
export function formatFunctionDefinitions(functions: FunctionDef[]) {
59+
export function formatFunctionDefinitions(functions: FunctionDef[]): string {
6060
const lines = ["namespace functions {", ""]
6161
for (const f of functions) {
6262
if (f.description) {

src/token-counts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export function messageTokensEstimate(message: Message): number {
122122
* @param funcs An array of OpenAI function definitions
123123
* @returns An estimate for the number of tokens the function definitions will use
124124
*/
125-
export function functionsTokensEstimate(funcs: FunctionDef[]) {
125+
export function functionsTokensEstimate(funcs: FunctionDef[]): number {
126126
const promptDefinitions = formatFunctionDefinitions(funcs)
127127
let tokens = stringTokens(promptDefinitions)
128128
tokens += 9 // Add nine per completion

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
/* Interop Constraints */
3232
"isolatedModules": true,
3333
"verbatimModuleSyntax": true,
34+
"isolatedDeclarations": true,
3435
"forceConsistentCasingInFileNames": true,
3536

3637
/* Type Checking */

0 commit comments

Comments
 (0)