File tree Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Expand file tree Collapse file tree 1 file changed +47
-0
lines changed Original file line number Diff line number Diff line change 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" ])
You can’t perform that action at this time.
0 commit comments