θΏ™ζ˜―indexlocζδΎ›ηš„ζœεŠ‘οΌŒδΈθ¦θΎ“ε…₯任何密码
Skip to content
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
3 changes: 2 additions & 1 deletion server/utils/AiProviders/anthropic/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class AnthropicLLM {
if (!process.env.ANTHROPIC_API_KEY)
throw new Error("No Anthropic API key was set.");

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

log(text, ...args) {
console.log(`\x1b[36m[${this.constructor.name}]\x1b[0m ${text}`, ...args);
console.log(`\x1b[36m[${this.className}]\x1b[0m ${text}`, ...args);
}

streamingEnabled() {
Expand Down
3 changes: 2 additions & 1 deletion server/utils/AiProviders/apipie/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class ApiPieLLM {
if (!process.env.APIPIE_LLM_API_KEY)
throw new Error("No ApiPie LLM API key was set.");

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

log(text, ...args) {
console.log(`\x1b[36m[${this.constructor.name}]\x1b[0m ${text}`, ...args);
console.log(`\x1b[36m[${this.className}]\x1b[0m ${text}`, ...args);
}

// This checks if the .cached_at file has a timestamp that is more than 1Week (in millis)
Expand Down
3 changes: 2 additions & 1 deletion server/utils/AiProviders/cometapi/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class CometApiLLM {
if (!process.env.COMETAPI_LLM_API_KEY)
throw new Error("No CometAPI API key was set.");

this.className = "CometApiLLM";
const { OpenAI: OpenAIApi } = require("openai");
this.basePath = "https://api.cometapi.com/v1";
this.openai = new OpenAIApi({
Expand Down Expand Up @@ -55,7 +56,7 @@ class CometApiLLM {
}

log(text, ...args) {
console.log(`\x1b[36m[${this.constructor.name}]\x1b[0m ${text}`, ...args);
console.log(`\x1b[36m[${this.className}]\x1b[0m ${text}`, ...args);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion server/utils/AiProviders/deepseek/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class DeepSeekLLM {
constructor(embedder = null, modelPreference = null) {
if (!process.env.DEEPSEEK_API_KEY)
throw new Error("No DeepSeek API key was set.");
this.className = "DeepSeekLLM";
const { OpenAI: OpenAIApi } = require("openai");

this.openai = new OpenAIApi({
Expand All @@ -35,7 +36,7 @@ class DeepSeekLLM {
}

log(text, ...args) {
console.log(`\x1b[36m[${this.constructor.name}]\x1b[0m ${text}`, ...args);
console.log(`\x1b[36m[${this.className}]\x1b[0m ${text}`, ...args);
}

#appendContext(contextTexts = []) {
Expand Down
3 changes: 2 additions & 1 deletion server/utils/AiProviders/dellProAiStudio/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class DellProAiStudioLLM {
if (!process.env.DPAIS_LLM_BASE_PATH)
throw new Error("No Dell Pro AI Studio Base Path was set.");

this.className = "DellProAiStudioLLM";
const { OpenAI: OpenAIApi } = require("openai");
this.dpais = new OpenAIApi({
baseURL: DellProAiStudioLLM.parseBasePath(),
Expand Down Expand Up @@ -50,7 +51,7 @@ class DellProAiStudioLLM {
}

log(text, ...args) {
console.log(`\x1b[36m[${this.constructor.name}]\x1b[0m ${text}`, ...args);
console.log(`\x1b[36m[${this.className}]\x1b[0m ${text}`, ...args);
}

#appendContext(contextTexts = []) {
Expand Down
3 changes: 2 additions & 1 deletion server/utils/AiProviders/gemini/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class GeminiLLM {
if (!process.env.GEMINI_API_KEY)
throw new Error("No Gemini API key was set.");

this.className = "GeminiLLM";
const { OpenAI: OpenAIApi } = require("openai");
this.model =
modelPreference ||
Expand Down Expand Up @@ -71,7 +72,7 @@ class GeminiLLM {
}

#log(text, ...args) {
console.log(`\x1b[32m[GeminiLLM]\x1b[0m ${text}`, ...args);
console.log(`\x1b[32m[${this.className}]\x1b[0m ${text}`, ...args);
}

// This checks if the .cached_at file has a timestamp that is more than 1Week (in millis)
Expand Down
3 changes: 2 additions & 1 deletion server/utils/AiProviders/genericOpenAi/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class GenericOpenAiLLM {
"GenericOpenAI must have a valid base path to use for the api."
);

this.className = "GenericOpenAiLLM";
this.basePath = process.env.GENERIC_OPEN_AI_BASE_PATH;
this.openai = new OpenAIApi({
baseURL: this.basePath,
Expand Down Expand Up @@ -45,7 +46,7 @@ class GenericOpenAiLLM {
}

log(text, ...args) {
console.log(`\x1b[36m[${this.constructor.name}]\x1b[0m ${text}`, ...args);
console.log(`\x1b[36m[${this.className}]\x1b[0m ${text}`, ...args);
}

#appendContext(contextTexts = []) {
Expand Down
3 changes: 2 additions & 1 deletion server/utils/AiProviders/koboldCPP/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class KoboldCPPLLM {
"KoboldCPP must have a valid base path to use for the api."
);

this.className = "KoboldCPPLLM";
this.basePath = process.env.KOBOLD_CPP_BASE_PATH;
this.openai = new OpenAIApi({
baseURL: this.basePath,
Expand All @@ -37,7 +38,7 @@ class KoboldCPPLLM {
}

log(text, ...args) {
console.log(`\x1b[36m[${this.constructor.name}]\x1b[0m ${text}`, ...args);
console.log(`\x1b[36m[${this.className}]\x1b[0m ${text}`, ...args);
}

#appendContext(contextTexts = []) {
Expand Down
3 changes: 2 additions & 1 deletion server/utils/AiProviders/liteLLM/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class LiteLLM {
"LiteLLM must have a valid base path to use for the api."
);

this.className = "LiteLLM";
this.basePath = process.env.LITE_LLM_BASE_PATH;
this.openai = new OpenAIApi({
baseURL: this.basePath,
Expand All @@ -35,7 +36,7 @@ class LiteLLM {
}

log(text, ...args) {
console.log(`\x1b[36m[${this.constructor.name}]\x1b[0m ${text}`, ...args);
console.log(`\x1b[36m[${this.className}]\x1b[0m ${text}`, ...args);
}

#appendContext(contextTexts = []) {
Expand Down
3 changes: 2 additions & 1 deletion server/utils/AiProviders/mistral/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class MistralLLM {
if (!process.env.MISTRAL_API_KEY)
throw new Error("No Mistral API key was set.");

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

log(text, ...args) {
console.log(`\x1b[36m[${this.constructor.name}]\x1b[0m ${text}`, ...args);
console.log(`\x1b[36m[${this.className}]\x1b[0m ${text}`, ...args);
}

#appendContext(contextTexts = []) {
Expand Down
3 changes: 2 additions & 1 deletion server/utils/AiProviders/moonshotAi/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class MoonshotAiLLM {
constructor(embedder = null, modelPreference = null) {
if (!process.env.MOONSHOT_AI_API_KEY)
throw new Error("No Moonshot AI API key was set.");
this.className = "MoonshotAiLLM";
const { OpenAI: OpenAIApi } = require("openai");

this.openai = new OpenAIApi({
Expand All @@ -36,7 +37,7 @@ class MoonshotAiLLM {
}

log(text, ...args) {
console.log(`\x1b[36m[${this.constructor.name}]\x1b[0m ${text}`, ...args);
console.log(`\x1b[36m[${this.className}]\x1b[0m ${text}`, ...args);
}

#appendContext(contextTexts = []) {
Expand Down
3 changes: 2 additions & 1 deletion server/utils/AiProviders/novita/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class NovitaLLM {
if (!process.env.NOVITA_LLM_API_KEY)
throw new Error("No Novita API key was set.");

this.className = "NovitaLLM";
const { OpenAI: OpenAIApi } = require("openai");
this.basePath = "https://api.novita.ai/v3/openai";
this.openai = new OpenAIApi({
Expand Down Expand Up @@ -57,7 +58,7 @@ class NovitaLLM {
}

log(text, ...args) {
console.log(`\x1b[36m[${this.constructor.name}]\x1b[0m ${text}`, ...args);
console.log(`\x1b[36m[${this.className}]\x1b[0m ${text}`, ...args);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion server/utils/AiProviders/nvidiaNim/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class NvidiaNimLLM {
if (!process.env.NVIDIA_NIM_LLM_BASE_PATH)
throw new Error("No NVIDIA NIM API Base Path was set.");

this.className = "NvidiaNimLLM";
const { OpenAI: OpenAIApi } = require("openai");
this.nvidiaNim = new OpenAIApi({
baseURL: parseNvidiaNimBasePath(process.env.NVIDIA_NIM_LLM_BASE_PATH),
Expand All @@ -33,7 +34,7 @@ class NvidiaNimLLM {
}

#log(text, ...args) {
console.log(`\x1b[36m[${this.constructor.name}]\x1b[0m ${text}`, ...args);
console.log(`\x1b[36m[${this.className}]\x1b[0m ${text}`, ...args);
}

#appendContext(contextTexts = []) {
Expand Down
3 changes: 2 additions & 1 deletion server/utils/AiProviders/openAi/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const {
class OpenAiLLM {
constructor(embedder = null, modelPreference = null) {
if (!process.env.OPEN_AI_KEY) throw new Error("No OpenAI API key was set.");
this.className = "OpenAiLLM";
const { OpenAI: OpenAIApi } = require("openai");

this.openai = new OpenAIApi({
Expand All @@ -33,7 +34,7 @@ class OpenAiLLM {
}

log(text, ...args) {
console.log(`\x1b[36m[${this.constructor.name}]\x1b[0m ${text}`, ...args);
console.log(`\x1b[36m[${this.className}]\x1b[0m ${text}`, ...args);
}

#appendContext(contextTexts = []) {
Expand Down
3 changes: 2 additions & 1 deletion server/utils/AiProviders/openRouter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class OpenRouterLLM {
if (!process.env.OPENROUTER_API_KEY)
throw new Error("No OpenRouter API key was set.");

this.className = "OpenRouterLLM";
const { OpenAI: OpenAIApi } = require("openai");
this.basePath = "https://openrouter.ai/api/v1";
this.openai = new OpenAIApi({
Expand Down Expand Up @@ -88,7 +89,7 @@ class OpenRouterLLM {
}

log(text, ...args) {
console.log(`\x1b[36m[${this.constructor.name}]\x1b[0m ${text}`, ...args);
console.log(`\x1b[36m[${this.className}]\x1b[0m ${text}`, ...args);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion server/utils/AiProviders/ppio/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class PPIOLLM {
constructor(embedder = null, modelPreference = null) {
if (!process.env.PPIO_API_KEY) throw new Error("No PPIO API key was set.");

this.className = "PPIOLLM";
const { OpenAI: OpenAIApi } = require("openai");
this.basePath = "https://api.ppinfra.com/v3/openai/";
this.openai = new OpenAIApi({
Expand Down Expand Up @@ -50,7 +51,7 @@ class PPIOLLM {
}

log(text, ...args) {
console.log(`\x1b[36m[${this.constructor.name}]\x1b[0m ${text}`, ...args);
console.log(`\x1b[36m[${this.className}]\x1b[0m ${text}`, ...args);
}

async #syncModels() {
Expand Down
3 changes: 2 additions & 1 deletion server/utils/AiProviders/textGenWebUI/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class TextGenWebUILLM {
"TextGenWebUI must have a valid base path to use for the api."
);

this.className = "TextGenWebUILLM";
this.basePath = process.env.TEXT_GEN_WEB_UI_BASE_PATH;
this.openai = new OpenAIApi({
baseURL: this.basePath,
Expand All @@ -33,7 +34,7 @@ class TextGenWebUILLM {
}

log(text, ...args) {
console.log(`\x1b[36m[${this.constructor.name}]\x1b[0m ${text}`, ...args);
console.log(`\x1b[36m[${this.className}]\x1b[0m ${text}`, ...args);
}

#appendContext(contextTexts = []) {
Expand Down
3 changes: 2 additions & 1 deletion server/utils/AiProviders/xai/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class XAiLLM {
constructor(embedder = null, modelPreference = null) {
if (!process.env.XAI_LLM_API_KEY)
throw new Error("No xAI API key was set.");
this.className = "XAiLLM";
const { OpenAI: OpenAIApi } = require("openai");

this.openai = new OpenAIApi({
Expand All @@ -34,7 +35,7 @@ class XAiLLM {
}

log(text, ...args) {
console.log(`\x1b[36m[${this.constructor.name}]\x1b[0m ${text}`, ...args);
console.log(`\x1b[36m[${this.className}]\x1b[0m ${text}`, ...args);
}

#appendContext(contextTexts = []) {
Expand Down
3 changes: 2 additions & 1 deletion server/utils/EmbeddingEngines/azureOpenAi/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class AzureOpenAiEmbedder {
if (!process.env.AZURE_OPENAI_KEY)
throw new Error("No Azure API key was set.");

this.className = "AzureOpenAiEmbedder";
this.apiVersion = "2024-12-01-preview";
const openai = new AzureOpenAI({
apiKey: process.env.AZURE_OPENAI_KEY,
Expand All @@ -29,7 +30,7 @@ class AzureOpenAiEmbedder {
}

log(text, ...args) {
console.log(`\x1b[36m[AzureOpenAiEmbedder]\x1b[0m ${text}`, ...args);
console.log(`\x1b[36m[${this.className}]\x1b[0m ${text}`, ...args);
}

async embedTextInput(textInput) {
Expand Down
3 changes: 2 additions & 1 deletion server/utils/EmbeddingEngines/gemini/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class GeminiEmbedder {
if (!process.env.GEMINI_EMBEDDING_API_KEY)
throw new Error("No Gemini API key was set.");

this.className = "GeminiEmbedder";
const { OpenAI: OpenAIApi } = require("openai");
this.model = process.env.EMBEDDING_MODEL_PREF || "text-embedding-004";
this.openai = new OpenAIApi({
Expand All @@ -29,7 +30,7 @@ class GeminiEmbedder {
}

log(text, ...args) {
console.log(`\x1b[36m[GeminiEmbedder]\x1b[0m ${text}`, ...args);
console.log(`\x1b[36m[${this.className}]\x1b[0m ${text}`, ...args);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion server/utils/EmbeddingEngines/genericOpenAi/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class GenericOpenAiEmbedder {
throw new Error(
"GenericOpenAI must have a valid base path to use for the api."
);
this.className = "GenericOpenAiEmbedder";
const { OpenAI: OpenAIApi } = require("openai");
this.basePath = process.env.EMBEDDING_BASE_PATH;
this.openai = new OpenAIApi({
Expand All @@ -25,7 +26,7 @@ class GenericOpenAiEmbedder {
}

log(text, ...args) {
console.log(`\x1b[36m[GenericOpenAiEmbedder]\x1b[0m ${text}`, ...args);
console.log(`\x1b[36m[${this.className}]\x1b[0m ${text}`, ...args);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion server/utils/EmbeddingEngines/lmstudio/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class LMStudioEmbedder {
if (!process.env.EMBEDDING_MODEL_PREF)
throw new Error("No embedding model was set.");

this.className = "LMStudioEmbedder";
const { OpenAI: OpenAIApi } = require("openai");
this.lmstudio = new OpenAIApi({
baseURL: parseLMStudioBasePath(process.env.EMBEDDING_BASE_PATH),
Expand All @@ -21,7 +22,7 @@ class LMStudioEmbedder {
}

log(text, ...args) {
console.log(`\x1b[36m[${this.constructor.name}]\x1b[0m ${text}`, ...args);
console.log(`\x1b[36m[${this.className}]\x1b[0m ${text}`, ...args);
}

async #isAlive() {
Expand Down
3 changes: 2 additions & 1 deletion server/utils/EmbeddingEngines/native/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class NativeEmbedder {
#fallbackHost = "https://cdn.anythingllm.com/support/models/";

constructor() {
this.className = "NativeEmbedder";
this.model = this.getEmbeddingModel();
this.modelInfo = this.getEmbedderInfo();
this.cacheDir = path.resolve(
Expand All @@ -50,7 +51,7 @@ class NativeEmbedder {
}

log(text, ...args) {
console.log(`\x1b[36m[NativeEmbedder]\x1b[0m ${text}`, ...args);
console.log(`\x1b[36m[${this.className}]\x1b[0m ${text}`, ...args);
}

/**
Expand Down
Loading