This commit is contained in:
GPT10
2024-07-20 11:03:05 +03:00
committed by GitHub
parent 37fb140563
commit bebbed856f
35 changed files with 15123 additions and 7395 deletions
+4 -3
View File
@@ -66,7 +66,8 @@ if (provider === 'openai' &&
process.exit(1);
}
class OpenAi implements AiEngine {
export class OpenAi implements AiEngine {
private openAiApiConfiguration = new OpenAiApiConfiguration({
apiKey: apiKey
});
@@ -91,7 +92,7 @@ class OpenAi implements AiEngine {
};
try {
const REQUEST_TOKENS = messages
.map((msg) => tokenCount(msg.content) + 4)
.map((msg) => tokenCount(msg.content as string) + 4)
.reduce((a, b) => a + b, 0);
if (REQUEST_TOKENS > MAX_TOKENS_INPUT - MAX_TOKENS_OUTPUT) {
@@ -124,6 +125,6 @@ class OpenAi implements AiEngine {
throw err;
}
};
}
export const api = new OpenAi();