Skip to content

Conversation

@HavenDV
Copy link
Contributor

@HavenDV HavenDV commented Jun 11, 2025

Summary by CodeRabbit

  • New Features

    • Expanded streaming chat responses to include detailed event types for improved real-time feedback.
    • Introduced new content and tool message types for greater flexibility in API interactions.
  • Improvements

    • Updated API endpoint summaries to clearly indicate version information.
    • Unified and simplified message and content types for easier integration.
    • Enhanced example code snippets for Go and Java SDKs to reflect schema updates.
  • Bug Fixes

    • Corrected enum values and descriptions for improved clarity and accuracy.

@coderabbitai
Copy link

coderabbitai bot commented Jun 11, 2025

Walkthrough

The OpenAPI specification for the Cohere API was updated to generalize schema names, unify message and content types, and introduce new schemas for content and tool messages. Example code snippets were revised to use the updated types, and streaming response schemas were expanded to cover detailed event types. Endpoint summaries now include versioning.

Changes

File(s) Change Summary
src/libs/Cohere/openapi.yaml Updated endpoint summaries with versioning; generalized and renamed multiple schemas; revised discriminator mappings; removed V2-specific types; added new schemas for content, tool messages, and sources; expanded streaming response schemas; updated example code snippets.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant API
    participant MessageHandler
    participant ContentHandler
    participant ToolHandler

    Client->>API: Send chat request (V1/V2)
    API->>MessageHandler: Parse UserMessage/SystemMessage/ToolMessage
    MessageHandler->>ContentHandler: Handle TextContent/ImageContent
    MessageHandler->>ToolHandler: Process ToolSource/ToolMessage
    API-->>Client: Return response (with new schema types and streaming events)
Loading

Poem

In the warren where schemas hop and play,
Old V2 names have hopped away.
Content and tools now shine anew,
With streaming events—so much to do!
Code snippets prance in fresh attire,
As rabbits cheer this change entire.
🐇✨

✨ Finishing Touches
🧪 Generate Unit Tests
  • Create PR with Unit Tests
  • Commit Unit Tests in branch bot/update-openapi_202506111524
  • Post Copyable Unit Tests in Comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@HavenDV HavenDV enabled auto-merge (squash) June 11, 2025 15:25
@coderabbitai coderabbitai bot changed the title feat:@coderabbitai feat:Update OpenAPI spec with generalized schemas and expanded streaming events Jun 11, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 11f1083 and 936f291.

