-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
genai[patch]: fix standard tests (#480)
Existing tests do not run because they don't start with a `Test` prefix. Here we separate them into their own modules and get them in a running state.
- Loading branch information
Showing
4 changed files
with
72 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
"""Standard LangChain interface tests""" | ||
|
||
from typing import Type | ||
|
||
import pytest | ||
from langchain_core.language_models import BaseChatModel | ||
from langchain_core.rate_limiters import InMemoryRateLimiter | ||
from langchain_standard_tests.integration_tests import ChatModelIntegrationTests | ||
|
||
from langchain_google_genai import ChatGoogleGenerativeAI | ||
|
||
rate_limiter = InMemoryRateLimiter(requests_per_second=0.25) | ||
|
||
|
||
class TestGeminiAIStandard(ChatModelIntegrationTests): | ||
@property | ||
def chat_model_class(self) -> Type[BaseChatModel]: | ||
return ChatGoogleGenerativeAI | ||
|
||
@property | ||
def chat_model_params(self) -> dict: | ||
return { | ||
"model": "models/gemini-1.0-pro-001", | ||
"rate_limiter": rate_limiter, | ||
} | ||
|
||
@pytest.mark.xfail(reason="Gemini 1.0 doesn't support tool_choice='any'") | ||
def test_structured_few_shot_examples(self, model: BaseChatModel) -> None: | ||
super().test_structured_few_shot_examples(model) | ||
|
||
@pytest.mark.xfail(reason="with_structured_output with JSON schema not supported.") | ||
def test_structured_output(self, model: BaseChatModel) -> None: | ||
super().test_structured_output(model) | ||
|
||
@pytest.mark.xfail(reason="with_structured_output with JSON schema not supported.") | ||
def test_structured_output_pydantic_2_v1(self, model: BaseChatModel) -> None: | ||
super().test_structured_output_pydantic_2_v1(model) | ||
|
||
@pytest.mark.xfail(reason="Not yet supported") | ||
def test_tool_message_histories_list_content(self, model: BaseChatModel) -> None: | ||
super().test_tool_message_histories_list_content(model) | ||
|
||
|
||
# TODO: increase quota on gemini-1.5-pro-001 and test as well |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from typing import Type | ||
|
||
from langchain_core.language_models import BaseChatModel | ||
from langchain_standard_tests.unit_tests import ChatModelUnitTests | ||
|
||
from langchain_google_genai import ChatGoogleGenerativeAI | ||
|
||
|
||
class TestGeminiAIStandard(ChatModelUnitTests): | ||
@property | ||
def chat_model_class(self) -> Type[BaseChatModel]: | ||
return ChatGoogleGenerativeAI | ||
|
||
@property | ||
def chat_model_params(self) -> dict: | ||
return {"model": "models/gemini-1.0-pro-001"} | ||
|
||
|
||
class TestGemini_15_AIStandard(ChatModelUnitTests): | ||
@property | ||
def chat_model_class(self) -> Type[BaseChatModel]: | ||
return ChatGoogleGenerativeAI | ||
|
||
@property | ||
def chat_model_params(self) -> dict: | ||
return {"model": "models/gemini-1.5-pro-001"} |