(m map[string]any, key string)
| 1323 | return nil, false |
| 1324 | } |
| 1325 | |
| 1326 | return &consumeResult{ |
| 1327 | ToolMessages: toolMessages, |
| 1328 | TrailingText: strings.Join(nonEmptyStrings(textParts), "\n"), |
| 1329 | MatchedIDs: matchedIDs, |
| 1330 | }, true |
| 1331 | } |
| 1332 | |
| 1333 | func convertAnthropicMessagesToOpenAI(messages []map[string]any) []map[string]any { |
| 1334 | converted := []map[string]any{} |
| 1335 | i := 0 |
| 1336 | |
| 1337 | for i < len(messages) { |
| 1338 | msg := messages[i] |
| 1339 | role := getStringDefault(msg, "role", "user") |
| 1340 | content := msg["content"] |
| 1341 | |
| 1342 | if contentStr, ok := content.(string); ok { |
| 1343 | converted = append(converted, map[string]any{"role": role, "content": contentStr}) |
| 1344 | i++ |
| 1345 | continue |
| 1346 | } |
no test coverage detected