Skip to content

Commit

Permalink
standard-tests: rename langchain_standard_tests to langchain_tests, r…
Browse files Browse the repository at this point in the history
…elease 0.3.2 (#28203)
  • Loading branch information
efriis authored Nov 19, 2024
1 parent 24eea2e commit 0dbaf05
Show file tree
Hide file tree
Showing 60 changed files with 70 additions and 83 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -219,11 +219,7 @@ jobs:
# Replace all dashes in the package name with underscores,
# since that's how Python imports packages with dashes in the name.
if [ "$PKG_NAME" == "langchain-tests" ]; then
IMPORT_NAME="langchain_standard_tests"
else
IMPORT_NAME="$(echo "$PKG_NAME" | sed s/-/_/g)"
fi
IMPORT_NAME="$(echo "$PKG_NAME" | sed s/-/_/g)"
poetry run python -c "import $IMPORT_NAME; print(dir($IMPORT_NAME))"
Expand Down
20 changes: 7 additions & 13 deletions docs/docs/contributing/how_to/integrations/standard_tests.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,10 @@
"First, let's install 2 dependencies:\n",
"\n",
"- `langchain-core` will define the interfaces we want to import to define our custom tool.\n",
"- `langchain-tests==0.3.0` will provide the standard tests we want to use.\n",
"- `langchain-tests==0.3.2` will provide the standard tests we want to use.\n",
"\n",
":::note\n",
"\n",
"The `langchain-tests` package contains the module `langchain_standard_tests`. This name\n",
"mistmatch is due to this package historically being called `langchain_standard_tests` and\n",
"the name not being available on PyPi. This will either be reconciled by our \n",
"[PEP 541 request](https://github.com/pypi/support/issues/5062) (we welcome upvotes!), \n",
"or in a new release of `langchain-tests`.\n",
"\n",
"Because added tests in new versions of `langchain-tests` will always break your CI/CD pipelines, we recommend pinning the \n",
"version of `langchain-tests==0.3.0` to avoid unexpected changes.\n",
"\n",
Expand Down Expand Up @@ -91,8 +85,8 @@
"\n",
"There are 2 namespaces in the `langchain-tests` package: \n",
"\n",
"- unit tests (`langchain_standard_tests.unit_tests`): designed to be used to test the tool in isolation and without access to external services\n",
"- integration tests (`langchain_standard_tests.integration_tests`): designed to be used to test the tool with access to external services (in particular, the external service that the tool is designed to interact with).\n",
"- unit tests (`langchain_tests.unit_tests`): designed to be used to test the tool in isolation and without access to external services\n",
"- integration tests (`langchain_tests.integration_tests`): designed to be used to test the tool with access to external services (in particular, the external service that the tool is designed to interact with).\n",
"\n",
":::note\n",
"\n",
Expand Down Expand Up @@ -122,7 +116,7 @@
"from typing import Type\n",
"\n",
"from langchain_parrot_link.tools import ParrotMultiplyTool\n",
"from langchain_standard_tests.unit_tests import ToolsUnitTests\n",
"from langchain_tests.unit_tests import ToolsUnitTests\n",
"\n",
"\n",
"class TestParrotMultiplyToolUnit(ToolsUnitTests):\n",
Expand Down Expand Up @@ -156,7 +150,7 @@
"from typing import Type\n",
"\n",
"from langchain_parrot_link.tools import ParrotMultiplyTool\n",
"from langchain_standard_tests.integration_tests import ToolsIntegrationTests\n",
"from langchain_tests.integration_tests import ToolsIntegrationTests\n",
"\n",
"\n",
"class TestParrotMultiplyToolIntegration(ToolsIntegrationTests):\n",
Expand Down Expand Up @@ -217,7 +211,7 @@
"from typing import Tuple, Type\n",
"\n",
"from langchain_parrot_link.chat_models import ChatParrotLink\n",
"from langchain_standard_tests.unit_tests import ChatModelUnitTests\n",
"from langchain_tests.unit_tests import ChatModelUnitTests\n",
"\n",
"\n",
"class TestChatParrotLinkUnit(ChatModelUnitTests):\n",
Expand All @@ -236,7 +230,7 @@
"from typing import Type\n",
"\n",
"from langchain_parrot_link.chat_models import ChatParrotLink\n",
"from langchain_standard_tests.integration_tests import ChatModelIntegrationTests\n",
"from langchain_tests.integration_tests import ChatModelIntegrationTests\n",
"\n",
"\n",
"class TestChatParrotLinkIntegration(ChatModelIntegrationTests):\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import pytest
from langchain_core.language_models import BaseChatModel
from langchain_standard_tests.integration_tests import ChatModelIntegrationTests
from langchain_tests.integration_tests import ChatModelIntegrationTests

from langchain_community.chat_models.litellm import ChatLiteLLM

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import pytest
from langchain_core.language_models import BaseChatModel
from langchain_standard_tests.integration_tests import ChatModelIntegrationTests
from langchain_tests.integration_tests import ChatModelIntegrationTests
from pydantic import SecretStr

from langchain_community.chat_models.moonshot import MoonshotChat
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pytest
from langchain_core.documents import Document
from langchain_standard_tests.integration_tests.base_store import BaseStoreSyncTests
from langchain_tests.integration_tests.base_store import BaseStoreSyncTests

from langchain_community.storage.mongodb import MongoDBByteStore, MongoDBStore

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import uuid

import pytest
from langchain_standard_tests.integration_tests.vectorstores import (
from langchain_tests.integration_tests.vectorstores import (
AsyncReadWriteTestSuite,
ReadWriteTestSuite,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
SystemMessage,
ToolMessage,
)
from langchain_standard_tests.unit_tests import ChatModelUnitTests
from langchain_tests.unit_tests import ChatModelUnitTests

from langchain_community.chat_models.cloudflare_workersai import (
ChatCloudflareWorkersAI,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import pytest
from langchain_core.language_models import BaseChatModel
from langchain_standard_tests.unit_tests import ChatModelUnitTests
from langchain_tests.unit_tests import ChatModelUnitTests

from langchain_community.chat_models.litellm import ChatLiteLLM

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import pytest
from langchain_core.documents import Document
from langchain_standard_tests.integration_tests.vectorstores import (
from langchain_tests.integration_tests.vectorstores import (
AsyncReadWriteTestSuite,
ReadWriteTestSuite,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from collections.abc import AsyncGenerator, Generator

import pytest
from langchain_standard_tests.integration_tests.indexer import (
from langchain_tests.integration_tests.indexer import (
AsyncDocumentIndexTestSuite,
DocumentIndexerTestSuite,
)
Expand Down
2 changes: 1 addition & 1 deletion libs/core/tests/unit_tests/stores/test_in_memory.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pytest
from langchain_standard_tests.integration_tests.base_store import (
from langchain_tests.integration_tests.base_store import (
BaseStoreAsyncTests,
BaseStoreSyncTests,
)
Expand Down
2 changes: 1 addition & 1 deletion libs/core/tests/unit_tests/vectorstores/test_in_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from unittest.mock import AsyncMock, Mock

import pytest
from langchain_standard_tests.integration_tests.vectorstores import (
from langchain_tests.integration_tests.vectorstores import (
AsyncReadWriteTestSuite,
ReadWriteTestSuite,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from langchain_core.messages import AIMessage
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.runnables import RunnableConfig
from langchain_standard_tests.integration_tests import ChatModelIntegrationTests
from langchain_tests.integration_tests import ChatModelIntegrationTests
from pydantic import BaseModel

from langchain.chat_models import init_chat_model
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from langchain_core.language_models import BaseChatModel
from langchain_core.messages import AIMessage
from langchain_standard_tests.integration_tests import ChatModelIntegrationTests
from langchain_tests.integration_tests import ChatModelIntegrationTests

from langchain_anthropic import ChatAnthropic

Expand Down
2 changes: 1 addition & 1 deletion libs/partners/anthropic/tests/unit_tests/test_standard.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import Type

from langchain_core.language_models import BaseChatModel
from langchain_standard_tests.unit_tests import ChatModelUnitTests
from langchain_tests.unit_tests import ChatModelUnitTests

from langchain_anthropic import ChatAnthropic

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import pytest
from langchain_core.language_models import BaseChatModel
from langchain_standard_tests.integration_tests import ( # type: ignore[import-not-found]
from langchain_tests.integration_tests import ( # type: ignore[import-not-found]
ChatModelIntegrationTests, # type: ignore[import-not-found]
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import Tuple, Type

from langchain_core.embeddings import Embeddings
from langchain_standard_tests.unit_tests.embeddings import EmbeddingsUnitTests
from langchain_tests.unit_tests.embeddings import EmbeddingsUnitTests

from langchain_fireworks import FireworksEmbeddings

Expand Down
2 changes: 1 addition & 1 deletion libs/partners/fireworks/tests/unit_tests/test_standard.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import Tuple, Type

from langchain_core.language_models import BaseChatModel
from langchain_standard_tests.unit_tests import ( # type: ignore[import-not-found]
from langchain_tests.unit_tests import ( # type: ignore[import-not-found]
ChatModelUnitTests, # type: ignore[import-not-found]
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ class Joke(BaseModel):


def test_tool_calling_no_arguments() -> None:
# Note: this is a variant of a test in langchain_standard_tests
# Note: this is a variant of a test in langchain_tests
# that as of 2024-08-19 fails with "Failed to call a function. Please
# adjust your prompt." when `tool_choice="any"` is specified, but
# passes when `tool_choice` is not specified.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import pytest
from langchain_core.language_models import BaseChatModel
from langchain_core.rate_limiters import InMemoryRateLimiter
from langchain_standard_tests.integration_tests import (
from langchain_tests.integration_tests import (
ChatModelIntegrationTests,
)

Expand Down
2 changes: 1 addition & 1 deletion libs/partners/groq/tests/unit_tests/test_standard.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import Type

from langchain_core.language_models import BaseChatModel
from langchain_standard_tests.unit_tests.chat_models import (
from langchain_tests.unit_tests.chat_models import (
ChatModelUnitTests,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from typing import Type

from langchain_standard_tests.integration_tests import EmbeddingsIntegrationTests
from langchain_tests.integration_tests import EmbeddingsIntegrationTests

from langchain_huggingface.embeddings import (
HuggingFaceEmbeddings,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import pytest
from langchain_core.language_models import BaseChatModel
from langchain_standard_tests.integration_tests import ChatModelIntegrationTests
from langchain_tests.integration_tests import ChatModelIntegrationTests

from langchain_huggingface import ChatHuggingFace, HuggingFaceEndpoint

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import Optional, Type

from langchain_core.language_models import BaseChatModel
from langchain_standard_tests.integration_tests import ( # type: ignore[import-not-found]
from langchain_tests.integration_tests import ( # type: ignore[import-not-found]
ChatModelIntegrationTests, # type: ignore[import-not-found]
)

Expand Down
2 changes: 1 addition & 1 deletion libs/partners/mistralai/tests/unit_tests/test_standard.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import Type

from langchain_core.language_models import BaseChatModel
from langchain_standard_tests.unit_tests import ( # type: ignore[import-not-found]
from langchain_tests.unit_tests import ( # type: ignore[import-not-found]
ChatModelUnitTests, # type: ignore[import-not-found]
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import pytest
from langchain_core.language_models import BaseChatModel
from langchain_standard_tests.integration_tests import ChatModelIntegrationTests
from langchain_tests.integration_tests import ChatModelIntegrationTests

from langchain_ollama.chat_models import ChatOllama

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from typing import Type

from langchain_standard_tests.integration_tests import EmbeddingsIntegrationTests
from langchain_tests.integration_tests import EmbeddingsIntegrationTests

from langchain_ollama.embeddings import OllamaEmbeddings

Expand Down
2 changes: 1 addition & 1 deletion libs/partners/ollama/tests/unit_tests/test_chat_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from typing import Dict, Type

from langchain_standard_tests.unit_tests import ChatModelUnitTests
from langchain_tests.unit_tests import ChatModelUnitTests

from langchain_ollama.chat_models import ChatOllama

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import pytest
from langchain_core.language_models import BaseChatModel
from langchain_standard_tests.integration_tests import ChatModelIntegrationTests
from langchain_tests.integration_tests import ChatModelIntegrationTests

from langchain_openai import AzureChatOpenAI

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@
)
from langchain_core.outputs import ChatGeneration, ChatResult, LLMResult
from langchain_core.prompts import ChatPromptTemplate
from langchain_standard_tests.integration_tests.chat_models import (
_validate_tool_call_message,
)
from langchain_standard_tests.integration_tests.chat_models import (
from langchain_tests.integration_tests.chat_models import _validate_tool_call_message
from langchain_tests.integration_tests.chat_models import (
magic_function as invalid_magic_function,
)
from pydantic import BaseModel, Field
Expand Down Expand Up @@ -1022,7 +1020,8 @@ def test_audio_input_modality() -> None:


def test_prediction_tokens() -> None:
code = dedent("""
code = dedent(
"""
/// <summary>
/// Represents a user with a first name, last name, and username.
/// </summary>
Expand All @@ -1043,7 +1042,8 @@ def test_prediction_tokens() -> None:
/// </summary>
public string Username { get; set; }
}
""")
"""
)

llm = ChatOpenAI(model="gpt-4o")
query = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from langchain_core.language_models import BaseChatModel
from langchain_core.messages import AIMessage
from langchain_standard_tests.integration_tests import ChatModelIntegrationTests
from langchain_tests.integration_tests import ChatModelIntegrationTests

from langchain_openai import ChatOpenAI

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import pytest
from langchain_core.language_models import BaseChatModel
from langchain_standard_tests.unit_tests import ChatModelUnitTests
from langchain_tests.unit_tests import ChatModelUnitTests

from langchain_openai import AzureChatOpenAI

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import Tuple, Type

from langchain_core.language_models import BaseChatModel
from langchain_standard_tests.unit_tests import ChatModelUnitTests
from langchain_tests.unit_tests import ChatModelUnitTests

from langchain_openai import ChatOpenAI

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Tuple, Type

from langchain_core.embeddings import Embeddings
from langchain_standard_tests.unit_tests.embeddings import EmbeddingsUnitTests
from langchain_tests.unit_tests.embeddings import EmbeddingsUnitTests

from langchain_openai import AzureOpenAIEmbeddings

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import Tuple, Type

from langchain_core.embeddings import Embeddings
from langchain_standard_tests.unit_tests.embeddings import EmbeddingsUnitTests
from langchain_tests.unit_tests.embeddings import EmbeddingsUnitTests

from langchain_openai import OpenAIEmbeddings

Expand Down
Loading

0 comments on commit 0dbaf05

Please sign in to comment.