Send images after text block for better results

This commit is contained in:
Saoud Rizwan
2024-08-08 03:12:54 -04:00
parent e949b3d5e6
commit efad5ecd91

View File

@@ -322,8 +322,8 @@ export class ClaudeDev {
if (images && images.length > 0) { if (images && images.length > 0) {
const textBlock: Anthropic.TextBlockParam = { type: "text", text: text ?? "" } const textBlock: Anthropic.TextBlockParam = { type: "text", text: text ?? "" }
const imageBlocks: Anthropic.ImageBlockParam[] = this.formatImagesIntoBlocks(images) const imageBlocks: Anthropic.ImageBlockParam[] = this.formatImagesIntoBlocks(images)
// "Just as with document-query placement, Claude works best when images come before text. Images placed after text or interpolated with text will still perform well, but if your use case allows it, we recommend an image-then-text structure." // Placing images after text leads to better results
return [...imageBlocks, textBlock] return [textBlock, ...imageBlocks]
} else { } else {
return text ?? "" return text ?? ""
} }
@@ -351,8 +351,8 @@ export class ClaudeDev {
while (this.requestCount < this.maxRequestsPerTask) { while (this.requestCount < this.maxRequestsPerTask) {
const { didEndLoop, inputTokens, outputTokens } = await this.recursivelyMakeClaudeRequests([ const { didEndLoop, inputTokens, outputTokens } = await this.recursivelyMakeClaudeRequests([
...imageBlocks,
textBlock, textBlock,
...imageBlocks,
]) ])
totalInputTokens += inputTokens totalInputTokens += inputTokens
totalOutputTokens += outputTokens totalOutputTokens += outputTokens