Changesets · Branches · Tags · Compare
| Changeset | 91054b807bf2e526364f182ff1cc5e1390aaa8620208986b8ea7036792947111 |
|---|---|
| Author | Dallin Romney <dallinromney@gmail.com> · 2025-07-07 15:29 -07:00 |
| Committer | Dallin Romney <dallinromney@gmail.com> · 2025-07-07 15:29 -07:00 |
| Parents | e317d4ccae55 |
1 file changed
modified packages/openai-adapters/src/apis/Bedrock.ts +16 −9
| @@ -181,7 +181,10 @@ | ||
| 181 | 181 | const trimmedContent = |
| 182 | 182 | typeof message.content === "string" |
| 183 | 183 | ? message.content.trim() |
| 184 | - : JSON.stringify(message.content); | |
| 184 | + : message.content | |
| 185 | + .map((c) => c.text) | |
| 186 | + .join("\n") | |
| 187 | + .trim(); | |
| 185 | 188 | |
| 186 | 189 | if (hasAddedToolCallIds.has(message.tool_call_id)) { |
| 187 | 190 | currentBlocks.push({ |
| @@ -208,15 +211,19 @@ | ||
| 208 | 211 | } |
| 209 | 212 | |
| 210 | 213 | // ASSISTANT messages |
| 211 | - const content = message.content; | |
| 212 | - if (content) { | |
| 213 | - if (typeof content === "string") { | |
| 214 | - currentBlocks.push({ text: content }); | |
| 215 | - } else { | |
| 216 | - content.forEach((part) => { | |
| 217 | - currentBlocks.push(this._oaiPartToBedrockPart(part)); | |
| 218 | - }); | |
| 214 | + if (typeof message.content === "string") { | |
| 215 | + const trimmedText = message.content.trim(); | |
| 216 | + if (trimmedText) { | |
| 217 | + currentBlocks.push({ text: trimmedText }); | |
| 219 | 218 | } |
| 219 | + } else { | |
| 220 | + message.content?.forEach((part) => { | |
| 221 | + const text = part.type === "text" ? part.text : part.refusal; | |
| 222 | + const trimmedText = text.trim(); | |
| 223 | + if (trimmedText) { | |
| 224 | + currentBlocks.push({ text: trimmedText }); | |
| 225 | + } | |
| 226 | + }); | |
| 220 | 227 | } |
| 221 | 228 | |
| 222 | 229 | // TOOL CALLS |