mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 08:50:15 +01:00
🔀 fix: MCP Improvements, Auto-Save Drafts, Artifact Markup (#7040)
* feat: Update MCP tool creation to use lowercase provider name * refactor: handle MCP image output edge cases where tool outputs must contain string responses * feat: Drop 'anyOf' and 'oneOf' fields from JSON schema conversion * feat: Transform 'oneOf' and 'anyOf' fields to Zod union in JSON schema conversion * fix: artifactPlugin to replace textDirective with expected text, closes #7029 * fix: auto-save functionality to handle conversation transitions from pending drafts, closes #7027 * refactor: improve async handling during user disconnection process * fix: use correct user ID variable for MCP tool calling * fix: improve handling of pending drafts in auto-save functionality * fix: add support for additional model names in getValueKey function * fix: reset form values on agent deletion when no agents remain
This commit is contained in:
parent
150116eefe
commit
7f1d01c35a
12 changed files with 856 additions and 73 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import type * as t from './types/mcp';
|
||||
const RECOGNIZED_PROVIDERS = new Set(['google', 'anthropic', 'openAI']);
|
||||
const RECOGNIZED_PROVIDERS = new Set(['google', 'anthropic', 'openai', 'openrouter', 'xai', 'deepseek', 'ollama']);
|
||||
const CONTENT_ARRAY_PROVIDERS = new Set(['google', 'anthropic', 'openai']);
|
||||
|
||||
const imageFormatters: Record<string, undefined | t.ImageFormatter> = {
|
||||
// google: (item) => ({
|
||||
|
|
@ -76,12 +77,12 @@ function parseAsString(result: t.MCPToolCallResponse): string {
|
|||
*
|
||||
* @param {t.MCPToolCallResponse} result - The MCPToolCallResponse object
|
||||
* @param {string} provider - The provider name (google, anthropic, openai)
|
||||
* @returns {t.FormattedToolResponse} Tuple of content and image_urls
|
||||
* @returns {t.FormattedContentResult} Tuple of content and image_urls
|
||||
*/
|
||||
export function formatToolContent(
|
||||
result: t.MCPToolCallResponse,
|
||||
provider: t.Provider,
|
||||
): t.FormattedToolResponse {
|
||||
): t.FormattedContentResult {
|
||||
if (!RECOGNIZED_PROVIDERS.has(provider)) {
|
||||
return [parseAsString(result), undefined];
|
||||
}
|
||||
|
|
@ -110,7 +111,7 @@ export function formatToolContent(
|
|||
if (!isImageContent(item)) {
|
||||
return;
|
||||
}
|
||||
if (currentTextBlock) {
|
||||
if (CONTENT_ARRAY_PROVIDERS.has(provider) && currentTextBlock) {
|
||||
formattedContent.push({ type: 'text', text: currentTextBlock });
|
||||
currentTextBlock = '';
|
||||
}
|
||||
|
|
@ -149,9 +150,14 @@ export function formatToolContent(
|
|||
}
|
||||
}
|
||||
|
||||
if (currentTextBlock) {
|
||||
if (CONTENT_ARRAY_PROVIDERS.has(provider) && currentTextBlock) {
|
||||
formattedContent.push({ type: 'text', text: currentTextBlock });
|
||||
}
|
||||
|
||||
return [formattedContent, imageUrls.length ? { content: imageUrls } : undefined];
|
||||
const artifacts = imageUrls.length ? { content: imageUrls } : undefined;
|
||||
if (CONTENT_ARRAY_PROVIDERS.has(provider)) {
|
||||
return [formattedContent, artifacts];
|
||||
}
|
||||
|
||||
return [currentTextBlock, artifacts];
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue