Skip to content

Commit 7cae646

Browse files
authored
Merge pull request #717 from sugarforever/feature/at-a-model
Feature/at a model
2 parents 8cc0b3a + 98adeb9 commit 7cae646

File tree

8 files changed

+1299
-550
lines changed

8 files changed

+1299
-550
lines changed

components/AgentChat.vue

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,15 @@ const onSend = async (data: ChatBoxFormData) => {
104104
}
105105
106106
// Validate content
107-
const hasValidContent = Array.isArray(data.content)
108-
? data.content.some(item =>
107+
const sanitizedContent = data.sanitizedContent ?? data.content
108+
const hasValidContent = Array.isArray(sanitizedContent)
109+
? sanitizedContent.some(item =>
109110
(item.type === 'text' && item.text?.trim()) ||
110111
(item.type === 'image_url' && item.image_url?.url)
111112
)
112-
: data.content.trim()
113+
: typeof sanitizedContent === 'string'
114+
? sanitizedContent.trim()
115+
: ''
113116
114117
if (!hasValidContent) {
115118
return
@@ -126,6 +129,7 @@ const onSend = async (data: ChatBoxFormData) => {
126129
id: Math.random(),
127130
contentType: Array.isArray(data.content) ? 'array' : 'string',
128131
content: data.content,
132+
sanitizedContent: data.sanitizedContent,
129133
startTime: timestamp,
130134
endTime: timestamp,
131135
model: 'user',
@@ -160,9 +164,9 @@ const onSend = async (data: ChatBoxFormData) => {
160164
161165
try {
162166
// Extract text content from the user message
163-
const promptText = Array.isArray(data.content)
164-
? data.content.find(item => item.type === 'text')?.text || ''
165-
: data.content
167+
const promptText = Array.isArray(sanitizedContent)
168+
? sanitizedContent.find(item => item.type === 'text')?.text || ''
169+
: sanitizedContent as string
166170
167171
sendMessage({
168172
type: 'request',
@@ -288,7 +292,7 @@ async function onAbortChat() {
288292
}
289293
290294
async function onResend(data: ChatMessage) {
291-
onSend({ content: data.content })
295+
onSend({ content: data.content, sanitizedContent: data.sanitizedContent })
292296
}
293297
294298
async function onRemove(data: ChatMessage) {

0 commit comments

Comments
 (0)