Skip to content

Conversation

@HavenDV
Copy link
Contributor

@HavenDV HavenDV commented Jun 9, 2025

Summary by CodeRabbit

  • New Features

    • Introduced new schema definitions for chat document and tool sources, as well as updated message and content types in the Chat API v2 specification.
  • Refactor

    • Updated and renamed message, content, and response format types throughout the API specification and code samples for improved clarity and consistency.
    • Simplified streaming response schemas and aligned code samples with the latest API structures.

@coderabbitai
Copy link

coderabbitai bot commented Jun 9, 2025

Walkthrough

The openapi.yaml specification for the Chat API v2 is updated to adopt new "V2" message and content schemas. Older types and schemas are renamed, replaced, or removed, and new chat-specific schemas are introduced. Code samples and discriminator mappings are revised to reference these updated types, reflecting a migration to a new chat message and content model.

Changes

File(s) Change Summary
src/libs/Cohere/openapi.yaml - Renamed schemas: UserMessageUserMessageV2, SystemMessageSystemMessageV2, TextContentChatTextContent, TextResponseFormatChatTextResponseFormat, TextResponseFormatV2ChatTextResponseFormatV2, ContentMessageContent.
- Removed schemas: ToolMessage, DocumentSource, ToolSource.
- Added schemas: ChatToolMessage, ChatDocumentSource, ChatToolSource.
- Updated union and discriminator mappings to new chat-specific types.
- Updated streaming response schema for /v2/chat.
- Updated code samples in multiple SDKs to use new types.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant API
    participant MessageModel

    Client->>API: Send /v2/chat request with UserMessageV2, SystemMessageV2, MessageContent
    API->>MessageModel: Pass chat message with new V2 schemas
    MessageModel-->>API: Generate ChatResponse or StreamedChatResponseV2
    API-->>Client: Return response referencing new chat-specific schemas (ChatToolMessage, ChatDocumentSource, etc.)
Loading

Poem

In YAML fields, new names appear,
V2 messages now crystal clear.
Old types retire, new ones take stage,
Chat flows refined upon the page.
Rabbits hop, schemas align—
A chat API, robust by design!
🐇✨


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 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 9, 2025 18:31
@HavenDV HavenDV merged commit 11f1083 into main Jun 9, 2025
3 of 4 checks passed
@HavenDV HavenDV deleted the bot/update-openapi_202506091830 branch June 9, 2025 18:33
@coderabbitai coderabbitai bot changed the title feat:@coderabbitai feat:Update Chat API v2 OpenAPI spec with new message and content schemas Jun 9, 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: 11

🧹 Nitpick comments (1)
src/libs/Cohere/openapi.yaml (1)

7869-7872: Unify parameter name and fix typo in Go tools snippet
The Go tools snippet uses "date" as the property key, but the Java example and spec define "day". Also remove the duplicated “a” in the second tool’s description.

Proposed adjustment:

