File tree 3 files changed +46
-1
lines changed
3 files changed +46
-1
lines changed Original file line number Diff line number Diff line change @@ -76,6 +76,7 @@ ruff = "^0.5"
76
76
77
77
[tool .poetry .group .typing .dependencies ]
78
78
mypy = " ^1.10"
79
+ types-requests = " ^2.32.0.20241016"
79
80
80
81
[tool .poetry .group .test .dependencies .langchain-core ]
81
82
path = " ../../core"
@@ -89,6 +90,8 @@ develop = true
89
90
path = " ../../core"
90
91
develop = true
91
92
93
+ [tool .poetry .group .test_integration .dependencies ]
94
+ requests = " ^2.32.3"
92
95
[tool .poetry .group .test_integration .dependencies .langchain-core ]
93
96
path = " ../../core"
94
97
develop = true
Original file line number Diff line number Diff line change 1
1
"""Test ChatAnthropic chat model."""
2
2
3
3
import json
4
+ from base64 import b64encode
4
5
from typing import List , Optional
5
6
6
7
import pytest
8
+ import requests
7
9
from langchain_core .callbacks import CallbackManager
8
10
from langchain_core .messages import (
9
11
AIMessage ,
@@ -575,3 +577,29 @@ def test_anthropic_bind_tools_tool_choice(tool_choice: str) -> None:
575
577
chat_model_with_tools = chat_model .bind_tools ([GetWeather ], tool_choice = tool_choice )
576
578
response = chat_model_with_tools .invoke ("what's the weather in ny and la" )
577
579
assert isinstance (response , AIMessage )
580
+
581
+
582
+ def test_pdf_document_input () -> None :
583
+ url = "https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf"
584
+ data = b64encode (requests .get (url ).content ).decode ()
585
+
586
+ result = ChatAnthropic (model_name = MODEL_NAME ).invoke ( # type: ignore[call-arg]
587
+ [
588
+ HumanMessage (
589
+ [
590
+ "summarize this document" ,
591
+ {
592
+ "type" : "document" ,
593
+ "source" : {
594
+ "type" : "base64" ,
595
+ "data" : data ,
596
+ "media_type" : "application/pdf" ,
597
+ },
598
+ },
599
+ ]
600
+ )
601
+ ]
602
+ )
603
+ assert isinstance (result , AIMessage )
604
+ assert isinstance (result .content , str )
605
+ assert len (result .content ) > 0
You can’t perform that action at this time.
0 commit comments