Skip to content

Upgrade Cohere integration #883

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

Upgrade Cohere integration #883

wants to merge 1 commit into from

Conversation

andreibondarev
Copy link
Collaborator

  • Bump up cohere gem to ~> 1.0.1
  • Enable Assistant support for Cohere

* Bump up cohere gem to ~> 1.0.1
* Enable Assistant support for Cohere
@andreibondarev andreibondarev linked an issue Nov 25, 2024 that may be closed by this pull request
@andreibondarev andreibondarev requested a review from Copilot April 17, 2025 18:20
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR upgrades the Cohere integration by bumping the cohere gem version to ~> 1.0.1 and enabling assistant support for Cohere. Key changes include:

  • Updating response parsing in CohereResponse to match the new Cohere API schema.
  • Adjusting the embed and chat methods in the Cohere wrapper.
  • Introducing CohereMessage and a new Cohere adapter in the assistant module to support tool calls and message formatting.

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
lib/langchain/llm/response/cohere_response.rb Adjusts response parsing and token calculation methods to conform with Cohere API changes.
lib/langchain/llm/cohere.rb Upgrades the gem version and revises parameter handling in embed and chat methods.
lib/langchain/assistant/messages/cohere_message.rb Introduces a new message class for Cohere with support for tool calls and role handling.
lib/langchain/assistant/llm/adapters/cohere.rb Adds a Cohere adapter, including chat parameter construction and tool build logic.
lib/langchain/assistant/llm/adapter.rb Updates the adapter selection logic to include the new Cohere adapter.
langchain.gemspec Bumps the development dependency for cohere-ruby to ~> 1.0.1.
Comments suppressed due to low confidence (1)

lib/langchain/llm/cohere.rb:88

  • The removal of the mandatory check for an empty messages argument may lead to unexpected behavior if an empty array is passed. Consider adding validation to ensure that messages are provided.
def chat(params = {})

# @param tool_choice [String] The tool choice
# @param parallel_tool_calls [Boolean] Whether to make parallel tool calls
# @return [Hash] The chat parameters
def build_chat_params(
Copy link
Preview

Copilot AI Apr 17, 2025

Choose a reason for hiding this comment

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

Consider providing a default value for the 'parallel_tool_calls' parameter to avoid a potential ArgumentError when it is not supplied.

Copilot uses AI. Check for mistakes.

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.

Update cohere interface to use cohere 1.0.1
1 participant