code stringlengths 24 2.07M | docstring stringlengths 25 85.3k | func_name stringlengths 1 92 | language stringclasses 1
value | repo stringlengths 5 64 | path stringlengths 4 172 | url stringlengths 44 218 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
async isValidChatCompletionModel(_modelName = "") {
return true;
} | Stubbed method for compatibility with LLM interface. | isValidChatCompletionModel | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/bedrock/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/bedrock/index.js | MIT |
constructPrompt({
systemPrompt = "",
contextTexts = [],
chatHistory = [],
userPrompt = "",
attachments = [],
}) {
const systemMessageContent = `${systemPrompt}${this.#appendContext(contextTexts)}`;
let messages = [];
// Handle system prompt (either real or simulated)
if (this.noSy... | Constructs the complete message array in the format expected by the Bedrock Converse API.
@param {object} params
@param {string} params.systemPrompt - The system prompt text.
@param {string[]} params.contextTexts - Array of context text snippets.
@param {Array<{role: 'user' | 'assistant', content: string, attachments?:... | constructPrompt | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/bedrock/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/bedrock/index.js | MIT |
async getChatCompletion(messages = null, { temperature }) {
if (!messages?.length)
throw new Error(
"AWSBedrock::getChatCompletion requires a non-empty messages array."
);
const hasSystem = messages[0]?.role === "system";
const systemBlock = hasSystem ? messages[0].content : undefined;
... | Sends a request for chat completion (non-streaming).
@param {Array<object> | null} messages - Formatted message array from constructPrompt.
@param {object} options - Request options.
@param {number} options.temperature - Sampling temperature.
@returns {Promise<object | null>} Response object with textResponse and metri... | getChatCompletion | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/bedrock/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/bedrock/index.js | MIT |
async streamGetChatCompletion(messages = null, { temperature }) {
if (!Array.isArray(messages) || messages.length === 0) {
throw new Error(
"AWSBedrock::streamGetChatCompletion requires a non-empty messages array."
);
}
const hasSystem = messages[0]?.role === "system";
const systemB... | Sends a request for streaming chat completion.
@param {Array<object> | null} messages - Formatted message array from constructPrompt.
@param {object} options - Request options.
@param {number} [options.temperature] - Sampling temperature.
@returns {Promise<import('../../helpers/chat/LLMPerformanceMonitor').MonitoredStr... | streamGetChatCompletion | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/bedrock/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/bedrock/index.js | MIT |
handleStream(response, stream, responseProps) {
const { uuid = uuidv4(), sources = [] } = responseProps;
let hasUsageMetrics = false;
let usage = { prompt_tokens: 0, completion_tokens: 0, total_tokens: 0 };
return new Promise(async (resolve) => {
let fullText = "";
let reasoningText = "";
... | Handles the stream response from the AWS Bedrock API ConverseStreamCommand.
Parses chunks, handles reasoning tags, and estimates token usage if not provided.
@param {object} response - The HTTP response object to write chunks to.
@param {import('../../helpers/chat/LLMPerformanceMonitor').MonitoredStream} stream - The m... | handleStream | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/bedrock/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/bedrock/index.js | MIT |
handleAbort = () => {
this.#log(`Client closed connection for stream ${uuid}. Aborting.`);
stream?.endMeasurement(usage); // Finalize metrics
clientAbortedHandler(resolve, fullText); // Resolve with partial text
} | Handles the stream response from the AWS Bedrock API ConverseStreamCommand.
Parses chunks, handles reasoning tags, and estimates token usage if not provided.
@param {object} response - The HTTP response object to write chunks to.
@param {import('../../helpers/chat/LLMPerformanceMonitor').MonitoredStream} stream - The m... | handleAbort | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/bedrock/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/bedrock/index.js | MIT |
handleAbort = () => {
this.#log(`Client closed connection for stream ${uuid}. Aborting.`);
stream?.endMeasurement(usage); // Finalize metrics
clientAbortedHandler(resolve, fullText); // Resolve with partial text
} | Handles the stream response from the AWS Bedrock API ConverseStreamCommand.
Parses chunks, handles reasoning tags, and estimates token usage if not provided.
@param {object} response - The HTTP response object to write chunks to.
@param {import('../../helpers/chat/LLMPerformanceMonitor').MonitoredStream} stream - The m... | handleAbort | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/bedrock/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/bedrock/index.js | MIT |
async embedTextInput(textInput) {
return await this.embedder.embedTextInput(textInput);
} | Handles the stream response from the AWS Bedrock API ConverseStreamCommand.
Parses chunks, handles reasoning tags, and estimates token usage if not provided.
@param {object} response - The HTTP response object to write chunks to.
@param {import('../../helpers/chat/LLMPerformanceMonitor').MonitoredStream} stream - The m... | embedTextInput | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/bedrock/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/bedrock/index.js | MIT |
async embedChunks(textChunks = []) {
return await this.embedder.embedChunks(textChunks);
} | Handles the stream response from the AWS Bedrock API ConverseStreamCommand.
Parses chunks, handles reasoning tags, and estimates token usage if not provided.
@param {object} response - The HTTP response object to write chunks to.
@param {import('../../helpers/chat/LLMPerformanceMonitor').MonitoredStream} stream - The m... | embedChunks | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/bedrock/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/bedrock/index.js | MIT |
async compressMessages(promptArgs = {}, rawHistory = []) {
const { messageArrayCompressor } = require("../../helpers/chat");
const messageArray = this.constructPrompt(promptArgs);
return await messageArrayCompressor(this, messageArray, rawHistory);
} | Handles the stream response from the AWS Bedrock API ConverseStreamCommand.
Parses chunks, handles reasoning tags, and estimates token usage if not provided.
@param {object} response - The HTTP response object to write chunks to.
@param {import('../../helpers/chat/LLMPerformanceMonitor').MonitoredStream} stream - The m... | compressMessages | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/bedrock/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/bedrock/index.js | MIT |
function getImageFormatFromMime(mimeType = "") {
if (!mimeType) return null;
const parts = mimeType.toLowerCase().split("/");
if (parts?.[0] !== "image") return null;
let format = parts?.[1];
if (!format) return null;
// Remap jpg to jpeg
switch (format) {
case "jpg":
format = "jpeg";
bre... | Parses a MIME type string (e.g., "image/jpeg") to extract and validate the image format
supported by Bedrock Converse. Handles 'image/jpg' as 'jpeg'.
@param {string | null | undefined} mimeType - The MIME type string.
@returns {string | null} The validated image format (e.g., "jpeg") or null if invalid/unsupported. | getImageFormatFromMime | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/bedrock/utils.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/bedrock/utils.js | MIT |
function base64ToUint8Array(base64String) {
try {
const binaryString = atob(base64String);
const len = binaryString.length;
const bytes = new Uint8Array(len);
for (let i = 0; i < len; i++) bytes[i] = binaryString.charCodeAt(i);
return bytes;
} catch (e) {
console.error(
`[AWSBedrock] E... | Decodes a pure base64 string (without data URI prefix) into a Uint8Array using the atob method.
This approach matches the technique previously used by Langchain's implementation.
@param {string} base64String - The pure base64 encoded data.
@returns {Uint8Array | null} The resulting byte array or null on decoding error. | base64ToUint8Array | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/bedrock/utils.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/bedrock/utils.js | MIT |
async handleStream(response, stream, responseProps) {
return new Promise(async (resolve) => {
const { uuid = v4(), sources = [] } = responseProps;
let fullText = "";
let usage = {
prompt_tokens: 0,
completion_tokens: 0,
};
const handleAbort = () => {
writeRespo... | Handles the stream response from the Cohere API.
@param {Object} response - the response object
@param {import('../../helpers/chat/LLMPerformanceMonitor').MonitoredStream} stream - the stream response from the Cohere API w/tracking
@param {Object} responseProps - the response properties
@returns {Promise<string>} | handleStream | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/cohere/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/cohere/index.js | MIT |
handleAbort = () => {
writeResponseChunk(response, {
uuid,
sources,
type: "abort",
textResponse: fullText,
close: true,
error: false,
});
response.removeListener("close", handleAbort);
stream.endMeasurement(usage);
resol... | Handles the stream response from the Cohere API.
@param {Object} response - the response object
@param {import('../../helpers/chat/LLMPerformanceMonitor').MonitoredStream} stream - the stream response from the Cohere API w/tracking
@param {Object} responseProps - the response properties
@returns {Promise<string>} | handleAbort | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/cohere/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/cohere/index.js | MIT |
handleAbort = () => {
writeResponseChunk(response, {
uuid,
sources,
type: "abort",
textResponse: fullText,
close: true,
error: false,
});
response.removeListener("close", handleAbort);
stream.endMeasurement(usage);
resol... | Handles the stream response from the Cohere API.
@param {Object} response - the response object
@param {import('../../helpers/chat/LLMPerformanceMonitor').MonitoredStream} stream - the stream response from the Cohere API w/tracking
@param {Object} responseProps - the response properties
@returns {Promise<string>} | handleAbort | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/cohere/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/cohere/index.js | MIT |
async embedTextInput(textInput) {
return await this.embedder.embedTextInput(textInput);
} | Handles the stream response from the Cohere API.
@param {Object} response - the response object
@param {import('../../helpers/chat/LLMPerformanceMonitor').MonitoredStream} stream - the stream response from the Cohere API w/tracking
@param {Object} responseProps - the response properties
@returns {Promise<string>} | embedTextInput | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/cohere/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/cohere/index.js | MIT |
async embedChunks(textChunks = []) {
return await this.embedder.embedChunks(textChunks);
} | Handles the stream response from the Cohere API.
@param {Object} response - the response object
@param {import('../../helpers/chat/LLMPerformanceMonitor').MonitoredStream} stream - the stream response from the Cohere API w/tracking
@param {Object} responseProps - the response properties
@returns {Promise<string>} | embedChunks | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/cohere/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/cohere/index.js | MIT |
async compressMessages(promptArgs = {}, rawHistory = []) {
const { messageArrayCompressor } = require("../../helpers/chat");
const messageArray = this.constructPrompt(promptArgs);
return await messageArrayCompressor(this, messageArray, rawHistory);
} | Handles the stream response from the Cohere API.
@param {Object} response - the response object
@param {import('../../helpers/chat/LLMPerformanceMonitor').MonitoredStream} stream - the stream response from the Cohere API w/tracking
@param {Object} responseProps - the response properties
@returns {Promise<string>} | compressMessages | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/cohere/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/cohere/index.js | MIT |
async getChatCompletion(messages = null, { temperature = 0.7 }) {
if (!(await this.isValidChatCompletionModel(this.model)))
throw new Error(
`DeepSeek chat: ${this.model} is not valid for chat completion!`
);
const result = await LLMPerformanceMonitor.measureAsyncFunction(
this.openai... | Parses and prepends reasoning from the response and returns the full text response.
@param {Object} response
@returns {string} | getChatCompletion | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/deepseek/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/deepseek/index.js | MIT |
async streamGetChatCompletion(messages = null, { temperature = 0.7 }) {
if (!(await this.isValidChatCompletionModel(this.model)))
throw new Error(
`DeepSeek chat: ${this.model} is not valid for chat completion!`
);
const measuredStreamRequest = await LLMPerformanceMonitor.measureStream(
... | Parses and prepends reasoning from the response and returns the full text response.
@param {Object} response
@returns {string} | streamGetChatCompletion | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/deepseek/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/deepseek/index.js | MIT |
handleStream(response, stream, responseProps) {
const { uuid = uuidv4(), sources = [] } = responseProps;
let hasUsageMetrics = false;
let usage = {
completion_tokens: 0,
};
return new Promise(async (resolve) => {
let fullText = "";
let reasoningText = "";
// Establish liste... | Parses and prepends reasoning from the response and returns the full text response.
@param {Object} response
@returns {string} | handleStream | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/deepseek/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/deepseek/index.js | MIT |
handleAbort = () => {
stream?.endMeasurement(usage);
clientAbortedHandler(resolve, fullText);
} | Parses and prepends reasoning from the response and returns the full text response.
@param {Object} response
@returns {string} | handleAbort | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/deepseek/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/deepseek/index.js | MIT |
handleAbort = () => {
stream?.endMeasurement(usage);
clientAbortedHandler(resolve, fullText);
} | Parses and prepends reasoning from the response and returns the full text response.
@param {Object} response
@returns {string} | handleAbort | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/deepseek/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/deepseek/index.js | MIT |
async embedTextInput(textInput) {
return await this.embedder.embedTextInput(textInput);
} | Parses and prepends reasoning from the response and returns the full text response.
@param {Object} response
@returns {string} | embedTextInput | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/deepseek/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/deepseek/index.js | MIT |
async embedChunks(textChunks = []) {
return await this.embedder.embedChunks(textChunks);
} | Parses and prepends reasoning from the response and returns the full text response.
@param {Object} response
@returns {string} | embedChunks | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/deepseek/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/deepseek/index.js | MIT |
async compressMessages(promptArgs = {}, rawHistory = []) {
const { messageArrayCompressor } = require("../../helpers/chat");
const messageArray = this.constructPrompt(promptArgs);
return await messageArrayCompressor(this, messageArray, rawHistory);
} | Parses and prepends reasoning from the response and returns the full text response.
@param {Object} response
@returns {string} | compressMessages | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/deepseek/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/deepseek/index.js | MIT |
static parseBasePath(providedBasePath = process.env.DPAIS_LLM_BASE_PATH) {
try {
const baseURL = new URL(providedBasePath);
const basePath = `${baseURL.origin}/v1/openai`;
return basePath;
} catch (e) {
return null;
}
} | Parse the base path for the Dell Pro AI Studio API
so we can use it for inference requests
@param {string} providedBasePath
@returns {string} | parseBasePath | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/dellProAiStudio/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/dellProAiStudio/index.js | MIT |
log(text, ...args) {
console.log(`\x1b[36m[${this.constructor.name}]\x1b[0m ${text}`, ...args);
} | Parse the base path for the Dell Pro AI Studio API
so we can use it for inference requests
@param {string} providedBasePath
@returns {string} | log | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/dellProAiStudio/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/dellProAiStudio/index.js | MIT |
streamingEnabled() {
return "streamGetChatCompletion" in this;
} | Parse the base path for the Dell Pro AI Studio API
so we can use it for inference requests
@param {string} providedBasePath
@returns {string} | streamingEnabled | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/dellProAiStudio/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/dellProAiStudio/index.js | MIT |
static promptWindowLimit(_modelName) {
const limit = process.env.DPAIS_LLM_MODEL_TOKEN_LIMIT || 4096;
if (!limit || isNaN(Number(limit)))
throw new Error("No Dell Pro AI Studio token context limit was set.");
return Number(limit);
} | Parse the base path for the Dell Pro AI Studio API
so we can use it for inference requests
@param {string} providedBasePath
@returns {string} | promptWindowLimit | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/dellProAiStudio/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/dellProAiStudio/index.js | MIT |
promptWindowLimit() {
const limit = process.env.DPAIS_LLM_MODEL_TOKEN_LIMIT || 4096;
if (!limit || isNaN(Number(limit)))
throw new Error("No Dell Pro AI Studio token context limit was set.");
return Number(limit);
} | Parse the base path for the Dell Pro AI Studio API
so we can use it for inference requests
@param {string} providedBasePath
@returns {string} | promptWindowLimit | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/dellProAiStudio/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/dellProAiStudio/index.js | MIT |
async isValidChatCompletionModel(_ = "") {
return true;
} | Parse the base path for the Dell Pro AI Studio API
so we can use it for inference requests
@param {string} providedBasePath
@returns {string} | isValidChatCompletionModel | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/dellProAiStudio/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/dellProAiStudio/index.js | MIT |
constructPrompt({
systemPrompt = "",
contextTexts = [],
chatHistory = [],
userPrompt = "",
_attachments = [], // not used for Dell Pro AI Studio - `attachments` passed in is ignored
}) {
const prompt = {
role: "system",
content: `${systemPrompt}${this.#appendContext(contextTexts)}`... | Construct the user prompt for this model.
@param {{attachments: import("../../helpers").Attachment[]}} param0
@returns | constructPrompt | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/dellProAiStudio/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/dellProAiStudio/index.js | MIT |
async getChatCompletion(messages = null, { temperature = 0.7 }) {
if (!this.model)
throw new Error(
`Dell Pro AI Studio chat: ${this.model} is not valid or defined model for chat completion!`
);
const result = await LLMPerformanceMonitor.measureAsyncFunction(
this.dpais.chat.completio... | Construct the user prompt for this model.
@param {{attachments: import("../../helpers").Attachment[]}} param0
@returns | getChatCompletion | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/dellProAiStudio/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/dellProAiStudio/index.js | MIT |
async streamGetChatCompletion(messages = null, { temperature = 0.7 }) {
if (!this.model)
throw new Error(
`Dell Pro AI Studio chat: ${this.model} is not valid or defined model for chat completion!`
);
const measuredStreamRequest = await LLMPerformanceMonitor.measureStream(
this.dpais.... | Construct the user prompt for this model.
@param {{attachments: import("../../helpers").Attachment[]}} param0
@returns | streamGetChatCompletion | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/dellProAiStudio/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/dellProAiStudio/index.js | MIT |
handleStream(response, stream, responseProps) {
return handleDefaultStreamResponseV2(response, stream, responseProps);
} | Construct the user prompt for this model.
@param {{attachments: import("../../helpers").Attachment[]}} param0
@returns | handleStream | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/dellProAiStudio/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/dellProAiStudio/index.js | MIT |
async embedTextInput(textInput) {
return await this.embedder.embedTextInput(textInput);
} | Construct the user prompt for this model.
@param {{attachments: import("../../helpers").Attachment[]}} param0
@returns | embedTextInput | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/dellProAiStudio/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/dellProAiStudio/index.js | MIT |
async embedChunks(textChunks = []) {
return await this.embedder.embedChunks(textChunks);
} | Construct the user prompt for this model.
@param {{attachments: import("../../helpers").Attachment[]}} param0
@returns | embedChunks | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/dellProAiStudio/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/dellProAiStudio/index.js | MIT |
async compressMessages(promptArgs = {}, rawHistory = []) {
const { messageArrayCompressor } = require("../../helpers/chat");
const messageArray = this.constructPrompt(promptArgs);
return await messageArrayCompressor(this, messageArray, rawHistory);
} | Construct the user prompt for this model.
@param {{attachments: import("../../helpers").Attachment[]}} param0
@returns | compressMessages | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/dellProAiStudio/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/dellProAiStudio/index.js | MIT |
get supportsSystemPrompt() {
return !NO_SYSTEM_PROMPT_MODELS.includes(this.model);
} | Checks if the model supports system prompts
This is a static list of models that are known to not support system prompts
since this information is not available in the API model response.
@returns {boolean} | supportsSystemPrompt | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/gemini/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/gemini/index.js | MIT |
static cacheIsStale() {
const MAX_STALE = 8.64e7; // 1 day in MS
if (!fs.existsSync(path.resolve(cacheFolder, ".cached_at"))) return true;
const now = Number(new Date());
const timestampMs = Number(
fs.readFileSync(path.resolve(cacheFolder, ".cached_at"))
);
return now - timestampMs > MAX_... | Checks if the model supports system prompts
This is a static list of models that are known to not support system prompts
since this information is not available in the API model response.
@returns {boolean} | cacheIsStale | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/gemini/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/gemini/index.js | MIT |
streamingEnabled() {
return "streamGetChatCompletion" in this;
} | Checks if the model supports system prompts
This is a static list of models that are known to not support system prompts
since this information is not available in the API model response.
@returns {boolean} | streamingEnabled | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/gemini/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/gemini/index.js | MIT |
static promptWindowLimit(modelName) {
try {
const cacheModelPath = path.resolve(cacheFolder, "models.json");
if (!fs.existsSync(cacheModelPath))
return MODEL_MAP.get("gemini", modelName) ?? 30_720;
const models = safeJsonParse(fs.readFileSync(cacheModelPath));
const model = models.f... | Checks if the model supports system prompts
This is a static list of models that are known to not support system prompts
since this information is not available in the API model response.
@returns {boolean} | promptWindowLimit | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/gemini/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/gemini/index.js | MIT |
promptWindowLimit() {
try {
if (!fs.existsSync(this.cacheModelPath))
return MODEL_MAP.get("gemini", this.model) ?? 30_720;
const models = safeJsonParse(fs.readFileSync(this.cacheModelPath));
const model = models.find((model) => model.id === this.model);
if (!model)
throw new ... | Checks if the model supports system prompts
This is a static list of models that are known to not support system prompts
since this information is not available in the API model response.
@returns {boolean} | promptWindowLimit | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/gemini/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/gemini/index.js | MIT |
isExperimentalModel(modelName) {
if (
fs.existsSync(cacheFolder) &&
fs.existsSync(path.resolve(cacheFolder, "models.json"))
) {
const models = safeJsonParse(
fs.readFileSync(path.resolve(cacheFolder, "models.json"))
);
const model = models.find((model) => model.id === model... | Checks if a model is experimental by reading from the cache if available, otherwise it will perform
a blind check against the v1BetaModels list - which is manually maintained and updated.
@param {string} modelName - The name of the model to check
@returns {boolean} A boolean indicating if the model is experimental | isExperimentalModel | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/gemini/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/gemini/index.js | MIT |
async isValidChatCompletionModel(modelName = "") {
const models = await this.fetchModels(process.env.GEMINI_API_KEY);
return models.some((model) => model.id === modelName);
} | Checks if a model is valid for chat completion (unused)
@deprecated
@param {string} modelName - The name of the model to check
@returns {Promise<boolean>} A promise that resolves to a boolean indicating if the model is valid | isValidChatCompletionModel | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/gemini/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/gemini/index.js | MIT |
constructPrompt({
systemPrompt = "",
contextTexts = [],
chatHistory = [],
userPrompt = "",
attachments = [], // This is the specific attachment for only this prompt
}) {
let prompt = [];
if (this.supportsSystemPrompt) {
prompt.push({
role: "system",
content: `${system... | Construct the user prompt for this model.
@param {{attachments: import("../../helpers").Attachment[]}} param0
@returns | constructPrompt | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/gemini/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/gemini/index.js | MIT |
async getChatCompletion(messages = null, { temperature = 0.7 }) {
const result = await LLMPerformanceMonitor.measureAsyncFunction(
this.openai.chat.completions
.create({
model: this.model,
messages,
temperature: temperature,
})
.catch((e) => {
co... | Construct the user prompt for this model.
@param {{attachments: import("../../helpers").Attachment[]}} param0
@returns | getChatCompletion | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/gemini/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/gemini/index.js | MIT |
async streamGetChatCompletion(messages = null, { temperature = 0.7 }) {
const measuredStreamRequest = await LLMPerformanceMonitor.measureStream(
this.openai.chat.completions.create({
model: this.model,
stream: true,
messages,
temperature: temperature,
}),
messages,
... | Construct the user prompt for this model.
@param {{attachments: import("../../helpers").Attachment[]}} param0
@returns | streamGetChatCompletion | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/gemini/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/gemini/index.js | MIT |
handleStream(response, stream, responseProps) {
return handleDefaultStreamResponseV2(response, stream, responseProps);
} | Construct the user prompt for this model.
@param {{attachments: import("../../helpers").Attachment[]}} param0
@returns | handleStream | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/gemini/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/gemini/index.js | MIT |
async compressMessages(promptArgs = {}, rawHistory = []) {
const { messageArrayCompressor } = require("../../helpers/chat");
const messageArray = this.constructPrompt(promptArgs);
return await messageArrayCompressor(this, messageArray, rawHistory);
} | Construct the user prompt for this model.
@param {{attachments: import("../../helpers").Attachment[]}} param0
@returns | compressMessages | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/gemini/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/gemini/index.js | MIT |
async embedTextInput(textInput) {
return await this.embedder.embedTextInput(textInput);
} | Construct the user prompt for this model.
@param {{attachments: import("../../helpers").Attachment[]}} param0
@returns | embedTextInput | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/gemini/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/gemini/index.js | MIT |
async embedChunks(textChunks = []) {
return await this.embedder.embedChunks(textChunks);
} | Construct the user prompt for this model.
@param {{attachments: import("../../helpers").Attachment[]}} param0
@returns | embedChunks | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/gemini/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/gemini/index.js | MIT |
constructPrompt({
systemPrompt = "",
contextTexts = [],
chatHistory = [],
userPrompt = "",
attachments = [],
}) {
const prompt = {
role: "system",
content: `${systemPrompt}${this.#appendContext(contextTexts)}`,
};
return [
prompt,
...formatChatHistory(chatHistor... | Construct the user prompt for this model.
@param {{attachments: import("../../helpers").Attachment[]}} param0
@returns | constructPrompt | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/genericOpenAi/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/genericOpenAi/index.js | MIT |
async getChatCompletion(messages = null, { temperature = 0.7 }) {
const result = await LLMPerformanceMonitor.measureAsyncFunction(
this.openai.chat.completions
.create({
model: this.model,
messages,
temperature,
max_tokens: this.maxTokens,
})
.ca... | Parses and prepends reasoning from the response and returns the full text response.
@param {Object} response
@returns {string} | getChatCompletion | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/genericOpenAi/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/genericOpenAi/index.js | MIT |
async streamGetChatCompletion(messages = null, { temperature = 0.7 }) {
const measuredStreamRequest = await LLMPerformanceMonitor.measureStream(
this.openai.chat.completions.create({
model: this.model,
stream: true,
messages,
temperature,
max_tokens: this.maxTokens,
... | Parses and prepends reasoning from the response and returns the full text response.
@param {Object} response
@returns {string} | streamGetChatCompletion | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/genericOpenAi/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/genericOpenAi/index.js | MIT |
handleStream(response, stream, responseProps) {
const { uuid = uuidv4(), sources = [] } = responseProps;
let hasUsageMetrics = false;
let usage = {
completion_tokens: 0,
};
return new Promise(async (resolve) => {
let fullText = "";
let reasoningText = "";
// Establish liste... | Parses and prepends reasoning from the response and returns the full text response.
@param {Object} response
@returns {string} | handleStream | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/genericOpenAi/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/genericOpenAi/index.js | MIT |
handleAbort = () => {
stream?.endMeasurement(usage);
clientAbortedHandler(resolve, fullText);
} | Parses and prepends reasoning from the response and returns the full text response.
@param {Object} response
@returns {string} | handleAbort | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/genericOpenAi/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/genericOpenAi/index.js | MIT |
handleAbort = () => {
stream?.endMeasurement(usage);
clientAbortedHandler(resolve, fullText);
} | Parses and prepends reasoning from the response and returns the full text response.
@param {Object} response
@returns {string} | handleAbort | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/genericOpenAi/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/genericOpenAi/index.js | MIT |
async embedTextInput(textInput) {
return await this.embedder.embedTextInput(textInput);
} | Parses and prepends reasoning from the response and returns the full text response.
@param {Object} response
@returns {string} | embedTextInput | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/genericOpenAi/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/genericOpenAi/index.js | MIT |
async embedChunks(textChunks = []) {
return await this.embedder.embedChunks(textChunks);
} | Parses and prepends reasoning from the response and returns the full text response.
@param {Object} response
@returns {string} | embedChunks | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/genericOpenAi/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/genericOpenAi/index.js | MIT |
async compressMessages(promptArgs = {}, rawHistory = []) {
const { messageArrayCompressor } = require("../../helpers/chat");
const messageArray = this.constructPrompt(promptArgs);
return await messageArrayCompressor(this, messageArray, rawHistory);
} | Parses and prepends reasoning from the response and returns the full text response.
@param {Object} response
@returns {string} | compressMessages | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/genericOpenAi/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/genericOpenAi/index.js | MIT |
constructPrompt({
systemPrompt = "",
contextTexts = [],
chatHistory = [],
userPrompt = "",
attachments = [], // This is the specific attachment for only this prompt
}) {
// NOTICE: SEE GroqLLM.#conditionalPromptStruct for more information on how attachments are handled with Groq.
return th... | Construct the user prompt for this model.
@param {{attachments: import("../../helpers").Attachment[]}} param0
@returns | constructPrompt | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/groq/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/groq/index.js | MIT |
async getChatCompletion(messages = null, { temperature = 0.7 }) {
if (!(await this.isValidChatCompletionModel(this.model)))
throw new Error(
`GroqAI:chatCompletion: ${this.model} is not valid for chat completion!`
);
const result = await LLMPerformanceMonitor.measureAsyncFunction(
thi... | Construct the user prompt for this model.
@param {{attachments: import("../../helpers").Attachment[]}} param0
@returns | getChatCompletion | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/groq/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/groq/index.js | MIT |
async streamGetChatCompletion(messages = null, { temperature = 0.7 }) {
if (!(await this.isValidChatCompletionModel(this.model)))
throw new Error(
`GroqAI:streamChatCompletion: ${this.model} is not valid for chat completion!`
);
const measuredStreamRequest = await LLMPerformanceMonitor.meas... | Construct the user prompt for this model.
@param {{attachments: import("../../helpers").Attachment[]}} param0
@returns | streamGetChatCompletion | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/groq/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/groq/index.js | MIT |
handleStream(response, stream, responseProps) {
return handleDefaultStreamResponseV2(response, stream, responseProps);
} | Construct the user prompt for this model.
@param {{attachments: import("../../helpers").Attachment[]}} param0
@returns | handleStream | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/groq/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/groq/index.js | MIT |
async embedTextInput(textInput) {
return await this.embedder.embedTextInput(textInput);
} | Construct the user prompt for this model.
@param {{attachments: import("../../helpers").Attachment[]}} param0
@returns | embedTextInput | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/groq/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/groq/index.js | MIT |
async embedChunks(textChunks = []) {
return await this.embedder.embedChunks(textChunks);
} | Construct the user prompt for this model.
@param {{attachments: import("../../helpers").Attachment[]}} param0
@returns | embedChunks | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/groq/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/groq/index.js | MIT |
async compressMessages(promptArgs = {}, rawHistory = []) {
const { messageArrayCompressor } = require("../../helpers/chat");
const messageArray = this.constructPrompt(promptArgs);
return await messageArrayCompressor(this, messageArray, rawHistory);
} | Construct the user prompt for this model.
@param {{attachments: import("../../helpers").Attachment[]}} param0
@returns | compressMessages | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/groq/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/groq/index.js | MIT |
constructPrompt({
systemPrompt = "",
contextTexts = [],
chatHistory = [],
userPrompt = "",
attachments = [],
}) {
const prompt = {
role: "system",
content: `${systemPrompt}${this.#appendContext(contextTexts)}`,
};
return [
prompt,
...formatChatHistory(chatHistor... | Construct the user prompt for this model.
@param {{attachments: import("../../helpers").Attachment[]}} param0
@returns | constructPrompt | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/koboldCPP/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/koboldCPP/index.js | MIT |
async getChatCompletion(messages = null, { temperature = 0.7 }) {
const result = await LLMPerformanceMonitor.measureAsyncFunction(
this.openai.chat.completions
.create({
model: this.model,
messages,
temperature,
max_tokens: this.maxTokens,
})
.ca... | Construct the user prompt for this model.
@param {{attachments: import("../../helpers").Attachment[]}} param0
@returns | getChatCompletion | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/koboldCPP/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/koboldCPP/index.js | MIT |
async streamGetChatCompletion(messages = null, { temperature = 0.7 }) {
const measuredStreamRequest = await LLMPerformanceMonitor.measureStream(
this.openai.chat.completions.create({
model: this.model,
stream: true,
messages,
temperature,
max_tokens: this.maxTokens,
... | Construct the user prompt for this model.
@param {{attachments: import("../../helpers").Attachment[]}} param0
@returns | streamGetChatCompletion | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/koboldCPP/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/koboldCPP/index.js | MIT |
handleStream(response, stream, responseProps) {
const { uuid = uuidv4(), sources = [] } = responseProps;
return new Promise(async (resolve) => {
let fullText = "";
let usage = {
prompt_tokens: LLMPerformanceMonitor.countTokens(stream.messages || []),
completion_tokens: 0,
};
... | Construct the user prompt for this model.
@param {{attachments: import("../../helpers").Attachment[]}} param0
@returns | handleStream | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/koboldCPP/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/koboldCPP/index.js | MIT |
handleAbort = () => {
usage.completion_tokens = LLMPerformanceMonitor.countTokens([
{ content: fullText },
]);
stream?.endMeasurement(usage);
clientAbortedHandler(resolve, fullText);
} | Construct the user prompt for this model.
@param {{attachments: import("../../helpers").Attachment[]}} param0
@returns | handleAbort | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/koboldCPP/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/koboldCPP/index.js | MIT |
handleAbort = () => {
usage.completion_tokens = LLMPerformanceMonitor.countTokens([
{ content: fullText },
]);
stream?.endMeasurement(usage);
clientAbortedHandler(resolve, fullText);
} | Construct the user prompt for this model.
@param {{attachments: import("../../helpers").Attachment[]}} param0
@returns | handleAbort | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/koboldCPP/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/koboldCPP/index.js | MIT |
async embedTextInput(textInput) {
return await this.embedder.embedTextInput(textInput);
} | Construct the user prompt for this model.
@param {{attachments: import("../../helpers").Attachment[]}} param0
@returns | embedTextInput | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/koboldCPP/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/koboldCPP/index.js | MIT |
async embedChunks(textChunks = []) {
return await this.embedder.embedChunks(textChunks);
} | Construct the user prompt for this model.
@param {{attachments: import("../../helpers").Attachment[]}} param0
@returns | embedChunks | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/koboldCPP/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/koboldCPP/index.js | MIT |
async compressMessages(promptArgs = {}, rawHistory = []) {
const { messageArrayCompressor } = require("../../helpers/chat");
const messageArray = this.constructPrompt(promptArgs);
return await messageArrayCompressor(this, messageArray, rawHistory);
} | Construct the user prompt for this model.
@param {{attachments: import("../../helpers").Attachment[]}} param0
@returns | compressMessages | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/koboldCPP/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/koboldCPP/index.js | MIT |
constructPrompt({
systemPrompt = "",
contextTexts = [],
chatHistory = [],
userPrompt = "",
attachments = [],
}) {
const prompt = {
role: "system",
content: `${systemPrompt}${this.#appendContext(contextTexts)}`,
};
return [
prompt,
...formatChatHistory(chatHistor... | Construct the user prompt for this model.
@param {{attachments: import("../../helpers").Attachment[]}} param0
@returns | constructPrompt | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/liteLLM/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/liteLLM/index.js | MIT |
async getChatCompletion(messages = null, { temperature = 0.7 }) {
const result = await LLMPerformanceMonitor.measureAsyncFunction(
this.openai.chat.completions
.create({
model: this.model,
messages,
temperature,
max_tokens: parseInt(this.maxTokens), // LiteLLM r... | Construct the user prompt for this model.
@param {{attachments: import("../../helpers").Attachment[]}} param0
@returns | getChatCompletion | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/liteLLM/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/liteLLM/index.js | MIT |
async streamGetChatCompletion(messages = null, { temperature = 0.7 }) {
const measuredStreamRequest = await LLMPerformanceMonitor.measureStream(
this.openai.chat.completions.create({
model: this.model,
stream: true,
messages,
temperature,
max_tokens: parseInt(this.maxTo... | Construct the user prompt for this model.
@param {{attachments: import("../../helpers").Attachment[]}} param0
@returns | streamGetChatCompletion | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/liteLLM/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/liteLLM/index.js | MIT |
handleStream(response, stream, responseProps) {
return handleDefaultStreamResponseV2(response, stream, responseProps);
} | Construct the user prompt for this model.
@param {{attachments: import("../../helpers").Attachment[]}} param0
@returns | handleStream | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/liteLLM/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/liteLLM/index.js | MIT |
async embedTextInput(textInput) {
return await this.embedder.embedTextInput(textInput);
} | Construct the user prompt for this model.
@param {{attachments: import("../../helpers").Attachment[]}} param0
@returns | embedTextInput | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/liteLLM/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/liteLLM/index.js | MIT |
async embedChunks(textChunks = []) {
return await this.embedder.embedChunks(textChunks);
} | Construct the user prompt for this model.
@param {{attachments: import("../../helpers").Attachment[]}} param0
@returns | embedChunks | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/liteLLM/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/liteLLM/index.js | MIT |
async compressMessages(promptArgs = {}, rawHistory = []) {
const { messageArrayCompressor } = require("../../helpers/chat");
const messageArray = this.constructPrompt(promptArgs);
return await messageArrayCompressor(this, messageArray, rawHistory);
} | Construct the user prompt for this model.
@param {{attachments: import("../../helpers").Attachment[]}} param0
@returns | compressMessages | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/liteLLM/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/liteLLM/index.js | MIT |
constructPrompt({
systemPrompt = "",
contextTexts = [],
chatHistory = [],
userPrompt = "",
attachments = [],
}) {
const prompt = {
role: "system",
content: `${systemPrompt}${this.#appendContext(contextTexts)}`,
};
return [
prompt,
...formatChatHistory(chatHistor... | Construct the user prompt for this model.
@param {{attachments: import("../../helpers").Attachment[]}} param0
@returns | constructPrompt | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/lmStudio/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/lmStudio/index.js | MIT |
async getChatCompletion(messages = null, { temperature = 0.7 }) {
if (!this.model)
throw new Error(
`LMStudio chat: ${this.model} is not valid or defined model for chat completion!`
);
const result = await LLMPerformanceMonitor.measureAsyncFunction(
this.lmstudio.chat.completions.crea... | Construct the user prompt for this model.
@param {{attachments: import("../../helpers").Attachment[]}} param0
@returns | getChatCompletion | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/lmStudio/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/lmStudio/index.js | MIT |
async streamGetChatCompletion(messages = null, { temperature = 0.7 }) {
if (!this.model)
throw new Error(
`LMStudio chat: ${this.model} is not valid or defined model for chat completion!`
);
const measuredStreamRequest = await LLMPerformanceMonitor.measureStream(
this.lmstudio.chat.co... | Construct the user prompt for this model.
@param {{attachments: import("../../helpers").Attachment[]}} param0
@returns | streamGetChatCompletion | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/lmStudio/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/lmStudio/index.js | MIT |
handleStream(response, stream, responseProps) {
return handleDefaultStreamResponseV2(response, stream, responseProps);
} | Construct the user prompt for this model.
@param {{attachments: import("../../helpers").Attachment[]}} param0
@returns | handleStream | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/lmStudio/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/lmStudio/index.js | MIT |
async embedTextInput(textInput) {
return await this.embedder.embedTextInput(textInput);
} | Construct the user prompt for this model.
@param {{attachments: import("../../helpers").Attachment[]}} param0
@returns | embedTextInput | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/lmStudio/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/lmStudio/index.js | MIT |
async embedChunks(textChunks = []) {
return await this.embedder.embedChunks(textChunks);
} | Construct the user prompt for this model.
@param {{attachments: import("../../helpers").Attachment[]}} param0
@returns | embedChunks | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/lmStudio/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/lmStudio/index.js | MIT |
async compressMessages(promptArgs = {}, rawHistory = []) {
const { messageArrayCompressor } = require("../../helpers/chat");
const messageArray = this.constructPrompt(promptArgs);
return await messageArrayCompressor(this, messageArray, rawHistory);
} | Construct the user prompt for this model.
@param {{attachments: import("../../helpers").Attachment[]}} param0
@returns | compressMessages | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/lmStudio/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/lmStudio/index.js | MIT |
function parseLMStudioBasePath(providedBasePath = "") {
try {
const baseURL = new URL(providedBasePath);
const basePath = `${baseURL.origin}/v1`;
return basePath;
} catch (e) {
return providedBasePath;
}
} | Parse the base path for the LMStudio API. Since the base path must end in /v1 and cannot have a trailing slash,
and the user can possibly set it to anything and likely incorrectly due to pasting behaviors, we need to ensure it is in the correct format.
@param {string} basePath
@returns {string} | parseLMStudioBasePath | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/lmStudio/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/lmStudio/index.js | MIT |
constructPrompt({
systemPrompt = "",
contextTexts = [],
chatHistory = [],
userPrompt = "",
attachments = [],
}) {
const prompt = {
role: "system",
content: `${systemPrompt}${this.#appendContext(contextTexts)}`,
};
return [
prompt,
...formatChatHistory(chatHistor... | Construct the user prompt for this model.
@param {{attachments: import("../../helpers").Attachment[]}} param0
@returns | constructPrompt | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/localAi/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/localAi/index.js | MIT |
async getChatCompletion(messages = null, { temperature = 0.7 }) {
if (!(await this.isValidChatCompletionModel(this.model)))
throw new Error(
`LocalAI chat: ${this.model} is not valid for chat completion!`
);
const result = await LLMPerformanceMonitor.measureAsyncFunction(
this.openai.... | Construct the user prompt for this model.
@param {{attachments: import("../../helpers").Attachment[]}} param0
@returns | getChatCompletion | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/localAi/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/localAi/index.js | MIT |
async streamGetChatCompletion(messages = null, { temperature = 0.7 }) {
if (!(await this.isValidChatCompletionModel(this.model)))
throw new Error(
`LocalAi chat: ${this.model} is not valid for chat completion!`
);
const measuredStreamRequest = await LLMPerformanceMonitor.measureStream(
... | Construct the user prompt for this model.
@param {{attachments: import("../../helpers").Attachment[]}} param0
@returns | streamGetChatCompletion | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/localAi/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/localAi/index.js | MIT |
handleStream(response, stream, responseProps) {
return handleDefaultStreamResponseV2(response, stream, responseProps);
} | Construct the user prompt for this model.
@param {{attachments: import("../../helpers").Attachment[]}} param0
@returns | handleStream | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/localAi/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/localAi/index.js | MIT |
async embedTextInput(textInput) {
return await this.embedder.embedTextInput(textInput);
} | Construct the user prompt for this model.
@param {{attachments: import("../../helpers").Attachment[]}} param0
@returns | embedTextInput | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/localAi/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/localAi/index.js | MIT |
async embedChunks(textChunks = []) {
return await this.embedder.embedChunks(textChunks);
} | Construct the user prompt for this model.
@param {{attachments: import("../../helpers").Attachment[]}} param0
@returns | embedChunks | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/localAi/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/localAi/index.js | MIT |
async compressMessages(promptArgs = {}, rawHistory = []) {
const { messageArrayCompressor } = require("../../helpers/chat");
const messageArray = this.constructPrompt(promptArgs);
return await messageArrayCompressor(this, messageArray, rawHistory);
} | Construct the user prompt for this model.
@param {{attachments: import("../../helpers").Attachment[]}} param0
@returns | compressMessages | javascript | Mintplex-Labs/anything-llm | server/utils/AiProviders/localAi/index.js | https://github.com/Mintplex-Labs/anything-llm/blob/master/server/utils/AiProviders/localAi/index.js | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.