mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-04-04 08:03:14 +00:00
fix: rm user message when dealing w/ image attachments, use proper tool attachment instead
This commit is contained in:
@@ -597,7 +597,7 @@ export namespace SessionPrompt {
|
||||
sessionID,
|
||||
system: [...(await SystemPrompt.environment()), ...(await SystemPrompt.custom())],
|
||||
messages: [
|
||||
...MessageV2.toModelMessage(sessionMessages),
|
||||
...MessageV2.toModelMessage(sessionMessages, { tools }),
|
||||
...(isLastStep
|
||||
? [
|
||||
{
|
||||
@@ -716,10 +716,18 @@ export namespace SessionPrompt {
|
||||
)
|
||||
return result
|
||||
},
|
||||
toModelOutput(result) {
|
||||
toModelOutput(result: { output: string; attachments?: MessageV2.FilePart[] }) {
|
||||
if (!result.attachments?.length) return { type: "text", value: result.output }
|
||||
return {
|
||||
type: "text",
|
||||
value: result.output,
|
||||
type: "content",
|
||||
value: [
|
||||
{ type: "text", text: result.output },
|
||||
...result.attachments.map((a) => ({
|
||||
type: "media" as const,
|
||||
data: a.url.slice(a.url.indexOf(",") + 1),
|
||||
mediaType: a.mime,
|
||||
})),
|
||||
],
|
||||
}
|
||||
},
|
||||
})
|
||||
@@ -806,10 +814,18 @@ export namespace SessionPrompt {
|
||||
content: result.content, // directly return content to preserve ordering when outputting to model
|
||||
}
|
||||
}
|
||||
item.toModelOutput = (result) => {
|
||||
item.toModelOutput = (result: { output: string; attachments?: MessageV2.FilePart[] }) => {
|
||||
if (!result.attachments?.length) return { type: "text", value: result.output }
|
||||
return {
|
||||
type: "text",
|
||||
value: result.output,
|
||||
type: "content",
|
||||
value: [
|
||||
{ type: "text", text: result.output },
|
||||
...result.attachments.map((a) => ({
|
||||
type: "media" as const,
|
||||
data: a.url.slice(a.url.indexOf(",") + 1),
|
||||
mediaType: a.mime,
|
||||
})),
|
||||
],
|
||||
}
|
||||
}
|
||||
tools[key] = item
|
||||
|
||||
Reference in New Issue
Block a user