File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
libs/partners/anthropic/tests/unit_tests Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change 1
1
"""Standard LangChain interface tests"""
2
2
3
+ import pytest
3
4
from langchain_core .language_models import BaseChatModel
4
5
from langchain_tests .unit_tests import ChatModelUnitTests
6
+ from pytest_benchmark .fixture import BenchmarkFixture # type: ignore[import-untyped]
5
7
6
8
from langchain_anthropic import ChatAnthropic
7
9
@@ -14,3 +16,16 @@ def chat_model_class(self) -> type[BaseChatModel]:
14
16
@property
15
17
def chat_model_params (self ) -> dict :
16
18
return {"model" : "claude-3-haiku-20240307" }
19
+
20
+
21
+ @pytest .mark .benchmark
22
+ def test_init_time_with_client (benchmark : BenchmarkFixture ) -> None :
23
+ """Test initialization time, accounting for lazy loading of client."""
24
+
25
+ def _init_in_loop_with_clients () -> None :
26
+ for _ in range (10 ):
27
+ llm = ChatAnthropic (model = "claude-3-5-haiku-latest" )
28
+ _ = llm ._client
29
+ _ = llm ._async_client
30
+
31
+ benchmark (_init_in_loop_with_clients )
You can’t perform that action at this time.
0 commit comments