Skip to content

⚡️ Enable isolatedDeclarations #39

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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