langchain-core 1.0.5__tar.gz → 1.1.1__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.0.5 → langchain_core-1.1.1}/.gitignore +3 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/PKG-INFO +2 -1
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/callbacks/manager.py +14 -14
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/indexing/api.py +2 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/language_models/__init__.py +8 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/language_models/_utils.py +1 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/language_models/chat_models.py +19 -39
- langchain_core-1.1.1/langchain_core/language_models/model_profile.py +84 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/messages/ai.py +2 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/messages/content.py +1 -1
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/messages/utils.py +2 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/output_parsers/pydantic.py +1 -1
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/prompts/chat.py +22 -17
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/prompts/string.py +87 -10
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/prompts/structured.py +7 -1
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/runnables/base.py +166 -152
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/runnables/branch.py +1 -1
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/runnables/config.py +25 -20
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/runnables/graph.py +3 -2
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/runnables/graph_mermaid.py +5 -1
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/tools/base.py +26 -2
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/tools/structured.py +14 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/tracers/event_stream.py +7 -2
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/utils/function_calling.py +4 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/utils/json_schema.py +29 -21
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/utils/mustache.py +24 -9
- langchain_core-1.1.1/langchain_core/utils/uuid.py +54 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/vectorstores/base.py +26 -18
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/version.py +1 -1
- {langchain_core-1.0.5 → langchain_core-1.1.1}/pyproject.toml +2 -4
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/benchmarks/test_async_callbacks.py +1 -1
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/benchmarks/test_imports.py +1 -1
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/language_models/chat_models/test_base.py +5 -12
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/language_models/test_imports.py +2 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/prompts/__snapshots__/test_chat.ambr +4 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/prompts/test_chat.py +161 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/prompts/test_structured.py +8 -2
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/runnables/__snapshots__/test_graph.ambr +2 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/runnables/__snapshots__/test_runnable.ambr +16 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/runnables/test_tracing_interops.py +11 -7
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/test_tools.py +101 -0
- langchain_core-1.1.1/tests/unit_tests/utils/test_uuid_utils.py +37 -0
- langchain_core-1.1.1/uv.lock +3555 -0
- langchain_core-1.0.5/uv.lock +0 -3439
- {langchain_core-1.0.5 → langchain_core-1.1.1}/Makefile +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/README.md +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/extended_testing_deps.txt +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/__init__.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/_api/__init__.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/_api/beta_decorator.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/_api/deprecation.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/_api/internal.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/_api/path.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/_import_utils.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/agents.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/caches.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/callbacks/__init__.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/callbacks/base.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/callbacks/file.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/callbacks/stdout.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/callbacks/streaming_stdout.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/callbacks/usage.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/chat_history.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/chat_loaders.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/chat_sessions.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/document_loaders/__init__.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/document_loaders/base.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/document_loaders/blob_loaders.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/document_loaders/langsmith.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/documents/__init__.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/documents/base.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/documents/compressor.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/documents/transformers.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/embeddings/__init__.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/embeddings/embeddings.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/embeddings/fake.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/env.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/example_selectors/__init__.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/example_selectors/base.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/example_selectors/length_based.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/example_selectors/semantic_similarity.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/exceptions.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/globals.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/indexing/__init__.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/indexing/base.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/indexing/in_memory.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/language_models/base.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/language_models/fake.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/language_models/fake_chat_models.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/language_models/llms.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/load/__init__.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/load/dump.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/load/load.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/load/mapping.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/load/serializable.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/messages/__init__.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/messages/base.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/messages/block_translators/__init__.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/messages/block_translators/anthropic.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/messages/block_translators/bedrock.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/messages/block_translators/bedrock_converse.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/messages/block_translators/google_genai.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/messages/block_translators/google_vertexai.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/messages/block_translators/groq.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/messages/block_translators/langchain_v0.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/messages/block_translators/openai.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/messages/chat.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/messages/function.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/messages/human.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/messages/modifier.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/messages/system.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/messages/tool.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/output_parsers/__init__.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/output_parsers/base.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/output_parsers/format_instructions.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/output_parsers/json.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/output_parsers/list.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/output_parsers/openai_functions.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/output_parsers/openai_tools.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/output_parsers/string.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/output_parsers/transform.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/output_parsers/xml.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/outputs/__init__.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/outputs/chat_generation.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/outputs/chat_result.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/outputs/generation.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/outputs/llm_result.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/outputs/run_info.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/prompt_values.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/prompts/__init__.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/prompts/base.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/prompts/dict.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/prompts/few_shot.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/prompts/few_shot_with_templates.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/prompts/image.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/prompts/loading.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/prompts/message.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/prompts/prompt.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/py.typed +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/rate_limiters.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/retrievers.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/runnables/__init__.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/runnables/configurable.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/runnables/fallbacks.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/runnables/graph_ascii.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/runnables/graph_png.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/runnables/history.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/runnables/passthrough.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/runnables/retry.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/runnables/router.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/runnables/schema.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/runnables/utils.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/stores.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/structured_query.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/sys_info.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/tools/__init__.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/tools/convert.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/tools/render.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/tools/retriever.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/tools/simple.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/tracers/__init__.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/tracers/_streaming.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/tracers/base.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/tracers/context.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/tracers/core.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/tracers/evaluation.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/tracers/langchain.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/tracers/log_stream.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/tracers/memory_stream.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/tracers/root_listeners.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/tracers/run_collector.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/tracers/schemas.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/tracers/stdout.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/utils/__init__.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/utils/_merge.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/utils/aiter.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/utils/env.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/utils/formatting.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/utils/html.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/utils/image.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/utils/input.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/utils/interactive_env.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/utils/iter.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/utils/json.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/utils/pydantic.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/utils/strings.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/utils/usage.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/utils/utils.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/vectorstores/__init__.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/vectorstores/in_memory.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/langchain_core/vectorstores/utils.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/scripts/check_imports.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/scripts/lint_imports.sh +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/__init__.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/benchmarks/__init__.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/integration_tests/__init__.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/integration_tests/test_compile.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/__init__.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/_api/__init__.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/_api/test_beta_decorator.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/_api/test_deprecation.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/_api/test_imports.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/_api/test_path.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/caches/__init__.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/caches/test_in_memory_cache.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/callbacks/__init__.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/callbacks/test_async_callback_manager.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/callbacks/test_dispatch_custom_event.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/callbacks/test_imports.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/callbacks/test_sync_callback_manager.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/callbacks/test_usage_callback.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/chat_history/__init__.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/chat_history/test_chat_history.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/conftest.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/data/prompt_file.txt +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/data/prompts/prompt_extra_args.json +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/data/prompts/prompt_missing_args.json +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/data/prompts/simple_prompt.json +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/dependencies/__init__.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/dependencies/test_dependencies.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/document_loaders/__init__.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/document_loaders/test_base.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/document_loaders/test_langsmith.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/documents/__init__.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/documents/test_document.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/documents/test_imports.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/documents/test_str.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/embeddings/__init__.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/embeddings/test_deterministic_embedding.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/example_selectors/__init__.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/example_selectors/test_base.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/example_selectors/test_imports.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/example_selectors/test_length_based_example_selector.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/example_selectors/test_similarity.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/examples/example-non-utf8.csv +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/examples/example-non-utf8.txt +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/examples/example-utf8.csv +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/examples/example-utf8.txt +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/examples/example_prompt.json +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/examples/examples.json +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/examples/examples.yaml +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/examples/few_shot_prompt.json +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/examples/few_shot_prompt.yaml +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/examples/few_shot_prompt_example_prompt.json +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/examples/few_shot_prompt_examples_in.json +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/examples/few_shot_prompt_yaml_examples.yaml +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/examples/jinja_injection_prompt.json +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/examples/jinja_injection_prompt.yaml +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/examples/prompt_with_output_parser.json +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/examples/simple_prompt.json +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/examples/simple_prompt.yaml +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/examples/simple_prompt_with_template_file.json +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/examples/simple_template.txt +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/fake/__init__.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/fake/callbacks.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/fake/test_fake_chat_model.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/indexing/__init__.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/indexing/test_hashed_document.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/indexing/test_in_memory_indexer.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/indexing/test_in_memory_record_manager.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/indexing/test_indexing.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/indexing/test_public_api.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/language_models/__init__.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/language_models/chat_models/__init__.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/language_models/chat_models/test_benchmark.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/language_models/chat_models/test_cache.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/language_models/chat_models/test_rate_limiting.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/language_models/llms/__init__.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/language_models/llms/test_base.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/language_models/llms/test_cache.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/load/__init__.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/load/test_imports.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/load/test_serializable.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/messages/__init__.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/messages/block_translators/__init__.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/messages/block_translators/test_anthropic.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/messages/block_translators/test_bedrock.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/messages/block_translators/test_bedrock_converse.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/messages/block_translators/test_groq.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/messages/block_translators/test_langchain_v0.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/messages/block_translators/test_openai.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/messages/block_translators/test_registration.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/messages/test_ai.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/messages/test_imports.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/messages/test_utils.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/output_parsers/__init__.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/output_parsers/test_base_parsers.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/output_parsers/test_imports.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/output_parsers/test_json.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/output_parsers/test_list_parser.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/output_parsers/test_openai_functions.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/output_parsers/test_openai_tools.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/output_parsers/test_pydantic_parser.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/output_parsers/test_xml_parser.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/outputs/__init__.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/outputs/test_chat_generation.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/outputs/test_imports.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/prompt_file.txt +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/prompts/__init__.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/prompts/__snapshots__/test_prompt.ambr +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/prompts/prompt_extra_args.json +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/prompts/prompt_missing_args.json +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/prompts/simple_prompt.json +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/prompts/test_dict.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/prompts/test_few_shot.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/prompts/test_few_shot_with_templates.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/prompts/test_image.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/prompts/test_imports.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/prompts/test_loading.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/prompts/test_prompt.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/prompts/test_string.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/prompts/test_utils.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/pydantic_utils.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/rate_limiters/__init__.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/rate_limiters/test_in_memory_rate_limiter.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/runnables/__init__.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/runnables/__snapshots__/test_fallbacks.ambr +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/runnables/test_concurrency.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/runnables/test_config.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/runnables/test_configurable.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/runnables/test_fallbacks.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/runnables/test_graph.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/runnables/test_history.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/runnables/test_imports.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/runnables/test_runnable.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/runnables/test_runnable_events_v1.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/runnables/test_runnable_events_v2.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/runnables/test_utils.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/stores/__init__.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/stores/test_in_memory.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/stubs.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/test_globals.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/test_imports.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/test_messages.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/test_outputs.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/test_prompt_values.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/test_pydantic_imports.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/test_pydantic_serde.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/test_retrievers.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/test_setup.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/test_sys_info.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/tracers/__init__.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/tracers/test_async_base_tracer.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/tracers/test_base_tracer.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/tracers/test_imports.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/tracers/test_langchain.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/tracers/test_memory_stream.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/tracers/test_run_collector.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/tracers/test_schemas.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/utils/__init__.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/utils/test_aiter.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/utils/test_env.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/utils/test_function_calling.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/utils/test_html.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/utils/test_imports.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/utils/test_iter.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/utils/test_json_schema.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/utils/test_pydantic.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/utils/test_rm_titles.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/utils/test_strings.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/utils/test_usage.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/utils/test_utils.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/vectorstores/__init__.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/vectorstores/test_in_memory.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/tests/unit_tests/vectorstores/test_utils.py +0 -0
- {langchain_core-1.0.5 → langchain_core-1.1.1}/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.
|
|
3
|
+
Version: 1.1.1
|
|
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/
|
|
@@ -18,6 +18,7 @@ Requires-Dist: pydantic<3.0.0,>=2.7.4
|
|
|
18
18
|
Requires-Dist: pyyaml<7.0.0,>=5.3.0
|
|
19
19
|
Requires-Dist: tenacity!=8.4.0,<10.0.0,>=8.1.0
|
|
20
20
|
Requires-Dist: typing-extensions<5.0.0,>=4.7.0
|
|
21
|
+
Requires-Dist: uuid-utils<1.0,>=0.12.0
|
|
21
22
|
Description-Content-Type: text/markdown
|
|
22
23
|
|
|
23
24
|
# 🦜🍎️ LangChain Core
|
|
@@ -6,7 +6,6 @@ import asyncio
|
|
|
6
6
|
import atexit
|
|
7
7
|
import functools
|
|
8
8
|
import logging
|
|
9
|
-
import uuid
|
|
10
9
|
from abc import ABC, abstractmethod
|
|
11
10
|
from collections.abc import Callable
|
|
12
11
|
from concurrent.futures import ThreadPoolExecutor
|
|
@@ -41,6 +40,7 @@ from langchain_core.tracers.context import (
|
|
|
41
40
|
from langchain_core.tracers.langchain import LangChainTracer
|
|
42
41
|
from langchain_core.tracers.stdout import ConsoleCallbackHandler
|
|
43
42
|
from langchain_core.utils.env import env_var_is_set
|
|
43
|
+
from langchain_core.utils.uuid import uuid7
|
|
44
44
|
|
|
45
45
|
if TYPE_CHECKING:
|
|
46
46
|
from collections.abc import AsyncGenerator, Coroutine, Generator, Sequence
|
|
@@ -504,7 +504,7 @@ class BaseRunManager(RunManagerMixin):
|
|
|
504
504
|
|
|
505
505
|
"""
|
|
506
506
|
return cls(
|
|
507
|
-
run_id=
|
|
507
|
+
run_id=uuid7(),
|
|
508
508
|
handlers=[],
|
|
509
509
|
inheritable_handlers=[],
|
|
510
510
|
tags=[],
|
|
@@ -1330,7 +1330,7 @@ class CallbackManager(BaseCallbackManager):
|
|
|
1330
1330
|
managers = []
|
|
1331
1331
|
for i, prompt in enumerate(prompts):
|
|
1332
1332
|
# Can't have duplicate runs with the same run ID (if provided)
|
|
1333
|
-
run_id_ = run_id if i == 0 and run_id is not None else
|
|
1333
|
+
run_id_ = run_id if i == 0 and run_id is not None else uuid7()
|
|
1334
1334
|
handle_event(
|
|
1335
1335
|
self.handlers,
|
|
1336
1336
|
"on_llm_start",
|
|
@@ -1384,7 +1384,7 @@ class CallbackManager(BaseCallbackManager):
|
|
|
1384
1384
|
run_id_ = run_id
|
|
1385
1385
|
run_id = None
|
|
1386
1386
|
else:
|
|
1387
|
-
run_id_ =
|
|
1387
|
+
run_id_ = uuid7()
|
|
1388
1388
|
handle_event(
|
|
1389
1389
|
self.handlers,
|
|
1390
1390
|
"on_chat_model_start",
|
|
@@ -1433,7 +1433,7 @@ class CallbackManager(BaseCallbackManager):
|
|
|
1433
1433
|
|
|
1434
1434
|
"""
|
|
1435
1435
|
if run_id is None:
|
|
1436
|
-
run_id =
|
|
1436
|
+
run_id = uuid7()
|
|
1437
1437
|
handle_event(
|
|
1438
1438
|
self.handlers,
|
|
1439
1439
|
"on_chain_start",
|
|
@@ -1488,7 +1488,7 @@ class CallbackManager(BaseCallbackManager):
|
|
|
1488
1488
|
|
|
1489
1489
|
"""
|
|
1490
1490
|
if run_id is None:
|
|
1491
|
-
run_id =
|
|
1491
|
+
run_id = uuid7()
|
|
1492
1492
|
|
|
1493
1493
|
handle_event(
|
|
1494
1494
|
self.handlers,
|
|
@@ -1537,7 +1537,7 @@ class CallbackManager(BaseCallbackManager):
|
|
|
1537
1537
|
The callback manager for the retriever run.
|
|
1538
1538
|
"""
|
|
1539
1539
|
if run_id is None:
|
|
1540
|
-
run_id =
|
|
1540
|
+
run_id = uuid7()
|
|
1541
1541
|
|
|
1542
1542
|
handle_event(
|
|
1543
1543
|
self.handlers,
|
|
@@ -1594,7 +1594,7 @@ class CallbackManager(BaseCallbackManager):
|
|
|
1594
1594
|
)
|
|
1595
1595
|
raise ValueError(msg)
|
|
1596
1596
|
if run_id is None:
|
|
1597
|
-
run_id =
|
|
1597
|
+
run_id = uuid7()
|
|
1598
1598
|
|
|
1599
1599
|
handle_event(
|
|
1600
1600
|
self.handlers,
|
|
@@ -1816,7 +1816,7 @@ class AsyncCallbackManager(BaseCallbackManager):
|
|
|
1816
1816
|
run_id_ = run_id
|
|
1817
1817
|
run_id = None
|
|
1818
1818
|
else:
|
|
1819
|
-
run_id_ =
|
|
1819
|
+
run_id_ = uuid7()
|
|
1820
1820
|
|
|
1821
1821
|
if inline_handlers:
|
|
1822
1822
|
inline_tasks.append(
|
|
@@ -1900,7 +1900,7 @@ class AsyncCallbackManager(BaseCallbackManager):
|
|
|
1900
1900
|
run_id_ = run_id
|
|
1901
1901
|
run_id = None
|
|
1902
1902
|
else:
|
|
1903
|
-
run_id_ =
|
|
1903
|
+
run_id_ = uuid7()
|
|
1904
1904
|
|
|
1905
1905
|
for handler in self.handlers:
|
|
1906
1906
|
task = ahandle_event(
|
|
@@ -1962,7 +1962,7 @@ class AsyncCallbackManager(BaseCallbackManager):
|
|
|
1962
1962
|
The async callback manager for the chain run.
|
|
1963
1963
|
"""
|
|
1964
1964
|
if run_id is None:
|
|
1965
|
-
run_id =
|
|
1965
|
+
run_id = uuid7()
|
|
1966
1966
|
|
|
1967
1967
|
await ahandle_event(
|
|
1968
1968
|
self.handlers,
|
|
@@ -2010,7 +2010,7 @@ class AsyncCallbackManager(BaseCallbackManager):
|
|
|
2010
2010
|
The async callback manager for the tool run.
|
|
2011
2011
|
"""
|
|
2012
2012
|
if run_id is None:
|
|
2013
|
-
run_id =
|
|
2013
|
+
run_id = uuid7()
|
|
2014
2014
|
|
|
2015
2015
|
await ahandle_event(
|
|
2016
2016
|
self.handlers,
|
|
@@ -2060,7 +2060,7 @@ class AsyncCallbackManager(BaseCallbackManager):
|
|
|
2060
2060
|
if not self.handlers:
|
|
2061
2061
|
return
|
|
2062
2062
|
if run_id is None:
|
|
2063
|
-
run_id =
|
|
2063
|
+
run_id = uuid7()
|
|
2064
2064
|
|
|
2065
2065
|
if kwargs:
|
|
2066
2066
|
msg = (
|
|
@@ -2102,7 +2102,7 @@ class AsyncCallbackManager(BaseCallbackManager):
|
|
|
2102
2102
|
The async callback manager for the retriever run.
|
|
2103
2103
|
"""
|
|
2104
2104
|
if run_id is None:
|
|
2105
|
-
run_id =
|
|
2105
|
+
run_id = uuid7()
|
|
2106
2106
|
|
|
2107
2107
|
await ahandle_event(
|
|
2108
2108
|
self.handlers,
|
|
@@ -302,6 +302,7 @@ def index(
|
|
|
302
302
|
are not able to specify the uid of the document.
|
|
303
303
|
|
|
304
304
|
!!! warning "Behavior changed in `langchain-core` 0.3.25"
|
|
305
|
+
|
|
305
306
|
Added `scoped_full` cleanup mode.
|
|
306
307
|
|
|
307
308
|
!!! warning
|
|
@@ -640,6 +641,7 @@ async def aindex(
|
|
|
640
641
|
are not able to specify the uid of the document.
|
|
641
642
|
|
|
642
643
|
!!! warning "Behavior changed in `langchain-core` 0.3.25"
|
|
644
|
+
|
|
643
645
|
Added `scoped_full` cleanup mode.
|
|
644
646
|
|
|
645
647
|
!!! warning
|
|
@@ -53,6 +53,10 @@ if TYPE_CHECKING:
|
|
|
53
53
|
ParrotFakeChatModel,
|
|
54
54
|
)
|
|
55
55
|
from langchain_core.language_models.llms import LLM, BaseLLM
|
|
56
|
+
from langchain_core.language_models.model_profile import (
|
|
57
|
+
ModelProfile,
|
|
58
|
+
ModelProfileRegistry,
|
|
59
|
+
)
|
|
56
60
|
|
|
57
61
|
__all__ = (
|
|
58
62
|
"LLM",
|
|
@@ -68,6 +72,8 @@ __all__ = (
|
|
|
68
72
|
"LanguageModelInput",
|
|
69
73
|
"LanguageModelLike",
|
|
70
74
|
"LanguageModelOutput",
|
|
75
|
+
"ModelProfile",
|
|
76
|
+
"ModelProfileRegistry",
|
|
71
77
|
"ParrotFakeChatModel",
|
|
72
78
|
"SimpleChatModel",
|
|
73
79
|
"get_tokenizer",
|
|
@@ -90,6 +96,8 @@ _dynamic_imports = {
|
|
|
90
96
|
"GenericFakeChatModel": "fake_chat_models",
|
|
91
97
|
"ParrotFakeChatModel": "fake_chat_models",
|
|
92
98
|
"LLM": "llms",
|
|
99
|
+
"ModelProfile": "model_profile",
|
|
100
|
+
"ModelProfileRegistry": "model_profile",
|
|
93
101
|
"BaseLLM": "llms",
|
|
94
102
|
"is_openai_data_block": "_utils",
|
|
95
103
|
}
|
|
@@ -140,6 +140,7 @@ def _normalize_messages(
|
|
|
140
140
|
- LangChain v0 standard content blocks for backward compatibility
|
|
141
141
|
|
|
142
142
|
!!! warning "Behavior changed in `langchain-core` 1.0.0"
|
|
143
|
+
|
|
143
144
|
In previous versions, this function returned messages in LangChain v0 format.
|
|
144
145
|
Now, it returns messages in LangChain v1 format, which upgraded chat models now
|
|
145
146
|
expect to receive when passing back in message history. For backward
|
|
@@ -15,7 +15,6 @@ from typing import TYPE_CHECKING, Any, Literal, cast
|
|
|
15
15
|
from pydantic import BaseModel, ConfigDict, Field
|
|
16
16
|
from typing_extensions import override
|
|
17
17
|
|
|
18
|
-
from langchain_core._api.beta_decorator import beta
|
|
19
18
|
from langchain_core.caches import BaseCache
|
|
20
19
|
from langchain_core.callbacks import (
|
|
21
20
|
AsyncCallbackManager,
|
|
@@ -34,6 +33,7 @@ from langchain_core.language_models.base import (
|
|
|
34
33
|
LangSmithParams,
|
|
35
34
|
LanguageModelInput,
|
|
36
35
|
)
|
|
36
|
+
from langchain_core.language_models.model_profile import ModelProfile
|
|
37
37
|
from langchain_core.load import dumpd, dumps
|
|
38
38
|
from langchain_core.messages import (
|
|
39
39
|
AIMessage,
|
|
@@ -76,8 +76,6 @@ from langchain_core.utils.utils import LC_ID_PREFIX, from_env
|
|
|
76
76
|
if TYPE_CHECKING:
|
|
77
77
|
import uuid
|
|
78
78
|
|
|
79
|
-
from langchain_model_profiles import ModelProfile # type: ignore[import-untyped]
|
|
80
|
-
|
|
81
79
|
from langchain_core.output_parsers.base import OutputParserLike
|
|
82
80
|
from langchain_core.runnables import Runnable, RunnableConfig
|
|
83
81
|
from langchain_core.tools import BaseTool
|
|
@@ -335,8 +333,23 @@ class BaseChatModel(BaseLanguageModel[AIMessage], ABC):
|
|
|
335
333
|
[`langchain-openai`](https://pypi.org/project/langchain-openai)) can also use this
|
|
336
334
|
field to roll out new content formats in a backward-compatible way.
|
|
337
335
|
|
|
338
|
-
!!! version-added "Added in `langchain-core` 1.0"
|
|
336
|
+
!!! version-added "Added in `langchain-core` 1.0.0"
|
|
337
|
+
|
|
338
|
+
"""
|
|
339
|
+
|
|
340
|
+
profile: ModelProfile | None = Field(default=None, exclude=True)
|
|
341
|
+
"""Profile detailing model capabilities.
|
|
342
|
+
|
|
343
|
+
!!! warning "Beta feature"
|
|
344
|
+
This is a beta feature. The format of model profiles is subject to change.
|
|
339
345
|
|
|
346
|
+
If not specified, automatically loaded from the provider package on initialization
|
|
347
|
+
if data is available.
|
|
348
|
+
|
|
349
|
+
Example profile data includes context window sizes, supported modalities, or support
|
|
350
|
+
for tool calling, structured output, and other features.
|
|
351
|
+
|
|
352
|
+
!!! version-added "Added in `langchain-core` 1.1.0"
|
|
340
353
|
"""
|
|
341
354
|
|
|
342
355
|
model_config = ConfigDict(
|
|
@@ -1619,7 +1632,7 @@ class BaseChatModel(BaseLanguageModel[AIMessage], ABC):
|
|
|
1619
1632
|
# }
|
|
1620
1633
|
```
|
|
1621
1634
|
|
|
1622
|
-
Example:
|
|
1635
|
+
Example: Dictionary schema (`include_raw=False`):
|
|
1623
1636
|
|
|
1624
1637
|
```python
|
|
1625
1638
|
from pydantic import BaseModel
|
|
@@ -1647,6 +1660,7 @@ class BaseChatModel(BaseLanguageModel[AIMessage], ABC):
|
|
|
1647
1660
|
```
|
|
1648
1661
|
|
|
1649
1662
|
!!! warning "Behavior changed in `langchain-core` 0.2.26"
|
|
1663
|
+
|
|
1650
1664
|
Added support for `TypedDict` class.
|
|
1651
1665
|
|
|
1652
1666
|
""" # noqa: E501
|
|
@@ -1688,40 +1702,6 @@ class BaseChatModel(BaseLanguageModel[AIMessage], ABC):
|
|
|
1688
1702
|
return RunnableMap(raw=llm) | parser_with_fallback
|
|
1689
1703
|
return llm | output_parser
|
|
1690
1704
|
|
|
1691
|
-
@property
|
|
1692
|
-
@beta()
|
|
1693
|
-
def profile(self) -> ModelProfile:
|
|
1694
|
-
"""Return profiling information for the model.
|
|
1695
|
-
|
|
1696
|
-
This property relies on the `langchain-model-profiles` package to retrieve chat
|
|
1697
|
-
model capabilities, such as context window sizes and supported features.
|
|
1698
|
-
|
|
1699
|
-
Raises:
|
|
1700
|
-
ImportError: If `langchain-model-profiles` is not installed.
|
|
1701
|
-
|
|
1702
|
-
Returns:
|
|
1703
|
-
A `ModelProfile` object containing profiling information for the model.
|
|
1704
|
-
"""
|
|
1705
|
-
try:
|
|
1706
|
-
from langchain_model_profiles import get_model_profile # noqa: PLC0415
|
|
1707
|
-
except ImportError as err:
|
|
1708
|
-
informative_error_message = (
|
|
1709
|
-
"To access model profiling information, please install the "
|
|
1710
|
-
"`langchain-model-profiles` package: "
|
|
1711
|
-
"`pip install langchain-model-profiles`."
|
|
1712
|
-
)
|
|
1713
|
-
raise ImportError(informative_error_message) from err
|
|
1714
|
-
|
|
1715
|
-
provider_id = self._llm_type
|
|
1716
|
-
model_name = (
|
|
1717
|
-
# Model name is not standardized across integrations. New integrations
|
|
1718
|
-
# should prefer `model`.
|
|
1719
|
-
getattr(self, "model", None)
|
|
1720
|
-
or getattr(self, "model_name", None)
|
|
1721
|
-
or getattr(self, "model_id", "")
|
|
1722
|
-
)
|
|
1723
|
-
return get_model_profile(provider_id, model_name) or {}
|
|
1724
|
-
|
|
1725
1705
|
|
|
1726
1706
|
class SimpleChatModel(BaseChatModel):
|
|
1727
1707
|
"""Simplified implementation for a chat model to inherit from.
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"""Model profile types and utilities."""
|
|
2
|
+
|
|
3
|
+
from typing_extensions import TypedDict
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class ModelProfile(TypedDict, total=False):
|
|
7
|
+
"""Model profile.
|
|
8
|
+
|
|
9
|
+
!!! warning "Beta feature"
|
|
10
|
+
This is a beta feature. The format of model profiles is subject to change.
|
|
11
|
+
|
|
12
|
+
Provides information about chat model capabilities, such as context window sizes
|
|
13
|
+
and supported features.
|
|
14
|
+
"""
|
|
15
|
+
|
|
16
|
+
# --- Input constraints ---
|
|
17
|
+
|
|
18
|
+
max_input_tokens: int
|
|
19
|
+
"""Maximum context window (tokens)"""
|
|
20
|
+
|
|
21
|
+
image_inputs: bool
|
|
22
|
+
"""Whether image inputs are supported."""
|
|
23
|
+
# TODO: add more detail about formats?
|
|
24
|
+
|
|
25
|
+
image_url_inputs: bool
|
|
26
|
+
"""Whether [image URL inputs](https://docs.langchain.com/oss/python/langchain/models#multimodal)
|
|
27
|
+
are supported."""
|
|
28
|
+
|
|
29
|
+
pdf_inputs: bool
|
|
30
|
+
"""Whether [PDF inputs](https://docs.langchain.com/oss/python/langchain/models#multimodal)
|
|
31
|
+
are supported."""
|
|
32
|
+
# TODO: add more detail about formats? e.g. bytes or base64
|
|
33
|
+
|
|
34
|
+
audio_inputs: bool
|
|
35
|
+
"""Whether [audio inputs](https://docs.langchain.com/oss/python/langchain/models#multimodal)
|
|
36
|
+
are supported."""
|
|
37
|
+
# TODO: add more detail about formats? e.g. bytes or base64
|
|
38
|
+
|
|
39
|
+
video_inputs: bool
|
|
40
|
+
"""Whether [video inputs](https://docs.langchain.com/oss/python/langchain/models#multimodal)
|
|
41
|
+
are supported."""
|
|
42
|
+
# TODO: add more detail about formats? e.g. bytes or base64
|
|
43
|
+
|
|
44
|
+
image_tool_message: bool
|
|
45
|
+
"""Whether images can be included in tool messages."""
|
|
46
|
+
|
|
47
|
+
pdf_tool_message: bool
|
|
48
|
+
"""Whether PDFs can be included in tool messages."""
|
|
49
|
+
|
|
50
|
+
# --- Output constraints ---
|
|
51
|
+
|
|
52
|
+
max_output_tokens: int
|
|
53
|
+
"""Maximum output tokens"""
|
|
54
|
+
|
|
55
|
+
reasoning_output: bool
|
|
56
|
+
"""Whether the model supports [reasoning / chain-of-thought](https://docs.langchain.com/oss/python/langchain/models#reasoning)"""
|
|
57
|
+
|
|
58
|
+
image_outputs: bool
|
|
59
|
+
"""Whether [image outputs](https://docs.langchain.com/oss/python/langchain/models#multimodal)
|
|
60
|
+
are supported."""
|
|
61
|
+
|
|
62
|
+
audio_outputs: bool
|
|
63
|
+
"""Whether [audio outputs](https://docs.langchain.com/oss/python/langchain/models#multimodal)
|
|
64
|
+
are supported."""
|
|
65
|
+
|
|
66
|
+
video_outputs: bool
|
|
67
|
+
"""Whether [video outputs](https://docs.langchain.com/oss/python/langchain/models#multimodal)
|
|
68
|
+
are supported."""
|
|
69
|
+
|
|
70
|
+
# --- Tool calling ---
|
|
71
|
+
tool_calling: bool
|
|
72
|
+
"""Whether the model supports [tool calling](https://docs.langchain.com/oss/python/langchain/models#tool-calling)"""
|
|
73
|
+
|
|
74
|
+
tool_choice: bool
|
|
75
|
+
"""Whether the model supports [tool choice](https://docs.langchain.com/oss/python/langchain/models#forcing-tool-calls)"""
|
|
76
|
+
|
|
77
|
+
# --- Structured output ---
|
|
78
|
+
structured_output: bool
|
|
79
|
+
"""Whether the model supports a native [structured output](https://docs.langchain.com/oss/python/langchain/models#structured-outputs)
|
|
80
|
+
feature"""
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
ModelProfileRegistry = dict[str, ModelProfile]
|
|
84
|
+
"""Registry mapping model identifiers or names to their ModelProfile."""
|
|
@@ -124,9 +124,11 @@ class UsageMetadata(TypedDict):
|
|
|
124
124
|
```
|
|
125
125
|
|
|
126
126
|
!!! warning "Behavior changed in `langchain-core` 0.3.9"
|
|
127
|
+
|
|
127
128
|
Added `input_token_details` and `output_token_details`.
|
|
128
129
|
|
|
129
130
|
!!! note "LangSmith SDK"
|
|
131
|
+
|
|
130
132
|
The LangSmith SDK also has a `UsageMetadata` class. While the two share fields,
|
|
131
133
|
LangSmith's `UsageMetadata` has additional fields to capture cost information
|
|
132
134
|
used by the LangSmith platform.
|
|
@@ -654,7 +654,7 @@ class PlainTextContentBlock(TypedDict):
|
|
|
654
654
|
|
|
655
655
|
!!! note
|
|
656
656
|
Title and context are optional fields that may be passed to the model. See
|
|
657
|
-
Anthropic [example](https://
|
|
657
|
+
Anthropic [example](https://platform.claude.com/docs/en/build-with-claude/citations#citable-vs-non-citable-content).
|
|
658
658
|
|
|
659
659
|
!!! note "Factory function"
|
|
660
660
|
`create_plaintext_block` may also be used as a factory to create a
|
|
@@ -738,8 +738,10 @@ def trim_messages(
|
|
|
738
738
|
Set to `len` to count the number of **messages** in the chat history.
|
|
739
739
|
|
|
740
740
|
!!! note
|
|
741
|
+
|
|
741
742
|
Use `count_tokens_approximately` to get fast, approximate token
|
|
742
743
|
counts.
|
|
744
|
+
|
|
743
745
|
This is recommended for using `trim_messages` on the hot path, where
|
|
744
746
|
exact token counting is not necessary.
|
|
745
747
|
|
|
@@ -37,7 +37,7 @@ class PydanticOutputParser(JsonOutputParser, Generic[TBaseModel]):
|
|
|
37
37
|
def _parser_exception(
|
|
38
38
|
self, e: Exception, json_object: dict
|
|
39
39
|
) -> OutputParserException:
|
|
40
|
-
json_string = json.dumps(json_object)
|
|
40
|
+
json_string = json.dumps(json_object, ensure_ascii=False)
|
|
41
41
|
name = self.pydantic_object.__name__
|
|
42
42
|
msg = f"Failed to parse {name} from completion {json_string}. Got: {e}"
|
|
43
43
|
return OutputParserException(msg, llm_output=json_string)
|
|
@@ -903,23 +903,28 @@ class ChatPromptTemplate(BaseChatPromptTemplate):
|
|
|
903
903
|
5. A string which is shorthand for `("human", template)`; e.g.,
|
|
904
904
|
`"{user_input}"`
|
|
905
905
|
template_format: Format of the template.
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
906
|
+
**kwargs: Additional keyword arguments passed to `BasePromptTemplate`,
|
|
907
|
+
including (but not limited to):
|
|
908
|
+
|
|
909
|
+
- `input_variables`: A list of the names of the variables whose values
|
|
910
|
+
are required as inputs to the prompt.
|
|
911
|
+
- `optional_variables`: A list of the names of the variables for
|
|
912
|
+
placeholder or `MessagePlaceholder` that are optional.
|
|
913
|
+
|
|
914
|
+
These variables are auto inferred from the prompt and user need not
|
|
915
|
+
provide them.
|
|
916
|
+
|
|
917
|
+
- `partial_variables`: A dictionary of the partial variables the prompt
|
|
918
|
+
template carries.
|
|
919
|
+
|
|
920
|
+
Partial variables populate the template so that you don't need to
|
|
921
|
+
pass them in every time you call the prompt.
|
|
922
|
+
|
|
923
|
+
- `validate_template`: Whether to validate the template.
|
|
924
|
+
- `input_types`: A dictionary of the types of the variables the prompt
|
|
925
|
+
template expects.
|
|
926
|
+
|
|
927
|
+
If not provided, all variables are assumed to be strings.
|
|
923
928
|
|
|
924
929
|
Examples:
|
|
925
930
|
Instantiation from a list of message templates:
|
|
@@ -19,9 +19,66 @@ if TYPE_CHECKING:
|
|
|
19
19
|
from collections.abc import Callable, Sequence
|
|
20
20
|
|
|
21
21
|
try:
|
|
22
|
-
from jinja2 import
|
|
22
|
+
from jinja2 import meta
|
|
23
|
+
from jinja2.exceptions import SecurityError
|
|
23
24
|
from jinja2.sandbox import SandboxedEnvironment
|
|
24
25
|
|
|
26
|
+
class _RestrictedSandboxedEnvironment(SandboxedEnvironment):
|
|
27
|
+
"""A more restrictive Jinja2 sandbox that blocks all attribute/method access.
|
|
28
|
+
|
|
29
|
+
This sandbox only allows simple variable lookups, no attribute or method access.
|
|
30
|
+
This prevents template injection attacks via methods like parse_raw().
|
|
31
|
+
"""
|
|
32
|
+
|
|
33
|
+
def is_safe_attribute(self, _obj: Any, _attr: str, _value: Any) -> bool:
|
|
34
|
+
"""Block ALL attribute access for security.
|
|
35
|
+
|
|
36
|
+
Only allow accessing variables directly from the context dict,
|
|
37
|
+
no attribute access on those objects.
|
|
38
|
+
|
|
39
|
+
Args:
|
|
40
|
+
_obj: The object being accessed (unused, always blocked).
|
|
41
|
+
_attr: The attribute name (unused, always blocked).
|
|
42
|
+
_value: The attribute value (unused, always blocked).
|
|
43
|
+
|
|
44
|
+
Returns:
|
|
45
|
+
False - all attribute access is blocked.
|
|
46
|
+
"""
|
|
47
|
+
# Block all attribute access
|
|
48
|
+
return False
|
|
49
|
+
|
|
50
|
+
def is_safe_callable(self, _obj: Any) -> bool:
|
|
51
|
+
"""Block all method calls for security.
|
|
52
|
+
|
|
53
|
+
Args:
|
|
54
|
+
_obj: The object being checked (unused, always blocked).
|
|
55
|
+
|
|
56
|
+
Returns:
|
|
57
|
+
False - all callables are blocked.
|
|
58
|
+
"""
|
|
59
|
+
return False
|
|
60
|
+
|
|
61
|
+
def getattr(self, obj: Any, attribute: str) -> Any:
|
|
62
|
+
"""Override getattr to block all attribute access.
|
|
63
|
+
|
|
64
|
+
Args:
|
|
65
|
+
obj: The object.
|
|
66
|
+
attribute: The attribute name.
|
|
67
|
+
|
|
68
|
+
Returns:
|
|
69
|
+
Never returns.
|
|
70
|
+
|
|
71
|
+
Raises:
|
|
72
|
+
SecurityError: Always, to block attribute access.
|
|
73
|
+
"""
|
|
74
|
+
msg = (
|
|
75
|
+
f"Access to attributes is not allowed in templates. "
|
|
76
|
+
f"Attempted to access '{attribute}' on {type(obj).__name__}. "
|
|
77
|
+
f"Use only simple variable names like {{{{variable}}}} "
|
|
78
|
+
f"without dots or methods."
|
|
79
|
+
)
|
|
80
|
+
raise SecurityError(msg)
|
|
81
|
+
|
|
25
82
|
_HAS_JINJA2 = True
|
|
26
83
|
except ImportError:
|
|
27
84
|
_HAS_JINJA2 = False
|
|
@@ -61,14 +118,10 @@ def jinja2_formatter(template: str, /, **kwargs: Any) -> str:
|
|
|
61
118
|
)
|
|
62
119
|
raise ImportError(msg)
|
|
63
120
|
|
|
64
|
-
#
|
|
65
|
-
#
|
|
66
|
-
#
|
|
67
|
-
|
|
68
|
-
# We recommend to never use jinja2 templates with untrusted inputs.
|
|
69
|
-
# https://jinja.palletsprojects.com/en/3.1.x/sandbox/
|
|
70
|
-
# approach not a guarantee of security.
|
|
71
|
-
return SandboxedEnvironment().from_string(template).render(**kwargs)
|
|
121
|
+
# Use a restricted sandbox that blocks ALL attribute/method access
|
|
122
|
+
# Only simple variable lookups like {{variable}} are allowed
|
|
123
|
+
# Attribute access like {{variable.attr}} or {{variable.method()}} is blocked
|
|
124
|
+
return _RestrictedSandboxedEnvironment().from_string(template).render(**kwargs)
|
|
72
125
|
|
|
73
126
|
|
|
74
127
|
def validate_jinja2(template: str, input_variables: list[str]) -> None:
|
|
@@ -103,7 +156,7 @@ def _get_jinja2_variables_from_template(template: str) -> set[str]:
|
|
|
103
156
|
"Please install it with `pip install jinja2`."
|
|
104
157
|
)
|
|
105
158
|
raise ImportError(msg)
|
|
106
|
-
env =
|
|
159
|
+
env = _RestrictedSandboxedEnvironment()
|
|
107
160
|
ast = env.parse(template)
|
|
108
161
|
return meta.find_undeclared_variables(ast)
|
|
109
162
|
|
|
@@ -273,6 +326,30 @@ def get_template_variables(template: str, template_format: str) -> list[str]:
|
|
|
273
326
|
msg = f"Unsupported template format: {template_format}"
|
|
274
327
|
raise ValueError(msg)
|
|
275
328
|
|
|
329
|
+
# For f-strings, block attribute access and indexing syntax
|
|
330
|
+
# This prevents template injection attacks via accessing dangerous attributes
|
|
331
|
+
if template_format == "f-string":
|
|
332
|
+
for var in input_variables:
|
|
333
|
+
# Formatter().parse() returns field names with dots/brackets if present
|
|
334
|
+
# e.g., "obj.attr" or "obj[0]" - we need to block these
|
|
335
|
+
if "." in var or "[" in var or "]" in var:
|
|
336
|
+
msg = (
|
|
337
|
+
f"Invalid variable name {var!r} in f-string template. "
|
|
338
|
+
f"Variable names cannot contain attribute "
|
|
339
|
+
f"access (.) or indexing ([])."
|
|
340
|
+
)
|
|
341
|
+
raise ValueError(msg)
|
|
342
|
+
|
|
343
|
+
# Block variable names that are all digits (e.g., "0", "100")
|
|
344
|
+
# These are interpreted as positional arguments, not keyword arguments
|
|
345
|
+
if var.isdigit():
|
|
346
|
+
msg = (
|
|
347
|
+
f"Invalid variable name {var!r} in f-string template. "
|
|
348
|
+
f"Variable names cannot be all digits as they are interpreted "
|
|
349
|
+
f"as positional arguments."
|
|
350
|
+
)
|
|
351
|
+
raise ValueError(msg)
|
|
352
|
+
|
|
276
353
|
return sorted(input_variables)
|
|
277
354
|
|
|
278
355
|
|
|
@@ -49,7 +49,13 @@ class StructuredPrompt(ChatPromptTemplate):
|
|
|
49
49
|
structured_output_kwargs: additional kwargs for structured output.
|
|
50
50
|
template_format: template format for the prompt.
|
|
51
51
|
"""
|
|
52
|
-
schema_ = schema_ or kwargs.pop("schema")
|
|
52
|
+
schema_ = schema_ or kwargs.pop("schema", None)
|
|
53
|
+
if not schema_:
|
|
54
|
+
err_msg = (
|
|
55
|
+
"Must pass in a non-empty structured output schema. Received: "
|
|
56
|
+
f"{schema_}"
|
|
57
|
+
)
|
|
58
|
+
raise ValueError(err_msg)
|
|
53
59
|
structured_output_kwargs = structured_output_kwargs or {}
|
|
54
60
|
for k in set(kwargs).difference(get_pydantic_field_names(self.__class__)):
|
|
55
61
|
structured_output_kwargs[k] = kwargs.pop(k)
|