Skip to content

Commit 6855bbf

Browse files
Refactor Class Name Logging (#4426)
* Add className property to various LLM and embedder classes to fix logging bug after minification * Fix bug with this.log method by applying the missing private field symbol
1 parent 473ff90 commit 6855bbf

File tree

30 files changed

+60
-30
lines changed

30 files changed

+60
-30
lines changed

server/utils/AiProviders/anthropic/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class AnthropicLLM {
1515
if (!process.env.ANTHROPIC_API_KEY)
1616
throw new Error("No Anthropic API key was set.");
1717

18+
this.className = "AnthropicLLM";
1819
// Docs: https://www.npmjs.com/package/@anthropic-ai/sdk
1920
const AnthropicAI = require("@anthropic-ai/sdk");
2021
const anthropic = new AnthropicAI({
@@ -37,7 +38,7 @@ class AnthropicLLM {
3738
}
3839

3940
log(text, ...args) {
40-
console.log(`\x1b[36m[${this.constructor.name}]\x1b[0m ${text}`, ...args);
41+
console.log(`\x1b[36m[${this.className}]\x1b[0m ${text}`, ...args);
4142
}
4243

4344
streamingEnabled() {

server/utils/AiProviders/apipie/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class ApiPieLLM {
2323
if (!process.env.APIPIE_LLM_API_KEY)
2424
throw new Error("No ApiPie LLM API key was set.");
2525

26+
this.className = "ApiPieLLM";
2627
const { OpenAI: OpenAIApi } = require("openai");
2728
this.basePath = "https://apipie.ai/v1";
2829
this.openai = new OpenAIApi({
@@ -49,7 +50,7 @@ class ApiPieLLM {
4950
}
5051

5152
log(text, ...args) {
52-
console.log(`\x1b[36m[${this.constructor.name}]\x1b[0m ${text}`, ...args);
53+
console.log(`\x1b[36m[${this.className}]\x1b[0m ${text}`, ...args);
5354
}
5455

5556
// This checks if the .cached_at file has a timestamp that is more than 1Week (in millis)

server/utils/AiProviders/cometapi/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class CometApiLLM {
2424
if (!process.env.COMETAPI_LLM_API_KEY)
2525
throw new Error("No CometAPI API key was set.");
2626

27+
this.className = "CometApiLLM";
2728
const { OpenAI: OpenAIApi } = require("openai");
2829
this.basePath = "https://api.cometapi.com/v1";
2930
this.openai = new OpenAIApi({
@@ -55,7 +56,7 @@ class CometApiLLM {
5556
}
5657

5758
log(text, ...args) {
58-
console.log(`\x1b[36m[${this.constructor.name}]\x1b[0m ${text}`, ...args);
59+
console.log(`\x1b[36m[${this.className}]\x1b[0m ${text}`, ...args);
5960
}
6061

6162
/**

server/utils/AiProviders/deepseek/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class DeepSeekLLM {
1313
constructor(embedder = null, modelPreference = null) {
1414
if (!process.env.DEEPSEEK_API_KEY)
1515
throw new Error("No DeepSeek API key was set.");
16+
this.className = "DeepSeekLLM";
1617
const { OpenAI: OpenAIApi } = require("openai");
1718

1819
this.openai = new OpenAIApi({
@@ -35,7 +36,7 @@ class DeepSeekLLM {
3536
}
3637

3738
log(text, ...args) {
38-
console.log(`\x1b[36m[${this.constructor.name}]\x1b[0m ${text}`, ...args);
39+
console.log(`\x1b[36m[${this.className}]\x1b[0m ${text}`, ...args);
3940
}
4041

4142
#appendContext(contextTexts = []) {

server/utils/AiProviders/dellProAiStudio/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ class DellProAiStudioLLM {
1313
if (!process.env.DPAIS_LLM_BASE_PATH)
1414
throw new Error("No Dell Pro AI Studio Base Path was set.");
1515

16+
this.className = "DellProAiStudioLLM";
1617
const { OpenAI: OpenAIApi } = require("openai");
1718
this.dpais = new OpenAIApi({
1819
baseURL: DellProAiStudioLLM.parseBasePath(),
@@ -50,7 +51,7 @@ class DellProAiStudioLLM {
5051
}
5152

5253
log(text, ...args) {
53-
console.log(`\x1b[36m[${this.constructor.name}]\x1b[0m ${text}`, ...args);
54+
console.log(`\x1b[36m[${this.className}]\x1b[0m ${text}`, ...args);
5455
}
5556

5657
#appendContext(contextTexts = []) {

server/utils/AiProviders/gemini/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class GeminiLLM {
2929
if (!process.env.GEMINI_API_KEY)
3030
throw new Error("No Gemini API key was set.");
3131

32+
this.className = "GeminiLLM";
3233
const { OpenAI: OpenAIApi } = require("openai");
3334
this.model =
3435
modelPreference ||
@@ -71,7 +72,7 @@ class GeminiLLM {
7172
}
7273

7374
#log(text, ...args) {
74-
console.log(`\x1b[32m[GeminiLLM]\x1b[0m ${text}`, ...args);
75+
console.log(`\x1b[32m[${this.className}]\x1b[0m ${text}`, ...args);
7576
}
7677

7778
// This checks if the .cached_at file has a timestamp that is more than 1Week (in millis)

server/utils/AiProviders/genericOpenAi/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class GenericOpenAiLLM {
1818
"GenericOpenAI must have a valid base path to use for the api."
1919
);
2020

21+
this.className = "GenericOpenAiLLM";
2122
this.basePath = process.env.GENERIC_OPEN_AI_BASE_PATH;
2223
this.openai = new OpenAIApi({
2324
baseURL: this.basePath,
@@ -45,7 +46,7 @@ class GenericOpenAiLLM {
4546
}
4647

4748
log(text, ...args) {
48-
console.log(`\x1b[36m[${this.constructor.name}]\x1b[0m ${text}`, ...args);
49+
console.log(`\x1b[36m[${this.className}]\x1b[0m ${text}`, ...args);
4950
}
5051

5152
#appendContext(contextTexts = []) {

server/utils/AiProviders/koboldCPP/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class KoboldCPPLLM {
1717
"KoboldCPP must have a valid base path to use for the api."
1818
);
1919

20+
this.className = "KoboldCPPLLM";
2021
this.basePath = process.env.KOBOLD_CPP_BASE_PATH;
2122
this.openai = new OpenAIApi({
2223
baseURL: this.basePath,
@@ -37,7 +38,7 @@ class KoboldCPPLLM {
3738
}
3839

3940
log(text, ...args) {
40-
console.log(`\x1b[36m[${this.constructor.name}]\x1b[0m ${text}`, ...args);
41+
console.log(`\x1b[36m[${this.className}]\x1b[0m ${text}`, ...args);
4142
}
4243

4344
#appendContext(contextTexts = []) {

server/utils/AiProviders/liteLLM/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class LiteLLM {
1515
"LiteLLM must have a valid base path to use for the api."
1616
);
1717

18+
this.className = "LiteLLM";
1819
this.basePath = process.env.LITE_LLM_BASE_PATH;
1920
this.openai = new OpenAIApi({
2021
baseURL: this.basePath,
@@ -35,7 +36,7 @@ class LiteLLM {
3536
}
3637

3738
log(text, ...args) {
38-
console.log(`\x1b[36m[${this.constructor.name}]\x1b[0m ${text}`, ...args);
39+
console.log(`\x1b[36m[${this.className}]\x1b[0m ${text}`, ...args);
3940
}
4041

4142
#appendContext(contextTexts = []) {

server/utils/AiProviders/mistral/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class MistralLLM {
1212
if (!process.env.MISTRAL_API_KEY)
1313
throw new Error("No Mistral API key was set.");
1414

15+
this.className = "MistralLLM";
1516
const { OpenAI: OpenAIApi } = require("openai");
1617
this.openai = new OpenAIApi({
1718
baseURL: "https://api.mistral.ai/v1",
@@ -31,7 +32,7 @@ class MistralLLM {
3132
}
3233

3334
log(text, ...args) {
34-
console.log(`\x1b[36m[${this.constructor.name}]\x1b[0m ${text}`, ...args);
35+
console.log(`\x1b[36m[${this.className}]\x1b[0m ${text}`, ...args);
3536
}
3637

3738
#appendContext(contextTexts = []) {

0 commit comments

Comments
 (0)