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

🐛 fix: Artifacts Type Error, Tool Token Counts, and Agent Chat Import (#5142)

Danny Avila6c9a468b8e4b
diff --git a/api/app/clients/BaseClient.js b/api/app/clients/BaseClient.js
index c4ca676ebf..5abdad686b 100644
--- a/api/app/clients/BaseClient.js
+++ b/api/app/clients/BaseClient.js
@@ -931,6 +931,24 @@ class BaseClient {
continue;
}
+ if (item.type === 'tool_call' && item.tool_call != null) {
+ const toolName = item.tool_call?.name || '';
+ if (toolName != null && toolName && typeof toolName === 'string') {
+ numTokens += this.getTokenCount(toolName);
+ }
+
+ const args = item.tool_call?.args || '';
+ if (args != null && args && typeof args === 'string') {
+ numTokens += this.getTokenCount(args);
+ }
+
+ const output = item.tool_call?.output || '';
+ if (output != null && output && typeof output === 'string') {
+ numTokens += this.getTokenCount(output);
+ }
+ continue;
+ }
+
const nestedValue = item[item.type];
if (!nestedValue) {
diff --git a/api/server/utils/import/importers.js b/api/server/utils/import/importers.js
index 9c4c0dc590..b828fed021 100644
--- a/api/server/utils/import/importers.js
+++ b/api/server/utils/import/importers.js
@@ -113,7 +113,7 @@ async function importLibreChatConvo(
*/
const traverseMessages = async (messages, parentMessageId = null) => {
for (const message of messages) {
- if (!message.text) {
+ if (!message.text && !message.content) {
continue;
}
@@ -121,6 +121,7 @@ async function importLibreChatConvo(
if (message.sender?.toLowerCase() === 'user' || message.isCreatedByUser) {
savedMessage = await importBatchBuilder.saveMessage({
text: message.text,
+ content: message.content,
sender: 'user',
isCreatedByUser: true,
parentMessageId: parentMessageId,
@@ -128,6 +129,7 @@ async function importLibreChatConvo(
} else {
savedMessage = await importBatchBuilder.saveMessage({
text: message.text,
+ content: message.content,
sender: message.sender,
isCreatedByUser: false,
model: options.model,
diff --git a/client/src/components/Chat/Input/Files/FilePreview.tsx b/client/src/components/Chat/Input/Files/FilePreview.tsx
index 41d3af9200..80933b8503 100644
--- a/client/src/components/Chat/Input/Files/FilePreview.tsx
+++ b/client/src/components/Chat/Input/Files/FilePreview.tsx
@@ -21,7 +21,11 @@ const FilePreview = ({
}) => {
const radius = 55; // Radius of the SVG circle
const circumference = 2 * Math.PI * radius;
- const progress = useProgress(file?.['progress'] ?? 1, 0.001, (file as ExtendedFile).size ?? 1);
+ const progress = useProgress(
+ file?.['progress'] ?? 1,
+ 0.001,
+ (file as ExtendedFile | undefined)?.size ?? 1,
+ );
// Calculate the offset based on the loading progress
const offset = circumference - progress * circumference;