Skip to content

Commit 52b8cb1

Browse files
committed
chore: run lint
1 parent efea921 commit 52b8cb1

File tree

1 file changed

+27
-14
lines changed

1 file changed

+27
-14
lines changed

src/routes/messages/non-stream-translation.ts

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -180,25 +180,38 @@ function mapContent(
180180
const hasImage = content.some((block) => block.type === "image")
181181
if (!hasImage) {
182182
return content
183-
.filter((block): block is AnthropicTextBlock | AnthropicThinkingBlock =>
184-
block.type === "text" || block.type === "thinking")
185-
.map((block) => block.type === "text" ? block.text : block.thinking)
183+
.filter(
184+
(block): block is AnthropicTextBlock | AnthropicThinkingBlock =>
185+
block.type === "text" || block.type === "thinking",
186+
)
187+
.map((block) => (block.type === "text" ? block.text : block.thinking))
186188
.join("\n\n")
187189
}
188190

189191
const contentParts: Array<ContentPart> = []
190192
for (const block of content) {
191-
if (block.type === "text") {
192-
contentParts.push({ type: "text", text: block.text })
193-
} else if (block.type === "thinking") {
194-
contentParts.push({ type: "text", text: block.thinking })
195-
} else if (block.type === "image") {
196-
contentParts.push({
197-
type: "image_url",
198-
image_url: {
199-
url: `data:${block.source.media_type};base64,${block.source.data}`,
200-
},
201-
})
193+
switch (block.type) {
194+
case "text": {
195+
contentParts.push({ type: "text", text: block.text })
196+
197+
break
198+
}
199+
case "thinking": {
200+
contentParts.push({ type: "text", text: block.thinking })
201+
202+
break
203+
}
204+
case "image": {
205+
contentParts.push({
206+
type: "image_url",
207+
image_url: {
208+
url: `data:${block.source.media_type};base64,${block.source.data}`,
209+
},
210+
})
211+
212+
break
213+
}
214+
// No default
202215
}
203216
}
204217
return contentParts

0 commit comments

Comments
 (0)