-
-
Notifications
You must be signed in to change notification settings - Fork 0
feat:Update Chat API v2 OpenAPI spec with new message and content schemas #204
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThe Changes
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.)
Poem
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. 🪧 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.
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
⛔ Files ignored due to path filters (67)
src/libs/Cohere/Generated/Cohere..JsonSerializerContext.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.JsonConverters.ChatMessageV2.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.JsonConverters.ChatTextContentType.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.JsonConverters.ChatTextContentTypeNullable.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.JsonConverters.ContentItem.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.JsonConverters.ContentVariant2Item.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.JsonConverters.ContentVariant2Item2.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.JsonConverters.Message.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.JsonConverters.MessageContent.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.JsonConverters.MessageContentDiscriminatorType.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.JsonConverters.MessageContentDiscriminatorTypeNullable.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.JsonConverters.ResponseFormat.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.JsonConverters.ResponseFormatV2.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.JsonConverters.Source.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.JsonConverters.SystemMessageV2ContentVariant2ItemDiscriminatorType.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.JsonConverters.SystemMessageV2ContentVariant2ItemDiscriminatorTypeNullable.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.JsonConverters.SystemMessageV2Role.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.JsonConverters.SystemMessageV2RoleNullable.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.JsonConverters.ToolContent.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.JsonConverters.UserMessageV2Role.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.JsonConverters.UserMessageV2RoleNullable.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.JsonSerializerContextTypes.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.Models.ChatDocumentSource.Json.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.Models.ChatDocumentSource.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.Models.ChatDocumentSourceDocument.Json.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.Models.ChatDocumentSourceDocument.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.Models.ChatMessageV2.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.Models.ChatTextContent.Json.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.Models.ChatTextContent.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.Models.ChatTextContentType.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.Models.ChatTextResponseFormat.Json.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.Models.ChatTextResponseFormat.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.Models.ChatTextResponseFormatV2.Json.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.Models.ChatTextResponseFormatV2.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.Models.ChatToolMessage.Json.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.Models.ChatToolMessage.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.Models.ChatToolSource.Json.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.Models.ChatToolSource.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.Models.ChatToolSourceToolOutput.Json.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.Models.ChatToolSourceToolOutput.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.Models.ContentItem.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.Models.ContentVariant2Item.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.Models.ContentVariant2Item2.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.Models.EmbedByTypeResponse.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.Models.Message.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.Models.MessageContent.Json.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.Models.MessageContent.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.Models.MessageContentDiscriminator.Json.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.Models.MessageContentDiscriminator.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.Models.MessageContentDiscriminatorType.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.Models.ResponseFormat.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.Models.ResponseFormatV2.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.Models.Source.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.Models.SystemMessageV2.Json.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.Models.SystemMessageV2.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.Models.SystemMessageV2ContentVariant2ItemDiscriminator.Json.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.Models.SystemMessageV2ContentVariant2ItemDiscriminator.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.Models.SystemMessageV2ContentVariant2ItemDiscriminatorType.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.Models.SystemMessageV2Role.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.Models.TextResponseFormatV2.Json.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.Models.ToolContent.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.Models.ToolMessage.Json.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.Models.ToolSource.Json.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.Models.ToolSourceToolOutput.Json.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.Models.UserMessageV2.Json.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.Models.UserMessageV2.g.csis excluded by!**/generated/**src/libs/Cohere/Generated/Cohere.Models.UserMessageV2Role.g.csis 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 usescohere.UserChatMessageV2, but the new schema names messages asUserMessageV2(or viaChatMessageV2.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 toChatResponseandStreamedChatResponseV2as per the new spec.
11492-11496: Updated content schema references
The replacement ofTextContentwithChatTextContentin theoneOfand discriminator mapping is correct.
11523-11527: Consistent content schema renames
The migration fromTextContenttoChatTextContenthere aligns with the updated schema definitions.
12099-12112: ChatTextContent definition is accurate
The schema correctly defines atextproperty and enforces"type": "text".
12128-12149: ChatTextResponseFormat updates look good
RenamingTextResponseFormat*toChatTextResponseFormat*and adjusting thetyperefs is correct.
13007-13007: Verify embed response change
TheEmbedByTypeResponsenow requirestexts, 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 oftext: '#/components/schemas/ChatTextResponseFormat'under the discriminator is aligned with the new schema.
16537-16545: ResponseFormatV2 mapping is correct
The mapping now referencesChatTextResponseFormatV2for"text", as intended.
16642-16644: Source union updated correctly
ReplacingToolSource/DocumentSourcewithChatToolSource/ChatDocumentSourcealigns with the new spec.
16727-16730: SystemMessageV2 stub definition
The newSystemMessageV2entry is in place; review upcoming properties for completeness.
16740-16745: SystemMessageV2 content schema updated
The content reference toChatTextContentis correct for V2 system messages.
16868-16875: ToolContent union looks good
The schema correctly unionsChatTextContentandDocumentContent.
| - 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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
| x-fern-type-name: Usage | ||
| UserMessage: | ||
| UserMessageV2: | ||
| title: User Message | ||
| required: | ||
| - role |
There was a problem hiding this comment.
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.
| 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 |
There was a problem hiding this comment.
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.
| - 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
| 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: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
| 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.
| - 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
| - 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.
| 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
| 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.
| - 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
| - 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.
| 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
| 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.
| 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 |
There was a problem hiding this comment.
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.
| 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.
Summary by CodeRabbit
New Features
Refactor