langchain/libs/partners/ai21/tests/integration_tests/test_standard.py
Bagatur d96f67b06f
standard-tests[patch]: Update chat model standard tests (#22378)
- Refactor standard test classes to make them easier to configure
- Update openai to support stop_sequences init param
- Update groq to support stop_sequences init param
- Update fireworks to support max_retries init param
- Update ChatModel.bind_tools to type tool_choice
- Update groq to handle tool_choice="any". **this may be controversial**

---------

Co-authored-by: Chester Curme <chester.curme@gmail.com>
2024-06-17 13:37:41 -07:00

49 lines
1.3 KiB
Python

"""Standard LangChain interface tests"""
import time
from typing import Type
import pytest
from langchain_core.language_models import BaseChatModel
from langchain_standard_tests.integration_tests import ChatModelIntegrationTests
from langchain_ai21 import ChatAI21
class BaseTestAI21(ChatModelIntegrationTests):
def teardown(self) -> None:
# avoid getting rate limited
time.sleep(1)
@property
def chat_model_class(self) -> Type[BaseChatModel]:
return ChatAI21
@pytest.mark.xfail(reason="Emits AIMessage instead of AIMessageChunk.")
def test_stream(self, model: BaseChatModel) -> None:
super().test_stream(model)
@pytest.mark.xfail(reason="Emits AIMessage instead of AIMessageChunk.")
async def test_astream(self, model: BaseChatModel) -> None:
await super().test_astream(model)
@pytest.mark.xfail(reason="Not implemented.")
def test_usage_metadata(self, model: BaseChatModel) -> None:
super().test_usage_metadata(model)
class TestAI21J2(BaseTestAI21):
@property
def chat_model_params(self) -> dict:
return {
"model": "j2-ultra",
}
class TestAI21Jamba(BaseTestAI21):
@property
def chat_model_params(self) -> dict:
return {
"model": "jamba-instruct-preview",
}