Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitb11daa7

Browse files
Merge pull request#1893 from iamfaran/feat/chat-file-attachments
[Feat]: file attachments support for chat component
2 parents2138238 +0f0a4d0 commitb11daa7

File tree

10 files changed

+567
-782
lines changed

10 files changed

+567
-782
lines changed

‎client/packages/lowcoder/src/comps/comps/chatComp/chatComp.tsx‎

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,13 +80,37 @@ export const ChatEventHandlerControl = eventHandlerControl(ChatEventOptions);
8080
exportfunctionaddSystemPromptToHistory(
8181
conversationHistory:ChatMessage[],
8282
systemPrompt:string
83-
):Array<{role:string;content:string;timestamp:number}>{
83+
):Array<{role:string;content:string;timestamp:number;attachments?:any[]}>{
8484
// Format conversation history for use in queries
85-
constformattedHistory=conversationHistory.map(msg=>({
86-
role:msg.role,
87-
content:msg.text,
88-
timestamp:msg.timestamp
89-
}));
85+
constformattedHistory=conversationHistory.map(msg=>{
86+
constbaseMessage={
87+
role:msg.role,
88+
content:msg.text,
89+
timestamp:msg.timestamp
90+
};
91+
92+
// Include attachment metadata if present (for API calls and external integrations)
93+
if(msg.attachments&&msg.attachments.length>0){
94+
return{
95+
...baseMessage,
96+
attachments:msg.attachments.map(att=>({
97+
id:att.id,
98+
type:att.type,
99+
name:att.name,
100+
contentType:att.contentType,
101+
// Include content for images (base64 data URLs are useful for APIs)
102+
...(att.type==="image"&&att.content&&{
103+
content:att.content.map(c=>({
104+
type:c.type,
105+
...(c.type==="image"&&{image:c.image})
106+
}))
107+
})
108+
}))
109+
};
110+
}
111+
112+
returnbaseMessage;
113+
});
90114

91115
// Create system message (always exists since we have default)
92116
constsystemMessage=[{

‎client/packages/lowcoder/src/comps/comps/chatComp/components/ChatCore.tsx‎

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import React from "react";
44
import{ChatProvider}from"./context/ChatContext";
55
import{ChatCoreMain}from"./ChatCoreMain";
66
import{ChatCoreProps}from"../types/chatTypes";
7+
import{TooltipProvider}from"@radix-ui/react-tooltip";
78

89
// ============================================================================
910
// CHAT CORE - THE SHARED FOUNDATION
@@ -18,14 +19,16 @@ export function ChatCore({
1819
onEvent
1920
}:ChatCoreProps){
2021
return(
21-
<ChatProviderstorage={storage}>
22-
<ChatCoreMain
23-
messageHandler={messageHandler}
22+
<TooltipProvider>
23+
<ChatProviderstorage={storage}>
24+
<ChatCoreMain
25+
messageHandler={messageHandler}
2426
placeholder={placeholder}
2527
onMessageUpdate={onMessageUpdate}
2628
onConversationUpdate={onConversationUpdate}
27-
onEvent={onEvent}
28-
/>
29-
</ChatProvider>
29+
onEvent={onEvent}
30+
/>
31+
</ChatProvider>
32+
</TooltipProvider>
3033
);
3134
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp