Conversation
Summary by CodeRabbit
Summary by CodeRabbit
WalkthroughThis set of changes refactors the message content handling across Anthropic, Gemini, and OpenAI integrations to use a unified, block-based content model. It introduces new types and custom serialization logic for Anthropic, consolidates Gemini message content into structured blocks, removes OpenAI-specific message types in favor of direct Bifrost schema usage, and updates the Prometheus plugin interface. Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant AnthropicIntegration
participant Bifrost
Client->>AnthropicIntegration: Send AnthropicMessageRequest
AnthropicIntegration->>AnthropicIntegration: Convert content (string or blocks) to BifrostMessage
AnthropicIntegration->>Bifrost: Send BifrostRequest
Bifrost-->>AnthropicIntegration: Return BifrostResponse
AnthropicIntegration->>AnthropicIntegration: Convert BifrostResponse to AnthropicMessageResponse (blocks or string)
AnthropicIntegration-->>Client: Return AnthropicMessageResponse
sequenceDiagram
participant Client
participant GeminiIntegration
participant Bifrost
Client->>GeminiIntegration: Send GeminiChatRequest
GeminiIntegration->>GeminiIntegration: Convert content parts to ContentBlocks
GeminiIntegration->>Bifrost: Send BifrostRequest
Bifrost-->>GeminiIntegration: Return BifrostResponse
GeminiIntegration->>GeminiIntegration: Extract ContentBlocks to Gemini response
GeminiIntegration-->>Client: Return GeminiChatResponse
sequenceDiagram
participant Client
participant OpenAIIntegration
participant Bifrost
Client->>OpenAIIntegration: Send OpenAIChatRequest (with BifrostMessages)
OpenAIIntegration->>Bifrost: Send BifrostRequest
Bifrost-->>OpenAIIntegration: Return BifrostResponse
OpenAIIntegration-->>Client: Return OpenAIChatResponse (direct mapping)
Possibly related PRs
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (5)
🧰 Additional context used🧠 Learnings (3)📓 Common learningstransports/bifrost-http/integrations/genai/types.go (5)transports/bifrost-http/integrations/anthropic/types.go (3)🧬 Code Graph Analysis (4)transports/bifrost-http/tracking/plugin.go (1)
transports/bifrost-http/integrations/genai/types.go (2)
transports/bifrost-http/integrations/openai/types.go (1)
transports/bifrost-http/integrations/anthropic/types.go (2)
🔇 Additional comments (5)
✨ Finishing Touches
🧪 Generate Unit Tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (1)
transports/go.sumis excluded by!**/*.sum
📒 Files selected for processing (5)
transports/bifrost-http/integrations/anthropic/types.go(8 hunks)transports/bifrost-http/integrations/genai/types.go(5 hunks)transports/bifrost-http/integrations/openai/types.go(4 hunks)transports/bifrost-http/tracking/plugin.go(3 hunks)transports/go.mod(1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: Pratham-Mishra04
PR: maximhq/bifrost#65
File: transports/bifrost-http/integrations/anthropic/types.go:131-180
Timestamp: 2025-06-10T13:11:37.842Z
Learning: In Anthropic API integration for Bifrost, messages won't contain both image and tool_result content blocks in the same message, so defensive guards against multiple embedded message structs are unnecessary in the content processing loop.
transports/bifrost-http/integrations/anthropic/types.go (1)
Learnt from: Pratham-Mishra04
PR: maximhq/bifrost#65
File: transports/bifrost-http/integrations/anthropic/types.go:131-180
Timestamp: 2025-06-10T13:11:37.842Z
Learning: In Anthropic API integration for Bifrost, messages won't contain both image and tool_result content blocks in the same message, so defensive guards against multiple embedded message structs are unnecessary in the content processing loop.
🧬 Code Graph Analysis (3)
transports/bifrost-http/integrations/genai/types.go (2)
core/schemas/bifrost.go (13)
ModelChatMessageRoleSystem(30-30)ModelChatMessageRole(25-25)BifrostMessage(148-156)ToolCall(319-323)ContentBlock(209-213)ContentBlockTypeText(205-205)ContentBlockTypeImage(206-206)ImageURLStruct(229-232)ModelChatMessageRoleTool(32-32)MessageContent(158-161)ToolMessage(216-218)ModelChatMessageRoleAssistant(28-28)AssistantMessage(221-226)core/utils.go (1)
Ptr(5-7)
transports/bifrost-http/tracking/plugin.go (1)
core/schemas/bifrost.go (2)
BifrostRequest(59-69)BifrostResponse(237-247)
transports/bifrost-http/integrations/openai/types.go (1)
core/schemas/bifrost.go (6)
BifrostMessage(148-156)Tool(113-117)ToolChoice(142-145)LogProbs(306-310)BifrostResponseChoice(342-348)LLMUsage(250-256)
🔇 Additional comments (12)
transports/go.mod (1)
7-7: LGTM!The core dependency update to v1.1.0 aligns with the PR objectives and supports the refactored content handling across integrations.
transports/bifrost-http/tracking/plugin.go (1)
99-101: LGTM!The addition of the
Cleanupmethod provides a standard way for plugins to release resources. The empty implementation is appropriate for this metrics plugin.transports/bifrost-http/integrations/genai/types.go (3)
140-140: Breaking change: Method signature updated.The method signature change from returning
[]schemas.BifrostMessagetoschemas.BifrostMessageis a breaking change. This aligns with the unified content model approach across integrations.
147-218: Excellent refactoring to unified content model!The consolidation of multiple message types (text, images, function calls) into a single message with structured content blocks improves consistency and maintainability. The implementation correctly handles all content types including tool calls.
329-337: Response deserialization correctly handles both content formats.The updated logic properly handles both simple string content and structured content blocks, ensuring backward compatibility while supporting the new content model.
transports/bifrost-http/integrations/openai/types.go (3)
12-30: Excellent simplification using Bifrost schema types directly!Removing custom message types in favor of direct
schemas.BifrostMessageusage reduces code duplication and improves maintainability. The integration is now more aligned with the core Bifrost schema.
50-50: Clean and direct field mapping.The simplified conversion logic with direct field assignments is much clearer and reduces the potential for conversion errors.
Also applies to: 67-68
123-140: Streamlined response conversion.The direct field copying approach for response conversion is efficient and maintains type safety.
transports/bifrost-http/integrations/anthropic/types.go (4)
38-80: Well-implemented custom marshaling for flexible content handling.The custom JSON marshaling/unmarshaling for
AnthropicContentelegantly handles both string and block array formats, ensuring backward compatibility while supporting the new structured content model.
87-91: Good improvement in type safety for tool schemas.Making
InputSchemaexplicitly typed with defined fields improves type safety and makes the API contract clearer.
261-290: Tool result handling looks correct based on the API constraints.The implementation correctly handles tool results with their associated content. Based on the retrieved learning, messages won't contain both image and tool_result blocks, so the current implementation is appropriate.
342-346: Simplified tool schema conversion.The direct field mapping for tool schemas is cleaner and more maintainable than the previous approach.
110e4f5 to
5dcba7a
Compare
There was a problem hiding this comment.
Actionable comments posted: 3
🔭 Outside diff range comments (3)
transports/go.mod (1)
3-3:⚠️ Potential issueUnreleased Go toolchain version specified
go 1.24.1does not exist (latest stable is 1.22.x). Using a future toolchain string will breakgocommands (go: unknown release).
Pin to the latest released minor (e.g.1.22) or omit the patch component (1.24) until it’s actually shipped.transports/bifrost-http/tracking/plugin.go (1)
45-55: 🧹 Nitpick (assertive)Consider early-return capability in PreHook
PreHooknow always returns(req, nil, nil).
If a plugin ever needs to short-circuit with a synthetic*schemas.BifrostResponse, the current implementation ignores that possibility.
At minimum, add a comment clarifying that this plugin never short-circuits, or returnnil, nil, nilwhenreqshould be halted.transports/bifrost-http/integrations/openai/types.go (1)
114-117:⚠️ Potential issue
convertParametersmay silently returnnileven when Tools / ToolChoice are set
return nilis triggered solely bylen(params.ExtraParams)==0, ignoringparams.Toolsorparams.ToolChoice.
Down-stream code will then omit tool metadata.-if len(params.ExtraParams) == 0 { - return nil -} +if len(params.ExtraParams) == 0 && params.Tools == nil && params.ToolChoice == nil { + return nil +}
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (1)
transports/go.sumis excluded by!**/*.sum
📒 Files selected for processing (5)
transports/bifrost-http/integrations/anthropic/types.go(8 hunks)transports/bifrost-http/integrations/genai/types.go(4 hunks)transports/bifrost-http/integrations/openai/types.go(4 hunks)transports/bifrost-http/tracking/plugin.go(3 hunks)transports/go.mod(1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: Pratham-Mishra04
PR: maximhq/bifrost#65
File: transports/bifrost-http/integrations/anthropic/types.go:131-180
Timestamp: 2025-06-10T13:11:37.842Z
Learning: In Anthropic API integration for Bifrost, messages won't contain both image and tool_result content blocks in the same message, so defensive guards against multiple embedded message structs are unnecessary in the content processing loop.
transports/bifrost-http/integrations/anthropic/types.go (1)
Learnt from: Pratham-Mishra04
PR: maximhq/bifrost#65
File: transports/bifrost-http/integrations/anthropic/types.go:131-180
Timestamp: 2025-06-10T13:11:37.842Z
Learning: In Anthropic API integration for Bifrost, messages won't contain both image and tool_result content blocks in the same message, so defensive guards against multiple embedded message structs are unnecessary in the content processing loop.
🧬 Code Graph Analysis (4)
transports/bifrost-http/tracking/plugin.go (1)
core/schemas/bifrost.go (2)
BifrostRequest(59-69)BifrostResponse(237-247)
transports/bifrost-http/integrations/genai/types.go (2)
core/schemas/bifrost.go (15)
ModelChatMessageRoleSystem(30-30)ModelChatMessageRole(25-25)BifrostMessage(148-156)MessageContent(158-161)ToolCall(319-323)ContentBlock(209-213)ModelChatMessageRoleAssistant(28-28)ContentBlockTypeText(205-205)FunctionCall(313-316)Function(106-110)ModelChatMessageRoleTool(32-32)ToolMessage(216-218)ContentBlockTypeImage(206-206)ImageURLStruct(229-232)AssistantMessage(221-226)core/utils.go (1)
Ptr(5-7)
transports/bifrost-http/integrations/openai/types.go (1)
core/schemas/bifrost.go (6)
BifrostMessage(148-156)Tool(113-117)ToolChoice(142-145)LogProbs(306-310)BifrostResponseChoice(342-348)LLMUsage(250-256)
transports/bifrost-http/integrations/anthropic/types.go (2)
core/schemas/bifrost.go (15)
BifrostRequest(59-69)Anthropic(41-41)BifrostMessage(148-156)MessageContent(158-161)ContentBlock(209-213)ContentBlockTypeText(205-205)ModelChatMessageRole(25-25)ToolCall(319-323)ContentBlockTypeImage(206-206)ImageURLStruct(229-232)Function(106-110)FunctionCall(313-316)ToolMessage(216-218)AssistantMessage(221-226)Tool(113-117)core/schemas/provider.go (1)
Provider(142-149)
🔇 Additional comments (1)
transports/go.mod (1)
7-8: Dependency bump LGTMBumping
bifrost/coretov1.1.0aligns the transports layer with the new schema types. No issues spotted here.
5112c64 to
8b01016
Compare
There was a problem hiding this comment.
Actionable comments posted: 8
🔭 Outside diff range comments (1)
transports/bifrost-http/integrations/openai/types.go (1)
114-118:⚠️ Potential issue
convertParametersdrops Tools / ToolChoice when no extra paramsYou return
nilsolely based onlen(ExtraParams), losing non-nilTools/ToolChoice.- if len(params.ExtraParams) == 0 { - return nil - } + if len(params.ExtraParams) == 0 && params.Tools == nil && params.ToolChoice == nil { + return nil + }
♻️ Duplicate comments (1)
transports/bifrost-http/tracking/plugin.go (1)
45-55: Ensure all otherPreHookimplementations match the new 3-value signatureThis file is updated, but any out-of-tree plugin still compiling against the old two-value form will break.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (1)
transports/go.sumis excluded by!**/*.sum
📒 Files selected for processing (5)
transports/bifrost-http/integrations/anthropic/types.go(8 hunks)transports/bifrost-http/integrations/genai/types.go(3 hunks)transports/bifrost-http/integrations/openai/types.go(4 hunks)transports/bifrost-http/tracking/plugin.go(3 hunks)transports/go.mod(1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: Pratham-Mishra04
PR: maximhq/bifrost#65
File: transports/bifrost-http/integrations/anthropic/types.go:131-180
Timestamp: 2025-06-10T13:11:37.842Z
Learning: In Anthropic API integration for Bifrost, messages won't contain both image and tool_result content blocks in the same message, so defensive guards against multiple embedded message structs are unnecessary in the content processing loop.
transports/bifrost-http/integrations/anthropic/types.go (1)
Learnt from: Pratham-Mishra04
PR: maximhq/bifrost#65
File: transports/bifrost-http/integrations/anthropic/types.go:131-180
Timestamp: 2025-06-10T13:11:37.842Z
Learning: In Anthropic API integration for Bifrost, messages won't contain both image and tool_result content blocks in the same message, so defensive guards against multiple embedded message structs are unnecessary in the content processing loop.
🧬 Code Graph Analysis (3)
transports/bifrost-http/tracking/plugin.go (1)
core/schemas/bifrost.go (2)
BifrostRequest(59-69)BifrostResponse(237-247)
transports/bifrost-http/integrations/openai/types.go (1)
core/schemas/bifrost.go (6)
BifrostMessage(148-156)Tool(113-117)ToolChoice(142-145)LogProbs(306-310)BifrostResponseChoice(342-348)LLMUsage(250-256)
transports/bifrost-http/integrations/genai/types.go (2)
core/schemas/bifrost.go (14)
BifrostMessage(148-156)ToolCall(319-323)ContentBlock(209-213)ModelChatMessageRoleAssistant(28-28)ContentBlockTypeText(205-205)FunctionCall(313-316)Function(106-110)ModelChatMessageRoleTool(32-32)MessageContent(158-161)ToolMessage(216-218)ContentBlockTypeImage(206-206)ImageURLStruct(229-232)ModelChatMessageRole(25-25)AssistantMessage(221-226)core/utils.go (1)
Ptr(5-7)
🔇 Additional comments (1)
transports/bifrost-http/integrations/anthropic/types.go (1)
400-405:thinkingis not an Anthropic content typeThe official spec allows
text,image,tool_use,tool_result.
Serialising an unknown type may be rejected by the API.
8b01016 to
d007882
Compare
d007882 to
80028cc
Compare
There was a problem hiding this comment.
Actionable comments posted: 3
🔭 Outside diff range comments (2)
transports/bifrost-http/integrations/openai/types.go (2)
111-116:⚠️ Potential issue
convertParametersdrops Tools / ToolChoice when no extra paramsIf the caller sets
ToolsorToolChoicebut nothing else,len(params.ExtraParams)==0makes the function returnnil, silently discarding those settings.- // Return nil if no parameters were set - if len(params.ExtraParams) == 0 { - return nil - } +// Return nil only when *nothing* is populated +if len(params.ExtraParams) == 0 && params.Tools == nil && params.ToolChoice == nil { + return nil +}
68-76: 🧹 Nitpick (assertive)Prefer dedicated fields over dumping into
ExtraParams
MaxTokens,Temperature,TopP, etc. already exist onModelParameters. Populate those first for provider-agnostic handling; fall back toExtraParamsonly for OpenAI-specific knobs.
♻️ Duplicate comments (1)
transports/go.mod (1)
7-8: Rungo mod tidyafter the version bump
The upgrade will likely leave stale entries ingo.sum; run a tidy to sync both files.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (1)
transports/go.sumis excluded by!**/*.sum
📒 Files selected for processing (5)
transports/bifrost-http/integrations/anthropic/types.go(8 hunks)transports/bifrost-http/integrations/genai/types.go(3 hunks)transports/bifrost-http/integrations/openai/types.go(4 hunks)transports/bifrost-http/tracking/plugin.go(3 hunks)transports/go.mod(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
transports/bifrost-http/tracking/plugin.go (1)
core/schemas/bifrost.go (2)
BifrostRequest(59-69)BifrostResponse(237-247)
transports/bifrost-http/integrations/genai/types.go (2)
core/schemas/bifrost.go (14)
BifrostMessage(148-156)ToolCall(319-323)ContentBlock(209-213)ModelChatMessageRoleAssistant(28-28)ContentBlockTypeText(205-205)FunctionCall(313-316)Function(106-110)ModelChatMessageRoleTool(32-32)MessageContent(158-161)ToolMessage(216-218)ContentBlockTypeImage(206-206)ImageURLStruct(229-232)ModelChatMessageRole(25-25)AssistantMessage(221-226)core/utils.go (1)
Ptr(5-7)
transports/bifrost-http/integrations/openai/types.go (1)
core/schemas/bifrost.go (6)
BifrostMessage(148-156)Tool(113-117)ToolChoice(142-145)LogProbs(306-310)BifrostResponseChoice(342-348)LLMUsage(250-256)
🔇 Additional comments (1)
transports/bifrost-http/integrations/genai/types.go (1)
110-118: Verify ToolCallID source –Namemay not be unique
ToolMessage.ToolCallIDis populated withFunctionResponse.Name, but the GenAI schema also exposes anIDfield. Using a stable ID (when present) prevents collisions when the same function is called multiple times.
80028cc to
112034d
Compare
There was a problem hiding this comment.
Actionable comments posted: 3
🔭 Outside diff range comments (3)
transports/go.mod (1)
3-3:⚠️ Potential issueInvalid Go toolchain version
go 1.24.1targets a release that does not (yet) exist.
Tooling (go mod tidy,go vet, CI runners) will error with
go: unsupported Go versionand block builds. Revert to the latest stable
(runtime‐supported) version used across the repo, e.g.go 1.23.transports/bifrost-http/integrations/openai/types.go (2)
111-114:⚠️ Potential issue
convertParametersdrops Tools / ToolChoice unintentionally
return nilis triggered whenExtraParamsis empty—even ifTools
orToolChoicewere set.
This silently strips tool definitions and explicit tool-choice from
every request.- if len(params.ExtraParams) == 0 { - return nil - } + if len(params.ExtraParams) == 0 && + params.Tools == nil && + params.ToolChoice == nil { + return nil + }
64-82: 🧹 Nitpick (assertive)Prefer typed fields over
ExtraParamsfor core knobs
MaxTokens,Temperature,TopP, etc. already have dedicated fields
onschemas.ModelParameters; populating them viaExtraParamsforces
every provider to repeat custom extraction logic.
Mapping to the canonical fields keeps behaviour consistent with Anthropic
and Gemini adapters and avoids drift.
♻️ Duplicate comments (2)
transports/go.mod (1)
7-9: Rungo mod tidyafter bumping deps
Same nit as earlier: tidy will prune indirects and updatego.sum.transports/bifrost-http/tracking/plugin.go (1)
98-101: Add an explanatory docstring for the no-opCleanup
Prior feedback still stands—please add a one-liner so future readers (and linters) know the no-op is intentional.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (1)
transports/go.sumis excluded by!**/*.sum
📒 Files selected for processing (5)
transports/bifrost-http/integrations/anthropic/types.go(8 hunks)transports/bifrost-http/integrations/genai/types.go(3 hunks)transports/bifrost-http/integrations/openai/types.go(4 hunks)transports/bifrost-http/tracking/plugin.go(3 hunks)transports/go.mod(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (3)
transports/bifrost-http/tracking/plugin.go (1)
core/schemas/bifrost.go (2)
BifrostRequest(59-69)BifrostResponse(237-247)
transports/bifrost-http/integrations/openai/types.go (1)
core/schemas/bifrost.go (6)
BifrostMessage(148-156)Tool(113-117)ToolChoice(142-145)LogProbs(306-310)BifrostResponseChoice(342-348)LLMUsage(250-256)
transports/bifrost-http/integrations/genai/types.go (2)
core/schemas/bifrost.go (14)
BifrostMessage(148-156)ToolCall(319-323)ContentBlock(209-213)ModelChatMessageRoleAssistant(28-28)ContentBlockTypeText(205-205)FunctionCall(313-316)Function(106-110)ModelChatMessageRoleTool(32-32)MessageContent(158-161)ToolMessage(216-218)ContentBlockTypeImage(206-206)ImageURLStruct(229-232)ModelChatMessageRole(25-25)AssistantMessage(221-226)core/utils.go (1)
Ptr(5-7)
112034d to
551229f
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🔭 Outside diff range comments (2)
transports/bifrost-http/tracking/plugin.go (1)
45-55: 🛠️ Refactor suggestionAvoid mutating
*context.Context– pass by value.Passing a pointer to
context.Contextis atypical and forces every hook to mutate shared state, risking nil-deref and data races.
Preferctx context.Contextand return the derived context instead:-func (p *PrometheusPlugin) PreHook(ctx *context.Context, req *schemas.BifrostRequest) ... +func (p *PrometheusPlugin) PreHook(ctx context.Context, req *schemas.BifrostRequest) (context.Context, *schemas.BifrostRequest, *schemas.BifrostResponse, error) { ctx = context.WithValue(ctx, startTimeKey, time.Now()) ... - return req, nil, nil + return ctx, req, nil, nil }transports/bifrost-http/integrations/openai/types.go (1)
111-114:⚠️ Potential issueParameter object may be dropped even when Tools/ToolChoice are set.
convertParametersreturnsnilsolely based onlen(params.ExtraParams), ignoringTools,ToolChoice, etc.
This strips tool metadata from the request.- if len(params.ExtraParams) == 0 { - return nil - } +if len(params.ExtraParams) == 0 && + params.Tools == nil && + params.ToolChoice == nil { + return nil +}
♻️ Duplicate comments (2)
transports/go.mod (1)
7-8: Still needsgo mod tidy.Version bump is fine, but
go.sumhasn’t been refreshed—rungo mod tidyto prune indirects and keep the sums in sync.transports/bifrost-http/tracking/plugin.go (1)
99-101: Add the missing docstring to this no-op.The earlier nit is still unresolved—document why
Cleanupintentionally does nothing to silence “dead code” questions.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (1)
transports/go.sumis excluded by!**/*.sum
📒 Files selected for processing (5)
transports/bifrost-http/integrations/anthropic/types.go(8 hunks)transports/bifrost-http/integrations/genai/types.go(3 hunks)transports/bifrost-http/integrations/openai/types.go(4 hunks)transports/bifrost-http/tracking/plugin.go(3 hunks)transports/go.mod(1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: Pratham-Mishra04
PR: maximhq/bifrost#65
File: transports/bifrost-http/integrations/anthropic/types.go:131-180
Timestamp: 2025-06-10T13:11:37.842Z
Learning: In Anthropic API integration for Bifrost, messages won't contain both image and tool_result content blocks in the same message, so defensive guards against multiple embedded message structs are unnecessary in the content processing loop.
transports/bifrost-http/integrations/genai/types.go (2)
Learnt from: Pratham-Mishra04
PR: maximhq/bifrost#54
File: core/schemas/bifrost.go:46-49
Timestamp: 2025-06-04T09:22:18.123Z
Learning: In core/schemas/bifrost.go, the RequestInput struct uses ChatCompletionInput *[]BifrostMessage (pointer-to-slice) rather than []BifrostMessage to properly represent union type semantics. For text completion requests, ChatCompletionInput should be nil to indicate "no chat payload at all", while for chat completion requests it should be non-nil (even if empty slice). This distinguishes between different request types rather than just empty vs non-empty chat messages.
Learnt from: Pratham-Mishra04
PR: maximhq/bifrost#74
File: core/providers/bedrock.go:909-916
Timestamp: 2025-06-11T15:05:45.322Z
Learning: In Bedrock chat responses (`core/providers/bedrock.go`), image content blocks are only possible in messages with the `user` role; assistant and tool messages will never contain image blocks.
transports/bifrost-http/integrations/anthropic/types.go (3)
Learnt from: Pratham-Mishra04
PR: maximhq/bifrost#65
File: transports/bifrost-http/integrations/anthropic/types.go:131-180
Timestamp: 2025-06-10T13:11:37.842Z
Learning: In Anthropic API integration for Bifrost, messages won't contain both image and tool_result content blocks in the same message, so defensive guards against multiple embedded message structs are unnecessary in the content processing loop.
Learnt from: Pratham-Mishra04
PR: maximhq/bifrost#63
File: transports/bifrost-http/integrations/openai/types.go:89-119
Timestamp: 2025-06-10T11:00:02.852Z
Learning: In the Bifrost OpenAI integration (transports/bifrost-http/integrations/openai/types.go), the convertOpenAIContent function currently only handles the last image URL when multiple images are present in a content array. The user Pratham-Mishra04 has acknowledged this limitation and indicated it's part of a larger architectural issue that will be addressed comprehensively later, rather than with piecemeal fixes.
Learnt from: Pratham-Mishra04
PR: maximhq/bifrost#75
File: transports/bifrost-http/integrations/anthropic/types.go:154-160
Timestamp: 2025-06-14T04:19:06.305Z
Learning: Anthropic's API does not support images in system messages, only text content is allowed in system messages for Anthropic integrations.
🧬 Code Graph Analysis (4)
transports/bifrost-http/tracking/plugin.go (1)
core/schemas/bifrost.go (2)
BifrostRequest(59-69)BifrostResponse(237-247)
transports/bifrost-http/integrations/genai/types.go (2)
core/schemas/bifrost.go (14)
BifrostMessage(148-156)ToolCall(319-323)ContentBlock(209-213)ModelChatMessageRoleAssistant(28-28)ContentBlockTypeText(205-205)FunctionCall(313-316)Function(106-110)ModelChatMessageRoleTool(32-32)MessageContent(158-161)ToolMessage(216-218)ContentBlockTypeImage(206-206)ImageURLStruct(229-232)ModelChatMessageRole(25-25)AssistantMessage(221-226)core/utils.go (1)
Ptr(5-7)
transports/bifrost-http/integrations/openai/types.go (1)
core/schemas/bifrost.go (6)
BifrostMessage(148-156)Tool(113-117)ToolChoice(142-145)LogProbs(306-310)BifrostResponseChoice(342-348)LLMUsage(250-256)
transports/bifrost-http/integrations/anthropic/types.go (2)
core/schemas/bifrost.go (15)
BifrostRequest(59-69)BifrostMessage(148-156)ModelChatMessageRoleSystem(30-30)MessageContent(158-161)ContentBlock(209-213)ModelChatMessageRole(25-25)ToolCall(319-323)ImageURLStruct(229-232)Function(106-110)FunctionCall(313-316)ToolMessage(216-218)ModelChatMessageRoleTool(32-32)ModelChatMessageRoleAssistant(28-28)AssistantMessage(221-226)Tool(113-117)core/schemas/provider.go (1)
Provider(142-149)
🔇 Additional comments (1)
transports/bifrost-http/integrations/anthropic/types.go (1)
95-103: Nice validation check.Guarding against both fields being set prevents ambiguous serialization—good catch.
551229f to
834a847
Compare
There was a problem hiding this comment.
Actionable comments posted: 3
🔭 Outside diff range comments (1)
transports/bifrost-http/integrations/openai/types.go (1)
111-114:⚠️ Potential issue
convertParametersdrops Tools / ToolChoiceYou return
nilwhenExtraParamsis empty, ignoring thatparams.Toolsorparams.ToolChoicemay be set.
This strips tool metadata from the outgoing request.- if len(params.ExtraParams) == 0 { - return nil - } + if len(params.ExtraParams) == 0 && + params.Tools == nil && + params.ToolChoice == nil { + return nil + }
♻️ Duplicate comments (2)
transports/go.mod (1)
7-8:go mod tidystill missingThe version bumps are fine, but please run
go mod tidyso that go.sum and indirects stay consistent.transports/bifrost-http/tracking/plugin.go (1)
98-101: Add the docstring that earlier review requested
Cleanupis still a bare method without the one-liner explaining the deliberate no-op.
Add something like// Cleanup implements schemas.Plugin; nothing to release.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (1)
transports/go.sumis excluded by!**/*.sum
📒 Files selected for processing (5)
transports/bifrost-http/integrations/anthropic/types.go(8 hunks)transports/bifrost-http/integrations/genai/types.go(3 hunks)transports/bifrost-http/integrations/openai/types.go(4 hunks)transports/bifrost-http/tracking/plugin.go(3 hunks)transports/go.mod(1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: Pratham-Mishra04
PR: maximhq/bifrost#65
File: transports/bifrost-http/integrations/anthropic/types.go:131-180
Timestamp: 2025-06-10T13:11:37.842Z
Learning: In Anthropic API integration for Bifrost, messages won't contain both image and tool_result content blocks in the same message, so defensive guards against multiple embedded message structs are unnecessary in the content processing loop.
transports/bifrost-http/integrations/genai/types.go (2)
Learnt from: Pratham-Mishra04
PR: maximhq/bifrost#54
File: core/schemas/bifrost.go:46-49
Timestamp: 2025-06-04T09:22:18.123Z
Learning: In core/schemas/bifrost.go, the RequestInput struct uses ChatCompletionInput *[]BifrostMessage (pointer-to-slice) rather than []BifrostMessage to properly represent union type semantics. For text completion requests, ChatCompletionInput should be nil to indicate "no chat payload at all", while for chat completion requests it should be non-nil (even if empty slice). This distinguishes between different request types rather than just empty vs non-empty chat messages.
Learnt from: Pratham-Mishra04
PR: maximhq/bifrost#74
File: core/providers/bedrock.go:909-916
Timestamp: 2025-06-11T15:05:45.322Z
Learning: In Bedrock chat responses (`core/providers/bedrock.go`), image content blocks are only possible in messages with the `user` role; assistant and tool messages will never contain image blocks.
transports/bifrost-http/integrations/anthropic/types.go (3)
Learnt from: Pratham-Mishra04
PR: maximhq/bifrost#65
File: transports/bifrost-http/integrations/anthropic/types.go:131-180
Timestamp: 2025-06-10T13:11:37.842Z
Learning: In Anthropic API integration for Bifrost, messages won't contain both image and tool_result content blocks in the same message, so defensive guards against multiple embedded message structs are unnecessary in the content processing loop.
Learnt from: Pratham-Mishra04
PR: maximhq/bifrost#63
File: transports/bifrost-http/integrations/openai/types.go:89-119
Timestamp: 2025-06-10T11:00:02.852Z
Learning: In the Bifrost OpenAI integration (transports/bifrost-http/integrations/openai/types.go), the convertOpenAIContent function currently only handles the last image URL when multiple images are present in a content array. The user Pratham-Mishra04 has acknowledged this limitation and indicated it's part of a larger architectural issue that will be addressed comprehensively later, rather than with piecemeal fixes.
Learnt from: Pratham-Mishra04
PR: maximhq/bifrost#75
File: transports/bifrost-http/integrations/anthropic/types.go:154-160
Timestamp: 2025-06-14T04:19:06.305Z
Learning: Anthropic's API does not support images in system messages, only text content is allowed in system messages for Anthropic integrations.
🧬 Code Graph Analysis (4)
transports/bifrost-http/tracking/plugin.go (1)
core/schemas/bifrost.go (2)
BifrostRequest(59-69)BifrostResponse(237-247)
transports/bifrost-http/integrations/genai/types.go (2)
core/schemas/bifrost.go (14)
BifrostMessage(148-156)ToolCall(319-323)ContentBlock(209-213)ModelChatMessageRoleAssistant(28-28)ContentBlockTypeText(205-205)FunctionCall(313-316)Function(106-110)ModelChatMessageRoleTool(32-32)MessageContent(158-161)ToolMessage(216-218)ContentBlockTypeImage(206-206)ImageURLStruct(229-232)ModelChatMessageRole(25-25)AssistantMessage(221-226)core/utils.go (1)
Ptr(5-7)
transports/bifrost-http/integrations/openai/types.go (1)
core/schemas/bifrost.go (6)
BifrostMessage(148-156)Tool(113-117)ToolChoice(142-145)LogProbs(306-310)BifrostResponseChoice(342-348)LLMUsage(250-256)
transports/bifrost-http/integrations/anthropic/types.go (2)
core/schemas/bifrost.go (15)
Anthropic(41-41)BifrostMessage(148-156)ModelChatMessageRoleSystem(30-30)MessageContent(158-161)ContentBlock(209-213)ModelChatMessageRole(25-25)ToolCall(319-323)ImageURLStruct(229-232)Function(106-110)FunctionCall(313-316)ToolMessage(216-218)ModelChatMessageRoleTool(32-32)ModelChatMessageRoleAssistant(28-28)AssistantMessage(221-226)Tool(113-117)core/schemas/provider.go (1)
Provider(142-149)
834a847 to
90d624f
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
♻️ Duplicate comments (3)
transports/go.mod (1)
7-8: Rungo mod tidyto ensure dependencies are properly synchronized.After updating the module versions, run
go mod tidyto clean up indirect dependencies and ensure go.sum is in sync with the new versions.transports/bifrost-http/tracking/plugin.go (2)
45-45: Verify all plugin implementations have been updated with the new PreHook signature.The PreHook method now returns three values. Ensure all implementations are updated to match.
#!/bin/bash # Description: Find all PreHook implementations to verify they match the new signature # Search for PreHook method implementations ast-grep --pattern 'func ($_ $_) PreHook($_, $_) ($_, $_, $_)' # Also search for old signature pattern to find any that need updating ast-grep --pattern 'func ($_ $_) PreHook($_, $_) ($_, $_)'Also applies to: 54-54
99-101: Add documentation to clarify the no-op Cleanup method.Add a comment explaining that this method implements the schemas.Plugin interface and intentionally performs no cleanup.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (1)
transports/go.sumis excluded by!**/*.sum
📒 Files selected for processing (5)
transports/bifrost-http/integrations/anthropic/types.go(8 hunks)transports/bifrost-http/integrations/genai/types.go(3 hunks)transports/bifrost-http/integrations/openai/types.go(4 hunks)transports/bifrost-http/tracking/plugin.go(3 hunks)transports/go.mod(1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: Pratham-Mishra04
PR: maximhq/bifrost#65
File: transports/bifrost-http/integrations/anthropic/types.go:131-180
Timestamp: 2025-06-10T13:11:37.842Z
Learning: In Anthropic API integration for Bifrost, messages won't contain both image and tool_result content blocks in the same message, so defensive guards against multiple embedded message structs are unnecessary in the content processing loop.
transports/bifrost-http/integrations/genai/types.go (2)
Learnt from: Pratham-Mishra04
PR: maximhq/bifrost#54
File: core/schemas/bifrost.go:46-49
Timestamp: 2025-06-04T09:22:18.123Z
Learning: In core/schemas/bifrost.go, the RequestInput struct uses ChatCompletionInput *[]BifrostMessage (pointer-to-slice) rather than []BifrostMessage to properly represent union type semantics. For text completion requests, ChatCompletionInput should be nil to indicate "no chat payload at all", while for chat completion requests it should be non-nil (even if empty slice). This distinguishes between different request types rather than just empty vs non-empty chat messages.
Learnt from: Pratham-Mishra04
PR: maximhq/bifrost#74
File: core/providers/bedrock.go:909-916
Timestamp: 2025-06-11T15:05:45.322Z
Learning: In Bedrock chat responses (`core/providers/bedrock.go`), image content blocks are only possible in messages with the `user` role; assistant and tool messages will never contain image blocks.
transports/bifrost-http/integrations/anthropic/types.go (3)
Learnt from: Pratham-Mishra04
PR: maximhq/bifrost#65
File: transports/bifrost-http/integrations/anthropic/types.go:131-180
Timestamp: 2025-06-10T13:11:37.842Z
Learning: In Anthropic API integration for Bifrost, messages won't contain both image and tool_result content blocks in the same message, so defensive guards against multiple embedded message structs are unnecessary in the content processing loop.
Learnt from: Pratham-Mishra04
PR: maximhq/bifrost#63
File: transports/bifrost-http/integrations/openai/types.go:89-119
Timestamp: 2025-06-10T11:00:02.852Z
Learning: In the Bifrost OpenAI integration (transports/bifrost-http/integrations/openai/types.go), the convertOpenAIContent function currently only handles the last image URL when multiple images are present in a content array. The user Pratham-Mishra04 has acknowledged this limitation and indicated it's part of a larger architectural issue that will be addressed comprehensively later, rather than with piecemeal fixes.
Learnt from: Pratham-Mishra04
PR: maximhq/bifrost#75
File: transports/bifrost-http/integrations/anthropic/types.go:154-160
Timestamp: 2025-06-14T04:19:06.305Z
Learning: Anthropic's API does not support images in system messages, only text content is allowed in system messages for Anthropic integrations.
🧬 Code Graph Analysis (3)
transports/bifrost-http/tracking/plugin.go (1)
core/schemas/bifrost.go (2)
BifrostRequest(59-69)BifrostResponse(237-247)
transports/bifrost-http/integrations/genai/types.go (2)
core/schemas/bifrost.go (14)
BifrostMessage(148-156)ToolCall(319-323)ContentBlock(209-213)ModelChatMessageRoleAssistant(28-28)ContentBlockTypeText(205-205)FunctionCall(313-316)Function(106-110)ModelChatMessageRoleTool(32-32)MessageContent(158-161)ToolMessage(216-218)ContentBlockTypeImage(206-206)ImageURLStruct(229-232)ModelChatMessageRole(25-25)AssistantMessage(221-226)core/utils.go (1)
Ptr(5-7)
transports/bifrost-http/integrations/openai/types.go (1)
core/schemas/bifrost.go (6)
BifrostMessage(148-156)Tool(113-117)ToolChoice(142-145)LogProbs(306-310)BifrostResponseChoice(342-348)LLMUsage(250-256)
🔇 Additional comments (7)
transports/bifrost-http/integrations/genai/types.go (2)
165-170: Correct handling of GenAI's "model" role.The role mapping properly converts GenAI's internal "model" role to the standard "assistant" role, preventing invalid roles in Bifrost requests.
161-198: Proper message collection and assignment.The implementation correctly:
- Includes thought-only messages in the condition (line 162)
- Appends messages to the slice (line 193)
- Assigns the messages to ChatCompletionInput (line 197)
All the issues from previous reviews have been addressed.
transports/bifrost-http/integrations/openai/types.go (2)
9-27: Excellent simplification using shared Bifrost types.The removal of custom OpenAI-specific types in favor of direct Bifrost schema usage improves maintainability and reduces code duplication.
Also applies to: 41-55
1-6:Details
✅ Verification successful
Verify removal of unused fnTypePtr variable.
Past reviews indicated an unused
fnTypePtrvariable declaration. Ensure it has been removed if it's no longer needed.
🏁 Script executed:
#!/bin/bash # Description: Check if fnTypePtr is declared but unused in the openai package # Search for fnTypePtr declaration and usage in openai package rg -A 2 -B 2 'fnTypePtr' transports/bifrost-http/integrations/openai/Length of output: 69
🏁 Script executed:
#!/bin/bash # Verify fnTypePtr is not present anywhere in the repository rg 'fnTypePtr'Length of output: 413
Removal of
fnTypePtrconfirmed in OpenAI integrationNo occurrences of
fnTypePtrfound intransports/bifrost-http/integrations/openai/types.go, so the unused variable has been successfully removed.transports/bifrost-http/integrations/anthropic/types.go (3)
95-132: Well-implemented custom JSON marshaling for flexible content.The custom marshaling/unmarshaling logic correctly handles both string and array content formats with proper validation.
198-209: Correct image URL handling with proper data URL format.Images are properly formatted with
data:<mime>;base64,prefix, addressing previous feedback. The default MIME type of "image/png" is sensible.Also applies to: 247-258
275-279: Proper role-based guard for assistant-specific fields.Tool calls are correctly restricted to assistant messages only, preventing invalid message structures.
90d624f to
bcee867
Compare
bcee867 to
641078f
Compare
There was a problem hiding this comment.
Actionable comments posted: 4
🔭 Outside diff range comments (2)
transports/bifrost-http/integrations/openai/types.go (1)
111-116:⚠️ Potential issue
Tools/ToolChoicesilently discarded
convertParametersreturnsnilwheneverExtraParamsis empty, ignoring populatedToolsorToolChoice.
This drops tool definitions from the final Bifrost request.- // Return nil if no parameters were set - if len(params.ExtraParams) == 0 { - return nil - } + // Return nil only when *nothing* is populated + if len(params.ExtraParams) == 0 && + params.ToolChoice == nil && + params.Tools == nil { + return nil + }transports/bifrost-http/integrations/genai/types.go (1)
41-48: 🧹 Nitpick (assertive)Redundant initial slice allocation
ChatCompletionInputis first set to an address of an empty slice and later reassigned (line 197).
The first allocation is wasted work—drop it and set the field once aftermessagesis fully built.
♻️ Duplicate comments (3)
transports/go.mod (1)
7-8:go mod tidystill requiredDependency bumps are in
go.mod, butgo.sumwasn’t updated. Rungo mod tidyto sync sums & prune indirects.transports/bifrost-http/integrations/genai/types.go (2)
385-393: Image blocks still discarded (acknowledged)Only text blocks are re-hydrated; images remain ignored. Previous discussion concluded this is acceptable for Gemini assistant messages. No action needed.
468-509: Helper still keeps explicit image listThe fallback list after the
"image/"prefix check is redundant; prefix alone suffices. Author previously opted to keep it – noting here for completeness.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
⛔ Files ignored due to path filters (1)
transports/go.sumis excluded by!**/*.sum
📒 Files selected for processing (5)
transports/bifrost-http/integrations/anthropic/types.go(8 hunks)transports/bifrost-http/integrations/genai/types.go(3 hunks)transports/bifrost-http/integrations/openai/types.go(4 hunks)transports/bifrost-http/tracking/plugin.go(3 hunks)transports/go.mod(1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: Pratham-Mishra04
PR: maximhq/bifrost#65
File: transports/bifrost-http/integrations/anthropic/types.go:131-180
Timestamp: 2025-06-10T13:11:37.867Z
Learning: In Anthropic API integration for Bifrost, messages won't contain both image and tool_result content blocks in the same message, so defensive guards against multiple embedded message structs are unnecessary in the content processing loop.
transports/bifrost-http/integrations/genai/types.go (3)
Learnt from: Pratham-Mishra04
PR: maximhq/bifrost#54
File: core/schemas/bifrost.go:46-49
Timestamp: 2025-06-04T09:22:18.123Z
Learning: In core/schemas/bifrost.go, the RequestInput struct uses ChatCompletionInput *[]BifrostMessage (pointer-to-slice) rather than []BifrostMessage to properly represent union type semantics. For text completion requests, ChatCompletionInput should be nil to indicate "no chat payload at all", while for chat completion requests it should be non-nil (even if empty slice). This distinguishes between different request types rather than just empty vs non-empty chat messages.
Learnt from: Pratham-Mishra04
PR: maximhq/bifrost#75
File: transports/bifrost-http/integrations/genai/types.go:365-374
Timestamp: 2025-06-12T09:06:26.608Z
Learning: Gemini integration currently guarantees that assistant messages never contain image content blocks, so re-hydration code can safely ignore them.
Learnt from: Pratham-Mishra04
PR: maximhq/bifrost#74
File: core/providers/bedrock.go:909-916
Timestamp: 2025-06-11T15:05:45.355Z
Learning: In Bedrock chat responses (`core/providers/bedrock.go`), image content blocks are only possible in messages with the `user` role; assistant and tool messages will never contain image blocks.
transports/bifrost-http/integrations/anthropic/types.go (3)
Learnt from: Pratham-Mishra04
PR: maximhq/bifrost#65
File: transports/bifrost-http/integrations/anthropic/types.go:131-180
Timestamp: 2025-06-10T13:11:37.867Z
Learning: In Anthropic API integration for Bifrost, messages won't contain both image and tool_result content blocks in the same message, so defensive guards against multiple embedded message structs are unnecessary in the content processing loop.
Learnt from: Pratham-Mishra04
PR: maximhq/bifrost#63
File: transports/bifrost-http/integrations/openai/types.go:89-119
Timestamp: 2025-06-10T11:00:02.875Z
Learning: In the Bifrost OpenAI integration (transports/bifrost-http/integrations/openai/types.go), the convertOpenAIContent function currently only handles the last image URL when multiple images are present in a content array. The user Pratham-Mishra04 has acknowledged this limitation and indicated it's part of a larger architectural issue that will be addressed comprehensively later, rather than with piecemeal fixes.
Learnt from: Pratham-Mishra04
PR: maximhq/bifrost#75
File: transports/bifrost-http/integrations/anthropic/types.go:154-160
Timestamp: 2025-06-14T04:19:06.327Z
Learning: Anthropic's API does not support images in system messages, only text content is allowed in system messages for Anthropic integrations.
🧬 Code Graph Analysis (3)
transports/bifrost-http/integrations/genai/types.go (2)
core/schemas/bifrost.go (14)
BifrostMessage(148-156)ToolCall(319-323)ContentBlock(209-213)ModelChatMessageRoleAssistant(28-28)ContentBlockTypeText(205-205)FunctionCall(313-316)Function(106-110)ModelChatMessageRoleTool(32-32)MessageContent(158-161)ToolMessage(216-218)ContentBlockTypeImage(206-206)ImageURLStruct(229-232)ModelChatMessageRole(25-25)AssistantMessage(221-226)core/utils.go (1)
Ptr(5-7)
transports/bifrost-http/tracking/plugin.go (1)
core/schemas/bifrost.go (3)
BifrostRequest(59-69)BifrostResponse(237-247)BifrostError(365-371)
transports/bifrost-http/integrations/openai/types.go (1)
core/schemas/bifrost.go (6)
BifrostMessage(148-156)Tool(113-117)ToolChoice(142-145)LogProbs(306-310)BifrostResponseChoice(342-348)LLMUsage(250-256)
641078f to
d10aa09
Compare
# Anthropic API Integration Improvements This PR enhances the Anthropic API integration by implementing a more flexible content handling system that properly supports both string and structured content formats. Key changes include: - Renamed `AnthropicContent` to `AnthropicContentBlock` to better reflect its purpose - Added a new `AnthropicContent` type that can handle both string content and arrays of content blocks - Added proper support for system content blocks in Anthropic requests - Implemented custom JSON marshaling/unmarshaling for content types to handle different formats - Added response types for Anthropic API including usage information - Enhanced tool schema handling with proper typing for input schemas - Updated the content conversion logic between Bifrost and Anthropic formats These changes align with Anthropic's API structure and improve the handling of different content formats (text, images, tool calls) in a more type-safe manner.

Anthropic API Integration Improvements
This PR enhances the Anthropic API integration by implementing a more flexible content handling system that properly supports both string and structured content formats. Key changes include:
AnthropicContenttoAnthropicContentBlockto better reflect its purposeAnthropicContenttype that can handle both string content and arrays of content blocksThese changes align with Anthropic's API structure and improve the handling of different content formats (text, images, tool calls) in a more type-safe manner.