mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 08:50:15 +01:00
🛠️ chore: Typing and Remove Comments (#9732)
* chore: Update documentation for formatToolContent function, remove JSDoc types and duplicate comments * chore: fix type errors due to attachment.filename in Attachment component
This commit is contained in:
parent
68c9f668c1
commit
aae3694b11
2 changed files with 14 additions and 20 deletions
|
|
@ -70,7 +70,7 @@ const ImageAttachment = memo(({ attachment }: { attachment: TAttachment }) => {
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Image
|
<Image
|
||||||
altText={attachment.filename}
|
altText={attachment.filename || 'attachment image'}
|
||||||
imagePath={filepath ?? ''}
|
imagePath={filepath ?? ''}
|
||||||
height={height ?? 0}
|
height={height ?? 0}
|
||||||
width={width ?? 0}
|
width={width ?? 0}
|
||||||
|
|
@ -89,8 +89,9 @@ export default function Attachment({ attachment }: { attachment?: TAttachment })
|
||||||
}
|
}
|
||||||
|
|
||||||
const { width, height, filepath = null } = attachment as TFile & TAttachmentMetadata;
|
const { width, height, filepath = null } = attachment as TFile & TAttachmentMetadata;
|
||||||
const isImage =
|
const isImage = attachment.filename
|
||||||
imageExtRegex.test(attachment.filename) && width != null && height != null && filepath != null;
|
? imageExtRegex.test(attachment.filename) && width != null && height != null && filepath != null
|
||||||
|
: false;
|
||||||
|
|
||||||
if (isImage) {
|
if (isImage) {
|
||||||
return <ImageAttachment attachment={attachment} />;
|
return <ImageAttachment attachment={attachment} />;
|
||||||
|
|
@ -110,11 +111,12 @@ export function AttachmentGroup({ attachments }: { attachments?: TAttachment[] }
|
||||||
|
|
||||||
attachments.forEach((attachment) => {
|
attachments.forEach((attachment) => {
|
||||||
const { width, height, filepath = null } = attachment as TFile & TAttachmentMetadata;
|
const { width, height, filepath = null } = attachment as TFile & TAttachmentMetadata;
|
||||||
const isImage =
|
const isImage = attachment.filename
|
||||||
imageExtRegex.test(attachment.filename) &&
|
? imageExtRegex.test(attachment.filename) &&
|
||||||
width != null &&
|
width != null &&
|
||||||
height != null &&
|
height != null &&
|
||||||
filepath != null;
|
filepath != null
|
||||||
|
: false;
|
||||||
|
|
||||||
if (isImage) {
|
if (isImage) {
|
||||||
imageAttachments.push(attachment);
|
imageAttachments.push(attachment);
|
||||||
|
|
|
||||||
|
|
@ -81,22 +81,14 @@ function parseAsString(result: t.MCPToolCallResponse): string {
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts MCPToolCallResponse content into recognized content block types
|
|
||||||
* Recognized types: "image", "image_url", "text", "json"
|
|
||||||
*
|
|
||||||
* @param {t.MCPToolCallResponse} result - The MCPToolCallResponse object
|
|
||||||
* @param {string} provider - The provider name (google, anthropic, openai)
|
|
||||||
* @returns {Array<Object>} Formatted content blocks
|
|
||||||
*/
|
|
||||||
/**
|
/**
|
||||||
* Converts MCPToolCallResponse content into recognized content block types
|
* Converts MCPToolCallResponse content into recognized content block types
|
||||||
* First element: string or formatted content (excluding image_url)
|
* First element: string or formatted content (excluding image_url)
|
||||||
* Second element: image_url content if any
|
* Second element: Recognized types - "image", "image_url", "text", "json"
|
||||||
*
|
*
|
||||||
* @param {t.MCPToolCallResponse} result - The MCPToolCallResponse object
|
* @param result - The MCPToolCallResponse object
|
||||||
* @param {string} provider - The provider name (google, anthropic, openai)
|
* @param provider - The provider name (google, anthropic, openai)
|
||||||
* @returns {t.FormattedContentResult} Tuple of content and image_urls
|
* @returns Tuple of content and image_urls
|
||||||
*/
|
*/
|
||||||
export function formatToolContent(
|
export function formatToolContent(
|
||||||
result: t.MCPToolCallResponse,
|
result: t.MCPToolCallResponse,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue