Skip to content

Commit 0292246

Browse files
committed
fix tests
1 parent 3e387ba commit 0292246

File tree

7 files changed

+85
-138
lines changed

7 files changed

+85
-138
lines changed

libs/vertexai/langchain_google_vertexai/functions_utils.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,15 +248,21 @@ def _format_to_gapic_function_declaration(
248248
tool: _FunctionDeclarationLike,
249249
) -> gapic.FunctionDeclaration:
250250
"Format tool into the Vertex function declaration."
251+
print("_format_to_gapic_function_declaration")
252+
print(tool)
251253
if isinstance(tool, BaseTool):
252254
return _format_base_tool_to_function_declaration(tool)
253255
elif isinstance(tool, type) and issubclass(tool, BaseModel):
254256
return _format_pydantic_to_function_declaration(tool)
255-
elif callable(tool):
257+
elif callable(tool) and not (
258+
isinstance(tool, type) and hasattr(tool, "__annotations__")
259+
):
256260
return _format_base_tool_to_function_declaration(callable_as_lc_tool()(tool))
257261
elif isinstance(tool, vertexai.FunctionDeclaration):
258262
return _format_vertex_to_function_declaration(tool)
259-
elif isinstance(tool, dict):
263+
elif isinstance(tool, dict) or (
264+
isinstance(tool, type) and hasattr(tool, "__annotations__")
265+
):
260266
# this could come from
261267
# 'langchain_core.utils.function_calling.convert_to_openai_tool'
262268
function = convert_to_openai_tool(cast(dict, tool))["function"]

libs/vertexai/poetry.lock

Lines changed: 72 additions & 72 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libs/vertexai/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ license = "MIT"
1212

1313
[tool.poetry.dependencies]
1414
python = ">=3.9,<4.0"
15-
langchain-core = ">=0.3.27,<0.4"
15+
langchain-core = ">=0.3.31,<0.4"
1616
google-cloud-aiplatform = "^1.76.0"
1717
google-cloud-storage = "^2.18.0"
1818
# optional dependencies

libs/vertexai/tests/integration_tests/test_standard.py

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import pytest
66
from langchain_core.language_models import BaseChatModel
77
from langchain_core.rate_limiters import InMemoryRateLimiter
8-
from langchain_core.tools import BaseTool
98
from langchain_tests.integration_tests import ChatModelIntegrationTests
109

1110
from langchain_google_vertexai import ChatVertexAI
@@ -41,28 +40,6 @@ def supports_audio_inputs(self) -> bool:
4140
return True
4241

4342

44-
@pytest.mark.first
45-
class TestGeminiAIStandard(ChatModelIntegrationTests):
46-
@property
47-
def chat_model_class(self) -> Type[BaseChatModel]:
48-
return ChatVertexAI
49-
50-
@property
51-
def chat_model_params(self) -> dict:
52-
return {
53-
"model_name": "gemini-1.0-pro-001",
54-
"rate_limiter": rate_limiter,
55-
"temperature": 0,
56-
"api_transport": None,
57-
}
58-
59-
@pytest.mark.xfail(reason="Gemini 1.0 doesn't support tool_choice='any'")
60-
def test_structured_few_shot_examples(
61-
self, model: BaseChatModel, my_adder_tool: BaseTool
62-
) -> None:
63-
super().test_structured_few_shot_examples(model, my_adder_tool)
64-
65-
6643
class TestGemini_15_AIStandard(ChatModelIntegrationTests):
6744
@property
6845
def chat_model_class(self) -> Type[BaseChatModel]:
@@ -71,7 +48,7 @@ def chat_model_class(self) -> Type[BaseChatModel]:
7148
@property
7249
def chat_model_params(self) -> dict:
7350
return {
74-
"model_name": "gemini-1.5-pro-001",
51+
"model_name": "gemini-1.5-pro-002",
7552
"rate_limiter": rate_limiter,
7653
"temperature": 0,
7754
"api_transport": None,

libs/vertexai/tests/unit_tests/__snapshots__/test_standard.ambr

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,4 @@
11
# serializer version: 1
2-
# name: TestGeminiAIStandard.test_serdes[serialized]
3-
dict({
4-
'id': list([
5-
'langchain',
6-
'chat_models',
7-
'vertexai',
8-
'ChatVertexAI',
9-
]),
10-
'kwargs': dict({
11-
'default_metadata': list([
12-
]),
13-
'location': 'us-central1',
14-
'max_output_tokens': 100,
15-
'max_retries': 2,
16-
'model_family': '1',
17-
'model_name': 'gemini-1.0-pro-001',
18-
'n': 1,
19-
'project': 'test-project',
20-
'request_parallelism': 5,
21-
'stop': list([
22-
]),
23-
'temperature': 0.0,
24-
}),
25-
'lc': 1,
26-
'name': 'ChatVertexAI',
27-
'type': 'constructor',
28-
})
29-
# ---
302
# name: TestGemini_15_AIStandard.test_serdes[serialized]
313
dict({
324
'id': list([

libs/vertexai/tests/unit_tests/test_chat_models.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929
PydanticToolsParser,
3030
)
3131
from pydantic import BaseModel
32-
from vertexai.generative_models import SafetySetting as VertexSafetySetting
32+
from vertexai.generative_models import ( # type: ignore
33+
SafetySetting as VertexSafetySetting,
34+
)
3335
from vertexai.language_models import ( # type: ignore
3436
ChatMessage,
3537
InputOutputTextPair,

libs/vertexai/tests/unit_tests/test_standard.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,6 @@
66
from langchain_google_vertexai import ChatVertexAI
77

88

9-
class TestGeminiAIStandard(ChatModelUnitTests):
10-
@property
11-
def chat_model_class(self) -> Type[BaseChatModel]:
12-
return ChatVertexAI
13-
14-
@property
15-
def chat_model_params(self) -> dict:
16-
return {"model_name": "gemini-1.0-pro-001"}
17-
18-
199
class TestGemini_15_AIStandard(ChatModelUnitTests):
2010
@property
2111
def chat_model_class(self) -> Type[BaseChatModel]:

0 commit comments

Comments
 (0)