Skip to content

Commit c23076d

Browse files
committed
Revert change to cohere and fix mcp tests naming
1 parent 5d05916 commit c23076d

File tree

4 files changed

+23
-16
lines changed

4 files changed

+23
-16
lines changed

pydantic_ai_slim/pydantic_ai/models/cohere.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ def __init__(
111111
*,
112112
provider: Literal['cohere'] | Provider[AsyncClientV2] = 'cohere',
113113
profile: ModelProfileSpec | None = None,
114+
settings: ModelSettings | None = None,
114115
):
115116
"""Initialize an Cohere model.
116117
@@ -121,6 +122,7 @@ def __init__(
121122
'cohere' or an instance of `Provider[AsyncClientV2]`. If not provided, a new provider will be
122123
created using the other parameters.
123124
profile: The model profile to use. Defaults to a profile picked by the provider based on the model name.
125+
settings: Model-specific settings that will be used as defaults for this model.
124126
"""
125127
self._model_name = model_name
126128

@@ -129,6 +131,8 @@ def __init__(
129131
self.client = provider.client
130132
self._profile = profile or provider.model_profile
131133

134+
super().__init__(settings=settings, profile=profile or provider.model_profile)
135+
132136
@property
133137
def base_url(self) -> str:
134138
client_wrapper = self.client._client_wrapper # type: ignore

tests/mcp_server.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ async def get_image_resource() -> EmbeddedResource:
5959

6060

6161
@mcp.tool()
62-
async def get_image_resource_1() -> ResourceLink:
62+
async def get_image_resource_link() -> ResourceLink:
6363
return ResourceLink(
6464
type='resource_link',
6565
uri=AnyUrl(Path(__file__).parent.joinpath('assets/kiwi.png').absolute().as_uri()),
@@ -81,7 +81,7 @@ async def get_audio_resource() -> EmbeddedResource:
8181

8282

8383
@mcp.tool()
84-
async def get_audio_resource_1() -> ResourceLink:
84+
async def get_audio_resource_link() -> ResourceLink:
8585
return ResourceLink(
8686
type='resource_link',
8787
uri=AnyUrl(Path(__file__).parent.joinpath('assets/marcelo.mp3').absolute().as_uri()),
@@ -101,7 +101,7 @@ async def get_product_name() -> EmbeddedResource:
101101

102102

103103
@mcp.tool()
104-
async def get_product_name_1() -> ResourceLink:
104+
async def get_product_name_link() -> ResourceLink:
105105
return ResourceLink(
106106
type='resource_link',
107107
uri=AnyUrl(Path(__file__).parent.joinpath('assets/product_name.txt').absolute().as_uri()),

tests/models/cassettes/test_model_names/test_known_model_names.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ interactions:
1515
response:
1616
headers:
1717
content-length:
18-
- '545'
18+
- '550'
1919
content-security-policy:
2020
- default-src 'none'; frame-ancestors 'none'
2121
content-type:
@@ -46,6 +46,7 @@ interactions:
4646
- text-to-text
4747
- model_id: claude-4-sonnet
4848
regions:
49+
- eu
4950
- us
5051
type:
5152
- text-to-text

tests/test_mcp.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -441,8 +441,8 @@ async def test_tool_returning_text_resource(allow_model_requests: None, agent: A
441441

442442

443443
@pytest.mark.vcr()
444-
async def test_tool_returning_text_resource_1(allow_model_requests: None, agent: Agent):
445-
async with agent.run_mcp_servers():
444+
async def test_tool_returning_text_resource_link(allow_model_requests: None, agent: Agent):
445+
async with agent:
446446
result = await agent.run('Get me the product name')
447447
assert result.output == snapshot('The product name is "PydanticAI".')
448448
assert result.all_messages() == snapshot(
@@ -458,7 +458,7 @@ async def test_tool_returning_text_resource_1(allow_model_requests: None, agent:
458458
ModelResponse(
459459
parts=[
460460
ToolCallPart(
461-
tool_name='get_product_name_1',
461+
tool_name='get_product_name_link',
462462
args='{}',
463463
tool_call_id='call_LaiWltzI39sdquflqeuF0EyE',
464464
)
@@ -483,7 +483,7 @@ async def test_tool_returning_text_resource_1(allow_model_requests: None, agent:
483483
ModelRequest(
484484
parts=[
485485
ToolReturnPart(
486-
tool_name='get_product_name_1',
486+
tool_name='get_product_name_link',
487487
content='PydanticAI',
488488
tool_call_id='call_LaiWltzI39sdquflqeuF0EyE',
489489
timestamp=IsDatetime(),
@@ -594,8 +594,10 @@ async def test_tool_returning_image_resource(allow_model_requests: None, agent:
594594

595595

596596
@pytest.mark.vcr()
597-
async def test_tool_returning_image_resource_1(allow_model_requests: None, agent: Agent, image_content: BinaryContent):
598-
async with agent.run_mcp_servers():
597+
async def test_tool_returning_image_resource_link(
598+
allow_model_requests: None, agent: Agent, image_content: BinaryContent
599+
):
600+
async with agent:
599601
result = await agent.run('Get me the image resource')
600602
assert result.output == snapshot(
601603
'This is an image of a sliced kiwi with a vibrant green interior and black seeds.'
@@ -613,7 +615,7 @@ async def test_tool_returning_image_resource_1(allow_model_requests: None, agent
613615
ModelResponse(
614616
parts=[
615617
ToolCallPart(
616-
tool_name='get_image_resource_1',
618+
tool_name='get_image_resource_link',
617619
args='{}',
618620
tool_call_id='call_nFsDHYDZigO0rOHqmChZ3pmt',
619621
)
@@ -638,7 +640,7 @@ async def test_tool_returning_image_resource_1(allow_model_requests: None, agent
638640
ModelRequest(
639641
parts=[
640642
ToolReturnPart(
641-
tool_name='get_image_resource_1',
643+
tool_name='get_image_resource_link',
642644
content='See file 1c8566',
643645
tool_call_id='call_nFsDHYDZigO0rOHqmChZ3pmt',
644646
timestamp=IsDatetime(),
@@ -728,11 +730,11 @@ async def test_tool_returning_audio_resource(
728730

729731

730732
@pytest.mark.vcr()
731-
async def test_tool_returning_audio_resource_1(
733+
async def test_tool_returning_audio_resource_link(
732734
allow_model_requests: None, agent: Agent, audio_content: BinaryContent, gemini_api_key: str
733735
):
734736
model = GoogleModel('gemini-2.5-pro-preview-03-25', provider=GoogleProvider(api_key=gemini_api_key))
735-
async with agent.run_mcp_servers():
737+
async with agent:
736738
result = await agent.run("What's the content of the audio resource?", model=model)
737739
assert result.output == snapshot('The audio resource contains a voice saying "Hello, my name is Marcelo."')
738740
assert result.all_messages() == snapshot(
@@ -741,7 +743,7 @@ async def test_tool_returning_audio_resource_1(
741743
parts=[UserPromptPart(content="What's the content of the audio resource?", timestamp=IsDatetime())]
742744
),
743745
ModelResponse(
744-
parts=[ToolCallPart(tool_name='get_audio_resource_1', args={}, tool_call_id=IsStr())],
746+
parts=[ToolCallPart(tool_name='get_audio_resource_link', args={}, tool_call_id=IsStr())],
745747
usage=Usage(
746748
requests=1,
747749
request_tokens=383,
@@ -756,7 +758,7 @@ async def test_tool_returning_audio_resource_1(
756758
ModelRequest(
757759
parts=[
758760
ToolReturnPart(
759-
tool_name='get_audio_resource_1',
761+
tool_name='get_audio_resource_link',
760762
content='See file 2d36ae',
761763
tool_call_id=IsStr(),
762764
timestamp=IsDatetime(),

0 commit comments

Comments
 (0)