@@ -443,14 +443,14 @@ async def test_tool_returning_text_resource(allow_model_requests: None, agent: A
443
443
@pytest .mark .vcr ()
444
444
async def test_tool_returning_text_resource_link (allow_model_requests : None , agent : Agent ):
445
445
async with agent :
446
- result = await agent .run ('Get me the product name' )
446
+ result = await agent .run ('Get me the product name via get_product_name_link ' )
447
447
assert result .output == snapshot ('The product name is "Pydantic AI".' )
448
448
assert result .all_messages () == snapshot (
449
449
[
450
450
ModelRequest (
451
451
parts = [
452
452
UserPromptPart (
453
- content = 'Get me the product name' ,
453
+ content = 'Get me the product name via get_product_name_link ' ,
454
454
timestamp = IsDatetime (),
455
455
)
456
456
]
@@ -460,14 +460,14 @@ async def test_tool_returning_text_resource_link(allow_model_requests: None, age
460
460
ToolCallPart (
461
461
tool_name = 'get_product_name_link' ,
462
462
args = '{}' ,
463
- tool_call_id = 'call_LaiWltzI39sdquflqeuF0EyE ' ,
463
+ tool_call_id = 'call_qi5GtBeIEyT7Y3yJvVFIi062 ' ,
464
464
)
465
465
],
466
466
usage = Usage (
467
467
requests = 1 ,
468
- request_tokens = 200 ,
468
+ request_tokens = 305 ,
469
469
response_tokens = 12 ,
470
- total_tokens = 212 ,
470
+ total_tokens = 317 ,
471
471
details = {
472
472
'accepted_prediction_tokens' : 0 ,
473
473
'audio_tokens' : 0 ,
@@ -478,25 +478,25 @@ async def test_tool_returning_text_resource_link(allow_model_requests: None, age
478
478
),
479
479
model_name = 'gpt-4o-2024-08-06' ,
480
480
timestamp = IsDatetime (),
481
- vendor_id = 'chatcmpl-BRmhyweJVYonarb7s9ckIMSHf2vHo ' ,
481
+ vendor_id = 'chatcmpl-BwdHSFe0EykAOpf0LWZzsWAodIQzb ' ,
482
482
),
483
483
ModelRequest (
484
484
parts = [
485
485
ToolReturnPart (
486
486
tool_name = 'get_product_name_link' ,
487
- content = 'PydanticAI ' ,
488
- tool_call_id = 'call_LaiWltzI39sdquflqeuF0EyE ' ,
487
+ content = 'Pydantic AI \n ' ,
488
+ tool_call_id = 'call_qi5GtBeIEyT7Y3yJvVFIi062 ' ,
489
489
timestamp = IsDatetime (),
490
490
)
491
491
]
492
492
),
493
493
ModelResponse (
494
- parts = [TextPart (content = 'The product name is "PydanticAI ".' )],
494
+ parts = [TextPart (content = 'The product name is "Pydantic AI ".' )],
495
495
usage = Usage (
496
496
requests = 1 ,
497
- request_tokens = 224 ,
498
- response_tokens = 12 ,
499
- total_tokens = 236 ,
497
+ request_tokens = 332 ,
498
+ response_tokens = 11 ,
499
+ total_tokens = 343 ,
500
500
details = {
501
501
'accepted_prediction_tokens' : 0 ,
502
502
'audio_tokens' : 0 ,
@@ -507,7 +507,7 @@ async def test_tool_returning_text_resource_link(allow_model_requests: None, age
507
507
),
508
508
model_name = 'gpt-4o-2024-08-06' ,
509
509
timestamp = IsDatetime (),
510
- vendor_id = 'chatcmpl-BRmhzqXFObpYwSzREMpJvX9kbDikR ' ,
510
+ vendor_id = 'chatcmpl-BwdHTIlBZWzXJPBR8VTOdC4O57ZQA ' ,
511
511
),
512
512
]
513
513
)
@@ -598,16 +598,16 @@ async def test_tool_returning_image_resource_link(
598
598
allow_model_requests : None , agent : Agent , image_content : BinaryContent
599
599
):
600
600
async with agent :
601
- result = await agent .run ('Get me the image resource' )
601
+ result = await agent .run ('Get me the image resource via get_image_resource_link ' )
602
602
assert result .output == snapshot (
603
- 'This is an image of a sliced kiwi with a vibrant green interior and black seeds .'
603
+ 'This is an image of a sliced kiwi fruit. It shows the green, seed-speckled interior with fuzzy brown skin around the edges .'
604
604
)
605
605
assert result .all_messages () == snapshot (
606
606
[
607
607
ModelRequest (
608
608
parts = [
609
609
UserPromptPart (
610
- content = 'Get me the image resource' ,
610
+ content = 'Get me the image resource via get_image_resource_link ' ,
611
611
timestamp = IsDatetime (),
612
612
)
613
613
]
@@ -617,14 +617,14 @@ async def test_tool_returning_image_resource_link(
617
617
ToolCallPart (
618
618
tool_name = 'get_image_resource_link' ,
619
619
args = '{}' ,
620
- tool_call_id = 'call_nFsDHYDZigO0rOHqmChZ3pmt ' ,
620
+ tool_call_id = 'call_eVFgn54V9Nuh8Y4zvuzkYjUp ' ,
621
621
)
622
622
],
623
623
usage = Usage (
624
624
requests = 1 ,
625
- request_tokens = 191 ,
625
+ request_tokens = 305 ,
626
626
response_tokens = 12 ,
627
- total_tokens = 203 ,
627
+ total_tokens = 317 ,
628
628
details = {
629
629
'accepted_prediction_tokens' : 0 ,
630
630
'audio_tokens' : 0 ,
@@ -635,14 +635,14 @@ async def test_tool_returning_image_resource_link(
635
635
),
636
636
model_name = 'gpt-4o-2024-08-06' ,
637
637
timestamp = IsDatetime (),
638
- vendor_id = 'chatcmpl-BRlo7KYJVXuNZ5lLLdYcKZDsX2CHb ' ,
638
+ vendor_id = 'chatcmpl-BwdHygYePH1mZgHo2Xxzib0Y7sId7 ' ,
639
639
),
640
640
ModelRequest (
641
641
parts = [
642
642
ToolReturnPart (
643
643
tool_name = 'get_image_resource_link' ,
644
644
content = 'See file 1c8566' ,
645
- tool_call_id = 'call_nFsDHYDZigO0rOHqmChZ3pmt ' ,
645
+ tool_call_id = 'call_eVFgn54V9Nuh8Y4zvuzkYjUp ' ,
646
646
timestamp = IsDatetime (),
647
647
),
648
648
UserPromptPart (content = ['This is file 1c8566:' , image_content ], timestamp = IsDatetime ()),
@@ -651,14 +651,14 @@ async def test_tool_returning_image_resource_link(
651
651
ModelResponse (
652
652
parts = [
653
653
TextPart (
654
- content = 'This is an image of a sliced kiwi with a vibrant green interior and black seeds .'
654
+ content = 'This is an image of a sliced kiwi fruit. It shows the green, seed-speckled interior with fuzzy brown skin around the edges .'
655
655
)
656
656
],
657
657
usage = Usage (
658
658
requests = 1 ,
659
- request_tokens = 1332 ,
660
- response_tokens = 19 ,
661
- total_tokens = 1351 ,
659
+ request_tokens = 1452 ,
660
+ response_tokens = 29 ,
661
+ total_tokens = 1481 ,
662
662
details = {
663
663
'accepted_prediction_tokens' : 0 ,
664
664
'audio_tokens' : 0 ,
@@ -669,7 +669,7 @@ async def test_tool_returning_image_resource_link(
669
669
),
670
670
model_name = 'gpt-4o-2024-08-06' ,
671
671
timestamp = IsDatetime (),
672
- vendor_id = 'chatcmpl-BRloBGHh27w3fQKwxq4fX2cPuZJa9 ' ,
672
+ vendor_id = 'chatcmpl-BwdI2D2r9dvqq3pbsA0qgwKDEdTtD ' ,
673
673
),
674
674
]
675
675
)
@@ -735,23 +735,33 @@ async def test_tool_returning_audio_resource_link(
735
735
):
736
736
model = GoogleModel ('gemini-2.5-pro-preview-03-25' , provider = GoogleProvider (api_key = gemini_api_key ))
737
737
async with agent :
738
- result = await agent .run ("What's the content of the audio resource?" , model = model )
739
- assert result .output == snapshot ('The audio resource contains a voice saying "Hello, my name is Marcelo." ' )
738
+ result = await agent .run ("What's the content of the audio resource via get_audio_resource_link ?" , model = model )
739
+ assert result .output == snapshot ('00:05 ' )
740
740
assert result .all_messages () == snapshot (
741
741
[
742
742
ModelRequest (
743
- parts = [UserPromptPart (content = "What's the content of the audio resource?" , timestamp = IsDatetime ())]
743
+ parts = [
744
+ UserPromptPart (
745
+ content = "What's the content of the audio resource via get_audio_resource_link?" ,
746
+ timestamp = IsDatetime (),
747
+ )
748
+ ]
744
749
),
745
750
ModelResponse (
746
- parts = [ToolCallPart (tool_name = 'get_audio_resource_link' , args = {}, tool_call_id = IsStr ())],
751
+ parts = [
752
+ TextPart (
753
+ content = 'The content of the audio resource is at a link that can be accessed by calling the function `get_audio_resource_link`.'
754
+ ),
755
+ ToolCallPart (tool_name = 'get_audio_resource_link' , args = {}, tool_call_id = IsStr ()),
756
+ ],
747
757
usage = Usage (
748
758
requests = 1 ,
749
- request_tokens = 383 ,
750
- response_tokens = 12 ,
751
- total_tokens = 520 ,
752
- details = {'thoughts_tokens' : 125 , 'text_prompt_tokens' : 383 },
759
+ request_tokens = 561 ,
760
+ response_tokens = 41 ,
761
+ total_tokens = 797 ,
762
+ details = {'thoughts_tokens' : 195 , 'text_prompt_tokens' : 561 },
753
763
),
754
- model_name = 'models/gemini-2.5-pro-preview-05-06 ' ,
764
+ model_name = 'models/gemini-2.5-pro' ,
755
765
timestamp = IsDatetime (),
756
766
vendor_details = {'finish_reason' : 'STOP' },
757
767
),
@@ -767,15 +777,15 @@ async def test_tool_returning_audio_resource_link(
767
777
]
768
778
),
769
779
ModelResponse (
770
- parts = [TextPart (content = 'The audio resource contains a voice saying "Hello, my name is Marcelo." ' )],
780
+ parts = [TextPart (content = '00:05 ' )],
771
781
usage = Usage (
772
782
requests = 1 ,
773
- request_tokens = 575 ,
774
- response_tokens = 15 ,
775
- total_tokens = 590 ,
776
- details = {'text_prompt_tokens' : 431 , 'audio_prompt_tokens' : 144 },
783
+ request_tokens = 784 ,
784
+ response_tokens = 5 ,
785
+ total_tokens = 789 ,
786
+ details = {'text_prompt_tokens' : 640 , 'audio_prompt_tokens' : 144 },
777
787
),
778
- model_name = 'models/gemini-2.5-pro-preview-05-06 ' ,
788
+ model_name = 'models/gemini-2.5-pro' ,
779
789
timestamp = IsDatetime (),
780
790
vendor_details = {'finish_reason' : 'STOP' },
781
791
),
0 commit comments