Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

🏄‍♂️ refactor: Optimize Reasoning UI & Token Streaming (#5546)

Danny Avila591a019766b2
diff --git a/api/app/clients/BaseClient.js b/api/app/clients/BaseClient.js
index 6cda447142..6ddcaa9721 100644
--- a/api/app/clients/BaseClient.js
+++ b/api/app/clients/BaseClient.js
@@ -7,15 +7,12 @@ const {
EModelEndpoint,
ErrorTypes,
Constants,
- CacheKeys,
- Time,
} = require('librechat-data-provider');
const { getMessages, saveMessage, updateMessage, saveConvo } = require('~/models');
const { addSpaceIfNeeded, isEnabled } = require('~/server/utils');
const { truncateToolCallOutputs } = require('./prompts');
const checkBalance = require('~/models/checkBalance');
const { getFiles } = require('~/models/File');
-const { getLogStores } = require('~/cache');
const TextStream = require('./TextStream');
const { logger } = require('~/config');
@@ -54,6 +51,12 @@ class BaseClient {
this.outputTokensKey = 'completion_tokens';
/** @type {Set<string>} */
this.savedMessageIds = new Set();
+ /**
+ * Flag to determine if the client re-submitted the latest assistant message.
+ * @type {boolean | undefined} */
+ this.continued;
+ /** @type {TMessage[]} */
+ this.currentMessages = [];
}
setOptions() {
@@ -589,6 +592,7 @@ class BaseClient {
} else {
latestMessage.text = generation;
}
+ this.continued = true;
} else {
this.currentMessages.push(userMessage);
}
@@ -720,17 +724,6 @@ class BaseClient {
this.responsePromise = this.saveMessageToDatabase(responseMessage, saveOptions, user);
this.savedMessageIds.add(responseMessage.messageId);
- if (responseMessage.text) {
- const messageCache = getLogStores(CacheKeys.MESSAGES);
- messageCache.set(
- responseMessageId,
- {
- text: responseMessage.text,
- complete: true,
- },
- Time.FIVE_MINUTES,
- );
- }
delete responseMessage.tokenCount;
return responseMessage;
}
diff --git a/api/app/clients/OpenAIClient.js b/api/app/clients/OpenAIClient.js
index 89b938b858..8b71dcbc52 100644
--- a/api/app/clients/OpenAIClient.js
+++ b/api/app/clients/OpenAIClient.js
@@ -1,6 +1,7 @@
const OpenAI = require('openai');
const { OllamaClient } = require('./OllamaClient');
const { HttpsProxyAgent } = require('https-proxy-agent');
+const { SplitStreamHandler, GraphEvents } = require('@librechat/agents');
const {
Constants,
ImageDetail,
@@ -28,17 +29,17 @@ const {
createContextHandlers,
} = require('./prompts');
const { encodeAndFormat } = require('~/server/services/Files/images/encode');
+const { addSpaceIfNeeded, isEnabled, sleep } = require('~/server/utils');
const Tokenizer = require('~/server/services/Tokenizer');
const { spendTokens } = require('~/models/spendTokens');
-const { isEnabled, sleep } = require('~/server/utils');
const { handleOpenAIErrors } = require('./tools/util');
const { createLLM, RunManager } = require('./llm');
+const { logger, sendEvent } = require('~/config');
const ChatGPTClient = require('./ChatGPTClient');
const { summaryBuffer } = require('./memory');
const { runTitleChain } = require('./chains');
const { tokenSplit } = require('./document');
const BaseClient = require('./BaseClient');
-const { logger } = require('~/config');
class OpenAIClient extends BaseClient {
constructor(apiKey, options = {}) {
@@ -65,6 +66,8 @@ class OpenAIClient extends BaseClient {
this.usage;
/** @type {boolean|undefined} */
this.isO1Model;
+ /** @type {SplitStreamHandler | undefined} */
+ this.streamHandler;
}
// TODO: PluginsClient calls this 3x, unneeded
@@ -1064,11 +1067,36 @@ ${convo}
});
}
+ getStreamText() {
+ if (!this.streamHandler) {
+ return '';
+ }
+
+ const reasoningTokens =
+ this.streamHandler.reasoningTokens.length > 0
+ ? `:::thinking\n${this.streamHandler.reasoningTokens.join('')}\n:::\n`
+ : '';
+
+ return `${reasoningTokens}${this.streamHandler.tokens.join('')}`;
+ }
+
+ getMessageMapMethod() {
+ /**
+ * @param {TMessage} msg
+ */
+ return (msg) => {
+ if (msg.text != null && msg.text && msg.text.startsWith(':::thinking')) {
+ msg.text = msg.text.replace(/:::thinking.*?:::/gs, '').trim();
+ }
+
+ return msg;
+ };
+ }
+
async chatCompletion({ payload, onProgress, abortController = null }) {
let error = null;
+ let intermediateReply = [];
const errorCallback = (err) => (error = err);
- const intermediateReply = [];
- const reasoningTokens = [];
try {
if (!abortController) {
abortController = new AbortController();
@@ -1266,6 +1294,19 @@ ${convo}
reasoningKey = 'reasoning';
}
+ this.streamHandler = new SplitStreamHandler({
+ reasoningKey,
+ accumulate: true,
+ runId: this.responseMessageId,
+ handlers: {
+ [GraphEvents.ON_RUN_STEP]: (event) => sendEvent(this.options.res, event),
+ [GraphEvents.ON_MESSAGE_DELTA]: (event) => sendEvent(this.options.res, event),
+ [GraphEvents.ON_REASONING_DELTA]: (event) => sendEvent(this.options.res, event),
+ },
+ });
+
+ intermediateReply = this.streamHandler.tokens;
+
if (modelOptions.stream) {
streamPromise = new Promise((resolve) => {
streamResolve = resolve;
@@ -1292,41 +1333,36 @@ ${convo}
}
if (typeof finalMessage.content !== 'string' || finalMessage.content.trim() === '') {
- finalChatCompletion.choices[0].message.content = intermediateReply.join('');
+ finalChatCompletion.choices[0].message.content = this.streamHandler.tokens.join('');
}
})
.on('finalMessage', (message) => {
if (message?.role !== 'assistant') {
- stream.messages.push({ role: 'assistant', content: intermediateReply.join('') });
+ stream.messages.push({
+ role: 'assistant',
+ content: this.streamHandler.tokens.join(''),
+ });
UnexpectedRoleError = true;
}
});
- let reasoningCompleted = false;
- for await (const chunk of stream) {
- if (chunk?.choices?.[0]?.delta?.[reasoningKey]) {
- if (reasoningTokens.length === 0) {
- const thinkingDirective = '<think>\n';
- intermediateReply.push(thinkingDirective);
- reasoningTokens.push(thinkingDirective);
- onProgress(thinkingDirective);
- }
- const reasoning_content = chunk?.choices?.[0]?.delta?.[reasoningKey] || '';
- intermediateReply.push(reasoning_content);
- reasoningTokens.push(reasoning_content);
- onProgress(reasoning_content);
- }
-
- const token = chunk?.choices?.[0]?.delta?.content || '';
- if (!reasoningCompleted && reasoningTokens.length > 0 && token) {
- reasoningCompleted = true;
- const separatorTokens = '\n</think>\n';
- reasoningTokens.push(separatorTokens);
- onProgress(separatorTokens);
- }
+ if (this.continued === true) {
+ const latestText = addSpaceIfNeeded(
+ this.currentMessages[this.currentMessages.length - 1]?.text ?? '',
+ );
+ this.streamHandler.handle({
+ choices: [
+ {
+ delta: {
+ content: latestText,
+ },
+ },
+ ],
+ });
+ }
- intermediateReply.push(token);
- onProgress(token);
+ for await (const chunk of stream) {
+ this.streamHandler.handle(chunk);
if (abortController.signal.aborted) {
stream.controller.abort();
break;
@@ -1369,7 +1405,7 @@ ${convo}
if (!Array.isArray(choices) || choices.length === 0) {
logger.warn('[OpenAIClient] Chat completion response has no choices');
- return intermediateReply.join('');
+ return this.streamHandler.tokens.join('');
}
const { message, finish_reason } = choices[0] ?? {};
@@ -1379,11 +1415,11 @@ ${convo}
if (!message) {
logger.warn('[OpenAIClient] Message is undefined in chatCompletion response');
- return intermediateReply.join('');
+ return this.streamHandler.tokens.join('');
}
if (typeof message.content !== 'string' || message.content.trim() === '') {
- const reply = intermediateReply.join('');
+ const reply = this.streamHandler.tokens.join('');
logger.debug(
'[OpenAIClient] chatCompletion: using intermediateReply due to empty message.content',
{ intermediateReply: reply },
@@ -1391,8 +1427,18 @@ ${convo}
return reply;
}
- if (reasoningTokens.length > 0 && this.options.context !== 'title') {
- return reasoningTokens.join('') + message.content;
+ if (
+ this.streamHandler.reasoningTokens.length > 0 &&
+ this.options.context !== 'title' &&
+ !message.content.startsWith('<think>')
+ ) {
+ return this.getStreamText();
+ } else if (
+ this.streamHandler.reasoningTokens.length > 0 &&
+ this.options.context !== 'title' &&
+ message.content.startsWith('<think>')
+ ) {
+ return message.content.replace('<think>', ':::thinking').replace('</think>', ':::');
}
return message.content;
diff --git a/api/app/clients/PluginsClient.js b/api/app/clients/PluginsClient.js
index 0e518bfea0..c15258f98c 100644
--- a/api/app/clients/PluginsClient.js
+++ b/api/app/clients/PluginsClient.js
@@ -1,5 +1,4 @@
const OpenAIClient = require('./OpenAIClient');
-const { CacheKeys, Time } = require('librechat-data-provider');
const { CallbackManager } = require('@langchain/core/callbacks/manager');
const { BufferMemory, ChatMessageHistory } = require('langchain/memory');
const { addImages, buildErrorInput, buildPromptPrefix } = require('./output_parsers');
@@ -11,7 +10,6 @@ const checkBalance = require('~/models/checkBalance');
const { isEnabled } = require('~/server/utils');
const { extractBaseURL } = require('~/utils');
const { loadTools } = require('./tools/util');
-const { getLogStores } = require('~/cache');
const { logger } = require('~/config');
class PluginsClient extends OpenAIClient {
@@ -256,17 +254,6 @@ class PluginsClient extends OpenAIClient {
}
this.responsePromise = this.saveMessageToDatabase(responseMessage, saveOptions, user);
- if (responseMessage.text) {
- const messageCache = getLogStores(CacheKeys.MESSAGES);
- messageCache.set(
- responseMessage.messageId,
- {
- text: responseMessage.text,
- complete: true,
- },
- Time.FIVE_MINUTES,
- );
- }
delete responseMessage.tokenCount;
return { ...responseMessage, ...result };
}
diff --git a/api/config/index.js b/api/config/index.js
index c66d92ae43..c2b21cfc07 100644
--- a/api/config/index.js
+++ b/api/config/index.js
@@ -16,7 +16,22 @@ async function getMCPManager() {
return mcpManager;
}
+/**
+ * Sends message data in Server Sent Events format.
+ * @param {ServerResponse} res - The server response.
+ * @param {{ data: string | Record<string, unknown>, event?: string }} event - The message event.
+ * @param {string} event.event - The type of event.
+ * @param {string} event.data - The message to be sent.
+ */
+const sendEvent = (res, event) => {
+ if (typeof event.data === 'string' && event.data.length === 0) {
+ return;
+ }
+ res.write(`event: message\ndata: ${JSON.stringify(event)}\n\n`);
+};
+
module.exports = {
logger,
+ sendEvent,
getMCPManager,
};
diff --git a/api/package.json b/api/package.json
index fe8b1f1f28..f7104d8944 100644
--- a/api/package.json
+++ b/api/package.json
@@ -41,10 +41,10 @@
"@keyv/redis": "^2.8.1",
"@langchain/community": "^0.3.14",
"@langchain/core": "^0.3.18",
- "@langchain/google-genai": "^0.1.6",
- "@langchain/google-vertexai": "^0.1.6",
+ "@langchain/google-genai": "^0.1.7",
+ "@langchain/google-vertexai": "^0.1.8",
"@langchain/textsplitters": "^0.1.0",
- "@librechat/agents": "^1.9.94",
+ "@librechat/agents": "^1.9.97",
"@waylaidwanderer/fetch-event-source": "^3.0.1",
"axios": "^1.7.7",
"bcryptjs": "^2.4.3",
diff --git a/api/server/controllers/AskController.js b/api/server/controllers/AskController.js
index 6534d6b3b3..b952ab0042 100644
--- a/api/server/controllers/AskController.js
+++ b/api/server/controllers/AskController.js
@@ -1,8 +1,6 @@
-const throttle = require('lodash/throttle');
-const { getResponseSender, Constants, CacheKeys, Time } = require('librechat-data-provider');
+const { getResponseSender, Constants } = require('librechat-data-provider');
const { createAbortController, handleAbortError } = require('~/server/middleware');
const { sendMessage, createOnProgress } = require('~/server/utils');
-const { getLogStores } = require('~/cache');
const { saveMessage } = require('~/models');
const { logger } = require('~/config');
@@ -57,33 +55,9 @@ const AskController = async (req, res, next, initializeClient, addTitle) => {
try {
const { client } = await initializeClient({ req, res, endpointOption });
- const messageCache = getLogStores(CacheKeys.MESSAGES);
- const { onProgress: progressCallback, getPartialText } = createOnProgress({
- onProgress: throttle(
- ({ text: partialText }) => {
- /*
- const unfinished = endpointOption.endpoint === EModelEndpoint.google ? false : true;
- messageCache.set(responseMessageId, {
- messageId: responseMessageId,
- sender,
- conversationId,
- parentMessageId: overrideParentMessageId ?? userMessageId,
- text: partialText,
- model: client.modelOptions.model,
- unfinished,
- error: false,
- user,
- }, Time.FIVE_MINUTES);
- */
-
- messageCache.set(responseMessageId, partialText, Time.FIVE_MINUTES);
- },
- 3000,
- { trailing: false },
- ),
- });
+ const { onProgress: progressCallback, getPartialText } = createOnProgress();
- getText = getPartialText;
+ getText = client.getStreamText != null ? client.getStreamText.bind(client) : getPartialText;
const getAbortData = () => ({
sender,
@@ -91,7 +65,7 @@ const AskController = async (req, res, next, initializeClient, addTitle) => {
userMessagePromise,
messageId: responseMessageId,
parentMessageId: overrideParentMessageId ?? userMessageId,
- text: getPartialText(),
+ text: getText(),
userMessage,
promptTokens,
});
diff --git a/api/server/controllers/EditController.js b/api/server/controllers/EditController.js
index 28fe2c4fea..ec618eabcf 100644
--- a/api/server/controllers/EditController.js
+++ b/api/server/controllers/EditController.js
@@ -1,8 +1,6 @@
-const throttle = require('lodash/throttle');
-const { getResponseSender, CacheKeys, Time } = require('librechat-data-provider');
+const { getResponseSender } = require('librechat-data-provider');
const { createAbortController, handleAbortError } = require('~/server/middleware');
const { sendMessage, createOnProgress } = require('~/server/utils');
-const { getLogStores } = require('~/cache');
const { saveMessage } = require('~/models');
const { logger } = require('~/config');
@@ -53,61 +51,43 @@ const EditController = async (req, res, next, initializeClient) => {
}
};
- const messageCache = getLogStores(CacheKeys.MESSAGES);
const { onProgress: progressCallback, getPartialText } = createOnProgress({
generation,
- onProgress: throttle(
- ({ text: partialText }) => {
- /*
- const unfinished = endpointOption.endpoint === EModelEndpoint.google ? false : true;
- {
- messageId: responseMessageId,
- sender,
- conversationId,
- parentMessageId: overrideParentMessageId ?? userMessageId,
- text: partialText,
- model: endpointOption.modelOptions.model,
- unfinished,
- isEdited: true,
- error: false,
- user,
- } */
- messageCache.set(responseMessageId, partialText, Time.FIVE_MINUTES);
- },
- 3000,
- { trailing: false },
- ),
});
- const getAbortData = () => ({
- conversationId,
- userMessagePromise,
- messageId: responseMessageId,
- sender,
- parentMessageId: overrideParentMessageId ?? userMessageId,
- text: getPartialText(),
- userMessage,
- promptTokens,
- });
+ let getText;
- const { abortController, onStart } = createAbortController(req, res, getAbortData, getReqData);
+ try {
+ const { client } = await initializeClient({ req, res, endpointOption });
- res.on('close', () => {
- logger.debug('[EditController] Request closed');
- if (!abortController) {
- return;
- } else if (abortController.signal.aborted) {
- return;
- } else if (abortController.requestCompleted) {
- return;
- }
+ getText = client.getStreamText != null ? client.getStreamText.bind(client) : getPartialText;
- abortController.abort();
- logger.debug('[EditController] Request aborted on close');
- });
+ const getAbortData = () => ({
+ conversationId,
+ userMessagePromise,
+ messageId: responseMessageId,
+ sender,
+ parentMessageId: overrideParentMessageId ?? userMessageId,
+ text: getText(),
+ userMessage,
+ promptTokens,
+ });
- try {
- const { client } = await initializeClient({ req, res, endpointOption });
+ const { abortController, onStart } = createAbortController(req, res, getAbortData, getReqData);
+
+ res.on('close', () => {
+ logger.debug('[EditController] Request closed');
+ if (!abortController) {
+ return;
+ } else if (abortController.signal.aborted) {
+ return;
+ } else if (abortController.requestCompleted) {
+ return;
+ }
+
+ abortController.abort();
+ logger.debug('[EditController] Request aborted on close');
+ });
let response = await client.sendMessage(text, {
user,
@@ -153,7 +133,7 @@ const EditController = async (req, res, next, initializeClient) => {
);
}
} catch (error) {
- const partialText = getPartialText();
+ const partialText = getText();
handleAbortError(res, req, error, {
partialText,
conversationId,
diff --git a/api/server/controllers/agents/callbacks.js b/api/server/controllers/agents/callbacks.js
index 706b9db83d..53b45d3b6d 100644
--- a/api/server/controllers/agents/callbacks.js
+++ b/api/server/controllers/agents/callbacks.js
@@ -10,7 +10,7 @@ const {
const { processCodeOutput } = require('~/server/services/Files/Code/process');
const { saveBase64Image } = require('~/server/services/Files/process');
const { loadAuthValues } = require('~/app/clients/tools/util');
-const { logger } = require('~/config');
+const { logger, sendEvent } = require('~/config');
/** @typedef {import('@librechat/agents').Graph} Graph */
/** @typedef {import('@librechat/agents').EventHandler} EventHandler */
@@ -21,20 +21,6 @@ const { logger } = require('~/config');
/** @typedef {import('@librechat/agents').ContentAggregatorResult['aggregateContent']} ContentAggregator */
/** @typedef {import('@librechat/agents').GraphEvents} GraphEvents */
-/**
- * Sends message data in Server Sent Events format.
- * @param {ServerResponse} res - The server response.
- * @param {{ data: string | Record<string, unknown>, event?: string }} event - The message event.
- * @param {string} event.event - The type of event.
- * @param {string} event.data - The message to be sent.
- */
-const sendEvent = (res, event) => {
- if (typeof event.data === 'string' && event.data.length === 0) {
- return;
- }
- res.write(`event: message\ndata: ${JSON.stringify(event)}\n\n`);
-};
-
class ModelEndHandler {
/**
* @param {Array<UsageMetadata>} collectedUsage
@@ -322,7 +308,6 @@ function createToolEndCallback({ req, res, artifactPromises }) {
}
module.exports = {
- sendEvent,
getDefaultHandlers,
createToolEndCallback,
};
diff --git a/api/server/controllers/assistants/chatV2.js b/api/server/controllers/assistants/chatV2.js
index 047a413433..24a8e38fa4 100644
--- a/api/server/controllers/assistants/chatV2.js
+++ b/api/server/controllers/assistants/chatV2.js
@@ -397,18 +397,6 @@ const chatV2 = async (req, res) => {
response = streamRunManager;
response.text = streamRunManager.intermediateText;
-
- if (response.text) {
- const messageCache = getLogStores(CacheKeys.MESSAGES);
- messageCache.set(
- responseMessageId,
- {
- complete: true,
- text: response.text,
- },
- Time.FIVE_MINUTES,
- );
- }
};
await processRun();
diff --git a/api/server/routes/ask/gptPlugins.js b/api/server/routes/ask/gptPlugins.js
index 8408e7a5d6..036654f845 100644
--- a/api/server/routes/ask/gptPlugins.js
+++ b/api/server/routes/ask/gptPlugins.js
@@ -1,11 +1,9 @@
const express = require('express');
-const throttle = require('lodash/throttle');
-const { getResponseSender, Constants, CacheKeys, Time } = require('librechat-data-provider');
+const { getResponseSender, Constants } = require('librechat-data-provider');
const { initializeClient } = require('~/server/services/Endpoints/gptPlugins');
const { sendMessage, createOnProgress } = require('~/server/utils');
const { addTitle } = require('~/server/services/Endpoints/openAI');
const { saveMessage, updateMessage } = require('~/models');
-const { getLogStores } = require('~/cache');
const {
handleAbort,
createAbortController,
@@ -72,15 +70,6 @@ router.post(
}
};
- const messageCache = getLogStores(CacheKeys.MESSAGES);
- const throttledCacheSet = throttle(
- (text) => {
- messageCache.set(responseMessageId, text, Time.FIVE_MINUTES);
- },
- 3000,
- { trailing: false },
- );
-
let streaming = null;
let timer = null;
@@ -89,13 +78,11 @@ router.post(
sendIntermediateMessage,
getPartialText,
} = createOnProgress({
- onProgress: ({ text: partialText }) => {
+ onProgress: () => {
if (timer) {
clearTimeout(timer);
}
- throttledCacheSet(partialText);
-
streaming = new Promise((resolve) => {
timer = setTimeout(() => {
resolve();
diff --git a/api/server/routes/edit/gptPlugins.js b/api/server/routes/edit/gptPlugins.js
index cd4e575e83..5547a1fcdf 100644
--- a/api/server/routes/edit/gptPlugins.js
+++ b/api/server/routes/edit/gptPlugins.js
@@ -1,6 +1,5 @@
const express = require('express');
-const throttle = require('lodash/throttle');
-const { getResponseSender, CacheKeys, Time } = require('librechat-data-provider');
+const { getResponseSender } = require('librechat-data-provider');
const {
setHeaders,
handleAbort,
@@ -14,7 +13,6 @@ const {
const { sendMessage, createOnProgress, formatSteps, formatAction } = require('~/server/utils');
const { initializeClient } = require('~/server/services/Endpoints/gptPlugins');
const { saveMessage, updateMessage } = require('~/models');
-const { getLogStores } = require('~/cache');
const { validateTools } = require('~/app');
const { logger } = require('~/config');
@@ -80,26 +78,16 @@ router.post(
}
};
- const messageCache = getLogStores(CacheKeys.MESSAGES);
- const throttledCacheSet = throttle(
- (text) => {
- messageCache.set(responseMessageId, text, Time.FIVE_MINUTES);
- },
- 3000,
- { trailing: false },
- );
-
const {
onProgress: progressCallback,
sendIntermediateMessage,
getPartialText,
} = createOnProgress({
generation,
- onProgress: ({ text: partialText }) => {
+ onProgress: () => {
if (plugin.loading === true) {
plugin.loading = false;
}
- throttledCacheSet(partialText);
},
});
diff --git a/api/server/routes/messages.js b/api/server/routes/messages.js
index 770cb0f67e..54c4aab1c2 100644
--- a/api/server/routes/messages.js
+++ b/api/server/routes/messages.js
@@ -21,7 +21,7 @@ router.post('/artifact/:messageId', async (req, res) => {
const { messageId } = req.params;
const { index, original, updated } = req.body;
- if (typeof index !== 'number' || index < 0 || !original || !updated) {
+ if (typeof index !== 'number' || index < 0 || original == null || updated == null) {
return res.status(400).json({ error: 'Invalid request parameters' });
}
diff --git a/api/server/services/Artifacts/update.js b/api/server/services/Artifacts/update.js
index f17c2c0b67..69cb4bb5c4 100644
--- a/api/server/services/Artifacts/update.js
+++ b/api/server/services/Artifacts/update.js
@@ -57,14 +57,42 @@ const findAllArtifacts = (message) => {
const replaceArtifactContent = (originalText, artifact, original, updated) => {
const artifactContent = artifact.text.substring(artifact.start, artifact.end);
- const relativeIndex = artifactContent.indexOf(original);
+
+ // Find boundaries between ARTIFACT_START and ARTIFACT_END
+ const contentStart = artifactContent.indexOf('\n', artifactContent.indexOf(ARTIFACT_START)) + 1;
+ const contentEnd = artifactContent.lastIndexOf(ARTIFACT_END);
+
+ if (contentStart === -1 || contentEnd === -1) {
+ return null;
+ }
+
+ // Check if there are code blocks
+ const codeBlockStart = artifactContent.indexOf('```\n', contentStart);
+ const codeBlockEnd = artifactContent.lastIndexOf('\n```', contentEnd);
+
+ // Determine where to look for the original content
+ let searchStart, searchEnd;
+ if (codeBlockStart !== -1 && codeBlockEnd !== -1) {
+ // If code blocks exist, search between them
+ searchStart = codeBlockStart + 4; // after ```\n
+ searchEnd = codeBlockEnd;
+ } else {
+ // Otherwise search in the whole artifact content
+ searchStart = contentStart;
+ searchEnd = contentEnd;
+ }
+
+ const innerContent = artifactContent.substring(searchStart, searchEnd);
+ // Remove trailing newline from original for comparison
+ const originalTrimmed = original.replace(/\n$/, '');
+ const relativeIndex = innerContent.indexOf(originalTrimmed);
if (relativeIndex === -1) {
return null;
}
- const absoluteIndex = artifact.start + relativeIndex;
- const endText = originalText.substring(absoluteIndex + original.length);
+ const absoluteIndex = artifact.start + searchStart + relativeIndex;
+ const endText = originalText.substring(absoluteIndex + originalTrimmed.length);
const hasTrailingNewline = endText.startsWith('\n');
const updatedText =
diff --git a/api/server/services/Artifacts/update.spec.js b/api/server/services/Artifacts/update.spec.js
index 8008e553ba..2f5b9d7bf6 100644
--- a/api/server/services/Artifacts/update.spec.js
+++ b/api/server/services/Artifacts/update.spec.js
@@ -260,8 +260,61 @@ console.log(greeting);`;
codeExample,
'updated content',
);
- console.log(result);
expect(result).toMatch(/id="2".*updated content/s);
expect(result).toMatch(new RegExp(`${ARTIFACT_START}.*updated content.*${ARTIFACT_END}`, 's'));
});
+
+ test('should handle empty content in artifact without code blocks', () => {
+ const artifactText = `${ARTIFACT_START}\n\n${ARTIFACT_END}`;
+ const artifact = {
+ start: 0,
+ end: artifactText.length,
+ text: artifactText,
+ source: 'text',
+ };
+
+ const result = replaceArtifactContent(artifactText, artifact, '', 'new content');
+ expect(result).toBe(`${ARTIFACT_START}\nnew content\n${ARTIFACT_END}`);
+ });
+
+ test('should handle empty content in artifact with code blocks', () => {
+ const artifactText = createArtifactText({ content: '' });
+ const artifact = {
+ start: 0,
+ end: artifactText.length,
+ text: artifactText,
+ source: 'text',
+ };
+
+ const result = replaceArtifactContent(artifactText, artifact, '', 'new content');
+ expect(result).toMatch(/```\nnew content\n```/);
+ });
+
+ test('should handle content with trailing newline in code blocks', () => {
+ const contentWithNewline = 'console.log("test")\n';
+ const message = {
+ text: `Some prefix text\n${createArtifactText({
+ content: contentWithNewline,
+ })}\nSome suffix text`,
+ };
+
+ const artifacts = findAllArtifacts(message);
+ expect(artifacts).toHaveLength(1);
+
+ const result = replaceArtifactContent(
+ message.text,
+ artifacts[0],
+ contentWithNewline,
+ 'updated content',
+ );
+
+ // Should update the content and preserve artifact structure
+ expect(result).toContain('```\nupdated content\n```');
+ // Should preserve surrounding text
+ expect(result).toMatch(/^Some prefix text\n/);
+ expect(result).toMatch(/\nSome suffix text$/);
+ // Should not have extra newlines
+ expect(result).not.toContain('\n\n```');
+ expect(result).not.toContain('```\n\n');
+ });
});
diff --git a/api/server/services/Files/Audio/TTSService.js b/api/server/services/Files/Audio/TTSService.js
index bfb90843da..cd718fdfc1 100644
--- a/api/server/services/Files/Audio/TTSService.js
+++ b/api/server/services/Files/Audio/TTSService.js
@@ -364,7 +364,7 @@ class TTSService {
shouldContinue = false;
});
- const processChunks = createChunkProcessor(req.body.messageId);
+ const processChunks = createChunkProcessor(req.user.id, req.body.messageId);
try {
while (shouldContinue) {
diff --git a/api/server/services/Files/Audio/streamAudio.js b/api/server/services/Files/Audio/streamAudio.js
index 7b6bef03f8..ac046e68a6 100644
--- a/api/server/services/Files/Audio/streamAudio.js
+++ b/api/server/services/Files/Audio/streamAudio.js
@@ -1,4 +1,5 @@
-const { CacheKeys, findLastSeparatorIndex, SEPARATORS } = require('librechat-data-provider');
+const { CacheKeys, findLastSeparatorIndex, SEPARATORS, Time } = require('librechat-data-provider');
+const { getMessage } = require('~/models/Message');
const { getLogStores } = require('~/cache');
/**
@@ -47,10 +48,11 @@ const MAX_NOT_FOUND_COUNT = 6;
const MAX_NO_CHANGE_COUNT = 10;
/**
+ * @param {string} user
* @param {string} messageId
* @returns {() => Promise<{ text: string, isFinished: boolean }[]>}
*/
-function createChunkProcessor(messageId) {
+function createChunkProcessor(user, messageId) {
let notFoundCount = 0;
let noChangeCount = 0;
let processedText = '';
@@ -73,15 +75,27 @@ function createChunkProcessor(messageId) {
}
/** @type { string | { text: string; complete: boolean } } */
- const message = await messageCache.get(messageId);
+ let message = await messageCache.get(messageId);
+ if (!message) {
+ message = await getMessage({ user, messageId });
+ }
if (!message) {
notFoundCount++;
return [];
+ } else {
+ messageCache.set(
+ messageId,
+ {
+ text: message.text,
+ complete: true,
+ },
+ Time.FIVE_MINUTES,
+ );
}
const text = typeof message === 'string' ? message : message.text;
- const complete = typeof message === 'string' ? false : message.complete;
+ const complete = typeof message === 'string' ? false : message.complete ?? true;
if (text === processedText) {
noChangeCount++;
diff --git a/api/server/services/Files/Audio/streamAudio.spec.js b/api/server/services/Files/Audio/streamAudio.spec.js
index 501e252c14..e76c0849c7 100644
--- a/api/server/services/Files/Audio/streamAudio.spec.js
+++ b/api/server/services/Files/Audio/streamAudio.spec.js
@@ -3,6 +3,13 @@ const { createChunkProcessor, splitTextIntoChunks } = require('./streamAudio');
jest.mock('keyv');
const globalCache = {};
+jest.mock('~/models/Message', () => {
+ return {
+ getMessage: jest.fn().mockImplementation((messageId) => {
+ return globalCache[messageId] || null;
+ }),
+ };
+});
jest.mock('~/cache/getLogStores', () => {
return jest.fn().mockImplementation(() => {
const EventEmitter = require('events');
@@ -56,9 +63,10 @@ describe('processChunks', () => {
jest.resetAllMocks();
mockMessageCache = {
get: jest.fn(),
+ set: jest.fn(),
};
require('~/cache/getLogStores').mockReturnValue(mockMessageCache);
- processChunks = createChunkProcessor('message-id');
+ processChunks = createChunkProcessor('userId', 'message-id');
});
it('should return an empty array when the message is not found', async () => {
diff --git a/api/server/services/Runs/StreamRunManager.js b/api/server/services/Runs/StreamRunManager.js
index ae00659983..4bab7326bb 100644
--- a/api/server/services/Runs/StreamRunManager.js
+++ b/api/server/services/Runs/StreamRunManager.js
@@ -1,19 +1,15 @@
-const throttle = require('lodash/throttle');
const {
- Time,
- CacheKeys,
+ Constants,
StepTypes,
ContentTypes,
ToolCallTypes,
MessageContentTypes,
AssistantStreamEvents,
- Constants,
} = require('librechat-data-provider');
const { retrieveAndProcessFile } = require('~/server/services/Files/process');
const { processRequiredActions } = require('~/server/services/ToolService');
const { createOnProgress, sendMessage, sleep } = require('~/server/utils');
const { processMessages } = require('~/server/services/Threads');
-const { getLogStores } = require('~/cache');
const { logger } = require('~/config');
/**
@@ -611,20 +607,8 @@ class StreamRunManager {
const index = this.getStepIndex(stepKey);
this.orderedRunSteps.set(index, message_creation);
- const messageCache = getLogStores(CacheKeys.MESSAGES);
- // Create the Factory Function to stream the message
- const { onProgress: progressCallback } = createOnProgress({
- onProgress: throttle(
- () => {
- messageCache.set(this.finalMessage.messageId, this.getText(), Time.FIVE_MINUTES);
- },
- 3000,
- { trailing: false },
- ),
- });
+ const { onProgress: progressCallback } = createOnProgress();
- // This creates a function that attaches all of the parameters
- // specified here to each SSE message generated by the TextStream
const onProgress = progressCallback({
index,
res: this.res,
diff --git a/api/server/utils/handleText.js b/api/server/utils/handleText.js
index 92f8253fc7..9567944d1c 100644
--- a/api/server/utils/handleText.js
+++ b/api/server/utils/handleText.js
@@ -18,7 +18,12 @@ const citationRegex = /\[\^\d+?\^]/g;
const addSpaceIfNeeded = (text) => (text.length > 0 && !text.endsWith(' ') ? text + ' ' : text);
const base = { message: true, initial: true };
-const createOnProgress = ({ generation = '', onProgress: _onProgress }) => {
+const createOnProgress = (
+ { generation = '', onProgress: _onProgress } = {
+ generation: '',
+ onProgress: null,
+ },
+) => {
let i = 0;
let tokens = addSpaceIfNeeded(generation);
diff --git a/client/public/assets/silence.mp3 b/client/public/assets/silence.mp3
new file mode 100644
index 0000000000..482395f021
Binary files /dev/null and b/client/public/assets/silence.mp3 differ
diff --git a/client/src/App.jsx b/client/src/App.jsx
index e2b11b261f..38e568e422 100644
--- a/client/src/App.jsx
+++ b/client/src/App.jsx
@@ -49,5 +49,14 @@ const App = () => {
export default () => (
<ScreenshotProvider>
<App />
+ <iframe
+ src="/assets/silence.mp3"
+ allow="autoplay"
+ id="audio"
+ title="audio-silence"
+ style={{
+ display: 'none',
+ }}
+ />
</ScreenshotProvider>
);
diff --git a/client/src/Providers/MessageContext.tsx b/client/src/Providers/MessageContext.tsx
index 6673dd2eb3..31e16460fb 100644
--- a/client/src/Providers/MessageContext.tsx
+++ b/client/src/Providers/MessageContext.tsx
@@ -1,7 +1,9 @@
import { createContext, useContext } from 'react';
type MessageContext = {
messageId: string;
+ nextType?: string;
partIndex?: number;
+ isExpanded: boolean;
conversationId?: string | null;
};
diff --git a/client/src/components/Artifacts/Artifact.tsx b/client/src/components/Artifacts/Artifact.tsx
index b8e21c4790..97558302b5 100644
--- a/client/src/components/Artifacts/Artifact.tsx
+++ b/client/src/components/Artifacts/Artifact.tsx
@@ -62,10 +62,6 @@ export function Artifact({
const content = extractContent(props.children);
logger.log('artifacts', 'updateArtifact: content.length', content.length);
- if (!content || content.trim() === '') {
- return;
- }
-
const title = props.title ?? 'Untitled Artifact';
const type = props.type ?? 'unknown';
const identifier = props.identifier ?? 'no-identifier';
diff --git a/client/src/components/Artifacts/ArtifactCodeEditor.tsx b/client/src/components/Artifacts/ArtifactCodeEditor.tsx
index 0f52e43f01..51f4645637 100644
--- a/client/src/components/Artifacts/ArtifactCodeEditor.tsx
+++ b/client/src/components/Artifacts/ArtifactCodeEditor.tsx
@@ -43,7 +43,6 @@ const CodeEditor = ({
},
onError: () => {
setIsMutating(false);
- setCurrentCode(artifact.content);
},
});
diff --git a/client/src/components/Artifacts/Thinking.tsx b/client/src/components/Artifacts/Thinking.tsx
index 4335603788..ed0540d337 100644
--- a/client/src/components/Artifacts/Thinking.tsx
+++ b/client/src/components/Artifacts/Thinking.tsx
@@ -1,20 +1,62 @@
-import { useState } from 'react';
+import { useState, useMemo, memo, useCallback } from 'react';
+import { useRecoilValue } from 'recoil';
import { Atom, ChevronDown } from 'lucide-react';
-import type { MouseEvent } from 'react';
-import useLocalize from '~/hooks/useLocalize';
+import type { MouseEvent, FC } from 'react';
+import { useLocalize } from '~/hooks';
+import store from '~/store';
-interface ThinkingProps {
- children: React.ReactNode;
-}
+const BUTTON_STYLES = {
+ base: 'group mt-3 flex w-fit items-center justify-center rounded-xl bg-surface-tertiary px-3 py-2 text-xs leading-[18px] animate-thinking-appear',
+ icon: 'icon-sm ml-1.5 transform-gpu text-text-primary transition-transform duration-200',
+} as const;
-const Thinking = ({ children }: ThinkingProps) => {
+const CONTENT_STYLES = {
+ wrapper: 'relative pl-3 text-text-secondary',
+ border:
+ 'absolute left-0 h-[calc(100%-10px)] border-l-2 border-border-medium dark:border-border-heavy',
+ partBorder:
+ 'absolute left-0 h-[calc(100%)] border-l-2 border-border-medium dark:border-border-heavy',
+ text: 'whitespace-pre-wrap leading-[26px]',
+} as const;
+
+export const ThinkingContent: FC<{ children: React.ReactNode; isPart?: boolean }> = memo(
+ ({ isPart, children }) => (
+ <div className={CONTENT_STYLES.wrapper}>
+ <div className={isPart === true ? CONTENT_STYLES.partBorder : CONTENT_STYLES.border} />
+ <p className={CONTENT_STYLES.text}>{children}</p>
+ </div>
+ ),
+);
+
+export const ThinkingButton = memo(
+ ({
+ isExpanded,
+ onClick,
+ label,
+ }: {
+ isExpanded: boolean;
+ onClick: (e: MouseEvent<HTMLButtonElement>) => void;
+ label: string;
+ }) => (
+ <button type="button" onClick={onClick} className={BUTTON_STYLES.base}>
+ <Atom size={14} className="mr-1.5 text-text-secondary" />
+ {label}
+ <ChevronDown className={`${BUTTON_STYLES.icon} ${isExpanded ? 'rotate-180' : ''}`} />
+ </button>
+ ),
+);
+
+const Thinking: React.ElementType = memo(({ children }: { children: React.ReactNode }) => {
const localize = useLocalize();
- const [isExpanded, setIsExpanded] = useState(true);
+ const showThinking = useRecoilValue<boolean>(store.showThinking);
+ const [isExpanded, setIsExpanded] = useState(showThinking);
- const handleClick = (e: MouseEvent<HTMLButtonElement>) => {
+ const handleClick = useCallback((e: MouseEvent<HTMLButtonElement>) => {
e.preventDefault();
- setIsExpanded(!isExpanded);
- };
+ setIsExpanded((prev) => !prev);
+ }, []);
+
+ const label = useMemo(() => localize('com_ui_thoughts'), [localize]);
if (children == null) {
return null;
@@ -22,28 +64,23 @@ const Thinking = ({ children }: ThinkingProps) => {
return (
<div className="mb-3">
- <button
- type="button"
- onClick={handleClick}
- className="group mb-3 flex w-fit items-center justify-center rounded-xl bg-surface-tertiary px-3.5 py-2 text-xs leading-[18px] text-text-primary transition-colors hover:bg-surface-secondary"
+ <ThinkingButton isExpanded={isExpanded} onClick={handleClick} label={label} />
+ <div
+ className="grid transition-all duration-300 ease-out"
+ style={{
+ gridTemplateRows: isExpanded ? '1fr' : '0fr',
+ }}
>
- <Atom size={14} className="mr-1.5 text-text-secondary" />
- {localize('com_ui_thoughts')}
- <ChevronDown
- className="icon-sm ml-1.5 text-text-primary transition-transform duration-200"
- style={{
- transform: isExpanded ? 'rotate(180deg)' : 'rotate(0deg)',
- }}
- />
- </button>
- {isExpanded && (
- <div className="relative pl-3 text-text-secondary">
- <div className="absolute left-0 top-[5px] h-[calc(100%-10px)] border-l-2 border-border-medium dark:border-border-heavy" />
- <p className="my-4 whitespace-pre-wrap leading-[26px]">{children}</p>
+ <div className="overflow-hidden">
+ <ThinkingContent>{children}</ThinkingContent>
</div>
- )}
+ </div>
</div>
);
-};
+});
+
+ThinkingButton.displayName = 'ThinkingButton';
+ThinkingContent.displayName = 'ThinkingContent';
+Thinking.displayName = 'Thinking';
-export default Thinking;
+export default memo(Thinking);
diff --git a/client/src/components/Audio/TTS.tsx b/client/src/components/Audio/TTS.tsx
index c8c3b28590..14c6346b0f 100644
--- a/client/src/components/Audio/TTS.tsx
+++ b/client/src/components/Audio/TTS.tsx
@@ -1,3 +1,4 @@
+/* eslint-disable jsx-a11y/media-has-caption */
import { useEffect, useMemo } from 'react';
import { useRecoilValue } from 'recoil';
import type { TMessageAudio } from '~/common';
@@ -78,7 +79,6 @@ export function BrowserTTS({ isLast, index, messageId, content, className }: TMe
logger.error('Error fetching audio:', error);
}}
id={`audio-${messageId}`}
- muted
autoPlay
/>
</>
@@ -169,7 +169,6 @@ export function EdgeTTS({ isLast, index, messageId, content, className }: TMessa
logger.error('Error fetching audio:', error);
}}
id={`audio-${messageId}`}
- muted
autoPlay
/>
) : null}
@@ -248,7 +247,6 @@ export function ExternalTTS({ isLast, index, messageId, content, className }: TM
logger.error('Error fetching audio:', error);
}}
id={`audio-${messageId}`}
- muted
autoPlay
/>
</>
diff --git a/client/src/components/Chat/Input/StreamAudio.tsx b/client/src/components/Chat/Input/StreamAudio.tsx
index cd36ac30a3..83eb9e7fae 100644
--- a/client/src/components/Chat/Input/StreamAudio.tsx
+++ b/client/src/components/Chat/Input/StreamAudio.tsx
@@ -53,7 +53,7 @@ export default function StreamAudio({ index = 0 }) {
const shouldFetch = !!(
token != null &&
automaticPlayback &&
- isSubmitting &&
+ !isSubmitting &&
latestMessage &&
!latestMessage.isCreatedByUser &&
latestText &&
@@ -118,14 +118,14 @@ export default function StreamAudio({ index = 0 }) {
}
let done = false;
- const chunks: Uint8Array[] = [];
+ const chunks: ArrayBuffer[] = [];
while (!done) {
const readPromise = reader.read();
const { value, done: readerDone } = (await Promise.race([
readPromise,
timeoutPromise(maxPromiseTime, promiseTimeoutMessage),
- ])) as ReadableStreamReadResult<Uint8Array>;
+ ])) as ReadableStreamReadResult<ArrayBuffer>;
if (cacheTTS && value) {
chunks.push(value);
@@ -195,8 +195,8 @@ export default function StreamAudio({ index = 0 }) {
useEffect(() => {
if (
- playbackRate &&
- globalAudioURL &&
+ playbackRate != null &&
+ globalAudioURL != null &&
playbackRate > 0 &&
audioRef.current &&
audioRef.current.playbackRate !== playbackRate
@@ -213,6 +213,7 @@ export default function StreamAudio({ index = 0 }) {
logger.log('StreamAudio.tsx - globalAudioURL:', globalAudioURL);
return (
+ // eslint-disable-next-line jsx-a11y/media-has-caption
<audio
ref={audioRef}
controls
@@ -226,7 +227,6 @@ export default function StreamAudio({ index = 0 }) {
}}
src={globalAudioURL ?? undefined}
id={globalAudioId}
- muted
autoPlay
/>
);
diff --git a/client/src/components/Chat/Messages/Content/ContentParts.tsx b/client/src/components/Chat/Messages/Content/ContentParts.tsx
index a59093e160..ce77e3bfdb 100644
--- a/client/src/components/Chat/Messages/Content/ContentParts.tsx
+++ b/client/src/components/Chat/Messages/Content/ContentParts.tsx
@@ -1,8 +1,10 @@
-import { memo, useMemo } from 'react';
-import { useRecoilValue } from 'recoil';
+import { memo, useMemo, useState } from 'react';
+import { useRecoilValue, useRecoilState } from 'recoil';
import { ContentTypes } from 'librechat-data-provider';
import type { TMessageContentParts, TAttachment, Agents } from 'librechat-data-provider';
+import { ThinkingButton } from '~/components/Artifacts/Thinking';
import EditTextPart from './Parts/EditTextPart';
+import useLocalize from '~/hooks/useLocalize';
import { mapAttachments } from '~/utils/map';
import { MessageContext } from '~/Providers';
import store from '~/store';
@@ -39,11 +41,20 @@ const ContentParts = memo(
siblingIdx,
setSiblingIdx,
}: ContentPartsProps) => {
+ const localize = useLocalize();
+ const [showThinking, setShowThinking] = useRecoilState<boolean>(store.showThinking);
+ const [isExpanded, setIsExpanded] = useState(showThinking);
const messageAttachmentsMap = useRecoilValue(store.messageAttachmentsMap);
const attachmentMap = useMemo(
() => mapAttachments(attachments ?? messageAttachmentsMap[messageId] ?? []),
[attachments, messageAttachmentsMap, messageId],
);
+
+ const hasReasoningParts = useMemo(
+ () => content?.some((part) => part?.type === ContentTypes.THINK && part.think) ?? false,
+ [content],
+ );
+
if (!content) {
return null;
}
@@ -74,6 +85,21 @@ const ContentParts = memo(
return (
<>
+ {hasReasoningParts && (
+ <div className="mb-5">
+ <ThinkingButton
+ isExpanded={isExpanded}
+ onClick={() =>
+ setIsExpanded((prev) => {
+ const val = !prev;
+ setShowThinking(val);
+ return val;
+ })
+ }
+ label={isSubmitting ? localize('com_ui_thinking') : localize('com_ui_thoughts')}
+ />
+ </div>
+ )}
{content
.filter((part) => part)
.map((part, idx) => {
@@ -88,6 +114,8 @@ const ContentParts = memo(
messageId,
conversationId,
partIndex: idx,
+ isExpanded,
+ nextType: content[idx + 1]?.type,
}}
>
<Part
diff --git a/client/src/components/Chat/Messages/Content/Markdown.tsx b/client/src/components/Chat/Messages/Content/Markdown.tsx
index 8f8a1a72f0..8cb33948b4 100644
--- a/client/src/components/Chat/Messages/Content/Markdown.tsx
+++ b/client/src/components/Chat/Messages/Content/Markdown.tsx
@@ -23,7 +23,7 @@ import useLocalize from '~/hooks/useLocalize';
import store from '~/store';
type TCodeProps = {
- inline: boolean;
+ inline?: boolean;
className?: string;
children: React.ReactNode;
};
@@ -42,7 +42,7 @@ export const code: React.ElementType = memo(({ className, children }: TCodeProps
}, [children, resetCounter]);
if (isMath) {
- return children;
+ return <>{children}</>;
} else if (isSingleLine) {
return (
<code onDoubleClick={handleDoubleClick} className={className}>
@@ -71,79 +71,86 @@ export const codeNoExecution: React.ElementType = memo(({ className, children }:
}
});
-export const a: React.ElementType = memo(
- ({ href, children }: { href: string; children: React.ReactNode }) => {
- const user = useRecoilValue(store.user);
- const { showToast } = useToastContext();
- const localize = useLocalize();
-
- const {
- file_id = '',
- filename = '',
- filepath,
- } = useMemo(() => {
- const pattern = new RegExp(`(?:files|outputs)/${user?.id}/([^\\s]+)`);
- const match = href.match(pattern);
- if (match && match[0]) {
- const path = match[0];
- const parts = path.split('/');
- const name = parts.pop();
- const file_id = parts.pop();
- return { file_id, filename: name, filepath: path };
- }
- return { file_id: '', filename: '', filepath: '' };
- }, [user?.id, href]);
-
- const { refetch: downloadFile } = useFileDownload(user?.id ?? '', file_id);
- const props: { target?: string; onClick?: React.MouseEventHandler } = { target: '_new' };
-
- if (!file_id || !filename) {
- return (
- <a href={href} {...props}>
- {children}
- </a>
- );
- }
+type TAnchorProps = {
+ href: string;
+ children: React.ReactNode;
+};
- const handleDownload = async (event: React.MouseEvent<HTMLAnchorElement>) => {
- event.preventDefault();
- try {
- const stream = await downloadFile();
- if (stream.data == null || stream.data === '') {
- console.error('Error downloading file: No data found');
- showToast({
- status: 'error',
- message: localize('com_ui_download_error'),
- });
- return;
- }
- const link = document.createElement('a');
- link.href = stream.data;
- link.setAttribute('download', filename);
- document.body.appendChild(link);
- link.click();
- document.body.removeChild(link);
- window.URL.revokeObjectURL(stream.data);
- } catch (error) {
- console.error('Error downloading file:', error);
- }
- };
+export const a: React.ElementType = memo(({ href, children }: TAnchorProps) => {
+ const user = useRecoilValue(store.user);
+ const { showToast } = useToastContext();
+ const localize = useLocalize();
+
+ const {
+ file_id = '',
+ filename = '',
+ filepath,
+ } = useMemo(() => {
+ const pattern = new RegExp(`(?:files|outputs)/${user?.id}/([^\\s]+)`);
+ const match = href.match(pattern);
+ if (match && match[0]) {
+ const path = match[0];
+ const parts = path.split('/');
+ const name = parts.pop();
+ const file_id = parts.pop();
+ return { file_id, filename: name, filepath: path };
+ }
+ return { file_id: '', filename: '', filepath: '' };
+ }, [user?.id, href]);
- props.onClick = handleDownload;
- props.target = '_blank';
+ const { refetch: downloadFile } = useFileDownload(user?.id ?? '', file_id);
+ const props: { target?: string; onClick?: React.MouseEventHandler } = { target: '_new' };
+ if (!file_id || !filename) {
return (
- <a
- href={filepath.startsWith('files/') ? `/api/${filepath}` : `/api/files/${filepath}`}
- {...props}
- >
+ <a href={href} {...props}>
{children}
</a>
);
- },
-);
+ }
+
+ const handleDownload = async (event: React.MouseEvent<HTMLAnchorElement>) => {
+ event.preventDefault();
+ try {
+ const stream = await downloadFile();
+ if (stream.data == null || stream.data === '') {
+ console.error('Error downloading file: No data found');
+ showToast({
+ status: 'error',
+ message: localize('com_ui_download_error'),
+ });
+ return;
+ }
+ const link = document.createElement('a');
+ link.href = stream.data;
+ link.setAttribute('download', filename);
+ document.body.appendChild(link);
+ link.click();
+ document.body.removeChild(link);
+ window.URL.revokeObjectURL(stream.data);
+ } catch (error) {
+ console.error('Error downloading file:', error);
+ }
+ };
+
+ props.onClick = handleDownload;
+ props.target = '_blank';
+
+ return (
+ <a
+ href={filepath.startsWith('files/') ? `/api/${filepath}` : `/api/files/${filepath}`}
+ {...props}
+ >
+ {children}
+ </a>
+ );
+});
-export const p: React.ElementType = memo(({ children }: { children: React.ReactNode }) => {
+type TParagraphProps = {
+ children: React.ReactNode;
+};
+
+export const p: React.ElementType = memo(({ children }: TParagraphProps) => {
return <p className="mb-2 whitespace-pre-wrap">{children}</p>;
});
@@ -157,27 +164,40 @@ type TContentProps = {
const Markdown = memo(({ content = '', showCursor, isLatestMessage }: TContentProps) => {
const LaTeXParsing = useRecoilValue<boolean>(store.LaTeXParsing);
-
const isInitializing = content === '';
- let currentContent = content;
- if (!isInitializing) {
- currentContent = currentContent.replace('<think>', ':::thinking') || '';
- currentContent = currentContent.replace('</think>', ':::') || '';
- currentContent = LaTeXParsing ? preprocessLaTeX(currentContent) : currentContent;
- }
+ const currentContent = useMemo(() => {
+ if (isInitializing) {
+ return '';
+ }
+ return LaTeXParsing ? preprocessLaTeX(content) : content;
+ }, [content, LaTeXParsing, isInitializing]);
+
+ const rehypePlugins = useMemo(
+ () => [
+ [rehypeKatex, { output: 'mathml' }],
+ [
+ rehypeHighlight,
+ {
+ detect: true,
+ ignoreMissing: true,
+ subset: langSubset,
+ },
+ ],
+ ],
+ [],
+ );
- const rehypePlugins = [
- [rehypeKatex, { output: 'mathml' }],
- [
- rehypeHighlight,
- {
- detect: true,
- ignoreMissing: true,
- subset: langSubset,
- },
+ const remarkPlugins: Pluggable[] = useMemo(
+ () => [
+ supersub,
+ remarkGfm,
+ remarkDirective,
+ artifactPlugin,
+ [remarkMath, { singleDollarTextMath: true }],
],
- ];
+ [],
+ );
if (isInitializing) {
return (
@@ -189,14 +209,6 @@ const Markdown = memo(({ content = '', showCursor, isLatestMessage }: TContentPr
);
}
- const remarkPlugins: Pluggable[] = [
- supersub,
- remarkGfm,
- remarkDirective,
- artifactPlugin,
- [remarkMath, { singleDollarTextMath: true }],
- ];
-
return (
<ArtifactProvider>
<CodeBlockProvider>
@@ -205,7 +217,6 @@ const Markdown = memo(({ content = '', showCursor, isLatestMessage }: TContentPr
remarkPlugins={remarkPlugins}
/* @ts-ignore */
rehypePlugins={rehypePlugins}
- // linkTarget="_new"
components={
{
code,
@@ -218,7 +229,7 @@ const Markdown = memo(({ content = '', showCursor, isLatestMessage }: TContentPr
}
}
>
- {isLatestMessage && showCursor === true ? currentContent + cursor : currentContent}
+ {isLatestMessage && (showCursor ?? false) ? currentContent + cursor : currentContent}
</ReactMarkdown>
</CodeBlockProvider>
</ArtifactProvider>
diff --git a/client/src/components/Chat/Messages/Content/Part.tsx b/client/src/components/Chat/Messages/Content/Part.tsx
index f64ab6f361..b67fbf6177 100644
--- a/client/src/components/Chat/Messages/Content/Part.tsx
+++ b/client/src/components/Chat/Messages/Content/Part.tsx
@@ -10,6 +10,7 @@ import type { TMessageContentParts, TAttachment } from 'librechat-data-provider'
import { ErrorMessage } from './MessageContent';
import ExecuteCode from './Parts/ExecuteCode';
import RetrievalCall from './RetrievalCall';
+import Reasoning from './Parts/Reasoning';
import CodeAnalyze from './CodeAnalyze';
import Container from './Container';
import ToolCall from './ToolCall';
@@ -46,6 +47,12 @@ const Part = memo(({ part, isSubmitting, attachments, showCursor, isCreatedByUse
<Text text={text} isCreatedByUser={isCreatedByUser} showCursor={showCursor} />
</Container>
);
+ } else if (part.type === ContentTypes.THINK) {
+ const reasoning = typeof part.think === 'string' ? part.think : part.think.value;
+ if (typeof reasoning !== 'string') {
+ return null;
+ }
+ return <Reasoning reasoning={reasoning} />;
} else if (part.type === ContentTypes.TOOL_CALL) {
const toolCall = part[ContentTypes.TOOL_CALL];
diff --git a/client/src/components/Chat/Messages/Content/Parts/Reasoning.tsx b/client/src/components/Chat/Messages/Content/Parts/Reasoning.tsx
new file mode 100644
index 0000000000..2dcb616a16
--- /dev/null
+++ b/client/src/components/Chat/Messages/Content/Parts/Reasoning.tsx
@@ -0,0 +1,34 @@
+import { memo, useMemo } from 'react';
+import { ContentTypes } from 'librechat-data-provider';
+import { ThinkingContent } from '~/components/Artifacts/Thinking';
+import { useMessageContext } from '~/Providers';
+import { cn } from '~/utils';
+
+type ReasoningProps = {
+ reasoning: string;
+};
+
+const Reasoning = memo(({ reasoning }: ReasoningProps) => {
+ const { isExpanded, nextType } = useMessageContext();
+ const reasoningText = useMemo(() => {
+ return reasoning.replace(/^<think>\s*/, '').replace(/\s*<\/think>$/, '');
+ }, [reasoning]);
+
+ return (
+ <div
+ className={cn(
+ 'grid transition-all duration-300 ease-out',
+ nextType !== ContentTypes.THINK && isExpanded && 'mb-10',
+ )}
+ style={{
+ gridTemplateRows: isExpanded ? '1fr' : '0fr',
+ }}
+ >
+ <div className="overflow-hidden">
+ <ThinkingContent isPart={true}>{reasoningText}</ThinkingContent>
+ </div>
+ </div>
+ );
+});
+
+export default Reasoning;
diff --git a/client/src/components/Chat/Messages/Content/Parts/Text.tsx b/client/src/components/Chat/Messages/Content/Parts/Text.tsx
index 5806f76aac..7c207f1512 100644
--- a/client/src/components/Chat/Messages/Content/Parts/Text.tsx
+++ b/client/src/components/Chat/Messages/Content/Parts/Text.tsx
@@ -46,7 +46,7 @@ const TextPart = memo(({ text, isCreatedByUser, showCursor }: TextPartProps) =>
showCursorState && !!text.length ? 'result-streaming' : '',
'markdown prose message-content dark:prose-invert light w-full break-words',
isCreatedByUser && !enableUserMsgMarkdown && 'whitespace-pre-wrap',
- isCreatedByUser ? 'dark:text-gray-20' : 'dark:text-gray-70',
+ isCreatedByUser ? 'dark:text-gray-20' : 'dark:text-gray-100',
)}
>
{content}
diff --git a/client/src/components/Chat/Messages/HoverButtons.tsx b/client/src/components/Chat/Messages/HoverButtons.tsx
index 0b27fc3765..9558c5c8f1 100644
--- a/client/src/components/Chat/Messages/HoverButtons.tsx
+++ b/client/src/components/Chat/Messages/HoverButtons.tsx
@@ -109,7 +109,9 @@ export default function HoverButtons({
messageId={message.messageId}
content={message.content ?? message.text}
isLast={isLast}
- className="hover-button rounded-md p-1 pl-0 text-gray-500 hover:bg-gray-100 hover:text-gray-500 dark:text-gray-400/70 dark:hover:bg-gray-700 dark:hover:text-gray-200 disabled:dark:hover:text-gray-400 md:group-hover:visible md:group-[.final-completion]:visible"
+ className={cn(
+ 'ml-0 flex items-center gap-1.5 rounded-md p-1 text-xs hover:bg-gray-100 hover:text-gray-500 focus:opacity-100 dark:text-gray-400/70 dark:hover:bg-gray-700 dark:hover:text-gray-200 disabled:dark:hover:text-gray-400 md:group-hover:visible md:group-[.final-completion]:visible',
+ )}
/>
)}
{isEditableEndpoint && (
diff --git a/client/src/components/Chat/Messages/MessageAudio.tsx b/client/src/components/Chat/Messages/MessageAudio.tsx
index 4dd1f21fcb..de35d1f7d5 100644
--- a/client/src/components/Chat/Messages/MessageAudio.tsx
+++ b/client/src/components/Chat/Messages/MessageAudio.tsx
@@ -1,4 +1,3 @@
-// client/src/components/Chat/Messages/MessageAudio.tsx
import { memo } from 'react';
import { useRecoilValue } from 'recoil';
import type { TMessageAudio } from '~/common';
diff --git a/client/src/components/Nav/SettingsTabs/Chat/Chat.tsx b/client/src/components/Nav/SettingsTabs/Chat/Chat.tsx
index 82675890eb..6da67d5915 100644
--- a/client/src/components/Nav/SettingsTabs/Chat/Chat.tsx
+++ b/client/src/components/Nav/SettingsTabs/Chat/Chat.tsx
@@ -5,6 +5,7 @@ import SendMessageKeyEnter from './EnterToSend';
import ShowCodeSwitch from './ShowCodeSwitch';
import { ForkSettings } from './ForkSettings';
import ChatDirection from './ChatDirection';
+import ShowThinking from './ShowThinking';
import LaTeXParsing from './LaTeXParsing';
import ModularChat from './ModularChat';
import SaveDraft from './SaveDraft';
@@ -37,6 +38,9 @@ function Chat() {
<div className="pb-3">
<LaTeXParsing />
</div>
+ <div className="pb-3">
+ <ShowThinking />
+ </div>
</div>
);
}
diff --git a/client/src/components/Nav/SettingsTabs/Chat/ShowThinking.tsx b/client/src/components/Nav/SettingsTabs/Chat/ShowThinking.tsx
new file mode 100644
index 0000000000..6cd20c3040
--- /dev/null
+++ b/client/src/components/Nav/SettingsTabs/Chat/ShowThinking.tsx
@@ -0,0 +1,37 @@
+import { useRecoilState } from 'recoil';
+import HoverCardSettings from '../HoverCardSettings';
+import { Switch } from '~/components/ui';
+import useLocalize from '~/hooks/useLocalize';
+import store from '~/store';
+
+export default function SaveDraft({
+ onCheckedChange,
+}: {
+ onCheckedChange?: (value: boolean) => void;
+}) {
+ const [showThinking, setSaveDrafts] = useRecoilState<boolean>(store.showThinking);
+ const localize = useLocalize();
+
+ const handleCheckedChange = (value: boolean) => {
+ setSaveDrafts(value);
+ if (onCheckedChange) {
+ onCheckedChange(value);
+ }
+ };
+
+ return (
+ <div className="flex items-center justify-between">
+ <div className="flex items-center space-x-2">
+ <div>{localize('com_nav_show_thinking')}</div>
+ <HoverCardSettings side="bottom" text="com_nav_info_show_thinking" />
+ </div>
+ <Switch
+ id="showThinking"
+ checked={showThinking}
+ onCheckedChange={handleCheckedChange}
+ className="ml-4"
+ data-testid="showThinking"
+ />
+ </div>
+ );
+}
diff --git a/client/src/hooks/Audio/usePauseGlobalAudio.ts b/client/src/hooks/Audio/usePauseGlobalAudio.ts
index 06fc7b730b..b14e39a23d 100644
--- a/client/src/hooks/Audio/usePauseGlobalAudio.ts
+++ b/client/src/hooks/Audio/usePauseGlobalAudio.ts
@@ -6,12 +6,13 @@ import store from '~/store';
function usePauseGlobalAudio(index = 0) {
/* Global Audio Variables */
const setAudioRunId = useSetRecoilState(store.audioRunFamily(index));
+ const setActiveRunId = useSetRecoilState(store.activeRunFamily(index));
const setGlobalIsPlaying = useSetRecoilState(store.globalAudioPlayingFamily(index));
const setIsGlobalAudioFetching = useSetRecoilState(store.globalAudioFetchingFamily(index));
const [globalAudioURL, setGlobalAudioURL] = useRecoilState(store.globalAudioURLFamily(index));
const pauseGlobalAudio = useCallback(() => {
- if (globalAudioURL) {
+ if (globalAudioURL != null && globalAudioURL !== '') {
const globalAudio = document.getElementById(globalAudioId);
if (globalAudio) {
console.log('Pausing global audio', globalAudioURL);
@@ -21,14 +22,16 @@ function usePauseGlobalAudio(index = 0) {
URL.revokeObjectURL(globalAudioURL);
setIsGlobalAudioFetching(false);
setGlobalAudioURL(null);
+ setActiveRunId(null);
setAudioRunId(null);
}
}, [
+ setAudioRunId,
+ setActiveRunId,
globalAudioURL,
setGlobalAudioURL,
setGlobalIsPlaying,
setIsGlobalAudioFetching,
- setAudioRunId,
]);
return { pauseGlobalAudio };
diff --git a/client/src/hooks/Chat/useChatFunctions.ts b/client/src/hooks/Chat/useChatFunctions.ts
index 3c58dc5290..24e74cf3bc 100644
--- a/client/src/hooks/Chat/useChatFunctions.ts
+++ b/client/src/hooks/Chat/useChatFunctions.ts
@@ -4,9 +4,9 @@ import {
Constants,
QueryKeys,
ContentTypes,
+ EModelEndpoint,
parseCompactConvo,
isAssistantsEndpoint,
- EModelEndpoint,
} from 'librechat-data-provider';
import { useSetRecoilState, useResetRecoilState, useRecoilValue } from 'recoil';
import type {
@@ -31,6 +31,15 @@ const logChatRequest = (request: Record<string, unknown>) => {
logger.log('=====================================');
};
+const usesContentStream = (endpoint: EModelEndpoint | undefined, endpointType?: string) => {
+ if (endpointType === EModelEndpoint.custom) {
+ return true;
+ }
+ if (endpoint === EModelEndpoint.openAI || endpoint === EModelEndpoint.azureOpenAI) {
+ return true;
+ }
+};
+
export default function useChatFunctions({
index = 0,
files,
@@ -219,8 +228,8 @@ export default function useChatFunctions({
unfinished: false,
isCreatedByUser: false,
isEdited: isEditOrContinue,
- iconURL: convo.iconURL,
- model: convo.model,
+ iconURL: convo?.iconURL,
+ model: convo?.model,
error: false,
};
@@ -247,6 +256,17 @@ export default function useChatFunctions({
},
];
setShowStopButton(true);
+ } else if (usesContentStream(endpoint, endpointType)) {
+ initialResponse.text = '';
+ initialResponse.content = [
+ {
+ type: ContentTypes.TEXT,
+ [ContentTypes.TEXT]: {
+ value: responseText,
+ },
+ },
+ ];
+ setShowStopButton(true);
} else {
setShowStopButton(true);
}
diff --git a/client/src/hooks/Input/useTextToSpeechExternal.ts b/client/src/hooks/Input/useTextToSpeechExternal.ts
index 8e616e4cde..634fd2c433 100644
--- a/client/src/hooks/Input/useTextToSpeechExternal.ts
+++ b/client/src/hooks/Input/useTextToSpeechExternal.ts
@@ -87,7 +87,7 @@ function useTextToSpeechExternal({
setDownloadFile(false);
};
- const { mutate: processAudio, isLoading: isProcessing } = useTextToSpeechMutation({
+ const { mutate: processAudio } = useTextToSpeechMutation({
onMutate: (variables) => {
const inputText = (variables.get('input') ?? '') as string;
if (inputText.length >= 4096) {
@@ -178,13 +178,14 @@ function useTextToSpeechExternal({
promiseAudioRef.current = null;
setIsSpeaking(false);
}
- }, []);
+ }, [setIsSpeaking]);
useEffect(() => cancelPromiseSpeech, [cancelPromiseSpeech]);
- const isLoading = useMemo(() => {
- return isProcessing || (isLast && globalIsFetching && !globalIsPlaying);
- }, [isProcessing, globalIsFetching, globalIsPlaying, isLast]);
+ const isLoading = useMemo(
+ () => isLast && globalIsFetching && !globalIsPlaying,
+ [globalIsFetching, globalIsPlaying, isLast],
+ );
const { data: voicesData = [] } = useVoicesQuery();
diff --git a/client/src/hooks/SSE/useStepHandler.ts b/client/src/hooks/SSE/useStepHandler.ts
index d9d64d2a4d..bc137edbc6 100644
--- a/client/src/hooks/SSE/useStepHandler.ts
+++ b/client/src/hooks/SSE/useStepHandler.ts
@@ -33,8 +33,11 @@ type TStepEvent = {
type MessageDeltaUpdate = { type: ContentTypes.TEXT; text: string; tool_call_ids?: string[] };
+type ReasoningDeltaUpdate = { type: ContentTypes.THINK; think: string };
+
type AllContentTypes =
| ContentTypes.TEXT
+ | ContentTypes.THINK
| ContentTypes.TOOL_CALL
| ContentTypes.IMAGE_FILE
| ContentTypes.IMAGE_URL
@@ -84,6 +87,18 @@ export default function useStepHandler({
if (contentPart.tool_call_ids != null) {
update.tool_call_ids = contentPart.tool_call_ids;
}
+ updatedContent[index] = update;
+ } else if (
+ contentType.startsWith(ContentTypes.THINK) &&
+ ContentTypes.THINK in contentPart &&
+ typeof contentPart.think === 'string'
+ ) {
+ const currentContent = updatedContent[index] as ReasoningDeltaUpdate;
+ const update: ReasoningDeltaUpdate = {
+ type: ContentTypes.THINK,
+ think: (currentContent.think || '') + contentPart.think,
+ };
+
updatedContent[index] = update;
} else if (contentType === ContentTypes.IMAGE_URL && 'image_url' in contentPart) {
const currentContent = updatedContent[index] as {
@@ -215,6 +230,28 @@ export default function useStepHandler({
const updatedResponse = updateContent(response, runStep.index, contentPart);
+ messageMap.current.set(responseMessageId, updatedResponse);
+ const currentMessages = getMessages() || [];
+ setMessages([...currentMessages.slice(0, -1), updatedResponse]);
+ }
+ } else if (event === 'on_reasoning_delta') {
+ const reasoningDelta = data as Agents.ReasoningDeltaEvent;
+ const runStep = stepMap.current.get(reasoningDelta.id);
+ const responseMessageId = runStep?.runId ?? '';
+
+ if (!runStep || !responseMessageId) {
+ console.warn('No run step or runId found for reasoning delta event');
+ return;
+ }
+
+ const response = messageMap.current.get(responseMessageId);
+ if (response && reasoningDelta.delta.content != null) {
+ const contentPart = Array.isArray(reasoningDelta.delta.content)
+ ? reasoningDelta.delta.content[0]
+ : reasoningDelta.delta.content;
+
+ const updatedResponse = updateContent(response, runStep.index, contentPart);
+
messageMap.current.set(responseMessageId, updatedResponse);
const currentMessages = getMessages() || [];
setMessages([...currentMessages.slice(0, -1), updatedResponse]);
diff --git a/client/src/localization/languages/Eng.ts b/client/src/localization/languages/Eng.ts
index 664b46d712..7ca511f8cf 100644
--- a/client/src/localization/languages/Eng.ts
+++ b/client/src/localization/languages/Eng.ts
@@ -410,6 +410,7 @@ export default {
com_ui_more_info: 'More info',
com_ui_preview: 'Preview',
com_ui_thoughts: 'Thoughts',
+ com_ui_thinking: 'Thinking...',
com_ui_upload: 'Upload',
com_ui_connect: 'Connect',
com_ui_locked: 'Locked',
@@ -843,10 +844,13 @@ export default {
com_nav_enable_cache_tts: 'Enable cache TTS',
com_nav_voice_select: 'Voice',
com_nav_enable_cloud_browser_voice: 'Use cloud-based voices',
+ com_nav_show_thinking: 'Open Thinking Dropdowns by Default',
com_nav_info_enter_to_send:
'When enabled, pressing `ENTER` will send your message. When disabled, pressing Enter will add a new line, and you\'ll need to press `CTRL + ENTER` / `⌘ + ENTER` to send your message.',
com_nav_info_save_draft:
'When enabled, the text and attachments you enter in the chat form will be automatically saved locally as drafts. These drafts will be available even if you reload the page or switch to a different conversation. Drafts are stored locally on your device and are deleted once the message is sent.',
+ com_nav_info_show_thinking:
+ 'When enabled, the chat will display the thinking dropdowns open by default, allowing you to view the AI\'s reasoning in real-time. When disabled, the thinking dropdowns will remain closed by default for a cleaner and more streamlined interface',
com_nav_info_fork_change_default:
'`Visible messages only` includes just the direct path to the selected message. `Include related branches` adds branches along the path. `Include all to/from here` includes all connected messages and branches.',
com_nav_info_fork_split_target_setting:
diff --git a/client/src/store/settings.ts b/client/src/store/settings.ts
index e4ce587d8d..5e18c8984f 100644
--- a/client/src/store/settings.ts
+++ b/client/src/store/settings.ts
@@ -36,8 +36,8 @@ const localStorageAtoms = {
saveDrafts: atomWithLocalStorage('saveDrafts', true),
forkSetting: atomWithLocalStorage('forkSetting', ''),
splitAtTarget: atomWithLocalStorage('splitAtTarget', false),
-
rememberDefaultFork: atomWithLocalStorage(LocalStorageKeys.REMEMBER_FORK_OPTION, false),
+ showThinking: atomWithLocalStorage('showThinking', false),
// Beta features settings
modularChat: atomWithLocalStorage('modularChat', true),
diff --git a/client/src/style.css b/client/src/style.css
index b57c9bdcf2..f632f8eb03 100644
--- a/client/src/style.css
+++ b/client/src/style.css
@@ -2014,7 +2014,7 @@ button.scroll-convo {
list-style-position: outside;
margin-top: 1em;
margin-bottom: 1em;
- padding-left: 3em;
+ padding-left: 1em;
}
.prose li,
diff --git a/config/translations/streamAudioTest.ts b/config/translations/streamAudioTest.ts
deleted file mode 100644
index 7564b2637b..0000000000
--- a/config/translations/streamAudioTest.ts
+++ /dev/null
@@ -1,134 +0,0 @@
-import { WebSocket } from 'ws';
-// const { ElevenLabsClient } = require('elevenlabs');
-
-const ELEVENLABS_API_KEY = 'a495399653cc5824ba1e41d914473e07';
-const VOICE_ID = '1RVpBInY9YUYMLSUQReV';
-
-interface AudioChunk {
- audio: string;
- isFinal: boolean;
- alignment: {
- char_start_times_ms: number[];
- chars_durations_ms: number[];
- chars: string[];
- };
- normalizedAlignment: {
- char_start_times_ms: number[];
- chars_durations_ms: number[];
- chars: string[];
- };
-}
-
-export function inputStreamTextToSpeech(
- textStream: AsyncIterable<string>,
-): AsyncGenerator<AudioChunk> {
- const model = 'eleven_turbo_v2';
- const wsUrl = `wss://api.elevenlabs.io/v1/text-to-speech/${VOICE_ID}/stream-input?model_id=${model}`;
- const socket = new WebSocket(wsUrl);
-
- socket.onopen = function () {
- const streamStart = {
- text: ' ',
- voice_settings: {
- stability: 0.5,
- similarity_boost: 0.8,
- },
- xi_api_key: ELEVENLABS_API_KEY,
- };
-
- socket.send(JSON.stringify(streamStart));
-
- // send stream until done
- const streamComplete = new Promise((resolve, reject) => {
- (async () => {
- for await (const message of textStream) {
- const request = {
- text: message,
- try_trigger_generation: true,
- };
- socket.send(JSON.stringify(request));
- }
- })()
- .then(resolve)
- .catch(reject);
- });
-
- streamComplete
- .then(() => {
- const endStream = {
- text: '',
- };
-
- socket.send(JSON.stringify(endStream));
- })
- .catch((e) => {
- throw e;
- });
- };
-
- return (async function* audioStream() {
- let isDone = false;
- let chunks: AudioChunk[] = [];
- let resolve: (value: unknown) => void;
- let waitForMessage = new Promise((r) => (resolve = r));
-
- socket.onmessage = function (event) {
- console.log(event);
- const audioChunk = JSON.parse(event.data as string) as AudioChunk;
- if (audioChunk.audio && audioChunk.alignment) {
- chunks.push(audioChunk);
- resolve(null);
- waitForMessage = new Promise((r) => (resolve = r));
- }
- };
-
- socket.onerror = function (error) {
- throw error;
- };
-
- // Handle socket closing
- socket.onclose = function () {
- isDone = true;
- };
-
- while (!isDone) {
- await waitForMessage;
- yield* chunks;
- chunks = [];
- }
- })();
-}
-
-import OpenAI from 'openai';
-import { ChatCompletionStream } from 'openai/lib/ChatCompletionStream';
-
-export async function streamCompletion({ systemPrompt, messages }) {
- const client = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
- return client.beta.chat.completions.stream({
- model: 'gpt-4-0125-preview',
- messages: [{ role: 'system', content: systemPrompt }, ...messages],
- });
-}
-
-export async function* llmMessageSource(llmStream: ChatCompletionStream): AsyncIterable<string> {
- for await (const chunk of llmStream) {
- const message = chunk.choices[0].delta.content;
- if (message) {
- yield message;
- }
- }
-}
-
-async function main(systemPrompt: string, prompt: string) {
- const llmStream = await streamCompletion({
- systemPrompt,
- messages: [{ role: 'user', content: prompt }],
- });
- const llmMessageStream = llmMessageSource(llmStream);
- console.log('Streaming LLM messages...');
- for await (const audio of inputStreamTextToSpeech(llmMessageStream)) {
- console.log(audio);
- }
-}
-
-main('Hello, how can I help you today?', 'What is the meaning of life?');
diff --git a/package-lock.json b/package-lock.json
index 908eef4095..c2c632510d 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -50,10 +50,10 @@
"@keyv/redis": "^2.8.1",
"@langchain/community": "^0.3.14",
"@langchain/core": "^0.3.18",
- "@langchain/google-genai": "^0.1.6",
- "@langchain/google-vertexai": "^0.1.6",
+ "@langchain/google-genai": "^0.1.7",
+ "@langchain/google-vertexai": "^0.1.8",
"@langchain/textsplitters": "^0.1.0",
- "@librechat/agents": "^1.9.94",
+ "@librechat/agents": "^1.9.97",
"@waylaidwanderer/fetch-event-source": "^3.0.1",
"axios": "^1.7.7",
"bcryptjs": "^2.4.3",
@@ -644,23 +644,23 @@
}
},
"api/node_modules/@librechat/agents": {
- "version": "1.9.94",
- "resolved": "https://registry.npmjs.org/@librechat/agents/-/agents-1.9.94.tgz",
- "integrity": "sha512-v/f2WmBKfP7PcMeKQn0BuzdxLkgZ5BXi3dx1jXLwWTM/1Qmtjrb1dGdZ+z3jIdsq9f86tSCbgCyO5dzTI9H4Hw==",
+ "version": "1.9.97",
+ "resolved": "https://registry.npmjs.org/@librechat/agents/-/agents-1.9.97.tgz",
+ "integrity": "sha512-saV8eY3fj0xnBClBHij/I6Xfq8WaNmctNHqEK6d1pJj7+7jTrI+3Ub8ZT6baa8khMuspFLCP5e7zewOKprudBQ==",
"dependencies": {
"@aws-crypto/sha256-js": "^5.2.0",
"@aws-sdk/credential-provider-node": "^3.613.0",
"@aws-sdk/types": "^3.609.0",
- "@langchain/anthropic": "^0.3.11",
+ "@langchain/anthropic": "^0.3.12",
"@langchain/aws": "^0.1.3",
- "@langchain/community": "^0.3.14",
- "@langchain/core": "^0.3.26",
- "@langchain/google-genai": "^0.1.6",
- "@langchain/google-vertexai": "^0.1.6",
- "@langchain/langgraph": "^0.2.34",
+ "@langchain/community": "^0.3.27",
+ "@langchain/core": "^0.3.36",
+ "@langchain/google-genai": "^0.1.7",
+ "@langchain/google-vertexai": "^0.1.8",
+ "@langchain/langgraph": "^0.2.41",
"@langchain/mistralai": "^0.0.26",
- "@langchain/ollama": "^0.1.1",
- "@langchain/openai": "^0.3.14",
+ "@langchain/ollama": "^0.1.5",
+ "@langchain/openai": "^0.4.2",
"@smithy/eventstream-codec": "^2.2.0",
"@smithy/protocol-http": "^3.0.6",
"@smithy/signature-v4": "^2.0.10",
@@ -672,6 +672,536 @@
"node": ">=14.0.0"
}
},
+ "api/node_modules/@librechat/agents/node_modules/@langchain/community": {
+ "version": "0.3.27",
+ "resolved": "https://registry.npmjs.org/@langchain/community/-/community-0.3.27.tgz",
+ "integrity": "sha512-YdVDysg/k4LiRJgtGo5IHlrtAMsWK5o7/WtgUGsyABAfKNAcFY2dBV5NClbEwS2GuE4Ll8TC3PxSWIctH42oeg==",
+ "dependencies": {
+ "@langchain/openai": ">=0.2.0 <0.5.0",
+ "binary-extensions": "^2.2.0",
+ "expr-eval": "^2.0.2",
+ "flat": "^5.0.2",
+ "js-yaml": "^4.1.0",
+ "langchain": ">=0.2.3 <0.3.0 || >=0.3.4 <0.4.0",
+ "langsmith": ">=0.2.8 <0.4.0",
+ "uuid": "^10.0.0",
+ "zod": "^3.22.3",
+ "zod-to-json-schema": "^3.22.5"
+ },
+ "engines": {
+ "node": ">=18"
+ },
+ "peerDependencies": {
+ "@arcjet/redact": "^v1.0.0-alpha.23",
+ "@aws-crypto/sha256-js": "^5.0.0",
+ "@aws-sdk/client-bedrock-agent-runtime": "^3.583.0",
+ "@aws-sdk/client-bedrock-runtime": "^3.422.0",
+ "@aws-sdk/client-dynamodb": "^3.310.0",
+ "@aws-sdk/client-kendra": "^3.352.0",
+ "@aws-sdk/client-lambda": "^3.310.0",
+ "@aws-sdk/client-s3": "^3.310.0",
+ "@aws-sdk/client-sagemaker-runtime": "^3.310.0",
+ "@aws-sdk/client-sfn": "^3.310.0",
+ "@aws-sdk/credential-provider-node": "^3.388.0",
+ "@azure/search-documents": "^12.0.0",
+ "@azure/storage-blob": "^12.15.0",
+ "@browserbasehq/sdk": "*",
+ "@browserbasehq/stagehand": "^1.0.0",
+ "@clickhouse/client": "^0.2.5",
+ "@cloudflare/ai": "*",
+ "@datastax/astra-db-ts": "^1.0.0",
+ "@elastic/elasticsearch": "^8.4.0",
+ "@getmetal/metal-sdk": "*",
+ "@getzep/zep-cloud": "^1.0.6",
+ "@getzep/zep-js": "^0.9.0",
+ "@gomomento/sdk": "^1.51.1",
+ "@gomomento/sdk-core": "^1.51.1",
+ "@google-ai/generativelanguage": "*",
+ "@google-cloud/storage": "^6.10.1 || ^7.7.0",
+ "@gradientai/nodejs-sdk": "^1.2.0",
+ "@huggingface/inference": "^2.6.4",
+ "@huggingface/transformers": "^3.2.3",
+ "@ibm-cloud/watsonx-ai": "*",
+ "@lancedb/lancedb": "^0.12.0",
+ "@langchain/core": ">=0.2.21 <0.4.0",
+ "@layerup/layerup-security": "^1.5.12",
+ "@libsql/client": "^0.14.0",
+ "@mendable/firecrawl-js": "^1.4.3",
+ "@mlc-ai/web-llm": "*",
+ "@mozilla/readability": "*",
+ "@neondatabase/serverless": "*",
+ "@notionhq/client": "^2.2.10",
+ "@opensearch-project/opensearch": "*",
+ "@pinecone-database/pinecone": "*",
+ "@planetscale/database": "^1.8.0",
+ "@premai/prem-sdk": "^0.3.25",
+ "@qdrant/js-client-rest": "^1.8.2",
+ "@raycast/api": "^1.55.2",
+ "@rockset/client": "^0.9.1",
+ "@smithy/eventstream-codec": "^2.0.5",
+ "@smithy/protocol-http": "^3.0.6",
+ "@smithy/signature-v4": "^2.0.10",
+ "@smithy/util-utf8": "^2.0.0",
+ "@spider-cloud/spider-client": "^0.0.21",
+ "@supabase/supabase-js": "^2.45.0",
+ "@tensorflow-models/universal-sentence-encoder": "*",
+ "@tensorflow/tfjs-converter": "*",
+ "@tensorflow/tfjs-core": "*",
+ "@upstash/ratelimit": "^1.1.3 || ^2.0.3",
+ "@upstash/redis": "^1.20.6",
+ "@upstash/vector": "^1.1.1",
+ "@vercel/kv": "*",
+ "@vercel/postgres": "*",
+ "@writerai/writer-sdk": "^0.40.2",
+ "@xata.io/client": "^0.28.0",
+ "@zilliz/milvus2-sdk-node": ">=2.3.5",
+ "apify-client": "^2.7.1",
+ "assemblyai": "^4.6.0",
+ "better-sqlite3": ">=9.4.0 <12.0.0",
+ "cassandra-driver": "^4.7.2",
+ "cborg": "^4.1.1",
+ "cheerio": "^1.0.0-rc.12",
+ "chromadb": "*",
+ "closevector-common": "0.1.3",
+ "closevector-node": "0.1.6",
+ "closevector-web": "0.1.6",
+ "cohere-ai": "*",
+ "convex": "^1.3.1",
+ "crypto-js": "^4.2.0",
+ "d3-dsv": "^2.0.0",
+ "discord.js": "^14.14.1",
+ "dria": "^0.0.3",
+ "duck-duck-scrape": "^2.2.5",
+ "epub2": "^3.0.1",
+ "faiss-node": "^0.5.1",
+ "fast-xml-parser": "*",
+ "firebase-admin": "^11.9.0 || ^12.0.0",
+ "google-auth-library": "*",
+ "googleapis": "*",
+ "hnswlib-node": "^3.0.0",
+ "html-to-text": "^9.0.5",
+ "ibm-cloud-sdk-core": "*",
+ "ignore": "^5.2.0",
+ "interface-datastore": "^8.2.11",
+ "ioredis": "^5.3.2",
+ "it-all": "^3.0.4",
+ "jsdom": "*",
+ "jsonwebtoken": "^9.0.2",
+ "llmonitor": "^0.5.9",
+ "lodash": "^4.17.21",
+ "lunary": "^0.7.10",
+ "mammoth": "^1.6.0",
+ "mongodb": ">=5.2.0",
+ "mysql2": "^3.9.8",
+ "neo4j-driver": "*",
+ "notion-to-md": "^3.1.0",
+ "officeparser": "^4.0.4",
+ "openai": "*",
+ "pdf-parse": "1.1.1",
+ "pg": "^8.11.0",
+ "pg-copy-streams": "^6.0.5",
+ "pickleparser": "^0.2.1",
+ "playwright": "^1.32.1",
+ "portkey-ai": "^0.1.11",
+ "puppeteer": "*",
+ "pyodide": ">=0.24.1 <0.27.0",
+ "redis": "*",
+ "replicate": "^0.29.4",
+ "sonix-speech-recognition": "^2.1.1",
+ "srt-parser-2": "^1.2.3",
+ "typeorm": "^0.3.20",
+ "typesense": "^1.5.3",
+ "usearch": "^1.1.1",
+ "voy-search": "0.6.2",
+ "weaviate-ts-client": "*",
+ "web-auth-library": "^1.0.3",
+ "word-extractor": "*",
+ "ws": "^8.14.2",
+ "youtubei.js": "*"
+ },
+ "peerDependenciesMeta": {
+ "@arcjet/redact": {
+ "optional": true
+ },
+ "@aws-crypto/sha256-js": {
+ "optional": true
+ },
+ "@aws-sdk/client-bedrock-agent-runtime": {
+ "optional": true
+ },
+ "@aws-sdk/client-bedrock-runtime": {
+ "optional": true
+ },
+ "@aws-sdk/client-dynamodb": {
+ "optional": true
+ },
+ "@aws-sdk/client-kendra": {
+ "optional": true
+ },
+ "@aws-sdk/client-lambda": {
+ "optional": true
+ },
+ "@aws-sdk/client-s3": {
+ "optional": true
+ },
+ "@aws-sdk/client-sagemaker-runtime": {
+ "optional": true
+ },
+ "@aws-sdk/client-sfn": {
+ "optional": true
+ },
+ "@aws-sdk/credential-provider-node": {
+ "optional": true
+ },
+ "@azure/search-documents": {
+ "optional": true
+ },
+ "@azure/storage-blob": {
+ "optional": true
+ },
+ "@browserbasehq/sdk": {
+ "optional": true
+ },
+ "@clickhouse/client": {
+ "optional": true
+ },
+ "@cloudflare/ai": {
+ "optional": true
+ },
+ "@datastax/astra-db-ts": {
+ "optional": true
+ },
+ "@elastic/elasticsearch": {
+ "optional": true
+ },
+ "@getmetal/metal-sdk": {
+ "optional": true
+ },
+ "@getzep/zep-cloud": {
+ "optional": true
+ },
+ "@getzep/zep-js": {
+ "optional": true
+ },
+ "@gomomento/sdk": {
+ "optional": true
+ },
+ "@gomomento/sdk-core": {
+ "optional": true
+ },
+ "@google-ai/generativelanguage": {
+ "optional": true
+ },
+ "@google-cloud/storage": {
+ "optional": true
+ },
+ "@gradientai/nodejs-sdk": {
+ "optional": true
+ },
+ "@huggingface/inference": {
+ "optional": true
+ },
+ "@huggingface/transformers": {
+ "optional": true
+ },
+ "@lancedb/lancedb": {
+ "optional": true
+ },
+ "@layerup/layerup-security": {
+ "optional": true
+ },
+ "@libsql/client": {
+ "optional": true
+ },
+ "@mendable/firecrawl-js": {
+ "optional": true
+ },
+ "@mlc-ai/web-llm": {
+ "optional": true
+ },
+ "@mozilla/readability": {
+ "optional": true
+ },
+ "@neondatabase/serverless": {
+ "optional": true
+ },
+ "@notionhq/client": {
+ "optional": true
+ },
+ "@opensearch-project/opensearch": {
+ "optional": true
+ },
+ "@pinecone-database/pinecone": {
+ "optional": true
+ },
+ "@planetscale/database": {
+ "optional": true
+ },
+ "@premai/prem-sdk": {
+ "optional": true
+ },
+ "@qdrant/js-client-rest": {
+ "optional": true
+ },
+ "@raycast/api": {
+ "optional": true
+ },
+ "@rockset/client": {
+ "optional": true
+ },
+ "@smithy/eventstream-codec": {
+ "optional": true
+ },
+ "@smithy/protocol-http": {
+ "optional": true
+ },
+ "@smithy/signature-v4": {
+ "optional": true
+ },
+ "@smithy/util-utf8": {
+ "optional": true
+ },
+ "@spider-cloud/spider-client": {
+ "optional": true
+ },
+ "@supabase/supabase-js": {
+ "optional": true
+ },
+ "@tensorflow-models/universal-sentence-encoder": {
+ "optional": true
+ },
+ "@tensorflow/tfjs-converter": {
+ "optional": true
+ },
+ "@tensorflow/tfjs-core": {
+ "optional": true
+ },
+ "@upstash/ratelimit": {
+ "optional": true
+ },
+ "@upstash/redis": {
+ "optional": true
+ },
+ "@upstash/vector": {
+ "optional": true
+ },
+ "@vercel/kv": {
+ "optional": true
+ },
+ "@vercel/postgres": {
+ "optional": true
+ },
+ "@writerai/writer-sdk": {
+ "optional": true
+ },
+ "@xata.io/client": {
+ "optional": true
+ },
+ "@zilliz/milvus2-sdk-node": {
+ "optional": true
+ },
+ "apify-client": {
+ "optional": true
+ },
+ "assemblyai": {
+ "optional": true
+ },
+ "better-sqlite3": {
+ "optional": true
+ },
+ "cassandra-driver": {
+ "optional": true
+ },
+ "cborg": {
+ "optional": true
+ },
+ "cheerio": {
+ "optional": true
+ },
+ "chromadb": {
+ "optional": true
+ },
+ "closevector-common": {
+ "optional": true
+ },
+ "closevector-node": {
+ "optional": true
+ },
+ "closevector-web": {
+ "optional": true
+ },
+ "cohere-ai": {
+ "optional": true
+ },
+ "convex": {
+ "optional": true
+ },
+ "crypto-js": {
+ "optional": true
+ },
+ "d3-dsv": {
+ "optional": true
+ },
+ "discord.js": {
+ "optional": true
+ },
+ "dria": {
+ "optional": true
+ },
+ "duck-duck-scrape": {
+ "optional": true
+ },
+ "epub2": {
+ "optional": true
+ },
+ "faiss-node": {
+ "optional": true
+ },
+ "fast-xml-parser": {
+ "optional": true
+ },
+ "firebase-admin": {
+ "optional": true
+ },
+ "google-auth-library": {
+ "optional": true
+ },
+ "googleapis": {
+ "optional": true
+ },
+ "hnswlib-node": {
+ "optional": true
+ },
+ "html-to-text": {
+ "optional": true
+ },
+ "ignore": {
+ "optional": true
+ },
+ "interface-datastore": {
+ "optional": true
+ },
+ "ioredis": {
+ "optional": true
+ },
+ "it-all": {
+ "optional": true
+ },
+ "jsdom": {
+ "optional": true
+ },
+ "jsonwebtoken": {
+ "optional": true
+ },
+ "llmonitor": {
+ "optional": true
+ },
+ "lodash": {
+ "optional": true
+ },
+ "lunary": {
+ "optional": true
+ },
+ "mammoth": {
+ "optional": true
+ },
+ "mongodb": {
+ "optional": true
+ },
+ "mysql2": {
+ "optional": true
+ },
+ "neo4j-driver": {
+ "optional": true
+ },
+ "notion-to-md": {
+ "optional": true
+ },
+ "officeparser": {
+ "optional": true
+ },
+ "pdf-parse": {
+ "optional": true
+ },
+ "pg": {
+ "optional": true
+ },
+ "pg-copy-streams": {
+ "optional": true
+ },
+ "pickleparser": {
+ "optional": true
+ },
+ "playwright": {
+ "optional": true
+ },
+ "portkey-ai": {
+ "optional": true
+ },
+ "puppeteer": {
+ "optional": true
+ },
+ "pyodide": {
+ "optional": true
+ },
+ "redis": {
+ "optional": true
+ },
+ "replicate": {
+ "optional": true
+ },
+ "sonix-speech-recognition": {
+ "optional": true
+ },
+ "srt-parser-2": {
+ "optional": true
+ },
+ "typeorm": {
+ "optional": true
+ },
+ "typesense": {
+ "optional": true
+ },
+ "usearch": {
+ "optional": true
+ },
+ "voy-search": {
+ "optional": true
+ },
+ "weaviate-ts-client": {
+ "optional": true
+ },
+ "web-auth-library": {
+ "optional": true
+ },
+ "word-extractor": {
+ "optional": true
+ },
+ "ws": {
+ "optional": true
+ },
+ "youtubei.js": {
+ "optional": true
+ }
+ }
+ },
+ "api/node_modules/@librechat/agents/node_modules/@langchain/openai": {
+ "version": "0.4.2",
+ "resolved": "https://registry.npmjs.org/@langchain/openai/-/openai-0.4.2.tgz",
+ "integrity": "sha512-Cuj7qbVcycALTP0aqZuPpEc7As8cwiGaU21MhXRyZFs+dnWxKYxZ1Q1z4kcx6cYkq/I+CNwwmk+sP+YruU73Aw==",
+ "dependencies": {
+ "js-tiktoken": "^1.0.12",
+ "openai": "^4.77.0",
+ "zod": "^3.22.4",
+ "zod-to-json-schema": "^3.22.3"
+ },
+ "engines": {
+ "node": ">=18"
+ },
+ "peerDependencies": {
+ "@langchain/core": ">=0.3.29 <0.4.0"
+ }
+ },
"api/node_modules/@types/node": {
"version": "18.19.14",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.14.tgz",
@@ -870,6 +1400,18 @@
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
"integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw=="
},
+ "api/node_modules/uuid": {
+ "version": "10.0.0",
+ "resolved": "https://registry.npmjs.org/uuid/-/uuid-10.0.0.tgz",
+ "integrity": "sha512-8XkAphELsDnEGrDxUOHB3RGvXz6TeuYSGEZBOjtTtPm2lwhGBjLgOzLHB63IUWfBpNucQjND6d3AOudO+H3RWQ==",
+ "funding": [
+ "https://github.com/sponsors/broofa",
+ "https://github.com/sponsors/ctavan"
+ ],
+ "bin": {
+ "uuid": "dist/bin/uuid"
+ }
+ },
"api/node_modules/webidl-conversions": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
@@ -6017,6 +6559,113 @@
"integrity": "sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==",
"dev": true
},
+ "node_modules/@browserbasehq/sdk": {
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/@browserbasehq/sdk/-/sdk-2.2.0.tgz",
+ "integrity": "sha512-CWusIff7KenGfMwg/kNnrdOi+1JUIYpj8ZtEciuEUOEQVp3BEYqbaXk4FxCoQPvyO0h4eUVE5Banc9b3GQU01Q==",
+ "peer": true,
+ "dependencies": {
+ "@types/node": "^18.11.18",
+ "@types/node-fetch": "^2.6.4",
+ "abort-controller": "^3.0.0",
+ "agentkeepalive": "^4.2.1",
+ "form-data-encoder": "1.7.2",
+ "formdata-node": "^4.3.2",
+ "node-fetch": "^2.6.7"
+ }
+ },
+ "node_modules/@browserbasehq/sdk/node_modules/@types/node": {
+ "version": "18.19.74",
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.74.tgz",
+ "integrity": "sha512-HMwEkkifei3L605gFdV+/UwtpxP6JSzM+xFk2Ia6DNFSwSVBRh9qp5Tgf4lNFOMfPVuU0WnkcWpXZpgn5ufO4A==",
+ "peer": true,
+ "dependencies": {
+ "undici-types": "~5.26.4"
+ }
+ },
+ "node_modules/@browserbasehq/stagehand": {
+ "version": "1.10.1",
+ "resolved": "https://registry.npmjs.org/@browserbasehq/stagehand/-/stagehand-1.10.1.tgz",
+ "integrity": "sha512-A222TCseFvKNvBwav7ZrZmug0JnYvy1vFI1ReNOtcymjhrZQLfklq1gm/luUjr8aRTbTzsUV8iclt5r0kyaXbA==",
+ "peer": true,
+ "dependencies": {
+ "@anthropic-ai/sdk": "^0.27.3",
+ "@browserbasehq/sdk": "^2.0.0",
+ "sharp": "^0.33.5",
+ "ws": "^8.18.0",
+ "zod-to-json-schema": "^3.23.5"
+ },
+ "peerDependencies": {
+ "@playwright/test": "^1.42.1",
+ "deepmerge": "^4.3.1",
+ "dotenv": "^16.4.5",
+ "openai": "^4.62.1",
+ "zod": "^3.23.8"
+ }
+ },
+ "node_modules/@browserbasehq/stagehand/node_modules/@anthropic-ai/sdk": {
+ "version": "0.27.3",
+ "resolved": "https://registry.npmjs.org/@anthropic-ai/sdk/-/sdk-0.27.3.tgz",
+ "integrity": "sha512-IjLt0gd3L4jlOfilxVXTifn42FnVffMgDC04RJK1KDZpmkBWLv0XC92MVVmkxrFZNS/7l3xWgP/I3nqtX1sQHw==",
+ "peer": true,
+ "dependencies": {
+ "@types/node": "^18.11.18",
+ "@types/node-fetch": "^2.6.4",
+ "abort-controller": "^3.0.0",
+ "agentkeepalive": "^4.2.1",
+ "form-data-encoder": "1.7.2",
+ "formdata-node": "^4.3.2",
+ "node-fetch": "^2.6.7"
+ }
+ },
+ "node_modules/@browserbasehq/stagehand/node_modules/@types/node": {
+ "version": "18.19.74",
+ "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.74.tgz",
+ "integrity": "sha512-HMwEkkifei3L605gFdV+/UwtpxP6JSzM+xFk2Ia6DNFSwSVBRh9qp5Tgf4lNFOMfPVuU0WnkcWpXZpgn5ufO4A==",
+ "peer": true,
+ "dependencies": {
+ "undici-types": "~5.26.4"
+ }
+ },
+ "node_modules/@browserbasehq/stagehand/node_modules/sharp": {
+ "version": "0.33.5",
+ "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.33.5.tgz",
+ "integrity": "sha512-haPVm1EkS9pgvHrQ/F3Xy+hgcuMV0Wm9vfIBSiwZ05k+xgb0PkBQpGsAA/oWdDobNaZTH5ppvHtzCFbnSEwHVw==",
+ "hasInstallScript": true,
+ "peer": true,
+ "dependencies": {
+ "color": "^4.2.3",
+ "detect-libc": "^2.0.3",
+ "semver": "^7.6.3"
+ },
+ "engines": {
+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ },
+ "optionalDependencies": {
+ "@img/sharp-darwin-arm64": "0.33.5",
+ "@img/sharp-darwin-x64": "0.33.5",
+ "@img/sharp-libvips-darwin-arm64": "1.0.4",
+ "@img/sharp-libvips-darwin-x64": "1.0.4",
+ "@img/sharp-libvips-linux-arm": "1.0.5",
+ "@img/sharp-libvips-linux-arm64": "1.0.4",
+ "@img/sharp-libvips-linux-s390x": "1.0.4",
+ "@img/sharp-libvips-linux-x64": "1.0.4",
+ "@img/sharp-libvips-linuxmusl-arm64": "1.0.4",
+ "@img/sharp-libvips-linuxmusl-x64": "1.0.4",
+ "@img/sharp-linux-arm": "0.33.5",
+ "@img/sharp-linux-arm64": "0.33.5",
+ "@img/sharp-linux-s390x": "0.33.5",
+ "@img/sharp-linux-x64": "0.33.5",
+ "@img/sharp-linuxmusl-arm64": "0.33.5",
+ "@img/sharp-linuxmusl-x64": "0.33.5",
+ "@img/sharp-wasm32": "0.33.5",
+ "@img/sharp-win32-ia32": "0.33.5",
+ "@img/sharp-win32-x64": "0.33.5"
+ }
+ },
"node_modules/@cfworker/json-schema": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/@cfworker/json-schema/-/json-schema-4.0.3.tgz",
@@ -7293,6 +7942,16 @@
"@dicebear/core": "^7.0.0"
}
},
+ "node_modules/@emnapi/runtime": {
+ "version": "1.3.1",
+ "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.3.1.tgz",
+ "integrity": "sha512-kEBmG8KyqtxJZv+ygbEim+KCGtIq1fC22Ms3S4ziXmYKm8uyoLX0MHONVKwp+9opg390VaKRNt4a7A9NwmpNhw==",
+ "optional": true,
+ "peer": true,
+ "dependencies": {
+ "tslib": "^2.4.0"
+ }
+ },
"node_modules/@esbuild/aix-ppc64": {
"version": "0.21.5",
"resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.21.5.tgz",
@@ -8445,6 +9104,367 @@
"undici-types": "~5.26.4"
}
},
+ "node_modules/@img/sharp-darwin-arm64": {
+ "version": "0.33.5",
+ "resolved": "https://registry.npmjs.org/@img/sharp-darwin-arm64/-/sharp-darwin-arm64-0.33.5.tgz",
+ "integrity": "sha512-UT4p+iz/2H4twwAoLCqfA9UH5pI6DggwKEGuaPy7nCVQ8ZsiY5PIcrRvD1DzuY3qYL07NtIQcWnBSY/heikIFQ==",
+ "cpu": [
+ "arm64"
+ ],
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "peer": true,
+ "engines": {
+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ },
+ "optionalDependencies": {
+ "@img/sharp-libvips-darwin-arm64": "1.0.4"
+ }
+ },
+ "node_modules/@img/sharp-darwin-x64": {
+ "version": "0.33.5",
+ "resolved": "https://registry.npmjs.org/@img/sharp-darwin-x64/-/sharp-darwin-x64-0.33.5.tgz",
+ "integrity": "sha512-fyHac4jIc1ANYGRDxtiqelIbdWkIuQaI84Mv45KvGRRxSAa7o7d1ZKAOBaYbnepLC1WqxfpimdeWfvqqSGwR2Q==",
+ "cpu": [
+ "x64"
+ ],
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "peer": true,
+ "engines": {
+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ },
+ "optionalDependencies": {
+ "@img/sharp-libvips-darwin-x64": "1.0.4"
+ }
+ },
+ "node_modules/@img/sharp-libvips-darwin-arm64": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-arm64/-/sharp-libvips-darwin-arm64-1.0.4.tgz",
+ "integrity": "sha512-XblONe153h0O2zuFfTAbQYAX2JhYmDHeWikp1LM9Hul9gVPjFY427k6dFEcOL72O01QxQsWi761svJ/ev9xEDg==",
+ "cpu": [
+ "arm64"
+ ],
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "peer": true,
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ }
+ },
+ "node_modules/@img/sharp-libvips-darwin-x64": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-x64/-/sharp-libvips-darwin-x64-1.0.4.tgz",
+ "integrity": "sha512-xnGR8YuZYfJGmWPvmlunFaWJsb9T/AO2ykoP3Fz/0X5XV2aoYBPkX6xqCQvUTKKiLddarLaxpzNe+b1hjeWHAQ==",
+ "cpu": [
+ "x64"
+ ],
+ "optional": true,
+ "os": [
+ "darwin"
+ ],
+ "peer": true,
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ }
+ },
+ "node_modules/@img/sharp-libvips-linux-arm": {
+ "version": "1.0.5",
+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm/-/sharp-libvips-linux-arm-1.0.5.tgz",
+ "integrity": "sha512-gvcC4ACAOPRNATg/ov8/MnbxFDJqf/pDePbBnuBDcjsI8PssmjoKMAz4LtLaVi+OnSb5FK/yIOamqDwGmXW32g==",
+ "cpu": [
+ "arm"
+ ],
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "peer": true,
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ }
+ },
+ "node_modules/@img/sharp-libvips-linux-arm64": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm64/-/sharp-libvips-linux-arm64-1.0.4.tgz",
+ "integrity": "sha512-9B+taZ8DlyyqzZQnoeIvDVR/2F4EbMepXMc/NdVbkzsJbzkUjhXv/70GQJ7tdLA4YJgNP25zukcxpX2/SueNrA==",
+ "cpu": [
+ "arm64"
+ ],
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "peer": true,
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ }
+ },
+ "node_modules/@img/sharp-libvips-linux-s390x": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-s390x/-/sharp-libvips-linux-s390x-1.0.4.tgz",
+ "integrity": "sha512-u7Wz6ntiSSgGSGcjZ55im6uvTrOxSIS8/dgoVMoiGE9I6JAfU50yH5BoDlYA1tcuGS7g/QNtetJnxA6QEsCVTA==",
+ "cpu": [
+ "s390x"
+ ],
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "peer": true,
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ }
+ },
+ "node_modules/@img/sharp-libvips-linux-x64": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-x64/-/sharp-libvips-linux-x64-1.0.4.tgz",
+ "integrity": "sha512-MmWmQ3iPFZr0Iev+BAgVMb3ZyC4KeFc3jFxnNbEPas60e1cIfevbtuyf9nDGIzOaW9PdnDciJm+wFFaTlj5xYw==",
+ "cpu": [
+ "x64"
+ ],
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "peer": true,
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ }
+ },
+ "node_modules/@img/sharp-libvips-linuxmusl-arm64": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-arm64/-/sharp-libvips-linuxmusl-arm64-1.0.4.tgz",
+ "integrity": "sha512-9Ti+BbTYDcsbp4wfYib8Ctm1ilkugkA/uscUn6UXK1ldpC1JjiXbLfFZtRlBhjPZ5o1NCLiDbg8fhUPKStHoTA==",
+ "cpu": [
+ "arm64"
+ ],
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "peer": true,
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ }
+ },
+ "node_modules/@img/sharp-libvips-linuxmusl-x64": {
+ "version": "1.0.4",
+ "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-x64/-/sharp-libvips-linuxmusl-x64-1.0.4.tgz",
+ "integrity": "sha512-viYN1KX9m+/hGkJtvYYp+CCLgnJXwiQB39damAO7WMdKWlIhmYTfHjwSbQeUK/20vY154mwezd9HflVFM1wVSw==",
+ "cpu": [
+ "x64"
+ ],
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "peer": true,
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ }
+ },
+ "node_modules/@img/sharp-linux-arm": {
+ "version": "0.33.5",
+ "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm/-/sharp-linux-arm-0.33.5.tgz",
+ "integrity": "sha512-JTS1eldqZbJxjvKaAkxhZmBqPRGmxgu+qFKSInv8moZ2AmT5Yib3EQ1c6gp493HvrvV8QgdOXdyaIBrhvFhBMQ==",
+ "cpu": [
+ "arm"
+ ],
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "peer": true,
+ "engines": {
+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ },
+ "optionalDependencies": {
+ "@img/sharp-libvips-linux-arm": "1.0.5"
+ }
+ },
+ "node_modules/@img/sharp-linux-arm64": {
+ "version": "0.33.5",
+ "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm64/-/sharp-linux-arm64-0.33.5.tgz",
+ "integrity": "sha512-JMVv+AMRyGOHtO1RFBiJy/MBsgz0x4AWrT6QoEVVTyh1E39TrCUpTRI7mx9VksGX4awWASxqCYLCV4wBZHAYxA==",
+ "cpu": [
+ "arm64"
+ ],
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "peer": true,
+ "engines": {
+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ },
+ "optionalDependencies": {
+ "@img/sharp-libvips-linux-arm64": "1.0.4"
+ }
+ },
+ "node_modules/@img/sharp-linux-s390x": {
+ "version": "0.33.5",
+ "resolved": "https://registry.npmjs.org/@img/sharp-linux-s390x/-/sharp-linux-s390x-0.33.5.tgz",
+ "integrity": "sha512-y/5PCd+mP4CA/sPDKl2961b+C9d+vPAveS33s6Z3zfASk2j5upL6fXVPZi7ztePZ5CuH+1kW8JtvxgbuXHRa4Q==",
+ "cpu": [
+ "s390x"
+ ],
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "peer": true,
+ "engines": {
+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ },
+ "optionalDependencies": {
+ "@img/sharp-libvips-linux-s390x": "1.0.4"
+ }
+ },
+ "node_modules/@img/sharp-linux-x64": {
+ "version": "0.33.5",
+ "resolved": "https://registry.npmjs.org/@img/sharp-linux-x64/-/sharp-linux-x64-0.33.5.tgz",
+ "integrity": "sha512-opC+Ok5pRNAzuvq1AG0ar+1owsu842/Ab+4qvU879ippJBHvyY5n2mxF1izXqkPYlGuP/M556uh53jRLJmzTWA==",
+ "cpu": [
+ "x64"
+ ],
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "peer": true,
+ "engines": {
+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ },
+ "optionalDependencies": {
+ "@img/sharp-libvips-linux-x64": "1.0.4"
+ }
+ },
+ "node_modules/@img/sharp-linuxmusl-arm64": {
+ "version": "0.33.5",
+ "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-arm64/-/sharp-linuxmusl-arm64-0.33.5.tgz",
+ "integrity": "sha512-XrHMZwGQGvJg2V/oRSUfSAfjfPxO+4DkiRh6p2AFjLQztWUuY/o8Mq0eMQVIY7HJ1CDQUJlxGGZRw1a5bqmd1g==",
+ "cpu": [
+ "arm64"
+ ],
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "peer": true,
+ "engines": {
+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ },
+ "optionalDependencies": {
+ "@img/sharp-libvips-linuxmusl-arm64": "1.0.4"
+ }
+ },
+ "node_modules/@img/sharp-linuxmusl-x64": {
+ "version": "0.33.5",
+ "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-x64/-/sharp-linuxmusl-x64-0.33.5.tgz",
+ "integrity": "sha512-WT+d/cgqKkkKySYmqoZ8y3pxx7lx9vVejxW/W4DOFMYVSkErR+w7mf2u8m/y4+xHe7yY9DAXQMWQhpnMuFfScw==",
+ "cpu": [
+ "x64"
+ ],
+ "optional": true,
+ "os": [
+ "linux"
+ ],
+ "peer": true,
+ "engines": {
+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ },
+ "optionalDependencies": {
+ "@img/sharp-libvips-linuxmusl-x64": "1.0.4"
+ }
+ },
+ "node_modules/@img/sharp-wasm32": {
+ "version": "0.33.5",
+ "resolved": "https://registry.npmjs.org/@img/sharp-wasm32/-/sharp-wasm32-0.33.5.tgz",
+ "integrity": "sha512-ykUW4LVGaMcU9lu9thv85CbRMAwfeadCJHRsg2GmeRa/cJxsVY9Rbd57JcMxBkKHag5U/x7TSBpScF4U8ElVzg==",
+ "cpu": [
+ "wasm32"
+ ],
+ "optional": true,
+ "peer": true,
+ "dependencies": {
+ "@emnapi/runtime": "^1.2.0"
+ },
+ "engines": {
+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ }
+ },
+ "node_modules/@img/sharp-win32-ia32": {
+ "version": "0.33.5",
+ "resolved": "https://registry.npmjs.org/@img/sharp-win32-ia32/-/sharp-win32-ia32-0.33.5.tgz",
+ "integrity": "sha512-T36PblLaTwuVJ/zw/LaH0PdZkRz5rd3SmMHX8GSmR7vtNSP5Z6bQkExdSK7xGWyxLw4sUknBuugTelgw2faBbQ==",
+ "cpu": [
+ "ia32"
+ ],
+ "optional": true,
+ "os": [
+ "win32"
+ ],
+ "peer": true,
+ "engines": {
+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ }
+ },
+ "node_modules/@img/sharp-win32-x64": {
+ "version": "0.33.5",
+ "resolved": "https://registry.npmjs.org/@img/sharp-win32-x64/-/sharp-win32-x64-0.33.5.tgz",
+ "integrity": "sha512-MpY/o8/8kj+EcnxwvrP4aTJSWw/aZ7JIGR4aBeZkZw5B7/Jn+tY9/VNwtcoGmdT7GfggGIU4kygOMSbYnOrAbg==",
+ "cpu": [
+ "x64"
+ ],
+ "optional": true,
+ "os": [
+ "win32"
+ ],
+ "peer": true,
+ "engines": {
+ "node": "^18.17.0 || ^20.3.0 || >=21.0.0"
+ },
+ "funding": {
+ "url": "https://opencollective.com/libvips"
+ }
+ },
"node_modules/@ioredis/commands": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/@ioredis/commands/-/commands-1.2.0.tgz",
@@ -9076,10 +10096,9 @@
}
},
"node_modules/@langchain/anthropic": {
- "version": "0.3.11",
- "resolved": "https://registry.npmjs.org/@langchain/anthropic/-/anthropic-0.3.11.tgz",
- "integrity": "sha512-rYjDZjMwVQ+cYeJd9IoSESdkkG8fc0m3siGRYKNy6qgYMnqCz8sUPKBanXwbZAs6wvspPCGgNK9WONfaCeX97A==",
- "license": "MIT",
+ "version": "0.3.12",
+ "resolved": "https://registry.npmjs.org/@langchain/anthropic/-/anthropic-0.3.12.tgz",
+ "integrity": "sha512-vYANJVeus+v8wieTST5GUGlennY87NMIjaFx6JCJN8MMtf2KVwyBWQAUAPyGwzVQ40tru3w0rK2ruvzYBRcWEg==",
"dependencies": {
"@anthropic-ai/sdk": "^0.32.1",
"fast-xml-parser": "^4.4.1",
@@ -9636,17 +10655,16 @@
}
},
"node_modules/@langchain/core": {
- "version": "0.3.26",
- "resolved": "https://registry.npmjs.org/@langchain/core/-/core-0.3.26.tgz",
- "integrity": "sha512-6RUQHEp8wv+JwtYIIEBYBzbLlcAQZFc7EDOgAM0ukExjh9HiXoJzoWpgMRRCrr/koIbtwXPJUqBprZK1I1CXHQ==",
- "license": "MIT",
+ "version": "0.3.36",
+ "resolved": "https://registry.npmjs.org/@langchain/core/-/core-0.3.36.tgz",
+ "integrity": "sha512-lOS6f5o2MarjGPomHPhzde9xI3lZW2NIOEdCv0dvjb1ZChWhwXWHtAMHSZmuSB53ySzDWAMkimimHd+Yqz5MwQ==",
"dependencies": {
"@cfworker/json-schema": "^4.0.2",
"ansi-styles": "^5.0.0",
"camelcase": "6",
"decamelize": "1.2.0",
"js-tiktoken": "^1.0.12",
- "langsmith": "^0.2.8",
+ "langsmith": ">=0.2.8 <0.4.0",
"mustache": "^4.2.0",
"p-queue": "^6.6.2",
"p-retry": "4",
@@ -9683,9 +10701,9 @@
}
},
"node_modules/@langchain/google-common": {
- "version": "0.1.6",
- "resolved": "https://registry.npmjs.org/@langchain/google-common/-/google-common-0.1.6.tgz",
- "integrity": "sha512-egGLnZ/OYu3hd37cIh7jx+Hx9kdrFpe6ADoLCwOnmRYZHoJ/nV1L+wNRAHVBgWzO5gIt4xL13nlZARTinjTTlA==",
+ "version": "0.1.8",
+ "resolved": "https://registry.npmjs.org/@langchain/google-common/-/google-common-0.1.8.tgz",
+ "integrity": "sha512-8auqWw2PMPhcHQHS+nMN3tVZrUPgSLckUaFeOHDOeSBiDvBd4KCybPwyl2oCwMDGvmyIxvOOckkMdeGaJ92vpQ==",
"dependencies": {
"uuid": "^10.0.0",
"zod-to-json-schema": "^3.22.4"
@@ -9710,11 +10728,11 @@
}
},
"node_modules/@langchain/google-gauth": {
- "version": "0.1.6",
- "resolved": "https://registry.npmjs.org/@langchain/google-gauth/-/google-gauth-0.1.6.tgz",
- "integrity": "sha512-3Gg4OK/5rNHwjfJrlnWNAUwfPzx90my4mvF1NPeUMIYOIVa9Rd3ROG/Ep18iimq3ZBjxceoKKNTeyQBvJ71csw==",
+ "version": "0.1.8",
+ "resolved": "https://registry.npmjs.org/@langchain/google-gauth/-/google-gauth-0.1.8.tgz",
+ "integrity": "sha512-2QK7d5SQMrnSv7X4j05BGfO74hiA8FJuNwSsQKZvzlGoVnNXil3x2aqD5V+zsYOPpxhkDCpNlmh2Pue2Wzy1rQ==",
"dependencies": {
- "@langchain/google-common": "~0.1.6",
+ "@langchain/google-common": "~0.1.8",
"google-auth-library": "^8.9.0"
},
"engines": {
@@ -9725,9 +10743,9 @@
}
},
"node_modules/@langchain/google-genai": {
- "version": "0.1.6",
- "resolved": "https://registry.npmjs.org/@langchain/google-genai/-/google-genai-0.1.6.tgz",
- "integrity": "sha512-LF3fan9pvgFa1vw2/IYGhi5KjppE0OvPFX3QQBUshBLpXWERP+BSpSD7jcXyqm9Kf7DcFj7w5/2knKeEwih8Xg==",
+ "version": "0.1.7",
+ "resolved": "https://registry.npmjs.org/@langchain/google-genai/-/google-genai-0.1.7.tgz",
+ "integrity": "sha512-m0cg2VKxxySFfiIFfoMEt22sM4DifmV7AYUN3/DBG8AABG1qLMpNTXUA+b9DGbRD21JFCQpny8Z8eFKRSZFHzA==",
"dependencies": {
"@google/generative-ai": "^0.21.0",
"zod-to-json-schema": "^3.22.4"
@@ -9740,11 +10758,11 @@
}
},
"node_modules/@langchain/google-vertexai": {
- "version": "0.1.6",
- "resolved": "https://registry.npmjs.org/@langchain/google-vertexai/-/google-vertexai-0.1.6.tgz",
- "integrity": "sha512-MU97EPpg+JX9S9zEVxHogkpnE2cxqtDD2NsvK0b8sPER75BTkQkhVprjJy5YWyN7x6I4IkLzQ1EAS8r8GzZiXQ==",
+ "version": "0.1.8",
+ "resolved": "https://registry.npmjs.org/@langchain/google-vertexai/-/google-vertexai-0.1.8.tgz",
+ "integrity": "sha512-n06ohihopz38agOm7BTASHMmFLz+XAZlzEvqtPC4Qa1fhYhzETQg2gCzEapIJ1yVk5MhrWqwKnVOQ+tIsFE88Q==",
"dependencies": {
- "@langchain/google-gauth": "~0.1.6"
+ "@langchain/google-gauth": "~0.1.8"
},
"engines": {
"node": ">=18"
@@ -9754,9 +10772,9 @@
}
},
"node_modules/@langchain/langgraph": {
- "version": "0.2.38",
- "resolved": "https://registry.npmjs.org/@langchain/langgraph/-/langgraph-0.2.38.tgz",
- "integrity": "sha512-mVy99pMftBGgUTBTCepSyzTovWCvpgdNcXsAjxTiMrMX6lzueNiBz0ljkY7UFoIoHYwurQbyl2WmMPFuxkSIAw==",
+ "version": "0.2.41",
+ "resolved": "https://registry.npmjs.org/@langchain/langgraph/-/langgraph-0.2.41.tgz",
+ "integrity": "sha512-NeNizWP4k9voEwJxuFtfopF02Lx1isuEsdZKYCN3ueJpOnkVg0iGx8woPBsQpYcrWcySkIt3zOkgtUsrNHqo3g==",
"dependencies": {
"@langchain/langgraph-checkpoint": "~0.0.13",
"@langchain/langgraph-sdk": "~0.0.32",
@@ -9797,9 +10815,9 @@
}
},
"node_modules/@langchain/langgraph-sdk": {
- "version": "0.0.33",
- "resolved": "https://registry.npmjs.org/@langchain/langgraph-sdk/-/langgraph-sdk-0.0.33.tgz",
- "integrity": "sha512-l/hRbI6roLzplBXy2VyDUwqY1TkK7RcjPmrMUuVdvCCH4LTwLfIXh/G1kHatNiN7VUTskw0FkfBbgq6gtj0ang==",
+ "version": "0.0.36",
+ "resolved": "https://registry.npmjs.org/@langchain/langgraph-sdk/-/langgraph-sdk-0.0.36.tgz",
+ "integrity": "sha512-KkAZM0uXBaMcD/dpGTBppOhbvNX6gz+Y1zFAC898OblegFkSvICrkd0oRQ5Ro/GWK/NAoDymnMUDXeZDdUkSuw==",
"dependencies": {
"@types/json-schema": "^7.0.15",
"p-queue": "^6.6.2",
@@ -9900,10 +10918,9 @@
}
},
"node_modules/@langchain/ollama": {
- "version": "0.1.2",
- "resolved": "https://registry.npmjs.org/@langchain/ollama/-/ollama-0.1.2.tgz",
- "integrity": "sha512-WCeogCFjdWf6jGwLt12cxkSpm5eVamv43b48DIlbJ4np9vChwVlZZB6FU7uEXNrJ9c0dsoa6877hJ5mYHdbJvw==",
- "license": "MIT",
+ "version": "0.1.5",
+ "resolved": "https://registry.npmjs.org/@langchain/ollama/-/ollama-0.1.5.tgz",
+ "integrity": "sha512-S2tF94uIJtXavekKg10LvTV+jIelOIrubaCnje8BopfiNOVcnzsSulUL4JH0wvdxMZq0vbE4/i9RwC2q9ivOmA==",
"dependencies": {
"ollama": "^0.5.9",
"uuid": "^10.0.0"
@@ -9945,39 +10962,6 @@
"@langchain/core": ">=0.2.26 <0.4.0"
}
},
- "node_modules/@langchain/openai/node_modules/@types/node": {
- "version": "18.19.64",
- "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.64.tgz",
- "integrity": "sha512-955mDqvO2vFf/oL7V3WiUtiz+BugyX8uVbaT2H8oj3+8dRyH2FLiNdowe7eNqRM7IOIZvzDH76EoAT+gwm6aIQ==",
- "dependencies": {
- "undici-types": "~5.26.4"
- }
- },
- "node_modules/@langchain/openai/node_modules/openai": {
- "version": "4.72.0",
- "resolved": "https://registry.npmjs.org/openai/-/openai-4.72.0.tgz",
- "integrity": "sha512-hFqG9BWCs7L7ifrhJXw7mJXmUBr7d9N6If3J9563o0jfwVA4wFANFDDaOIWFdgDdwgCXg5emf0Q+LoLCGszQYA==",
- "dependencies": {
- "@types/node": "^18.11.18",
- "@types/node-fetch": "^2.6.4",
- "abort-controller": "^3.0.0",
- "agentkeepalive": "^4.2.1",
- "form-data-encoder": "1.7.2",
- "formdata-node": "^4.3.2",
- "node-fetch": "^2.6.7"
- },
- "bin": {
- "openai": "bin/cli"
- },
- "peerDependencies": {
- "zod": "^3.23.8"
- },
- "peerDependenciesMeta": {
- "zod": {
- "optional": true
- }
- }
- },
"node_modules/@langchain/textsplitters": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/@langchain/textsplitters/-/textsplitters-0.0.3.tgz",
@@ -10256,18 +11240,17 @@
}
},
"node_modules/@playwright/test": {
- "version": "1.41.2",
- "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.41.2.tgz",
- "integrity": "sha512-qQB9h7KbibJzrDpkXkYvsmiDJK14FULCCZgEcoe2AvFAS64oCirWTwzTlAYEbKaRxWs5TFesE1Na6izMv3HfGg==",
- "dev": true,
+ "version": "1.50.0",
+ "resolved": "https://registry.npmjs.org/@playwright/test/-/test-1.50.0.tgz",
+ "integrity": "sha512-ZGNXbt+d65EGjBORQHuYKj+XhCewlwpnSd/EDuLPZGSiEWmgOJB5RmMCCYGy5aMfTs9wx61RivfDKi8H/hcMvw==",
"dependencies": {
- "playwright": "1.41.2"
+ "playwright": "1.50.0"
},
"bin": {
"playwright": "cli.js"
},
"engines": {
- "node": ">=16"
+ "node": ">=18"
}
},
"node_modules/@prettier/eslint": {
@@ -15885,13 +16868,6 @@
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw=="
},
- "node_modules/base-64": {
- "version": "0.1.0",
- "resolved": "https://registry.npmjs.org/base-64/-/base-64-0.1.0.tgz",
- "integrity": "sha512-Y5gU45svrR5tI2Vt/X9GPd3L0HNIKzGu202EjxrXMpuc2V2CiKgemAbUUsqYmZJvPtCXoUKjNZwBJzsNScUbXA==",
- "optional": true,
- "peer": true
- },
"node_modules/base64-js": {
"version": "1.5.1",
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
@@ -16449,16 +17425,6 @@
"url": "https://github.com/sponsors/wooorm"
}
},
- "node_modules/charenc": {
- "version": "0.0.2",
- "resolved": "https://registry.npmjs.org/charenc/-/charenc-0.0.2.tgz",
- "integrity": "sha512-yrLQ/yVUFXkzg7EDQsPieE/53+0RlaWTs+wBrvW36cyilJ2SaDWfl4Yj7MtLTXleV9uEKefbAGUPv2/iWSooRA==",
- "optional": true,
- "peer": true,
- "engines": {
- "node": "*"
- }
- },
"node_modules/cheerio": {
"version": "1.0.0-rc.12",
"resolved": "https://registry.npmjs.org/cheerio/-/cheerio-1.0.0-rc.12.tgz",
@@ -17246,16 +18212,6 @@
"node": ">= 8"
}
},
- "node_modules/crypt": {
- "version": "0.0.2",
- "resolved": "https://registry.npmjs.org/crypt/-/crypt-0.0.2.tgz",
- "integrity": "sha512-mCxBlsHFYh9C+HVpiEacem8FEBnMXgU9gy4zmNC+SXAZNB/1idgp/aulFJ4FgCi7GPEVbfyng092GqL2k2rmow==",
- "optional": true,
- "peer": true,
- "engines": {
- "node": "*"
- }
- },
"node_modules/crypto-browserify": {
"version": "3.12.0",
"resolved": "https://registry.npmjs.org/crypto-browserify/-/crypto-browserify-3.12.0.tgz",
@@ -17683,7 +18639,6 @@
"version": "4.3.1",
"resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz",
"integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==",
- "dev": true,
"engines": {
"node": ">=0.10.0"
}
@@ -17781,9 +18736,9 @@
}
},
"node_modules/detect-libc": {
- "version": "2.0.2",
- "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.2.tgz",
- "integrity": "sha512-UX6sGumvvqSaXgdKGUsgZWqcUyIXZ/vZTrlRT/iobiKhGL0zL4d3osHj3uqllWJK+i+sixDS/3COVEOFbupFyw==",
+ "version": "2.0.3",
+ "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.3.tgz",
+ "integrity": "sha512-bwy0MGW55bG41VqxxypOsdSdGqLwXPI/focwgTYCFMbdUiBAxLg9CFzG08sz2aqzknwiX7Hkl0bQENjg8iLByw==",
"engines": {
"node": ">=8"
}
@@ -17861,17 +18816,6 @@
"resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.12.0.tgz",
"integrity": "sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA=="
},
- "node_modules/digest-fetch": {
- "version": "1.3.0",
- "resolved": "https://registry.npmjs.org/digest-fetch/-/digest-fetch-1.3.0.tgz",
- "integrity": "sha512-CGJuv6iKNM7QyZlM2T3sPAdZWd/p9zQiRNS9G+9COUCwzWFTs0Xp8NF5iePx7wtvhDykReiRRrSeNb4oMmB8lA==",
- "optional": true,
- "peer": true,
- "dependencies": {
- "base-64": "^0.1.0",
- "md5": "^2.3.0"
- }
- },
"node_modules/dir-glob": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz",
@@ -21478,13 +22422,6 @@
"url": "https://github.com/sponsors/ljharb"
}
},
- "node_modules/is-buffer": {
- "version": "1.1.6",
- "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz",
- "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==",
- "optional": true,
- "peer": true
- },
"node_modules/is-builtin-module": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-3.2.1.tgz",
@@ -23380,14 +24317,6 @@
"node": ">=18"
}
},
- "node_modules/langchain/node_modules/@types/node": {
- "version": "18.19.61",
- "resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.61.tgz",
- "integrity": "sha512-z8fH66NcVkDzBItOao+Nyh0fiy7CYdxIyxnNCcZ60aY0I+EA/y4TSi/S/W9i8DIQvwVo7a0pgzAxmDeNnqrpkw==",
- "dependencies": {
- "undici-types": "~5.26.4"
- }
- },
"node_modules/langchain/node_modules/ansi-styles": {
"version": "5.2.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz",
@@ -23420,31 +24349,6 @@
}
}
},
- "node_modules/langchain/node_modules/openai": {
- "version": "4.68.4",
- "resolved": "https://registry.npmjs.org/openai/-/openai-4.68.4.tgz",
- "integrity": "sha512-LRinV8iU9VQplkr25oZlyrsYGPGasIwYN8KFMAAFTHHLHjHhejtJ5BALuLFrkGzY4wfbKhOhuT+7lcHZ+F3iEA==",
- "dependencies": {
- "@types/node": "^18.11.18",
- "@types/node-fetch": "^2.6.4",
- "abort-controller": "^3.0.0",
- "agentkeepalive": "^4.2.1",
- "form-data-encoder": "1.7.2",
- "formdata-node": "^4.3.2",
- "node-fetch": "^2.6.7"
- },
- "bin": {
- "openai": "bin/cli"
- },
- "peerDependencies": {
- "zod": "^3.23.8"
- },
- "peerDependenciesMeta": {
- "zod": {
- "optional": true
- }
- }
- },
"node_modules/langchain/node_modules/uuid": {
"version": "10.0.0",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-10.0.0.tgz",
@@ -24453,18 +25357,6 @@
"resolved": "https://registry.npmjs.org/remove-accents/-/remove-accents-0.5.0.tgz",
"integrity": "sha512-8g3/Otx1eJaVD12e31UbJj1YzdtVvzH85HV7t+9MJYk/u3XmkOUJ5Ys9wQrf9PCPK8+xn4ymzqYCiZl6QWKn+A=="
},
- "node_modules/md5": {
- "version": "2.3.0",
- "resolved": "https://registry.npmjs.org/md5/-/md5-2.3.0.tgz",
- "integrity": "sha512-T1GITYmFaKuO91vxyoQMFETst+O71VUPEU3ze5GNzDm0OWdP8v1ziTaAEPUr/3kLsY3Sftgz242A1SetQiDL7g==",
- "optional": true,
- "peer": true,
- "dependencies": {
- "charenc": "0.0.2",
- "crypt": "0.0.2",
- "is-buffer": "~1.1.6"
- }
- },
"node_modules/md5.js": {
"version": "1.3.5",
"resolved": "https://registry.npmjs.org/md5.js/-/md5.js-1.3.5.tgz",
@@ -26794,23 +27686,32 @@
}
},
"node_modules/openai": {
- "version": "4.11.1",
- "resolved": "https://registry.npmjs.org/openai/-/openai-4.11.1.tgz",
- "integrity": "sha512-GU0HQWbejXuVAQlDjxIE8pohqnjptFDIm32aPlNT1H9ucMz1VJJD0DaTJRQsagNaJ97awWjjVLEG7zCM6sm4SA==",
- "optional": true,
- "peer": true,
+ "version": "4.80.1",
+ "resolved": "https://registry.npmjs.org/openai/-/openai-4.80.1.tgz",
+ "integrity": "sha512-+6+bbXFwbIE88foZsBEt36bPkgZPdyFN82clAXG61gnHb2gXdZApDyRrcAHqEtpYICywpqaNo57kOm9dtnb7Cw==",
"dependencies": {
"@types/node": "^18.11.18",
"@types/node-fetch": "^2.6.4",
"abort-controller": "^3.0.0",
"agentkeepalive": "^4.2.1",
- "digest-fetch": "^1.3.0",
"form-data-encoder": "1.7.2",
"formdata-node": "^4.3.2",
"node-fetch": "^2.6.7"
},
"bin": {
"openai": "bin/cli"
+ },
+ "peerDependencies": {
+ "ws": "^8.18.0",
+ "zod": "^3.23.8"
+ },
+ "peerDependenciesMeta": {
+ "ws": {
+ "optional": true
+ },
+ "zod": {
+ "optional": true
+ }
}
},
"node_modules/openai-chat-tokens": {
@@ -26825,8 +27726,6 @@
"version": "18.19.14",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.14.tgz",
"integrity": "sha512-EnQ4Us2rmOS64nHDWr0XqAD8DsO6f3XR6lf9UIIrZQpUzPVdN/oPuEzfDWNHSyXLvoGgjuEm/sPwFGSSs35Wtg==",
- "optional": true,
- "peer": true,
"dependencies": {
"undici-types": "~5.26.4"
}
@@ -27503,40 +28402,37 @@
}
},
"node_modules/playwright": {
- "version": "1.41.2",
- "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.41.2.tgz",
- "integrity": "sha512-v0bOa6H2GJChDL8pAeLa/LZC4feoAMbSQm1/jF/ySsWWoaNItvrMP7GEkvEEFyCTUYKMxjQKaTSg5up7nR6/8A==",
- "devOptional": true,
+ "version": "1.50.0",
+ "resolved": "https://registry.npmjs.org/playwright/-/playwright-1.50.0.tgz",
+ "integrity": "sha512-+GinGfGTrd2IfX1TA4N2gNmeIksSb+IAe589ZH+FlmpV3MYTx6+buChGIuDLQwrGNCw2lWibqV50fU510N7S+w==",
"dependencies": {
- "playwright-core": "1.41.2"
+ "playwright-core": "1.50.0"
},
"bin": {
"playwright": "cli.js"
},
"engines": {
- "node": ">=16"
+ "node": ">=18"
},
"optionalDependencies": {
"fsevents": "2.3.2"
}
},
"node_modules/playwright-core": {
- "version": "1.41.2",
- "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.41.2.tgz",
- "integrity": "sha512-VaTvwCA4Y8kxEe+kfm2+uUUw5Lubf38RxF7FpBxLPmGe5sdNkSg5e3ChEigaGrX7qdqT3pt2m/98LiyvU2x6CA==",
- "devOptional": true,
+ "version": "1.50.0",
+ "resolved": "https://registry.npmjs.org/playwright-core/-/playwright-core-1.50.0.tgz",
+ "integrity": "sha512-CXkSSlr4JaZs2tZHI40DsZUN/NIwgaUPsyLuOAaIZp2CyF2sN5MM5NJsyB188lFSSozFxQ5fPT4qM+f0tH/6wQ==",
"bin": {
"playwright-core": "cli.js"
},
"engines": {
- "node": ">=16"
+ "node": ">=18"
}
},
"node_modules/playwright/node_modules/fsevents": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
- "dev": true,
"hasInstallScript": true,
"optional": true,
"os": [
@@ -34836,9 +35732,9 @@
}
},
"node_modules/ws": {
- "version": "8.17.1",
- "resolved": "https://registry.npmjs.org/ws/-/ws-8.17.1.tgz",
- "integrity": "sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==",
+ "version": "8.18.0",
+ "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.0.tgz",
+ "integrity": "sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==",
"engines": {
"node": ">=10.0.0"
},
diff --git a/packages/data-provider/src/types/agents.ts b/packages/data-provider/src/types/agents.ts
index 9ab57607d4..745786e3b9 100644
--- a/packages/data-provider/src/types/agents.ts
+++ b/packages/data-provider/src/types/agents.ts
@@ -8,6 +8,11 @@ export namespace Agents {
export type ImageDetail = 'auto' | 'low' | 'high';
+ export type ReasoningContentText = {
+ type: ContentTypes.THINK;
+ think: string;
+ };
+
export type MessageContentText = {
type: ContentTypes.TEXT;
text: string;
@@ -20,6 +25,7 @@ export namespace Agents {
};
export type MessageContentComplex =
+ | ReasoningContentText
| MessageContentText
| MessageContentImageUrl
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -212,12 +218,44 @@ export namespace Agents {
* The delta containing the fields that have changed on the Message.
*/
export interface MessageDelta {
+ /**
+ * The content of the message in array of text and/or images.
+ */
+ content?: Agents.MessageContentComplex[];
+ }
+
+ /**
+ * Represents a reasoning delta i.e. any changed fields on a message during
+ * streaming.
+ */
+ export interface ReasoningDeltaEvent {
+ /**
+ * The identifier of the message, which can be referenced in API endpoints.
+ */
+ id: string;
+
+ /**
+ * The delta containing the fields that have changed.
+ */
+ delta: ReasoningDelta;
+ }
+
+ /**
+ * The reasoning delta containing the fields that have changed on the Message.
+ */
+ export interface ReasoningDelta {
/**
* The content of the message in array of text and/or images.
*/
content?: MessageContentComplex[];
}
- export type ContentType = ContentTypes.TEXT | ContentTypes.IMAGE_URL | string;
+
+ export type ReasoningDeltaUpdate = { type: ContentTypes.THINK; think: string };
+ export type ContentType =
+ | ContentTypes.THINK
+ | ContentTypes.TEXT
+ | ContentTypes.IMAGE_URL
+ | string;
}
export type ToolCallResult = {
diff --git a/packages/data-provider/src/types/assistants.ts b/packages/data-provider/src/types/assistants.ts
index 810e357b31..bd5ef9d773 100644
--- a/packages/data-provider/src/types/assistants.ts
+++ b/packages/data-provider/src/types/assistants.ts
@@ -432,6 +432,7 @@ export type ContentPart = (
export type TMessageContentParts =
| { type: ContentTypes.ERROR; text: Text & PartMetadata }
+ | { type: ContentTypes.THINK; think: string | (Text & PartMetadata) }
| { type: ContentTypes.TEXT; text: string | (Text & PartMetadata); tool_call_ids?: string[] }
| {
type: ContentTypes.TOOL_CALL;
diff --git a/packages/data-provider/src/types/runs.ts b/packages/data-provider/src/types/runs.ts
index 2d66d58695..1f40d39b72 100644
--- a/packages/data-provider/src/types/runs.ts
+++ b/packages/data-provider/src/types/runs.ts
@@ -1,5 +1,6 @@
export enum ContentTypes {
TEXT = 'text',
+ THINK = 'think',
TEXT_DELTA = 'text_delta',
TOOL_CALL = 'tool_call',
IMAGE_FILE = 'image_file',