Skip to content

Commit 1d01dc0

Browse files
billytrend-cohereWorkshop Participant
authored andcommitted
Add cohere client (#236)
* Add CohereModel * Format * Update pyproject.toml * Update src/strands/models/cohere.py * Revert cusom cli, keep only compat layer * Format and fixes
1 parent cb6f2e4 commit 1d01dc0

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

tests-integ/test_model_cohere.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import os
2+
3+
import pytest
4+
5+
import strands
6+
from strands import Agent
7+
from strands.models.openai import OpenAIModel
8+
9+
10+
@pytest.fixture
11+
def model():
12+
return OpenAIModel(
13+
client_args={
14+
"base_url": "https://api.cohere.com/compatibility/v1",
15+
"api_key": os.getenv("CO_API_KEY"),
16+
},
17+
model_id="command-a-03-2025",
18+
params={"stream_options": None},
19+
)
20+
21+
22+
@pytest.fixture
23+
def tools():
24+
@strands.tool
25+
def tool_time() -> str:
26+
return "12:00"
27+
28+
@strands.tool
29+
def tool_weather() -> str:
30+
return "sunny"
31+
32+
return [tool_time, tool_weather]
33+
34+
35+
@pytest.fixture
36+
def agent(model, tools):
37+
return Agent(model=model, tools=tools)
38+
39+
40+
@pytest.mark.skipif(
41+
"CO_API_KEY" not in os.environ,
42+
reason="CO_API_KEY environment variable missing",
43+
)
44+
def test_agent(agent):
45+
result = agent("What is the time and weather in New York?")
46+
text = result.message["content"][0]["text"].lower()
47+
assert all(string in text for string in ["12:00", "sunny"])

0 commit comments

Comments
 (0)