⛔ Files ignored due to path filters (79)
  • src/libs/Cohere/Generated/Cohere..JsonSerializerContext.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.CohereClient.Chat.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.CohereClient.Chatv2.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.CohereClient.Embed.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.CohereClient.Embedv2.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.CohereClient.Rerank.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.CohereClient.Rerankv2.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.ICohereClient.Chat.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.ICohereClient.Chatv2.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.ICohereClient.Embed.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.ICohereClient.Embedv2.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.ICohereClient.Rerank.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.ICohereClient.Rerankv2.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.JsonConverters.ChatMessageV2.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.JsonConverters.Content2.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.JsonConverters.ContentDiscriminatorType.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.JsonConverters.ContentDiscriminatorTypeNullable.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.JsonConverters.ContentItem.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.JsonConverters.ContentVariant2Item.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.JsonConverters.ContentVariant2Item2.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.JsonConverters.Message.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.JsonConverters.ResponseFormat.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.JsonConverters.ResponseFormatV2.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.JsonConverters.Source.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.JsonConverters.SystemMessageContentVariant2ItemDiscriminatorType.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.JsonConverters.SystemMessageContentVariant2ItemDiscriminatorTypeNullable.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.JsonConverters.SystemMessageRole.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.JsonConverters.SystemMessageRoleNullable.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.JsonConverters.TextContentType.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.JsonConverters.TextContentTypeNullable.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.JsonConverters.ToolContent.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.JsonConverters.UserMessageRole.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.JsonConverters.UserMessageRoleNullable.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.JsonSerializerContextTypes.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.ChatDocumentSourceDocument.Json.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.ChatMessageV2.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.ChatTextResponseFormatV2.Json.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.ChatToolSourceToolOutput.Json.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.Content2.Json.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.Content2.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.ContentDiscriminator.Json.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.ContentDiscriminator.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.ContentDiscriminatorType.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.ContentItem.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.ContentVariant2Item.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.ContentVariant2Item2.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.DocumentSource.Json.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.DocumentSource.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.DocumentSourceDocument.Json.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.DocumentSourceDocument.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.EmbedByTypeResponse.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.Message.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.MessageContentDiscriminator.Json.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.ResponseFormat.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.ResponseFormatV2.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.Source.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.SystemMessage.Json.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.SystemMessage.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.SystemMessageContentVariant2ItemDiscriminator.Json.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.SystemMessageContentVariant2ItemDiscriminator.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.SystemMessageContentVariant2ItemDiscriminatorType.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.SystemMessageRole.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.TextContent.Json.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.TextContent.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.TextContentType.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.TextResponseFormat.Json.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.TextResponseFormat.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.TextResponseFormatV2.Json.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.TextResponseFormatV2.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.ToolContent.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.ToolMessage.Json.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.ToolMessage.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.ToolSource.Json.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.ToolSource.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.ToolSourceToolOutput.Json.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.ToolSourceToolOutput.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.UserMessage.Json.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.UserMessage.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.UserMessageRole.g.cs is excluded by !**/generated/**
📒 Files selected for processing (1)
  • src/libs/Cohere/openapi.yaml (25 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Test / Build, test and publish
🔇 Additional comments (26)
src/libs/Cohere/openapi.yaml (26)

20-23: Versioned endpoint summaries updated correctly
Including “V1” in the summaries for /v1/chat provides clear versioning information. The description remains accurate and complementary.


2148-2151: Consistent versioning in summary for /v1/embed
The “Embed V1 API” summary and description are aligned and informative.


6856-6859: Rerank V1 API summary is clear and precise
The summary “Rerank V1 API” accurately reflects the endpoint’s purpose and version.


7382-7385: Updated /v2/chat summary for versioning
The “Chat V2 API” summary and streaming description are properly versioned.


7558-7561: Go example updated to use v2 client and general message types
The snippet correctly initializes the v2 client and employs UserMessage/AssistantMessage builders instead of older V2-specific content types.


7596-7602: Java/Go document example aligned with updated schemas
The document-based chat examples now use the new V2ChatRequest structure and general message/content types.


7738-7744: Streaming examples reflect detailed event schemas
Python, Java, and Go streaming snippets correctly iterate over the new discriminator-based StreamedChatResponseV2 events.


7866-7872: Tool usage examples adopt unified tool message schemas
Java and Go samples now use the new ToolV2 and ToolV2Function definitions consistent with updated schemas.


7938-7946: Non-streamed response schema enriched with additional properties
The addition of finish_reason, id, logprobs, message, and usage properties improves feedback granularity.


7957-7984: Streaming response schema mapping updated to detailed event types
The response-stream discriminator now covers all fine-grained events (ChatMessageStartEvent, ChatContentDeltaEvent, etc.), enhancing client parsing.


11275-11278: Consistent versioning in summary for /v2/rerank
The “Rerank V2 API” summary and description align with v2 conventions.


11535-11539: Content array now references TextContent
Replaced legacy chat-specific content with the new TextContent schema.


11565-11570: Nested message content correctly updated to TextContent
The oneOf mapping and discriminator for message items now use TextContent.


11905-11908: ChatMessageV2 oneOf references updated
Now uses UserMessage/SystemMessage in place of the older V2 variants.


16490-16499: ResponseFormat mapping correctly updated
The oneOf now references TextResponseFormat and JSONResponseFormat with proper discriminator values.


16520-16529: ResponseFormatV2 mapping correctly updated
The oneOf discriminator for V2 now maps text and json_object to the appropriate schemas.


16624-16628: Source schema oneOf updated
Replaced the old chat-specific source variants with the generalized ToolSource and DocumentSource schemas.


16711-16714: Verify completeness of SystemMessage schema
The snippet shows only title and required: - role. Ensure that the content property (and any other necessary fields) is defined and matches other message schemas.


16721-16728: SystemMessage content mapping updated to TextContent
The oneOf for message arrays now correctly references TextContent with a matching discriminator.


16734-16735: The x-fern-type-name annotation for codegen is expected and does not require changes.


16735-16748: TextContent schema well-defined
Defines required type/text properties and uses a clear discriminator.


16749-16760: TextResponseFormat schema correct
The TextResponseFormat object is properly specified with audiences and the type property.


16761-16769: TextResponseFormatV2 schema correct
The V2 variant matches the naming and mapping conventions of the new response formats.


16885-16893: ToolContent schema updated
The oneOf correctly uses TextContent and DocumentContent, with a matching discriminator mapping.


16894-16901: ToolMessage schema properly defined
Includes required role and tool_results fields referencing ToolResult.


17154-17165: UserMessage schema leverages Content union
The content property correctly allows a string or array of Content blocks, and the role is constrained to user.

Comment on lines +12549 to +12559
Content:
oneOf:
- $ref: '#/components/schemas/TextContent'
- $ref: '#/components/schemas/ImageContent'
description: A Content block which contains information about the content type and the content itself.
discriminator:
propertyName: type
mapping:
image_url: '#/components/schemas/ImageContent'
text: '#/components/schemas/TextContent'
x-fern-type-name: Content
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Mismatch between Content discriminator mapping and ContentType enum
The mapping includes image_url but the ContentType enum only defines text, which will cause validation failures. Please add image_url to the ContentType enum.

🤖 Prompt for AI Agents
In src/libs/Cohere/openapi.yaml around lines 12549 to 12559, the discriminator
mapping for the Content schema includes "image_url" but the ContentType enum
only defines "text". To fix this, add "image_url" as a valid value in the
ContentType enum to ensure consistency and prevent validation errors.

Comment on lines +16947 to 16958
ToolSource:
title: Tool Output
type: object
properties:
id:
type: string
description: The unique identifier of the document
tool_output:
type: object
x-fern-type-name: ToolSource-z53ra6
x-fern-type-name: ToolSource
ToolV2:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Untyped tool_output in ToolSource schema
The tool_output property is declared as a free-form object. It should reference the appropriate schema (e.g., ToolContent or ToolResult) instead of object.

🤖 Prompt for AI Agents
In src/libs/Cohere/openapi.yaml around lines 16947 to 16958, the property
tool_output in the ToolSource schema is currently typed as a generic object.
Replace this with a reference to the correct schema, such as ToolContent or
ToolResult, by updating the type declaration to use $ref pointing to the
appropriate schema definition instead of using type: object.

Comment on lines 16313 to 16321
- $ref: '#/components/schemas/ChatMessage'
- $ref: '#/components/schemas/ChatToolMessage'
- $ref: '#/components/schemas/ToolMessage'
discriminator:
propertyName: role
mapping:
CHATBOT: '#/components/schemas/ChatMessage'
SYSTEM: '#/components/schemas/ChatMessage'
TOOL: '#/components/schemas/ChatToolMessage'
TOOL: '#/components/schemas/ToolMessage'
USER: '#/components/schemas/ChatMessage'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Incorrect discriminator mapping keys in Message schema
The mapping uses uppercase role values (TOOL, USER, etc.), but actual payloads use lowercase (tool, user, etc.). This mismatch will break resolution. Update the keys to match case-sensitive role values.

🤖 Prompt for AI Agents
In src/libs/Cohere/openapi.yaml around lines 16313 to 16321, the discriminator
mapping keys in the Message schema use uppercase role values, but the actual
payloads use lowercase. Update the mapping keys from uppercase (e.g., TOOL,
USER) to lowercase (e.g., tool, user) to ensure correct schema resolution.

Comment on lines +12988 to +12998
DocumentSource:
type: object
properties:
document:
type: object
x-fern-type-name: DocumentSource-w70a62
id:
type: string
description: The unique identifier of the document
description: A document source object containing the unique identifier of the document and the document itself.
x-fern-type-name: DocumentSource
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Reference DocumentContent in DocumentSource schema
The document property is currently a free-form object. Replace its definition with $ref: '#/components/schemas/DocumentContent' to leverage the existing schema.

🤖 Prompt for AI Agents
In src/libs/Cohere/openapi.yaml around lines 12988 to 12998, the DocumentSource
schema defines the document property as a generic object. Replace this with a
reference to the existing DocumentContent schema by changing the document
property's type to use $ref: '#/components/schemas/DocumentContent'. This will
ensure the document property conforms to the defined DocumentContent structure.

@HavenDV HavenDV closed this Jun 11, 2025
auto-merge was automatically disabled June 11, 2025 22:46

Pull request was closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants