Skip to content

Commit

Permalink
core,standard-tests[patch]: add Ser/Des test and update serialization…
Browse files Browse the repository at this point in the history
… mapping (#26042)
  • Loading branch information
baskaryan authored Sep 4, 2024
2 parents af11fbf + 1241a00 commit de97d50
Show file tree
Hide file tree
Showing 47 changed files with 3,100 additions and 2,083 deletions.
3 changes: 3 additions & 0 deletions libs/cli/langchain_cli/integration_template/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ integration_test integration_tests: TEST_FILE = tests/integration_tests/
test tests:
poetry run pytest --disable-socket --allow-unix-socket $(TEST_FILE)

test_watch:
poetry run ptw --snapshot-update --now . -- -vv $(TEST_FILE)

# integration tests are run without the --disable-socket flag to allow network calls
integration_test integration_tests:
poetry run pytest $(TEST_FILE)
Expand Down
1 change: 1 addition & 0 deletions libs/cli/langchain_cli/integration_template/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pytest = "^7.4.3"
pytest-asyncio = "^0.23.2"
pytest-socket = "^0.7.0"
langchain-core = { path = "../../core", develop = true }
pytest-watcher = "^0.3.4"

[tool.poetry.group.codespell]
optional = true
Expand Down
10 changes: 10 additions & 0 deletions libs/community/tests/unit_tests/load/test_serializable.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,16 @@ def test_serializable_mapping() -> None:
"modifier",
"RemoveMessage",
),
("langchain", "chat_models", "mistralai", "ChatMistralAI"): (
"langchain_mistralai",
"chat_models",
"ChatMistralAI",
),
("langchain_groq", "chat_models", "ChatGroq"): (
"langchain_groq",
"chat_models",
"ChatGroq",
),
}
serializable_modules = import_all_modules("langchain")

Expand Down
1 change: 1 addition & 0 deletions libs/core/langchain_core/load/load.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"langchain_core",
"langchain_community",
"langchain_anthropic",
"langchain_groq",
]

ALL_SERIALIZABLE_MAPPINGS = {
Expand Down
10 changes: 10 additions & 0 deletions libs/core/langchain_core/load/mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,11 @@
"chat_models",
"ChatAnthropic",
),
("langchain_groq", "chat_models", "ChatGroq"): (
"langchain_groq",
"chat_models",
"ChatGroq",
),
("langchain", "chat_models", "fireworks", "ChatFireworks"): (
"langchain_fireworks",
"chat_models",
Expand All @@ -287,6 +292,11 @@
"chat_models",
"ChatVertexAI",
),
("langchain", "chat_models", "mistralai", "ChatMistralAI"): (
"langchain_mistralai",
"chat_models",
"ChatMistralAI",
),
("langchain", "schema", "output", "ChatGenerationChunk"): (
"langchain_core",
"outputs",
Expand Down
4 changes: 4 additions & 0 deletions libs/partners/airbyte/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ integration_test integration_tests: TEST_FILE = tests/integration_tests/
test tests integration_test integration_tests:
poetry run pytest $(TEST_FILE)

test_watch:
poetry run ptw --snapshot-update --now . -- -vv $(TEST_FILE)


######################
# LINTING AND FORMATTING
######################
Expand Down
3 changes: 3 additions & 0 deletions libs/partners/anthropic/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ integration_test integration_tests: TEST_FILE=tests/integration_tests/
test tests integration_test integration_tests:
poetry run pytest $(TEST_FILE)

test_watch:
poetry run ptw --snapshot-update --now . -- -vv $(TEST_FILE)


######################
# LINTING AND FORMATTING
Expand Down
113 changes: 58 additions & 55 deletions libs/partners/anthropic/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# serializer version: 1
# name: TestAnthropicStandard.test_serdes[serialized]
dict({
'graph': dict({
'edges': list([
dict({
'source': 0,
'target': 1,
}),
dict({
'source': 1,
'target': 2,
}),
]),
'nodes': list([
dict({
'data': 'ChatAnthropicInput',
'id': 0,
'type': 'schema',
}),
dict({
'data': dict({
'id': list([
'langchain',
'chat_models',
'anthropic',
'ChatAnthropic',
]),
'name': 'ChatAnthropic',
}),
'id': 1,
'type': 'runnable',
}),
dict({
'data': 'ChatAnthropicOutput',
'id': 2,
'type': 'schema',
}),
]),
}),
'id': list([
'langchain',
'chat_models',
'anthropic',
'ChatAnthropic',
]),
'kwargs': dict({
'anthropic_api_key': dict({
'id': list([
'ANTHROPIC_API_KEY',
]),
'lc': 1,
'type': 'secret',
}),
'anthropic_api_url': 'https://api.anthropic.com',
'default_request_timeout': 60.0,
'max_retries': 2,
'max_tokens': 100,
'model': 'claude-3-haiku-20240307',
'stop_sequences': list([
]),
'stream_usage': True,
'temperature': 0.0,
}),
'lc': 1,
'name': 'ChatAnthropic',
'type': 'constructor',
})
# ---
3 changes: 3 additions & 0 deletions libs/partners/azure-dynamic-sessions/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ test:
tests:
poetry run pytest $(TEST_FILE)

test_watch:
poetry run ptw --snapshot-update --now . -- -vv $(TEST_FILE)


######################
# LINTING AND FORMATTING
Expand Down
Loading

0 comments on commit de97d50

Please sign in to comment.