together: Add rate limiter to integration tests (#24714)

Rate limit the integration tests to avoid getting 429s.
This commit is contained in:
Eugene Yurtsev 2024-07-26 10:59:33 -04:00 committed by GitHub
parent e00cc74926
commit 03d62a737a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -4,12 +4,17 @@ from typing import Type
import pytest
from langchain_core.language_models import BaseChatModel
from langchain_standard_tests.integration_tests import ( # type: ignore[import-not-found]
ChatModelIntegrationTests, # type: ignore[import-not-found]
)
from langchain_core.rate_limiters import InMemoryRateLimiter
from langchain_standard_tests.integration_tests import ChatModelIntegrationTests
from langchain_together import ChatTogether
# Initialize the rate limiter in global scope, so it can be re-used
# across tests.
rate_limiter = InMemoryRateLimiter(
requests_per_second=0.5,
)
class TestTogetherStandard(ChatModelIntegrationTests):
@property
@ -18,7 +23,10 @@ class TestTogetherStandard(ChatModelIntegrationTests):
@property
def chat_model_params(self) -> dict:
return {"model": "mistralai/Mistral-7B-Instruct-v0.1"}
return {
"model": "mistralai/Mistral-7B-Instruct-v0.1",
"rate_limiter": rate_limiter,
}
@pytest.mark.xfail(reason=("May not call a tool."))
def test_tool_calling_with_no_arguments(self, model: BaseChatModel) -> None: