-
-
Notifications
You must be signed in to change notification settings - Fork 0
feat:Update openapi.yaml file in src/libs/Cohere directory #95
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 in this pull request involve modifications to the Changes
Possibly related PRs
Suggested reviewers
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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: 2
🧹 Outside diff range and nitpick comments (1)
src/libs/Cohere/openapi.yaml (1)
Line range hint
914-1088
: Maintain consistent complexity between Java and cURL examplesThe Java examples are significantly more complex than their cURL counterparts, particularly in the Documents example. Consider:
- Adding more realistic document content in the cURL Documents example
- Including response handling examples in cURL similar to Java
- Showing error handling patterns in both formats
For the Documents cURL example, consider showing a more realistic document structure:
-"data": "Cohere is the best!" +"data": "This is a sample document that demonstrates RAG capabilities. It contains relevant information that can be used to answer user queries..."
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
src/libs/Cohere/openapi.yaml
(3 hunks)
🔥 Files not summarized due to errors (1)
- src/libs/Cohere/openapi.yaml: Error: Server error: no LLM provider could handle the message
@@ -911,7 +911,7 @@ paths: | |||
code: "/* (C)2024 */\npackage chatv2post;\n\nimport com.cohere.api.Cohere;\nimport com.cohere.api.resources.v2.requests.V2ChatRequest;\nimport com.cohere.api.types.*;\nimport java.util.List;\n\npublic class Default {\n public static void main(String[] args) {\n Cohere cohere = Cohere.builder().token(\"<<apiKey>>\").clientName(\"snippet\").build();\n\n ChatResponse response =\n cohere\n .v2()\n .chat(\n V2ChatRequest.builder()\n .model(\"command-r-plus-08-2024\")\n .messages(\n List.of(\n ChatMessageV2.user(\n UserMessage.builder()\n .content(UserMessageContent.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 System.out.println(response);\n }\n}\n" | |||
- sdk: curl | |||
name: Default | |||
code: "curl --request POST \\\n --url https://api.cohere.com/v2/chat \\\n --header 'accept: application/json' \\\n --header 'content-type: application/json' \\\n --header \"Authorization: bearer $CO_API_KEY\" \\\n --data '{\n \"model\": \"command-r-plus-08-2024\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"message\": \"Hello world!\"\n }\n ],\n }'" | |||
code: "curl --request POST \\\n --url https://api.cohere.com/v2/chat \\\n --header 'accept: application/json' \\\n --header 'content-type: application/json' \\\n --header \"Authorization: bearer $CO_API_KEY\" \\\n --data '{\n \"model\": \"command-r-plus-08-2024\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Hello world!\"\n }\n ],\n }'" |
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
Improve code quality in Java examples
The Java examples could be improved in several ways:
- String concatenation should be replaced with String literals for better readability
- Consider extracting large document content to separate files or constants
- Add error handling for missing API keys
Example improvement for string concatenation:
-content(UserMessageContent.of("Who discovered" + " gravity?"))
+content(UserMessageContent.of("Who discovered gravity?"))
Also applies to: 949-949, 1088-1088
Security: Remove hardcoded API key from examples
The Java examples use a hardcoded API key <<apiKey>>
. While it's a placeholder, it's better to demonstrate secure practices by showing how to load the API key from environment variables or a secure configuration system.
Replace the API key initialization in Java examples with:
-Cohere cohere = Cohere.builder().token("<<apiKey>>").clientName("snippet").build();
+String apiKey = System.getenv("CO_API_KEY"); // Load from environment variable
+Cohere cohere = Cohere.builder().token(apiKey).clientName("snippet").build();
Committable suggestion skipped: line range outside the PR's diff.
Summary by CodeRabbit