langchain-core 1.2.2__tar.gz → 1.2.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {langchain_core-1.2.2 → langchain_core-1.2.7}/PKG-INFO +1 -1
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/_api/__init__.py +19 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/_api/deprecation.py +110 -81
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/_api/internal.py +2 -1
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/caches.py +1 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/callbacks/base.py +14 -13
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/callbacks/manager.py +1 -1
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/document_loaders/langsmith.py +3 -2
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/example_selectors/length_based.py +1 -1
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/indexing/api.py +11 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/language_models/base.py +22 -6
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/language_models/chat_models.py +29 -9
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/language_models/llms.py +4 -1
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/language_models/model_profile.py +1 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/load/__init__.py +10 -2
- langchain_core-1.2.7/langchain_core/load/_validation.py +176 -0
- langchain_core-1.2.7/langchain_core/load/dump.py +120 -0
- langchain_core-1.2.7/langchain_core/load/load.py +671 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/load/mapping.py +12 -19
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/load/serializable.py +9 -8
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/messages/ai.py +26 -26
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/messages/base.py +5 -2
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/messages/block_translators/anthropic.py +18 -8
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/messages/block_translators/bedrock.py +16 -2
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/messages/block_translators/bedrock_converse.py +16 -4
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/messages/block_translators/google_genai.py +20 -3
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/messages/block_translators/groq.py +16 -2
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/messages/block_translators/openai.py +44 -15
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/messages/content.py +199 -135
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/messages/utils.py +236 -73
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/output_parsers/base.py +3 -2
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/output_parsers/openai_functions.py +3 -3
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/output_parsers/pydantic.py +13 -3
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/prompt_values.py +18 -5
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/prompts/base.py +13 -13
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/prompts/chat.py +17 -10
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/prompts/dict.py +7 -4
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/prompts/few_shot_with_templates.py +2 -1
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/prompts/image.py +2 -2
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/prompts/message.py +1 -1
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/prompts/string.py +18 -10
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/prompts/structured.py +3 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/runnables/base.py +14 -5
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/runnables/config.py +3 -1
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/runnables/graph_ascii.py +3 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/runnables/graph_mermaid.py +11 -7
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/runnables/graph_png.py +4 -3
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/runnables/history.py +4 -4
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/runnables/passthrough.py +10 -16
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/runnables/router.py +4 -4
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/runnables/utils.py +9 -3
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/tools/base.py +45 -9
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/tools/convert.py +2 -2
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/tools/retriever.py +4 -2
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/tools/simple.py +3 -2
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/tools/structured.py +3 -2
- langchain_core-1.2.7/langchain_core/tracers/_compat.py +93 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/tracers/context.py +1 -1
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/tracers/core.py +14 -4
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/tracers/evaluation.py +4 -3
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/tracers/event_stream.py +8 -8
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/tracers/langchain.py +59 -7
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/tracers/log_stream.py +4 -4
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/tracers/run_collector.py +2 -1
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/utils/_merge.py +11 -12
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/utils/aiter.py +1 -1
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/utils/env.py +2 -2
- langchain_core-1.2.7/langchain_core/utils/formatting.py +80 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/utils/function_calling.py +29 -28
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/utils/html.py +8 -2
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/utils/input.py +3 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/utils/json.py +24 -2
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/utils/json_schema.py +20 -2
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/utils/mustache.py +22 -3
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/utils/pydantic.py +13 -12
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/utils/usage.py +21 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/utils/uuid.py +3 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/vectorstores/__init__.py +19 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/vectorstores/in_memory.py +1 -1
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/vectorstores/utils.py +2 -2
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/version.py +1 -1
- {langchain_core-1.2.2 → langchain_core-1.2.7}/pyproject.toml +4 -10
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/benchmarks/test_async_callbacks.py +1 -1
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/benchmarks/test_imports.py +1 -1
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/_api/test_deprecation.py +85 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/callbacks/test_sync_callback_manager.py +0 -5
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/document_loaders/test_langsmith.py +3 -1
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/example_selectors/test_base.py +1 -1
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/example_selectors/test_length_based_example_selector.py +15 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/fake/callbacks.py +4 -2
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/language_models/chat_models/test_base.py +18 -25
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/language_models/chat_models/test_cache.py +59 -1
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/load/test_imports.py +8 -1
- langchain_core-1.2.7/tests/unit_tests/load/test_secret_injection.py +431 -0
- langchain_core-1.2.7/tests/unit_tests/load/test_serializable.py +893 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/messages/block_translators/test_openai.py +15 -14
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/messages/test_ai.py +2 -2
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/messages/test_utils.py +187 -4
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/output_parsers/test_openai_tools.py +11 -7
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/output_parsers/test_pydantic_parser.py +6 -10
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/outputs/test_chat_generation.py +4 -2
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/prompts/__snapshots__/test_chat.ambr +0 -20
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/prompts/test_chat.py +323 -47
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/prompts/test_dict.py +1 -1
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/prompts/test_few_shot.py +5 -3
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/prompts/test_image.py +2 -2
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/prompts/test_loading.py +1 -1
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/prompts/test_prompt.py +2 -2
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/prompts/test_structured.py +4 -6
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/pydantic_utils.py +23 -22
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/runnables/__snapshots__/test_graph.ambr +0 -10
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/runnables/__snapshots__/test_runnable.ambr +0 -80
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/runnables/test_concurrency.py +2 -2
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/runnables/test_config.py +2 -2
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/runnables/test_fallbacks.py +21 -21
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/runnables/test_graph.py +45 -2
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/runnables/test_history.py +8 -9
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/runnables/test_runnable.py +62 -55
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/runnables/test_runnable_events_v1.py +9 -13
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/runnables/test_runnable_events_v2.py +5 -11
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/runnables/test_tracing_interops.py +16 -8
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/runnables/test_utils.py +6 -5
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/stores/test_in_memory.py +3 -1
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/test_messages.py +30 -6
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/test_tools.py +309 -44
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/tracers/test_async_base_tracer.py +63 -46
- langchain_core-1.2.7/tests/unit_tests/tracers/test_automatic_metadata.py +155 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/tracers/test_base_tracer.py +63 -46
- langchain_core-1.2.7/tests/unit_tests/tracers/test_langchain.py +570 -0
- langchain_core-1.2.7/tests/unit_tests/utils/test_formatting.py +127 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/utils/test_function_calling.py +11 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/utils/test_json_schema.py +78 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/utils/test_utils.py +104 -1
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/vectorstores/test_in_memory.py +1 -1
- {langchain_core-1.2.2 → langchain_core-1.2.7}/uv.lock +142 -68
- langchain_core-1.2.2/langchain_core/load/dump.py +0 -82
- langchain_core-1.2.2/langchain_core/load/load.py +0 -289
- langchain_core-1.2.2/langchain_core/utils/formatting.py +0 -51
- langchain_core-1.2.2/tests/unit_tests/load/test_serializable.py +0 -367
- langchain_core-1.2.2/tests/unit_tests/tracers/test_langchain.py +0 -147
- {langchain_core-1.2.2 → langchain_core-1.2.7}/.gitignore +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/Makefile +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/README.md +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/extended_testing_deps.txt +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/__init__.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/_api/beta_decorator.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/_api/path.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/_import_utils.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/agents.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/callbacks/__init__.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/callbacks/file.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/callbacks/stdout.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/callbacks/streaming_stdout.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/callbacks/usage.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/chat_history.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/chat_loaders.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/chat_sessions.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/document_loaders/__init__.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/document_loaders/base.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/document_loaders/blob_loaders.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/documents/__init__.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/documents/base.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/documents/compressor.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/documents/transformers.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/embeddings/__init__.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/embeddings/embeddings.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/embeddings/fake.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/env.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/example_selectors/__init__.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/example_selectors/base.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/example_selectors/semantic_similarity.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/exceptions.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/globals.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/indexing/__init__.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/indexing/base.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/indexing/in_memory.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/language_models/__init__.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/language_models/_utils.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/language_models/fake.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/language_models/fake_chat_models.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/messages/__init__.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/messages/block_translators/__init__.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/messages/block_translators/google_vertexai.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/messages/block_translators/langchain_v0.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/messages/chat.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/messages/function.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/messages/human.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/messages/modifier.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/messages/system.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/messages/tool.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/output_parsers/__init__.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/output_parsers/format_instructions.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/output_parsers/json.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/output_parsers/list.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/output_parsers/openai_tools.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/output_parsers/string.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/output_parsers/transform.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/output_parsers/xml.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/outputs/__init__.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/outputs/chat_generation.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/outputs/chat_result.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/outputs/generation.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/outputs/llm_result.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/outputs/run_info.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/prompts/__init__.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/prompts/few_shot.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/prompts/loading.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/prompts/prompt.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/py.typed +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/rate_limiters.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/retrievers.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/runnables/__init__.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/runnables/branch.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/runnables/configurable.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/runnables/fallbacks.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/runnables/graph.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/runnables/retry.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/runnables/schema.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/stores.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/structured_query.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/sys_info.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/tools/__init__.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/tools/render.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/tracers/__init__.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/tracers/_streaming.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/tracers/base.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/tracers/memory_stream.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/tracers/root_listeners.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/tracers/schemas.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/tracers/stdout.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/utils/__init__.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/utils/image.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/utils/interactive_env.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/utils/iter.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/utils/strings.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/utils/utils.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/langchain_core/vectorstores/base.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/scripts/check_imports.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/scripts/lint_imports.sh +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/__init__.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/benchmarks/__init__.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/integration_tests/__init__.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/integration_tests/test_compile.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/__init__.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/_api/__init__.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/_api/test_beta_decorator.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/_api/test_imports.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/_api/test_path.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/caches/__init__.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/caches/test_in_memory_cache.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/callbacks/__init__.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/callbacks/test_async_callback_manager.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/callbacks/test_dispatch_custom_event.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/callbacks/test_imports.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/callbacks/test_usage_callback.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/chat_history/__init__.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/chat_history/test_chat_history.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/conftest.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/data/prompt_file.txt +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/data/prompts/prompt_extra_args.json +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/data/prompts/prompt_missing_args.json +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/data/prompts/simple_prompt.json +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/dependencies/__init__.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/dependencies/test_dependencies.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/document_loaders/__init__.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/document_loaders/test_base.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/documents/__init__.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/documents/test_document.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/documents/test_imports.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/documents/test_str.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/embeddings/__init__.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/embeddings/test_deterministic_embedding.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/example_selectors/__init__.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/example_selectors/test_imports.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/example_selectors/test_similarity.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/examples/example-non-utf8.csv +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/examples/example-non-utf8.txt +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/examples/example-utf8.csv +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/examples/example-utf8.txt +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/examples/example_prompt.json +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/examples/examples.json +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/examples/examples.yaml +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/examples/few_shot_prompt.json +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/examples/few_shot_prompt.yaml +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/examples/few_shot_prompt_example_prompt.json +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/examples/few_shot_prompt_examples_in.json +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/examples/few_shot_prompt_yaml_examples.yaml +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/examples/jinja_injection_prompt.json +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/examples/jinja_injection_prompt.yaml +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/examples/prompt_with_output_parser.json +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/examples/simple_prompt.json +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/examples/simple_prompt.yaml +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/examples/simple_prompt_with_template_file.json +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/examples/simple_template.txt +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/fake/__init__.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/fake/test_fake_chat_model.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/indexing/__init__.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/indexing/test_hashed_document.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/indexing/test_in_memory_indexer.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/indexing/test_in_memory_record_manager.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/indexing/test_indexing.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/indexing/test_public_api.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/language_models/__init__.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/language_models/chat_models/__init__.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/language_models/chat_models/test_benchmark.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/language_models/chat_models/test_rate_limiting.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/language_models/llms/__init__.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/language_models/llms/test_base.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/language_models/llms/test_cache.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/language_models/test_imports.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/load/__init__.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/messages/__init__.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/messages/block_translators/__init__.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/messages/block_translators/test_anthropic.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/messages/block_translators/test_bedrock.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/messages/block_translators/test_bedrock_converse.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/messages/block_translators/test_google_genai.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/messages/block_translators/test_groq.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/messages/block_translators/test_langchain_v0.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/messages/block_translators/test_registration.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/messages/test_imports.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/output_parsers/__init__.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/output_parsers/test_base_parsers.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/output_parsers/test_imports.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/output_parsers/test_json.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/output_parsers/test_list_parser.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/output_parsers/test_openai_functions.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/output_parsers/test_xml_parser.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/outputs/__init__.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/outputs/test_imports.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/prompt_file.txt +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/prompts/__init__.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/prompts/__snapshots__/test_prompt.ambr +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/prompts/prompt_extra_args.json +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/prompts/prompt_missing_args.json +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/prompts/simple_prompt.json +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/prompts/test_few_shot_with_templates.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/prompts/test_imports.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/prompts/test_string.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/prompts/test_utils.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/rate_limiters/__init__.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/rate_limiters/test_in_memory_rate_limiter.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/runnables/__init__.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/runnables/__snapshots__/test_fallbacks.ambr +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/runnables/test_configurable.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/runnables/test_imports.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/stores/__init__.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/stubs.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/test_globals.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/test_imports.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/test_outputs.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/test_prompt_values.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/test_pydantic_imports.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/test_pydantic_serde.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/test_retrievers.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/test_setup.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/test_sys_info.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/tracers/__init__.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/tracers/test_imports.py +2 -2
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/tracers/test_memory_stream.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/tracers/test_run_collector.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/tracers/test_schemas.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/utils/__init__.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/utils/test_aiter.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/utils/test_env.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/utils/test_html.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/utils/test_imports.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/utils/test_iter.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/utils/test_pydantic.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/utils/test_rm_titles.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/utils/test_strings.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/utils/test_usage.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/utils/test_uuid_utils.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/vectorstores/__init__.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/vectorstores/test_utils.py +0 -0
- {langchain_core-1.2.2 → langchain_core-1.2.7}/tests/unit_tests/vectorstores/test_vectorstore.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: langchain-core
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.7
|
|
4
4
|
Summary: Building applications with LLMs through composability
|
|
5
5
|
Project-URL: Homepage, https://docs.langchain.com/
|
|
6
6
|
Project-URL: Documentation, https://reference.langchain.com/python/langchain_core/
|
|
@@ -58,6 +58,20 @@ _dynamic_imports = {
|
|
|
58
58
|
|
|
59
59
|
|
|
60
60
|
def __getattr__(attr_name: str) -> object:
|
|
61
|
+
"""Dynamically import and return an attribute from a submodule.
|
|
62
|
+
|
|
63
|
+
This function enables lazy loading of API functions from submodules, reducing
|
|
64
|
+
initial import time and circular dependency issues.
|
|
65
|
+
|
|
66
|
+
Args:
|
|
67
|
+
attr_name: Name of the attribute to import.
|
|
68
|
+
|
|
69
|
+
Returns:
|
|
70
|
+
The imported attribute object.
|
|
71
|
+
|
|
72
|
+
Raises:
|
|
73
|
+
AttributeError: If the attribute is not a valid dynamic import.
|
|
74
|
+
"""
|
|
61
75
|
module_name = _dynamic_imports.get(attr_name)
|
|
62
76
|
result = import_attr(attr_name, module_name, __spec__.parent)
|
|
63
77
|
globals()[attr_name] = result
|
|
@@ -65,4 +79,9 @@ def __getattr__(attr_name: str) -> object:
|
|
|
65
79
|
|
|
66
80
|
|
|
67
81
|
def __dir__() -> list[str]:
|
|
82
|
+
"""Return a list of available attributes for this module.
|
|
83
|
+
|
|
84
|
+
Returns:
|
|
85
|
+
List of attribute names that can be imported from this module.
|
|
86
|
+
"""
|
|
68
87
|
return list(__all__)
|
|
@@ -28,6 +28,27 @@ from pydantic.v1.fields import FieldInfo as FieldInfoV1
|
|
|
28
28
|
from langchain_core._api.internal import is_caller_internal
|
|
29
29
|
|
|
30
30
|
|
|
31
|
+
def _build_deprecation_message(
|
|
32
|
+
*,
|
|
33
|
+
alternative: str = "",
|
|
34
|
+
alternative_import: str = "",
|
|
35
|
+
) -> str:
|
|
36
|
+
"""Build a simple deprecation message for `__deprecated__` attribute.
|
|
37
|
+
|
|
38
|
+
Args:
|
|
39
|
+
alternative: An alternative API name.
|
|
40
|
+
alternative_import: A fully qualified import path for the alternative.
|
|
41
|
+
|
|
42
|
+
Returns:
|
|
43
|
+
A deprecation message string for IDE/type checker display.
|
|
44
|
+
"""
|
|
45
|
+
if alternative_import:
|
|
46
|
+
return f"Use {alternative_import} instead."
|
|
47
|
+
if alternative:
|
|
48
|
+
return f"Use {alternative} instead."
|
|
49
|
+
return "Deprecated."
|
|
50
|
+
|
|
51
|
+
|
|
31
52
|
class LangChainDeprecationWarning(DeprecationWarning):
|
|
32
53
|
"""A class for issuing deprecation warnings for LangChain users."""
|
|
33
54
|
|
|
@@ -81,60 +102,57 @@ def deprecated(
|
|
|
81
102
|
) -> Callable[[T], T]:
|
|
82
103
|
"""Decorator to mark a function, a class, or a property as deprecated.
|
|
83
104
|
|
|
84
|
-
When deprecating a classmethod, a staticmethod, or a property, the
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
underlying callable), but *over* `@property`.
|
|
105
|
+
When deprecating a classmethod, a staticmethod, or a property, the `@deprecated`
|
|
106
|
+
decorator should go *under* `@classmethod` and `@staticmethod` (i.e., `deprecated`
|
|
107
|
+
should directly decorate the underlying callable), but *over* `@property`.
|
|
88
108
|
|
|
89
|
-
When deprecating a class `C` intended to be used as a base class in a
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
own (deprecation-emitting) `C.__init__`).
|
|
109
|
+
When deprecating a class `C` intended to be used as a base class in a multiple
|
|
110
|
+
inheritance hierarchy, `C` *must* define an `__init__` method (if `C` instead
|
|
111
|
+
inherited its `__init__` from its own base class, then `@deprecated` would mess up
|
|
112
|
+
`__init__` inheritance when installing its own (deprecation-emitting) `C.__init__`).
|
|
94
113
|
|
|
95
|
-
Parameters are the same as for `warn_deprecated`, except that *obj_type*
|
|
96
|
-
|
|
97
|
-
|
|
114
|
+
Parameters are the same as for `warn_deprecated`, except that *obj_type* defaults to
|
|
115
|
+
'class' if decorating a class, 'attribute' if decorating a property, and 'function'
|
|
116
|
+
otherwise.
|
|
98
117
|
|
|
99
118
|
Args:
|
|
100
|
-
since:
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
and %(removal)s format specifiers will be replaced by the
|
|
119
|
+
since: The release at which this API became deprecated.
|
|
120
|
+
message: Override the default deprecation message.
|
|
121
|
+
|
|
122
|
+
The `%(since)s`, `%(name)s`, `%(alternative)s`, `%(obj_type)s`,
|
|
123
|
+
`%(addendum)s`, and `%(removal)s` format specifiers will be replaced by the
|
|
106
124
|
values of the respective arguments passed to this function.
|
|
107
|
-
name:
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
alternative_import:
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
obj_type:
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
package:
|
|
128
|
-
The package of the deprecated object.
|
|
125
|
+
name: The name of the deprecated object.
|
|
126
|
+
alternative: An alternative API that the user may use in place of the deprecated
|
|
127
|
+
API.
|
|
128
|
+
|
|
129
|
+
The deprecation warning will tell the user about this alternative if
|
|
130
|
+
provided.
|
|
131
|
+
alternative_import: An alternative import that the user may use instead.
|
|
132
|
+
pending: If `True`, uses a `PendingDeprecationWarning` instead of a
|
|
133
|
+
`DeprecationWarning`.
|
|
134
|
+
|
|
135
|
+
Cannot be used together with removal.
|
|
136
|
+
obj_type: The object type being deprecated.
|
|
137
|
+
addendum: Additional text appended directly to the final message.
|
|
138
|
+
removal: The expected removal version.
|
|
139
|
+
|
|
140
|
+
With the default (an empty string), a removal version is automatically
|
|
141
|
+
computed from since. Set to other Falsy values to not schedule a removal
|
|
142
|
+
date.
|
|
143
|
+
|
|
144
|
+
Cannot be used together with pending.
|
|
145
|
+
package: The package of the deprecated object.
|
|
129
146
|
|
|
130
147
|
Returns:
|
|
131
148
|
A decorator to mark a function or class as deprecated.
|
|
132
149
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
150
|
+
Example:
|
|
151
|
+
```python
|
|
152
|
+
@deprecated("1.4.0")
|
|
153
|
+
def the_function_to_deprecate():
|
|
154
|
+
pass
|
|
155
|
+
```
|
|
138
156
|
"""
|
|
139
157
|
_validate_deprecation_params(
|
|
140
158
|
removal, alternative, alternative_import, pending=pending
|
|
@@ -223,6 +241,11 @@ def deprecated(
|
|
|
223
241
|
obj.__init__ = functools.wraps(obj.__init__)( # type: ignore[misc]
|
|
224
242
|
warn_if_direct_instance
|
|
225
243
|
)
|
|
244
|
+
# Set __deprecated__ for PEP 702 (IDE/type checker support)
|
|
245
|
+
obj.__deprecated__ = _build_deprecation_message( # type: ignore[attr-defined]
|
|
246
|
+
alternative=alternative,
|
|
247
|
+
alternative_import=alternative_import,
|
|
248
|
+
)
|
|
226
249
|
return obj
|
|
227
250
|
|
|
228
251
|
elif isinstance(obj, FieldInfoV1):
|
|
@@ -315,12 +338,15 @@ def deprecated(
|
|
|
315
338
|
|
|
316
339
|
def finalize(wrapper: Callable[..., Any], new_doc: str) -> T: # noqa: ARG001
|
|
317
340
|
"""Finalize the property."""
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
_DeprecatedProperty(
|
|
321
|
-
fget=obj.fget, fset=obj.fset, fdel=obj.fdel, doc=new_doc
|
|
322
|
-
),
|
|
341
|
+
prop = _DeprecatedProperty(
|
|
342
|
+
fget=obj.fget, fset=obj.fset, fdel=obj.fdel, doc=new_doc
|
|
323
343
|
)
|
|
344
|
+
# Set __deprecated__ for PEP 702 (IDE/type checker support)
|
|
345
|
+
prop.__deprecated__ = _build_deprecation_message( # type: ignore[attr-defined]
|
|
346
|
+
alternative=alternative,
|
|
347
|
+
alternative_import=alternative_import,
|
|
348
|
+
)
|
|
349
|
+
return cast("T", prop)
|
|
324
350
|
|
|
325
351
|
else:
|
|
326
352
|
_name = _name or cast("type | Callable", obj).__qualname__
|
|
@@ -343,6 +369,11 @@ def deprecated(
|
|
|
343
369
|
"""
|
|
344
370
|
wrapper = functools.wraps(wrapped)(wrapper)
|
|
345
371
|
wrapper.__doc__ = new_doc
|
|
372
|
+
# Set __deprecated__ for PEP 702 (IDE/type checker support)
|
|
373
|
+
wrapper.__deprecated__ = _build_deprecation_message( # type: ignore[attr-defined]
|
|
374
|
+
alternative=alternative,
|
|
375
|
+
alternative_import=alternative_import,
|
|
376
|
+
)
|
|
346
377
|
return cast("T", wrapper)
|
|
347
378
|
|
|
348
379
|
old_doc = inspect.cleandoc(old_doc or "").strip("\n")
|
|
@@ -398,7 +429,7 @@ def deprecated(
|
|
|
398
429
|
|
|
399
430
|
@contextlib.contextmanager
|
|
400
431
|
def suppress_langchain_deprecation_warning() -> Generator[None, None, None]:
|
|
401
|
-
"""Context manager to suppress LangChainDeprecationWarning
|
|
432
|
+
"""Context manager to suppress `LangChainDeprecationWarning`."""
|
|
402
433
|
with warnings.catch_warnings():
|
|
403
434
|
warnings.simplefilter("ignore", LangChainDeprecationWarning)
|
|
404
435
|
warnings.simplefilter("ignore", LangChainPendingDeprecationWarning)
|
|
@@ -421,35 +452,33 @@ def warn_deprecated(
|
|
|
421
452
|
"""Display a standardized deprecation.
|
|
422
453
|
|
|
423
454
|
Args:
|
|
424
|
-
since:
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
and %(removal)s format specifiers will be replaced by the
|
|
455
|
+
since: The release at which this API became deprecated.
|
|
456
|
+
message: Override the default deprecation message.
|
|
457
|
+
|
|
458
|
+
The `%(since)s`, `%(name)s`, `%(alternative)s`, `%(obj_type)s`,
|
|
459
|
+
`%(addendum)s`, and `%(removal)s` format specifiers will be replaced by the
|
|
430
460
|
values of the respective arguments passed to this function.
|
|
431
|
-
name:
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
alternative_import:
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
obj_type:
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
package:
|
|
452
|
-
The package of the deprecated object.
|
|
461
|
+
name: The name of the deprecated object.
|
|
462
|
+
alternative: An alternative API that the user may use in place of the
|
|
463
|
+
deprecated API.
|
|
464
|
+
|
|
465
|
+
The deprecation warning will tell the user about this alternative if
|
|
466
|
+
provided.
|
|
467
|
+
alternative_import: An alternative import that the user may use instead.
|
|
468
|
+
pending: If `True`, uses a `PendingDeprecationWarning` instead of a
|
|
469
|
+
`DeprecationWarning`.
|
|
470
|
+
|
|
471
|
+
Cannot be used together with removal.
|
|
472
|
+
obj_type: The object type being deprecated.
|
|
473
|
+
addendum: Additional text appended directly to the final message.
|
|
474
|
+
removal: The expected removal version.
|
|
475
|
+
|
|
476
|
+
With the default (an empty string), a removal version is automatically
|
|
477
|
+
computed from since. Set to other Falsy values to not schedule a removal
|
|
478
|
+
date.
|
|
479
|
+
|
|
480
|
+
Cannot be used together with pending.
|
|
481
|
+
package: The package of the deprecated object.
|
|
453
482
|
"""
|
|
454
483
|
if not pending:
|
|
455
484
|
if not removal:
|
|
@@ -534,8 +563,8 @@ def rename_parameter(
|
|
|
534
563
|
"""Decorator indicating that parameter *old* of *func* is renamed to *new*.
|
|
535
564
|
|
|
536
565
|
The actual implementation of *func* should use *new*, not *old*. If *old* is passed
|
|
537
|
-
to *func*, a DeprecationWarning is emitted, and its value is used, even if *new*
|
|
538
|
-
also passed by keyword.
|
|
566
|
+
to *func*, a `DeprecationWarning` is emitted, and its value is used, even if *new*
|
|
567
|
+
is also passed by keyword.
|
|
539
568
|
|
|
540
569
|
Args:
|
|
541
570
|
since: The version in which the parameter was renamed.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import inspect
|
|
2
|
+
from typing import cast
|
|
2
3
|
|
|
3
4
|
|
|
4
5
|
def is_caller_internal(depth: int = 2) -> bool:
|
|
@@ -16,7 +17,7 @@ def is_caller_internal(depth: int = 2) -> bool:
|
|
|
16
17
|
return False
|
|
17
18
|
# Directly access the module name from the frame's global variables
|
|
18
19
|
module_globals = frame.f_globals
|
|
19
|
-
caller_module_name = module_globals.get("__name__", "")
|
|
20
|
+
caller_module_name = cast("str", module_globals.get("__name__", ""))
|
|
20
21
|
return caller_module_name.startswith("langchain")
|
|
21
22
|
finally:
|
|
22
23
|
del frame
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
Distinct from provider-based [prompt caching](https://docs.langchain.com/oss/python/langchain/models#prompt-caching).
|
|
4
4
|
|
|
5
5
|
!!! warning "Beta feature"
|
|
6
|
+
|
|
6
7
|
This is a beta feature. Please be wary of deploying experimental code to production
|
|
7
8
|
unless you've taken appropriate precautions.
|
|
8
9
|
|
|
@@ -960,28 +960,29 @@ class BaseCallbackManager(CallbackManagerMixin):
|
|
|
960
960
|
# ['tag2', 'tag1']
|
|
961
961
|
```
|
|
962
962
|
""" # noqa: E501
|
|
963
|
-
|
|
963
|
+
# Combine handlers and inheritable_handlers separately, using sets
|
|
964
|
+
# to deduplicate (order not preserved)
|
|
965
|
+
combined_handlers = list(set(self.handlers) | set(other.handlers))
|
|
966
|
+
combined_inheritable = list(
|
|
967
|
+
set(self.inheritable_handlers) | set(other.inheritable_handlers)
|
|
968
|
+
)
|
|
969
|
+
|
|
970
|
+
return self.__class__(
|
|
964
971
|
parent_run_id=self.parent_run_id or other.parent_run_id,
|
|
965
|
-
handlers=
|
|
966
|
-
inheritable_handlers=
|
|
972
|
+
handlers=combined_handlers,
|
|
973
|
+
inheritable_handlers=combined_inheritable,
|
|
967
974
|
tags=list(set(self.tags + other.tags)),
|
|
968
975
|
inheritable_tags=list(set(self.inheritable_tags + other.inheritable_tags)),
|
|
969
976
|
metadata={
|
|
970
977
|
**self.metadata,
|
|
971
978
|
**other.metadata,
|
|
972
979
|
},
|
|
980
|
+
inheritable_metadata={
|
|
981
|
+
**self.inheritable_metadata,
|
|
982
|
+
**other.inheritable_metadata,
|
|
983
|
+
},
|
|
973
984
|
)
|
|
974
985
|
|
|
975
|
-
handlers = self.handlers + other.handlers
|
|
976
|
-
inheritable_handlers = self.inheritable_handlers + other.inheritable_handlers
|
|
977
|
-
|
|
978
|
-
for handler in handlers:
|
|
979
|
-
manager.add_handler(handler)
|
|
980
|
-
|
|
981
|
-
for handler in inheritable_handlers:
|
|
982
|
-
manager.add_handler(handler, inherit=True)
|
|
983
|
-
return manager
|
|
984
|
-
|
|
985
986
|
@property
|
|
986
987
|
def is_async(self) -> bool:
|
|
987
988
|
"""Whether the callback manager is async."""
|
|
@@ -12,7 +12,6 @@ from concurrent.futures import ThreadPoolExecutor
|
|
|
12
12
|
from contextlib import asynccontextmanager, contextmanager
|
|
13
13
|
from contextvars import copy_context
|
|
14
14
|
from typing import TYPE_CHECKING, Any, TypeVar, cast
|
|
15
|
-
from uuid import UUID
|
|
16
15
|
|
|
17
16
|
from langsmith.run_helpers import get_tracing_context
|
|
18
17
|
from typing_extensions import Self, override
|
|
@@ -44,6 +43,7 @@ from langchain_core.utils.uuid import uuid7
|
|
|
44
43
|
|
|
45
44
|
if TYPE_CHECKING:
|
|
46
45
|
from collections.abc import AsyncGenerator, Coroutine, Generator, Sequence
|
|
46
|
+
from uuid import UUID
|
|
47
47
|
|
|
48
48
|
from tenacity import RetryCallState
|
|
49
49
|
|
|
@@ -11,6 +11,7 @@ from typing_extensions import override
|
|
|
11
11
|
|
|
12
12
|
from langchain_core.document_loaders.base import BaseLoader
|
|
13
13
|
from langchain_core.documents import Document
|
|
14
|
+
from langchain_core.tracers._compat import pydantic_to_dict
|
|
14
15
|
|
|
15
16
|
|
|
16
17
|
class LangSmithLoader(BaseLoader):
|
|
@@ -118,14 +119,14 @@ class LangSmithLoader(BaseLoader):
|
|
|
118
119
|
for key in self.content_key:
|
|
119
120
|
content = content[key]
|
|
120
121
|
content_str = self.format_content(content)
|
|
121
|
-
metadata = example
|
|
122
|
+
metadata = pydantic_to_dict(example)
|
|
122
123
|
# Stringify datetime and UUID types.
|
|
123
124
|
for k in ("dataset_id", "created_at", "modified_at", "source_run_id", "id"):
|
|
124
125
|
metadata[k] = str(metadata[k]) if metadata[k] else metadata[k]
|
|
125
126
|
yield Document(content_str, metadata=metadata)
|
|
126
127
|
|
|
127
128
|
|
|
128
|
-
def _stringify(x: str | dict) -> str:
|
|
129
|
+
def _stringify(x: str | dict[str, Any]) -> str:
|
|
129
130
|
if isinstance(x, str):
|
|
130
131
|
return x
|
|
131
132
|
try:
|
|
@@ -242,6 +242,17 @@ def _delete(
|
|
|
242
242
|
vector_store: VectorStore | DocumentIndex,
|
|
243
243
|
ids: list[str],
|
|
244
244
|
) -> None:
|
|
245
|
+
"""Delete documents from a vector store or document index by their IDs.
|
|
246
|
+
|
|
247
|
+
Args:
|
|
248
|
+
vector_store: The vector store or document index to delete from.
|
|
249
|
+
ids: List of document IDs to delete.
|
|
250
|
+
|
|
251
|
+
Raises:
|
|
252
|
+
IndexingException: If the delete operation fails.
|
|
253
|
+
TypeError: If the `vector_store` is neither a `VectorStore` nor a
|
|
254
|
+
`DocumentIndex`.
|
|
255
|
+
"""
|
|
245
256
|
if isinstance(vector_store, VectorStore):
|
|
246
257
|
delete_ok = vector_store.delete(ids)
|
|
247
258
|
if delete_ok is not None and delete_ok is False:
|
|
@@ -12,13 +12,14 @@ from typing import (
|
|
|
12
12
|
Literal,
|
|
13
13
|
TypeAlias,
|
|
14
14
|
TypeVar,
|
|
15
|
+
cast,
|
|
15
16
|
)
|
|
16
17
|
|
|
17
18
|
from pydantic import BaseModel, ConfigDict, Field, field_validator
|
|
18
19
|
from typing_extensions import TypedDict, override
|
|
19
20
|
|
|
20
|
-
from langchain_core.caches import BaseCache
|
|
21
|
-
from langchain_core.callbacks import Callbacks
|
|
21
|
+
from langchain_core.caches import BaseCache # noqa: TC001
|
|
22
|
+
from langchain_core.callbacks import Callbacks # noqa: TC001
|
|
22
23
|
from langchain_core.globals import get_verbose
|
|
23
24
|
from langchain_core.messages import (
|
|
24
25
|
AIMessage,
|
|
@@ -86,13 +87,28 @@ def get_tokenizer() -> Any:
|
|
|
86
87
|
return GPT2TokenizerFast.from_pretrained("gpt2")
|
|
87
88
|
|
|
88
89
|
|
|
90
|
+
_GPT2_TOKENIZER_WARNED = False
|
|
91
|
+
|
|
92
|
+
|
|
89
93
|
def _get_token_ids_default_method(text: str) -> list[int]:
|
|
90
|
-
"""Encode the text into token IDs."""
|
|
91
|
-
#
|
|
94
|
+
"""Encode the text into token IDs using the fallback GPT-2 tokenizer."""
|
|
95
|
+
global _GPT2_TOKENIZER_WARNED # noqa: PLW0603
|
|
96
|
+
if not _GPT2_TOKENIZER_WARNED:
|
|
97
|
+
warnings.warn(
|
|
98
|
+
"Using fallback GPT-2 tokenizer for token counting. "
|
|
99
|
+
"Token counts may be inaccurate for non-GPT-2 models. "
|
|
100
|
+
"For accurate counts, use a model-specific method if available.",
|
|
101
|
+
stacklevel=3,
|
|
102
|
+
)
|
|
103
|
+
_GPT2_TOKENIZER_WARNED = True
|
|
104
|
+
|
|
92
105
|
tokenizer = get_tokenizer()
|
|
93
106
|
|
|
94
|
-
#
|
|
95
|
-
|
|
107
|
+
# Pass verbose=False to suppress the "Token indices sequence length is longer than
|
|
108
|
+
# the specified maximum sequence length" warning from HuggingFace. This warning is
|
|
109
|
+
# about GPT-2's 1024 token context limit, but we're only using the tokenizer for
|
|
110
|
+
# counting, not for model input.
|
|
111
|
+
return cast("list[int]", tokenizer.encode(text, verbose=False))
|
|
96
112
|
|
|
97
113
|
|
|
98
114
|
LanguageModelInput = PromptValue | str | Sequence[MessageLikeRepresentation]
|
|
@@ -341,6 +341,7 @@ class BaseChatModel(BaseLanguageModel[AIMessage], ABC):
|
|
|
341
341
|
"""Profile detailing model capabilities.
|
|
342
342
|
|
|
343
343
|
!!! warning "Beta feature"
|
|
344
|
+
|
|
344
345
|
This is a beta feature. The format of model profiles is subject to change.
|
|
345
346
|
|
|
346
347
|
If not specified, automatically loaded from the provider package on initialization
|
|
@@ -358,7 +359,10 @@ class BaseChatModel(BaseLanguageModel[AIMessage], ABC):
|
|
|
358
359
|
|
|
359
360
|
@cached_property
|
|
360
361
|
def _serialized(self) -> dict[str, Any]:
|
|
361
|
-
|
|
362
|
+
# self is always a Serializable object in this case, thus the result is
|
|
363
|
+
# guaranteed to be a dict since dumps uses the default callback, which uses
|
|
364
|
+
# obj.to_json which always returns TypedDict subclasses
|
|
365
|
+
return cast("dict[str, Any]", dumpd(self))
|
|
362
366
|
|
|
363
367
|
# --- Runnable methods ---
|
|
364
368
|
|
|
@@ -461,7 +465,7 @@ class BaseChatModel(BaseLanguageModel[AIMessage], ABC):
|
|
|
461
465
|
|
|
462
466
|
# Check if a runtime streaming flag has been passed in.
|
|
463
467
|
if "stream" in kwargs:
|
|
464
|
-
return kwargs["stream"]
|
|
468
|
+
return bool(kwargs["stream"])
|
|
465
469
|
|
|
466
470
|
if "streaming" in self.model_fields_set:
|
|
467
471
|
streaming_value = getattr(self, "streaming", None)
|
|
@@ -547,7 +551,7 @@ class BaseChatModel(BaseLanguageModel[AIMessage], ABC):
|
|
|
547
551
|
):
|
|
548
552
|
if block["type"] != index_type:
|
|
549
553
|
index_type = block["type"]
|
|
550
|
-
index
|
|
554
|
+
index += 1
|
|
551
555
|
if "index" not in block:
|
|
552
556
|
block["index"] = index
|
|
553
557
|
run_manager.on_llm_new_token(
|
|
@@ -679,7 +683,7 @@ class BaseChatModel(BaseLanguageModel[AIMessage], ABC):
|
|
|
679
683
|
):
|
|
680
684
|
if block["type"] != index_type:
|
|
681
685
|
index_type = block["type"]
|
|
682
|
-
index
|
|
686
|
+
index += 1
|
|
683
687
|
if "index" not in block:
|
|
684
688
|
block["index"] = index
|
|
685
689
|
await run_manager.on_llm_new_token(
|
|
@@ -730,7 +734,7 @@ class BaseChatModel(BaseLanguageModel[AIMessage], ABC):
|
|
|
730
734
|
|
|
731
735
|
# --- Custom methods ---
|
|
732
736
|
|
|
733
|
-
def _combine_llm_outputs(self,
|
|
737
|
+
def _combine_llm_outputs(self, _llm_outputs: list[dict | None], /) -> dict:
|
|
734
738
|
return {}
|
|
735
739
|
|
|
736
740
|
def _convert_cached_generations(self, cache_val: list) -> list[ChatGeneration]:
|
|
@@ -1144,7 +1148,15 @@ class BaseChatModel(BaseLanguageModel[AIMessage], ABC):
|
|
|
1144
1148
|
if check_cache:
|
|
1145
1149
|
if llm_cache:
|
|
1146
1150
|
llm_string = self._get_llm_string(stop=stop, **kwargs)
|
|
1147
|
-
|
|
1151
|
+
normalized_messages = [
|
|
1152
|
+
(
|
|
1153
|
+
msg.model_copy(update={"id": None})
|
|
1154
|
+
if getattr(msg, "id", None) is not None
|
|
1155
|
+
else msg
|
|
1156
|
+
)
|
|
1157
|
+
for msg in messages
|
|
1158
|
+
]
|
|
1159
|
+
prompt = dumps(normalized_messages)
|
|
1148
1160
|
cache_val = llm_cache.lookup(prompt, llm_string)
|
|
1149
1161
|
if isinstance(cache_val, list):
|
|
1150
1162
|
converted_generations = self._convert_cached_generations(cache_val)
|
|
@@ -1187,7 +1199,7 @@ class BaseChatModel(BaseLanguageModel[AIMessage], ABC):
|
|
|
1187
1199
|
):
|
|
1188
1200
|
if block["type"] != index_type:
|
|
1189
1201
|
index_type = block["type"]
|
|
1190
|
-
index
|
|
1202
|
+
index += 1
|
|
1191
1203
|
if "index" not in block:
|
|
1192
1204
|
block["index"] = index
|
|
1193
1205
|
if run_manager:
|
|
@@ -1262,7 +1274,15 @@ class BaseChatModel(BaseLanguageModel[AIMessage], ABC):
|
|
|
1262
1274
|
if check_cache:
|
|
1263
1275
|
if llm_cache:
|
|
1264
1276
|
llm_string = self._get_llm_string(stop=stop, **kwargs)
|
|
1265
|
-
|
|
1277
|
+
normalized_messages = [
|
|
1278
|
+
(
|
|
1279
|
+
msg.model_copy(update={"id": None})
|
|
1280
|
+
if getattr(msg, "id", None) is not None
|
|
1281
|
+
else msg
|
|
1282
|
+
)
|
|
1283
|
+
for msg in messages
|
|
1284
|
+
]
|
|
1285
|
+
prompt = dumps(normalized_messages)
|
|
1266
1286
|
cache_val = await llm_cache.alookup(prompt, llm_string)
|
|
1267
1287
|
if isinstance(cache_val, list):
|
|
1268
1288
|
converted_generations = self._convert_cached_generations(cache_val)
|
|
@@ -1305,7 +1325,7 @@ class BaseChatModel(BaseLanguageModel[AIMessage], ABC):
|
|
|
1305
1325
|
):
|
|
1306
1326
|
if block["type"] != index_type:
|
|
1307
1327
|
index_type = block["type"]
|
|
1308
|
-
index
|
|
1328
|
+
index += 1
|
|
1309
1329
|
if "index" not in block:
|
|
1310
1330
|
block["index"] = index
|
|
1311
1331
|
if run_manager:
|
|
@@ -301,7 +301,10 @@ class BaseLLM(BaseLanguageModel[str], ABC):
|
|
|
301
301
|
|
|
302
302
|
@functools.cached_property
|
|
303
303
|
def _serialized(self) -> dict[str, Any]:
|
|
304
|
-
|
|
304
|
+
# self is always a Serializable object in this case, thus the result is
|
|
305
|
+
# guaranteed to be a dict since dumps uses the default callback, which uses
|
|
306
|
+
# obj.to_json which always returns TypedDict subclasses
|
|
307
|
+
return cast("dict[str, Any]", dumpd(self))
|
|
305
308
|
|
|
306
309
|
# --- Runnable methods ---
|
|
307
310
|
|
|
@@ -6,7 +6,7 @@ from langchain_core._import_utils import import_attr
|
|
|
6
6
|
|
|
7
7
|
if TYPE_CHECKING:
|
|
8
8
|
from langchain_core.load.dump import dumpd, dumps
|
|
9
|
-
from langchain_core.load.load import loads
|
|
9
|
+
from langchain_core.load.load import InitValidator, loads
|
|
10
10
|
from langchain_core.load.serializable import Serializable
|
|
11
11
|
|
|
12
12
|
# Unfortunately, we have to eagerly import load from langchain_core/load/load.py
|
|
@@ -15,11 +15,19 @@ if TYPE_CHECKING:
|
|
|
15
15
|
# the `from langchain_core.load.load import load` absolute import should also work.
|
|
16
16
|
from langchain_core.load.load import load
|
|
17
17
|
|
|
18
|
-
__all__ = (
|
|
18
|
+
__all__ = (
|
|
19
|
+
"InitValidator",
|
|
20
|
+
"Serializable",
|
|
21
|
+
"dumpd",
|
|
22
|
+
"dumps",
|
|
23
|
+
"load",
|
|
24
|
+
"loads",
|
|
25
|
+
)
|
|
19
26
|
|
|
20
27
|
_dynamic_imports = {
|
|
21
28
|
"dumpd": "dump",
|
|
22
29
|
"dumps": "dump",
|
|
30
|
+
"InitValidator": "load",
|
|
23
31
|
"loads": "load",
|
|
24
32
|
"Serializable": "serializable",
|
|
25
33
|
}
|