Skip to content

Add cohere client #236

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

billytrend-cohere
Copy link

@billytrend-cohere billytrend-cohere commented Jun 17, 2025

Add cohere client based on openai compatiblity layer

@Unshure Unshure self-assigned this Jun 19, 2025
Copy link
Member

@Unshure Unshure left a comment

Choose a reason for hiding this comment

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

Thank you for the contribution here! This looks like a light wrapper around the existing OpenAI implementation, which is not an implementation pattern we like to follow. Instead, I would be happy to accept a ModelProvider that uses Cohere's own sdk: https://docs.cohere.com/reference/about#python

Let me know if this is an update you are interested in contributing!

@billytrend-cohere
Copy link
Author

Added some docs here strands-agents/docs#108

@Unshure
Copy link
Member

Unshure commented Jun 27, 2025

We are planning on having a mostly docs-based implementation, so lets remove this implementation, but keep the newly added integration test.

@Unshure Unshure force-pushed the billy/cohere-compat branch from 88e35bc to 18cd037 Compare June 27, 2025 18:55
@Unshure
Copy link
Member

Unshure commented Jun 27, 2025

I accidentally committed a change to your pr, so I had to undo that, sorry about that.

Comment on lines +7 to +15
from strands.models.cohere import CohereModel


@pytest.fixture
def model():
return CohereModel(
model_id="command-a-03-2025",
api_key=os.getenv("CO_API_KEY"),
)
Copy link
Member

Choose a reason for hiding this comment

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

Lets update this to use the openAI model provider

Suggested change
from strands.models.cohere import CohereModel
@pytest.fixture
def model():
return CohereModel(
model_id="command-a-03-2025",
api_key=os.getenv("CO_API_KEY"),
)
from strands.models.openai import OpenAIModel
@pytest.fixture
def model():
return OpenAIModel(
client_args={
"base_url": "https://api.cohere.com/compatibility/v1",
"api_key": os.getenv("CO_API_KEY"),
},
model_id="command-a-03-2025",
params={
"stream_options": None
}
)

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.

3 participants