- "properties": map[string]interface{}{
-     "date": map[string]interface{}{ ... },
+ "properties": map[string]interface{}{
+     "day": map[string]interface{}{ ... },
...
- Description: cohere.String("Connects to a a product catalog …"),
+ Description: cohere.String("Connects to a product catalog …"),
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 8e415f3 and a6402f2.

⛔ Files ignored due to path filters (67)
  • src/libs/Cohere/Generated/Cohere..JsonSerializerContext.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.ChatTextContentType.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.JsonConverters.ChatTextContentTypeNullable.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.MessageContent.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.JsonConverters.MessageContentDiscriminatorType.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.JsonConverters.MessageContentDiscriminatorTypeNullable.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.SystemMessageV2ContentVariant2ItemDiscriminatorType.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.JsonConverters.SystemMessageV2ContentVariant2ItemDiscriminatorTypeNullable.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.JsonConverters.SystemMessageV2Role.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.JsonConverters.SystemMessageV2RoleNullable.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.UserMessageV2Role.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.JsonConverters.UserMessageV2RoleNullable.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.JsonSerializerContextTypes.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.ChatDocumentSource.Json.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.ChatDocumentSource.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.ChatDocumentSourceDocument.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.ChatTextContent.Json.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.ChatTextContent.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.ChatTextContentType.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.ChatTextResponseFormat.Json.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.ChatTextResponseFormat.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.ChatTextResponseFormatV2.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.ChatToolMessage.Json.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.ChatToolMessage.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.ChatToolSource.Json.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.ChatToolSource.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.ChatToolSourceToolOutput.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.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.MessageContent.Json.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.MessageContent.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.MessageContentDiscriminator.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.MessageContentDiscriminatorType.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.SystemMessageV2.Json.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.SystemMessageV2.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.SystemMessageV2ContentVariant2ItemDiscriminator.Json.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.SystemMessageV2ContentVariant2ItemDiscriminator.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.SystemMessageV2ContentVariant2ItemDiscriminatorType.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.SystemMessageV2Role.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.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.ToolSource.Json.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.UserMessageV2.Json.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.UserMessageV2.g.cs is excluded by !**/generated/**
  • src/libs/Cohere/Generated/Cohere.Models.UserMessageV2Role.g.cs is excluded by !**/generated/**
📒 Files selected for processing (1)
  • src/libs/Cohere/openapi.yaml (23 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Test / Build, test and publish
🔇 Additional comments (14)
src/libs/Cohere/openapi.yaml (14)

7558-7561: Verify Python SDK message type
The Python example still uses cohere.UserChatMessageV2, but the new schema names messages as UserMessageV2 (or via ChatMessageV2.user). Please confirm the correct Python SDK class and update the snippet accordingly.


7866-7868: No issues in Java tools snippet
The Java tools example aligns with the updated API shapes.


7938-7940: Streaming config references are correct
The streaming block now properly points to ChatResponse and StreamedChatResponseV2 as per the new spec.


11492-11496: Updated content schema references
The replacement of TextContent with ChatTextContent in the oneOf and discriminator mapping is correct.


11523-11527: Consistent content schema renames
The migration from TextContent to ChatTextContent here aligns with the updated schema definitions.


12099-12112: ChatTextContent definition is accurate
The schema correctly defines a text property and enforces "type": "text".


12128-12149: ChatTextResponseFormat updates look good
Renaming TextResponseFormat* to ChatTextResponseFormat* and adjusting the type refs is correct.


13007-13007: Verify embed response change
The EmbedByTypeResponse now requires texts, but the PR summary and high-level AI summary don't mention embed updates. Please confirm this change is intentional.

Likely an incorrect or invalid review comment.


16508-16516: ResponseFormat mapping is correct
The addition of text: '#/components/schemas/ChatTextResponseFormat' under the discriminator is aligned with the new schema.


16537-16545: ResponseFormatV2 mapping is correct
The mapping now references ChatTextResponseFormatV2 for "text", as intended.


16642-16644: Source union updated correctly
Replacing ToolSource/DocumentSource with ChatToolSource/ChatDocumentSource aligns with the new spec.


16727-16730: SystemMessageV2 stub definition
The new SystemMessageV2 entry is in place; review upcoming properties for completeness.


16740-16745: SystemMessageV2 content schema updated
The content reference to ChatTextContent is correct for V2 system messages.


16868-16875: ToolContent union looks good
The schema correctly unions ChatTextContent and DocumentContent.

Comment on lines 17112 to 17123
- type: string
- type: array
items:
$ref: '#/components/schemas/Content'
$ref: '#/components/schemas/MessageContent'
description: "The content of the message. This can be a string or a list of content blocks.\nIf a string is provided, it will be treated as a text content block.\n"
role:
enum:
- user
type: string
description: A message from the user.
x-fern-type-name: UserMessage
x-fern-type-name: UserMessageV2
WandbConfig:
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Correct content property syntax in UserMessageV2
The content property needs a oneOf wrapper, not a plain list of - type: entries. For example:

content:
  oneOf:
    - type: string
    - type: array
      items:
        $ref: '#/components/schemas/MessageContent'

This will ensure valid YAML and correct typing.

🤖 Prompt for AI Agents
In src/libs/Cohere/openapi.yaml around lines 17112 to 17123, the content
property under UserMessageV2 is incorrectly defined as a list of types instead
of using a oneOf wrapper. To fix this, replace the current list of type entries
with a oneOf block that includes the string type and the array type referencing
MessageContent. This change will ensure valid YAML syntax and correct schema
typing.

Comment on lines 17102 to 17106
x-fern-type-name: Usage
UserMessage:
UserMessageV2:
title: User Message
required:
- role
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Require content in UserMessageV2
UserMessageV2 only requires role; it must also require the content field.

Add:

UserMessageV2:
  required:
    - role
    - content
🤖 Prompt for AI Agents
In src/libs/Cohere/openapi.yaml around lines 17102 to 17106, the UserMessageV2
schema currently requires only the role field but should also require the
content field. Update the required array under UserMessageV2 to include both
role and content fields to ensure content is mandatory.

Comment on lines +12243 to +12253
required:
- role
properties:
role:
$ref: '#/components/schemas/ChatRole'
tool_results:
type: array
items:
$ref: '#/components/schemas/ToolResult'
description: "Represents tool result in the chat history.\n"
x-fern-type-name: ChatToolMessage
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Require tool_results in ChatToolMessage
The ChatToolMessage schema only requires role; it must also require the tool_results array.

Add:

ChatToolMessage:
  required:
    - role
    - tool_results
🤖 Prompt for AI Agents
In src/libs/Cohere/openapi.yaml around lines 12243 to 12253, the ChatToolMessage
schema currently only requires the 'role' property but should also require the
'tool_results' array. Update the 'required' section of the ChatToolMessage
schema to include both 'role' and 'tool_results' to ensure 'tool_results' is
mandatory.

Comment on lines +7596 to 7598
- code: "/* (C)2024 */\npackage chatv2post;\n\nimport com.cohere.api.Cohere;\nimport com.cohere.api.resources.v2.requests.V2ChatRequest;\nimport com.cohere.api.resources.v2.types.V2ChatRequestDocumentsItem;\nimport com.cohere.api.types.*;\nimport java.util.List;\n\npublic class Documents {\n public static void main(String[] args) {\n Cohere cohere = Cohere.builder().clientName(\"snippet\").build();\n\n ChatResponse response =\n cohere\n .v2()\n .chat(\n V2ChatRequest.builder()\n .model(\"command-a-03-2025\")\n .messages(\n List.of(\n ChatMessageV2.user(\n UserMessageV2.builder()\n .content(\n UserMessageV2Content.of(\"Who is\" + \" the most\" + \" popular?\"))\n .build())))\n .documents(\n List.of(\n V2ChatRequestDocumentsItem.of(\n \"↓ Skip to Main Content\\n\\n\"\n + \"Music industry – One step\"\n + \" closer to being\"\n + \" accurate\\n\\n\"\n + \"CSPC: Backstreet Boys\"\n + \" Popularity Analysis\\n\\n\"\n + \"Hernán Lopez Posted on\"\n + \" February 9, 2017 Posted in\"\n + \" CSPC 72 Comments Tagged\"\n + \" with Backstreet Boys, Boy\"\n + \" band\\n\\n\"\n + \"At one point, Backstreet\"\n + \" Boys defined success:\"\n + \" massive albums sales across\"\n + \" the globe, great singles\"\n + \" sales, plenty of chart\"\n + \" topping releases, hugely\"\n + \" hyped tours and tremendous\"\n + \" media coverage.\\n\\n\"\n + \"It is true that they\"\n + \" benefited from\"\n + \" extraordinarily good market\"\n + \" conditions in all markets.\"\n + \" After all, the all-time\"\n + \" record year for the music\"\n + \" business, as far as\"\n + \" revenues in billion dollars\"\n + \" are concerned, was actually\"\n + \" 1999. That is, back when\"\n + \" this five men group was at\"\n + \" its peak.\"),\n V2ChatRequestDocumentsItem.of(\n \"↓ Skip to Main Content\\n\\n\"\n + \"Music industry – One step\"\n + \" closer to being\"\n + \" accurate\\n\\n\"\n + \"CSPC: NSYNC Popularity\"\n + \" Analysis\\n\\n\"\n + \"MJD Posted on February 9,\"\n + \" 2018 Posted in CSPC 27\"\n + \" Comments Tagged with Boy\"\n + \" band, N'Sync\\n\\n\"\n + \"At the turn of the\"\n + \" millennium three teen acts\"\n + \" were huge in the US, the\"\n + \" Backstreet Boys, Britney\"\n + \" Spears and NSYNC. The\"\n + \" latter is the only one we\"\n + \" haven’t study so far. It\"\n + \" took 15 years and Adele to\"\n + \" break their record of 2,4\"\n + \" million units sold of No\"\n + \" Strings Attached in its\"\n + \" first week alone.\\n\\n\"\n + \"It wasn’t a fluke, as the\"\n + \" second fastest selling\"\n + \" album of the Soundscan era\"\n + \" prior 2015, was also theirs\"\n + \" since Celebrity debuted\"\n + \" with 1,88 million units\"\n + \" sold.\"),\n V2ChatRequestDocumentsItem.of(\n \" 1997, 1998, 2000 and 2001 also\"\n + \" rank amongst some of the\"\n + \" very best years.\\n\\n\"\n + \"Yet the way many music\"\n + \" consumers – especially\"\n + \" teenagers and young women’s\"\n + \" – embraced their output\"\n + \" deserves its own chapter.\"\n + \" If Jonas Brothers and more\"\n + \" recently One Direction\"\n + \" reached a great level of\"\n + \" popularity during the past\"\n + \" decade, the type of success\"\n + \" achieved by Backstreet Boys\"\n + \" is in a completely\"\n + \" different level as they\"\n + \" really dominated the\"\n + \" business for a few years\"\n + \" all over the world,\"\n + \" including in some countries\"\n + \" that were traditionally\"\n + \" hard to penetrate for\"\n + \" Western artists.\\n\\n\"\n + \"We will try to analyze the\"\n + \" extent of that hegemony\"\n + \" with this new article with\"\n + \" final results which will\"\n + \" more than surprise many\"\n + \" readers.\"),\n V2ChatRequestDocumentsItem.of(\n \" Was the teen group led by Justin\"\n + \" Timberlake really that big?\"\n + \" Was it only in the US where\"\n + \" they found success? Or were\"\n + \" they a global\"\n + \" phenomenon?\\n\\n\"\n + \"As usual, I’ll be using the\"\n + \" Commensurate Sales to\"\n + \" Popularity Concept in order\"\n + \" to relevantly gauge their\"\n + \" results. This concept will\"\n + \" not only bring you sales\"\n + \" information for all NSYNC‘s\"\n + \" albums, physical and\"\n + \" download singles, as well\"\n + \" as audio and video\"\n + \" streaming, but it will also\"\n + \" determine their true\"\n + \" popularity. If you are not\"\n + \" yet familiar with the CSPC\"\n + \" method, the next page\"\n + \" explains it with a short\"\n + \" video. I fully recommend\"\n + \" watching the video before\"\n + \" getting into the sales\"\n + \" figures.\")))\n .build());\n System.out.println(response);\n }\n}\n"
name: Documents
sdk: java
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix Java “documents” snippet to match new schema
The V2ChatRequestDocumentsItem.of(...) call only passes raw content, but the spec now expects both id and document fields. Update to use the builder and supply both properties.

Proposed change:

- .documents(
-     List.of(
-         V2ChatRequestDocumentsItem.of("...raw text...")
-     )
- )
+ .documents(
+     List.of(
+         V2ChatRequestDocumentsItem.builder()
+             .id("1")
+             .document(Map.of(
+                 "text", "Cohere is the best!",
+                 "title", "The best"
+             ))
+             .build()
+     )
+ )

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In src/libs/Cohere/openapi.yaml around lines 7596 to 7598, the Java snippet for
the "documents" field uses V2ChatRequestDocumentsItem.of(...) with only raw
content, but the updated schema requires both "id" and "document" fields. Fix
this by replacing the .of(...) calls with the builder pattern, setting both the
"id" (a unique identifier string) and the "document" (the content string)
properties accordingly for each document item.

Comment on lines 16316 to +16328
Message:
oneOf:
- $ref: '#/components/schemas/ChatMessage'
- $ref: '#/components/schemas/ToolMessage'
- $ref: '#/components/schemas/ChatToolMessage'
discriminator:
propertyName: role
mapping:
CHATBOT: '#/components/schemas/ChatMessage'
SYSTEM: '#/components/schemas/ChatMessage'
TOOL: '#/components/schemas/ToolMessage'
TOOL: '#/components/schemas/ChatToolMessage'
USER: '#/components/schemas/ChatMessage'
x-fern-type-name: Message
MessageContent:
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix x-fern-type-name on MessageContent
The block is titled MessageContent but still has x-fern-type-name: Content. Update it to x-fern-type-name: MessageContent.

Proposed edit:

 MessageContent:
   oneOf: ...
   discriminator: ...
-  x-fern-type-name: Content
+  x-fern-type-name: MessageContent
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
Message:
oneOf:
- $ref: '#/components/schemas/ChatMessage'
- $ref: '#/components/schemas/ToolMessage'
- $ref: '#/components/schemas/ChatToolMessage'
discriminator:
propertyName: role
mapping:
CHATBOT: '#/components/schemas/ChatMessage'
SYSTEM: '#/components/schemas/ChatMessage'
TOOL: '#/components/schemas/ToolMessage'
TOOL: '#/components/schemas/ChatToolMessage'
USER: '#/components/schemas/ChatMessage'
x-fern-type-name: Message
MessageContent:
MessageContent:
oneOf: ...
discriminator: ...
x-fern-type-name: MessageContent
🤖 Prompt for AI Agents
In src/libs/Cohere/openapi.yaml around lines 16316 to 16328, the
x-fern-type-name for the MessageContent block is incorrectly set to Content.
Update the x-fern-type-name value to MessageContent to match the block title and
maintain consistency.

Comment on lines +7599 to 7601
- code: "package main\n\nimport (\n\t\"context\"\n\t\"log\"\n\t\"os\"\n\n\tcohere \"github.com/cohere-ai/cohere-go/v2\"\n\tclient \"github.com/cohere-ai/cohere-go/v2/client\"\n)\n\nfunc main() {\n\tco := client.NewClient(client.WithToken(os.Getenv(\"CO_API_KEY\")))\n\n\tresp, err := co.V2.Chat(\n\t\tcontext.TODO(),\n\t\t&cohere.V2ChatRequest{\n\t\t\tModel: \"command-a-03-2025\",\n\t\t\tDocuments: []*cohere.V2ChatRequestDocumentsItem{\n\t\t\t\t{\n\t\t\t\t\tString: \"Cohere is the best!\",\n\t\t\t\t},\n\t\t\t},\n\t\t\tMessages: cohere.ChatMessages{\n\t\t\t\t{\n\t\t\t\t\tRole: \"user\",\n\t\t\t\t\tUser: &cohere.UserMessageV2{Content: &cohere.UserMessageV2Content{\n\t\t\t\t\t\tString: \"Who's the best?\",\n\t\t\t\t\t}},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t)\n\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tlog.Printf(\"%+v\", resp)\n}\n"
name: Documents
sdk: go
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix Go “documents” snippet to match new schema
The Go example initializes V2ChatRequestDocumentsItem{String: ...} but the request now expects ID and Document fields. Adjust to include both.

Proposed change:

- Documents: []*cohere.V2ChatRequestDocumentsItem{
-     { String: "Cohere is the best!" },
- },
+ Documents: []*cohere.V2ChatRequestDocumentsItem{
+     {
+         ID: cohere.String("1"),
+         Document: map[string]interface{}{
+             "text":  "Cohere is the best!",
+             "title": "The best",
+         },
+     },
+ },
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- code: "package main\n\nimport (\n\t\"context\"\n\t\"log\"\n\t\"os\"\n\n\tcohere \"github.com/cohere-ai/cohere-go/v2\"\n\tclient \"github.com/cohere-ai/cohere-go/v2/client\"\n)\n\nfunc main() {\n\tco := client.NewClient(client.WithToken(os.Getenv(\"CO_API_KEY\")))\n\n\tresp, err := co.V2.Chat(\n\t\tcontext.TODO(),\n\t\t&cohere.V2ChatRequest{\n\t\t\tModel: \"command-a-03-2025\",\n\t\t\tDocuments: []*cohere.V2ChatRequestDocumentsItem{\n\t\t\t\t{\n\t\t\t\t\tString: \"Cohere is the best!\",\n\t\t\t\t},\n\t\t\t},\n\t\t\tMessages: cohere.ChatMessages{\n\t\t\t\t{\n\t\t\t\t\tRole: \"user\",\n\t\t\t\t\tUser: &cohere.UserMessageV2{Content: &cohere.UserMessageV2Content{\n\t\t\t\t\t\tString: \"Who's the best?\",\n\t\t\t\t\t}},\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t)\n\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\n\tlog.Printf(\"%+v\", resp)\n}\n"
name: Documents
sdk: go
resp, err := co.V2.Chat(
context.TODO(),
&cohere.V2ChatRequest{
Model: "command-a-03-2025",
- Documents: []*cohere.V2ChatRequestDocumentsItem{
- { String: "Cohere is the best!" },
- },
+ Documents: []*cohere.V2ChatRequestDocumentsItem{
+ {
+ ID: cohere.String("1"),
+ Document: map[string]interface{}{
+ "text": "Cohere is the best!",
+ "title": "The best",
+ },
+ },
+ },
Messages: cohere.ChatMessages{
{
Role: "user",
User: &cohere.UserMessageV2{Content: &cohere.UserMessageV2Content{
String: "Who's the best?",
}},
},
},
},
)
🤖 Prompt for AI Agents
In src/libs/Cohere/openapi.yaml around lines 7599 to 7601, the Go code snippet
for the "Documents" field incorrectly uses V2ChatRequestDocumentsItem with a
String field, but the current schema requires both ID and Document fields.
Update the snippet to initialize each document with the required ID and Document
fields instead of String, ensuring the structure matches the new schema.

Comment on lines 11871 to 11885
ChatMessageV2:
oneOf:
- $ref: '#/components/schemas/UserMessage'
- $ref: '#/components/schemas/UserMessageV2'
- $ref: '#/components/schemas/AssistantMessage'
- $ref: '#/components/schemas/SystemMessage'
- $ref: '#/components/schemas/SystemMessageV2'
- $ref: '#/components/schemas/ToolMessageV2'
description: Represents a single message in the chat history from a given role.
discriminator:
propertyName: role
mapping:
assistant: '#/components/schemas/AssistantMessage'
system: '#/components/schemas/SystemMessage'
system: '#/components/schemas/SystemMessageV2'
tool: '#/components/schemas/ToolMessageV2'
user: '#/components/schemas/UserMessage'
user: '#/components/schemas/UserMessageV2'
x-fern-type-name: ChatMessageV2
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Map tool role to ChatToolMessage
ChatMessageV2 discriminator still references ToolMessageV2; it should use the newly introduced ChatToolMessage schema.

Proposed change:

 ChatMessageV2:
   discriminator:
     mapping:
-      tool: '#/components/schemas/ToolMessageV2'
+      tool: '#/components/schemas/ChatToolMessage'
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
ChatMessageV2:
oneOf:
- $ref: '#/components/schemas/UserMessage'
- $ref: '#/components/schemas/UserMessageV2'
- $ref: '#/components/schemas/AssistantMessage'
- $ref: '#/components/schemas/SystemMessage'
- $ref: '#/components/schemas/SystemMessageV2'
- $ref: '#/components/schemas/ToolMessageV2'
description: Represents a single message in the chat history from a given role.
discriminator:
propertyName: role
mapping:
assistant: '#/components/schemas/AssistantMessage'
system: '#/components/schemas/SystemMessage'
system: '#/components/schemas/SystemMessageV2'
tool: '#/components/schemas/ToolMessageV2'
user: '#/components/schemas/UserMessage'
user: '#/components/schemas/UserMessageV2'
x-fern-type-name: ChatMessageV2
ChatMessageV2:
oneOf:
- $ref: '#/components/schemas/UserMessageV2'
- $ref: '#/components/schemas/AssistantMessage'
- $ref: '#/components/schemas/SystemMessageV2'
- $ref: '#/components/schemas/ToolMessageV2'
description: Represents a single message in the chat history from a given role.
discriminator:
propertyName: role
mapping:
assistant: '#/components/schemas/AssistantMessage'
system: '#/components/schemas/SystemMessageV2'
tool: '#/components/schemas/ChatToolMessage'
user: '#/components/schemas/UserMessageV2'
x-fern-type-name: ChatMessageV2
🤖 Prompt for AI Agents
In src/libs/Cohere/openapi.yaml between lines 11871 and 11885, the discriminator
mapping for the role "tool" in ChatMessageV2 incorrectly references
ToolMessageV2 instead of the newly introduced ChatToolMessage schema. Update the
mapping for "tool" to point to '#/components/schemas/ChatToolMessage' to
correctly reflect the new schema.

Comment on lines +7738 to 7740
- code: "/* (C)2024 */\npackage chatv2post;\n\nimport com.cohere.api.Cohere;\nimport com.cohere.api.resources.v2.requests.V2ChatStreamRequest;\nimport com.cohere.api.types.*;\nimport java.util.List;\n\npublic class Stream {\n public static void main(String[] args) {\n Cohere cohere = Cohere.builder().clientName(\"snippet\").build();\n\n Iterable<StreamedChatResponseV2> response =\n cohere\n .v2()\n .chatStream(\n V2ChatStreamRequest.builder()\n .model(\"command-a-03-2025\")\n .messages(\n List.of(\n ChatMessageV2.user(\n UserMessageV2.builder()\n .content(UserMessageV2Content.of(\"Who discovered\" + \" gravity?\"))\n .build()),\n ChatMessageV2.assistant(\n AssistantMessage.builder()\n .content(\n AssistantMessageContent.of(\n \"The man\"\n + \" who is\"\n + \" widely\"\n + \" credited\"\n + \" with\"\n + \" discovering\"\n + \" gravity\"\n + \" is Sir\"\n + \" Isaac\"\n + \" Newton\"))\n .build())))\n .build());\n\n for (StreamedChatResponseV2 chatResponse : response) {\n if (chatResponse.isContentDelta()) {\n System.out.println(\n chatResponse\n .getContentDelta()\n .flatMap(ChatContentDeltaEvent::getDelta)\n .flatMap(ChatContentDeltaEventDelta::getMessage)\n .flatMap(ChatContentDeltaEventDeltaMessage::getContent)\n .flatMap(ChatContentDeltaEventDeltaMessageContent::getText)\n .orElse(\"\"));\n }\n }\n\n System.out.println(response);\n }\n}\n"
name: Streaming
sdk: java
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Correct Java streaming snippet printing logic
The sample prints the entire response object instead of each delta’s text, and the final System.out.println(response) is redundant. Change to print the extracted text from chatResponse, then remove the trailing println.

Proposed change:

-    if (chatResponse.isContentDelta()) {
-      System.out.println(
-          chatResponse
-              .getContentDelta()...
-              .orElse(""));
-    }
-
-    System.out.println(response);
+    if (chatResponse.isContentDelta()) {
+      System.out.println(
+          chatResponse
+              .getContentDelta()...
+              .orElse(""));
+    }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- code: "/* (C)2024 */\npackage chatv2post;\n\nimport com.cohere.api.Cohere;\nimport com.cohere.api.resources.v2.requests.V2ChatStreamRequest;\nimport com.cohere.api.types.*;\nimport java.util.List;\n\npublic class Stream {\n public static void main(String[] args) {\n Cohere cohere = Cohere.builder().clientName(\"snippet\").build();\n\n Iterable<StreamedChatResponseV2> response =\n cohere\n .v2()\n .chatStream(\n V2ChatStreamRequest.builder()\n .model(\"command-a-03-2025\")\n .messages(\n List.of(\n ChatMessageV2.user(\n UserMessageV2.builder()\n .content(UserMessageV2Content.of(\"Who discovered\" + \" gravity?\"))\n .build()),\n ChatMessageV2.assistant(\n AssistantMessage.builder()\n .content(\n AssistantMessageContent.of(\n \"The man\"\n + \" who is\"\n + \" widely\"\n + \" credited\"\n + \" with\"\n + \" discovering\"\n + \" gravity\"\n + \" is Sir\"\n + \" Isaac\"\n + \" Newton\"))\n .build())))\n .build());\n\n for (StreamedChatResponseV2 chatResponse : response) {\n if (chatResponse.isContentDelta()) {\n System.out.println(\n chatResponse\n .getContentDelta()\n .flatMap(ChatContentDeltaEvent::getDelta)\n .flatMap(ChatContentDeltaEventDelta::getMessage)\n .flatMap(ChatContentDeltaEventDeltaMessage::getContent)\n .flatMap(ChatContentDeltaEventDeltaMessageContent::getText)\n .orElse(\"\"));\n }\n }\n\n System.out.println(response);\n }\n}\n"
name: Streaming
sdk: java
for (StreamedChatResponseV2 chatResponse : response) {
if (chatResponse.isContentDelta()) {
System.out.println(
chatResponse
.getContentDelta()
.flatMap(ChatContentDeltaEvent::getDelta)
.flatMap(ChatContentDeltaEventDelta::getMessage)
.flatMap(ChatContentDeltaEventDeltaMessage::getContent)
.flatMap(ChatContentDeltaEventDeltaMessageContent::getText)
.orElse(""));
}
}
🤖 Prompt for AI Agents
In src/libs/Cohere/openapi.yaml around lines 7738 to 7740, the Java streaming
snippet incorrectly prints the entire response object at the end instead of just
the extracted text deltas from each chatResponse. To fix this, ensure the code
prints only the text extracted from each content delta inside the loop and
remove the final System.out.println(response) statement to avoid redundant
output.

Comment on lines +11782 to +11792
ChatDocumentSource:
type: object
properties:
document:
type: object
x-fern-type-name: ChatDocumentSource-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: ChatDocumentSource
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Strongly reference existing ChatDocument schema and add required
The new ChatDocumentSource defines document: object, but you should reuse the ChatDocument schema instead of a bare object and declare both id and document as required.

Suggested:

 ChatDocumentSource:
   type: object
+  required:
+    - id
+    - document
   properties:
-    document:
-      type: object
-      x-fern-type-name: ChatDocumentSource-w70a62
+    document:
+      $ref: '#/components/schemas/ChatDocument'
     id:
       type: string
       description: The unique identifier of the document
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
ChatDocumentSource:
type: object
properties:
document:
type: object
x-fern-type-name: ChatDocumentSource-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: ChatDocumentSource
ChatDocumentSource:
type: object
required:
- id
- document
properties:
document:
$ref: '#/components/schemas/ChatDocument'
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: ChatDocumentSource
🤖 Prompt for AI Agents
In src/libs/Cohere/openapi.yaml around lines 11782 to 11792, the
ChatDocumentSource schema currently defines the document property as a generic
object and does not mark any properties as required. To fix this, replace the
document property's type with a strong reference to the existing ChatDocument
schema and add a required array listing both id and document to ensure these
fields are mandatory.

Comment on lines +12272 to +12282
ChatToolSource:
title: Tool Output
type: object
properties:
id:
type: string
description: The unique identifier of the document
tool_output:
type: object
x-fern-type-name: ChatToolSource-z53ra6
x-fern-type-name: ChatToolSource
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 ToolContent in ChatToolSource and require fields
The tool_output property should use $ref: '#/components/schemas/ToolContent' and both id and tool_output must be marked as required.

Example:

 ChatToolSource:
   type: object
+  required:
+    - id
+    - tool_output
   properties:
     id:
       type: string
... 
-    tool_output:
-      type: object
-      x-fern-type-name: ChatToolSource-z53ra6
+    tool_output:
+      $ref: '#/components/schemas/ToolContent'
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
ChatToolSource:
title: Tool Output
type: object
properties:
id:
type: string
description: The unique identifier of the document
tool_output:
type: object
x-fern-type-name: ChatToolSource-z53ra6
x-fern-type-name: ChatToolSource
ChatToolSource:
title: Tool Output
type: object
required:
- id
- tool_output
properties:
id:
type: string
description: The unique identifier of the document
tool_output:
$ref: '#/components/schemas/ToolContent'
x-fern-type-name: ChatToolSource
🤖 Prompt for AI Agents
In src/libs/Cohere/openapi.yaml around lines 12272 to 12282, the ChatToolSource
schema defines tool_output as an object but should reference the existing
ToolContent schema using $ref: '#/components/schemas/ToolContent'. Additionally,
add a required array listing both "id" and "tool_output" to make these fields
mandatory. Update the schema accordingly to fix these issues.

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