Skip to content

Commit

Permalink
⚡️ Enable isolatedDeclarations (#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
NatoBoram authored Jul 18, 2024
1 parent 90f12a6 commit 4b5b966
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/token-counts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
/* Interop Constraints */
"isolatedModules": true,
"verbatimModuleSyntax": true,
"isolatedDeclarations": true,
"forceConsistentCasingInFileNames": true,

/* Type Checking */
Expand Down

0 comments on commit 4b5b966

Please sign in to comment.