langchain-core 0.3.0.dev1__tar.gz → 0.3.0.dev3__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-0.3.0.dev1 → langchain_core-0.3.0.dev3}/PKG-INFO +3 -3
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/_api/deprecation.py +20 -1
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/documents/base.py +0 -5
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/example_selectors/length_based.py +11 -13
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/indexing/in_memory.py +2 -2
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/language_models/base.py +2 -2
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/load/load.py +1 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/load/mapping.py +11 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/load/serializable.py +0 -6
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/messages/base.py +1 -6
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/messages/utils.py +27 -20
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/output_parsers/json.py +2 -2
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/output_parsers/openai_functions.py +7 -3
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/output_parsers/pydantic.py +1 -1
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/prompts/base.py +1 -1
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/runnables/base.py +77 -5
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/runnables/branch.py +4 -1
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/runnables/configurable.py +4 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/runnables/fallbacks.py +1 -1
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/runnables/utils.py +27 -5
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/tools/base.py +27 -8
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/tools/convert.py +4 -4
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/tools/simple.py +1 -1
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/tools/structured.py +1 -1
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/tracers/core.py +1 -1
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/tracers/langchain.py +18 -6
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/tracers/schemas.py +9 -3
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/utils/function_calling.py +1 -1
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/utils/pydantic.py +37 -59
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/utils/utils.py +1 -1
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/pyproject.toml +28 -14
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/README.md +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/__init__.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/_api/__init__.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/_api/beta_decorator.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/_api/internal.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/_api/path.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/agents.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/beta/__init__.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/beta/runnables/__init__.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/beta/runnables/context.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/caches.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/callbacks/__init__.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/callbacks/base.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/callbacks/file.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/callbacks/manager.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/callbacks/stdout.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/callbacks/streaming_stdout.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/chat_history.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/chat_loaders.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/chat_sessions.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/document_loaders/__init__.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/document_loaders/base.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/document_loaders/blob_loaders.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/document_loaders/langsmith.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/documents/__init__.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/documents/compressor.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/documents/transformers.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/embeddings/__init__.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/embeddings/embeddings.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/embeddings/fake.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/env.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/example_selectors/__init__.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/example_selectors/base.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/example_selectors/semantic_similarity.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/exceptions.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/globals.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/graph_vectorstores/__init__.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/graph_vectorstores/base.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/graph_vectorstores/links.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/indexing/__init__.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/indexing/api.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/indexing/base.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/language_models/__init__.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/language_models/chat_models.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/language_models/fake.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/language_models/fake_chat_models.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/language_models/llms.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/load/__init__.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/load/dump.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/memory.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/messages/__init__.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/messages/ai.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/messages/chat.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/messages/function.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/messages/human.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/messages/modifier.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/messages/system.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/messages/tool.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/output_parsers/__init__.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/output_parsers/base.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/output_parsers/format_instructions.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/output_parsers/list.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/output_parsers/openai_tools.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/output_parsers/string.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/output_parsers/transform.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/output_parsers/xml.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/outputs/__init__.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/outputs/chat_generation.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/outputs/chat_result.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/outputs/generation.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/outputs/llm_result.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/outputs/run_info.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/prompt_values.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/prompts/__init__.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/prompts/chat.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/prompts/few_shot.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/prompts/few_shot_with_templates.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/prompts/image.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/prompts/loading.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/prompts/pipeline.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/prompts/prompt.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/prompts/string.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/prompts/structured.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/py.typed +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/pydantic_v1/__init__.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/pydantic_v1/dataclasses.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/pydantic_v1/main.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/rate_limiters.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/retrievers.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/runnables/__init__.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/runnables/config.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/runnables/graph.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/runnables/graph_ascii.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/runnables/graph_mermaid.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/runnables/graph_png.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/runnables/history.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/runnables/learnable.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/runnables/passthrough.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/runnables/retry.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/runnables/router.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/runnables/schema.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/stores.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/structured_query.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/sys_info.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/tools/__init__.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/tools/render.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/tools/retriever.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/tracers/__init__.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/tracers/_streaming.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/tracers/base.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/tracers/context.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/tracers/evaluation.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/tracers/event_stream.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/tracers/langchain_v1.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/tracers/log_stream.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/tracers/memory_stream.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/tracers/root_listeners.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/tracers/run_collector.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/tracers/stdout.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/utils/__init__.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/utils/_merge.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/utils/aiter.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/utils/env.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/utils/formatting.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/utils/html.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/utils/image.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/utils/input.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/utils/interactive_env.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/utils/iter.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/utils/json.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/utils/json_schema.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/utils/loading.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/utils/mustache.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/utils/strings.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/vectorstores/__init__.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/vectorstores/base.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/vectorstores/in_memory.py +0 -0
- {langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/vectorstores/utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: langchain-core
|
|
3
|
-
Version: 0.3.0.
|
|
3
|
+
Version: 0.3.0.dev3
|
|
4
4
|
Summary: Building applications with LLMs through composability
|
|
5
5
|
Home-page: https://github.com/langchain-ai/langchain
|
|
6
6
|
License: MIT
|
|
@@ -13,9 +13,9 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.12
|
|
14
14
|
Requires-Dist: PyYAML (>=5.3)
|
|
15
15
|
Requires-Dist: jsonpatch (>=1.33,<2.0)
|
|
16
|
-
Requires-Dist: langsmith (>=0.1.
|
|
16
|
+
Requires-Dist: langsmith (>=0.1.112,<0.2.0)
|
|
17
17
|
Requires-Dist: packaging (>=23.2,<25)
|
|
18
|
-
Requires-Dist: pydantic (>=2,<3)
|
|
18
|
+
Requires-Dist: pydantic (>=2.9,<3.0)
|
|
19
19
|
Requires-Dist: tenacity (>=8.1.0,<9.0.0,!=8.4.0)
|
|
20
20
|
Requires-Dist: typing-extensions (>=4.7)
|
|
21
21
|
Project-URL: Repository, https://github.com/langchain-ai/langchain
|
|
@@ -144,7 +144,7 @@ def deprecated(
|
|
|
144
144
|
_package: str = package,
|
|
145
145
|
) -> T:
|
|
146
146
|
"""Implementation of the decorator returned by `deprecated`."""
|
|
147
|
-
from langchain_core.utils.pydantic import FieldInfoV1
|
|
147
|
+
from langchain_core.utils.pydantic import FieldInfoV1, FieldInfoV2
|
|
148
148
|
|
|
149
149
|
def emit_warning() -> None:
|
|
150
150
|
"""Emit the warning."""
|
|
@@ -238,6 +238,25 @@ def deprecated(
|
|
|
238
238
|
exclude=obj.exclude,
|
|
239
239
|
),
|
|
240
240
|
)
|
|
241
|
+
elif isinstance(obj, FieldInfoV2):
|
|
242
|
+
wrapped = None
|
|
243
|
+
if not _obj_type:
|
|
244
|
+
_obj_type = "attribute"
|
|
245
|
+
if not _name:
|
|
246
|
+
raise ValueError(f"Field {obj} must have a name to be deprecated.")
|
|
247
|
+
old_doc = obj.description
|
|
248
|
+
|
|
249
|
+
def finalize(wrapper: Callable[..., Any], new_doc: str) -> T:
|
|
250
|
+
return cast(
|
|
251
|
+
T,
|
|
252
|
+
FieldInfoV2(
|
|
253
|
+
default=obj.default,
|
|
254
|
+
default_factory=obj.default_factory,
|
|
255
|
+
description=new_doc,
|
|
256
|
+
alias=obj.alias,
|
|
257
|
+
exclude=obj.exclude,
|
|
258
|
+
),
|
|
259
|
+
)
|
|
241
260
|
|
|
242
261
|
elif isinstance(obj, property):
|
|
243
262
|
if not _obj_type:
|
|
@@ -9,7 +9,6 @@ from typing import Any, Dict, Generator, List, Literal, Optional, Union, cast
|
|
|
9
9
|
from pydantic import ConfigDict, Field, model_validator
|
|
10
10
|
|
|
11
11
|
from langchain_core.load.serializable import Serializable
|
|
12
|
-
from langchain_core.utils.pydantic import v1_repr
|
|
13
12
|
|
|
14
13
|
PathLike = Union[str, PurePath]
|
|
15
14
|
|
|
@@ -297,7 +296,3 @@ class Document(BaseMedia):
|
|
|
297
296
|
return f"page_content='{self.page_content}' metadata={self.metadata}"
|
|
298
297
|
else:
|
|
299
298
|
return f"page_content='{self.page_content}'"
|
|
300
|
-
|
|
301
|
-
def __repr__(self) -> str:
|
|
302
|
-
# TODO(0.3): Remove this override after confirming unit tests!
|
|
303
|
-
return v1_repr(self)
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
import re
|
|
4
4
|
from typing import Callable, Dict, List
|
|
5
5
|
|
|
6
|
-
from pydantic import BaseModel,
|
|
6
|
+
from pydantic import BaseModel, Field, model_validator
|
|
7
|
+
from typing_extensions import Self
|
|
7
8
|
|
|
8
9
|
from langchain_core.example_selectors.base import BaseExampleSelector
|
|
9
10
|
from langchain_core.prompts.prompt import PromptTemplate
|
|
@@ -28,7 +29,7 @@ class LengthBasedExampleSelector(BaseExampleSelector, BaseModel):
|
|
|
28
29
|
max_length: int = 2048
|
|
29
30
|
"""Max length for the prompt, beyond which examples are cut."""
|
|
30
31
|
|
|
31
|
-
example_text_lengths: List[int] =
|
|
32
|
+
example_text_lengths: List[int] = Field(default_factory=list) # :meta private:
|
|
32
33
|
"""Length of each example."""
|
|
33
34
|
|
|
34
35
|
def add_example(self, example: Dict[str, str]) -> None:
|
|
@@ -52,17 +53,14 @@ class LengthBasedExampleSelector(BaseExampleSelector, BaseModel):
|
|
|
52
53
|
|
|
53
54
|
self.add_example(example)
|
|
54
55
|
|
|
55
|
-
@
|
|
56
|
-
def
|
|
57
|
-
"""
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
get_text_length = values["get_text_length"]
|
|
64
|
-
string_examples = [example_prompt.format(**eg) for eg in values["examples"]]
|
|
65
|
-
return [get_text_length(eg) for eg in string_examples]
|
|
56
|
+
@model_validator(mode="after")
|
|
57
|
+
def post_init(self) -> Self:
|
|
58
|
+
"""Validate that the examples are formatted correctly."""
|
|
59
|
+
if self.example_text_lengths:
|
|
60
|
+
return self
|
|
61
|
+
string_examples = [self.example_prompt.format(**eg) for eg in self.examples]
|
|
62
|
+
self.example_text_lengths = [self.get_text_length(eg) for eg in string_examples]
|
|
63
|
+
return self
|
|
66
64
|
|
|
67
65
|
def select_examples(self, input_variables: Dict[str, str]) -> List[dict]:
|
|
68
66
|
"""Select which examples to use based on the input lengths.
|
{langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/indexing/in_memory.py
RENAMED
|
@@ -32,7 +32,7 @@ class InMemoryDocumentIndex(DocumentIndex):
|
|
|
32
32
|
for item in items:
|
|
33
33
|
if item.id is None:
|
|
34
34
|
id_ = str(uuid.uuid4())
|
|
35
|
-
item_ = item.
|
|
35
|
+
item_ = item.model_copy()
|
|
36
36
|
item_.id = id_
|
|
37
37
|
else:
|
|
38
38
|
item_ = item
|
|
@@ -79,4 +79,4 @@ class InMemoryDocumentIndex(DocumentIndex):
|
|
|
79
79
|
counts_by_doc.append((document, count))
|
|
80
80
|
|
|
81
81
|
counts_by_doc.sort(key=lambda x: x[1], reverse=True)
|
|
82
|
-
return [doc.
|
|
82
|
+
return [doc.model_copy() for doc, count in counts_by_doc[: self.top_k]]
|
{langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/language_models/base.py
RENAMED
|
@@ -18,7 +18,7 @@ from typing import (
|
|
|
18
18
|
Union,
|
|
19
19
|
)
|
|
20
20
|
|
|
21
|
-
from pydantic import BaseModel, ConfigDict, Field,
|
|
21
|
+
from pydantic import BaseModel, ConfigDict, Field, field_validator
|
|
22
22
|
from typing_extensions import TypeAlias, TypedDict
|
|
23
23
|
|
|
24
24
|
from langchain_core._api import deprecated
|
|
@@ -134,7 +134,7 @@ class BaseLanguageModel(
|
|
|
134
134
|
arbitrary_types_allowed=True,
|
|
135
135
|
)
|
|
136
136
|
|
|
137
|
-
@
|
|
137
|
+
@field_validator("verbose", mode="before")
|
|
138
138
|
def set_verbose(cls, verbose: Optional[bool]) -> bool:
|
|
139
139
|
"""If verbose is None, set it.
|
|
140
140
|
|
|
@@ -297,6 +297,17 @@ SERIALIZABLE_MAPPING: Dict[Tuple[str, ...], Tuple[str, ...]] = {
|
|
|
297
297
|
"chat_models",
|
|
298
298
|
"ChatMistralAI",
|
|
299
299
|
),
|
|
300
|
+
("langchain", "chat_models", "bedrock", "ChatBedrock"): (
|
|
301
|
+
"langchain_aws",
|
|
302
|
+
"chat_models",
|
|
303
|
+
"bedrock",
|
|
304
|
+
"ChatBedrock",
|
|
305
|
+
),
|
|
306
|
+
("langchain_google_genai", "chat_models", "ChatGoogleGenerativeAI"): (
|
|
307
|
+
"langchain_google_genai",
|
|
308
|
+
"chat_models",
|
|
309
|
+
"ChatGoogleGenerativeAI",
|
|
310
|
+
),
|
|
300
311
|
("langchain", "schema", "output", "ChatGenerationChunk"): (
|
|
301
312
|
"langchain_core",
|
|
302
313
|
"outputs",
|
|
@@ -13,8 +13,6 @@ from typing import (
|
|
|
13
13
|
from pydantic import BaseModel, ConfigDict
|
|
14
14
|
from typing_extensions import NotRequired
|
|
15
15
|
|
|
16
|
-
from langchain_core.utils.pydantic import v1_repr
|
|
17
|
-
|
|
18
16
|
|
|
19
17
|
class BaseSerialized(TypedDict):
|
|
20
18
|
"""Base class for serialized objects.
|
|
@@ -259,10 +257,6 @@ class Serializable(BaseModel, ABC):
|
|
|
259
257
|
def to_json_not_implemented(self) -> SerializedNotImplemented:
|
|
260
258
|
return to_json_not_implemented(self)
|
|
261
259
|
|
|
262
|
-
def __repr__(self) -> str:
|
|
263
|
-
# TODO(0.3): Remove this override after confirming unit tests!
|
|
264
|
-
return v1_repr(self)
|
|
265
|
-
|
|
266
260
|
|
|
267
261
|
def _is_field_useful(inst: Serializable, key: str, value: Any) -> bool:
|
|
268
262
|
"""Check if a field is useful as a constructor argument.
|
|
@@ -8,7 +8,6 @@ from langchain_core.load.serializable import Serializable
|
|
|
8
8
|
from langchain_core.utils import get_bolded_text
|
|
9
9
|
from langchain_core.utils._merge import merge_dicts, merge_lists
|
|
10
10
|
from langchain_core.utils.interactive_env import is_interactive_env
|
|
11
|
-
from langchain_core.utils.pydantic import v1_repr
|
|
12
11
|
|
|
13
12
|
if TYPE_CHECKING:
|
|
14
13
|
from langchain_core.prompts.chat import ChatPromptTemplate
|
|
@@ -111,10 +110,6 @@ class BaseMessage(Serializable):
|
|
|
111
110
|
def pretty_print(self) -> None:
|
|
112
111
|
print(self.pretty_repr(html=is_interactive_env())) # noqa: T201
|
|
113
112
|
|
|
114
|
-
def __repr__(self) -> str:
|
|
115
|
-
# TODO(0.3): Remove this override after confirming unit tests!
|
|
116
|
-
return v1_repr(self)
|
|
117
|
-
|
|
118
113
|
|
|
119
114
|
def merge_content(
|
|
120
115
|
first_content: Union[str, List[Union[str, Dict]]],
|
|
@@ -237,7 +232,7 @@ def message_to_dict(message: BaseMessage) -> dict:
|
|
|
237
232
|
Message as a dict. The dict will have a "type" key with the message type
|
|
238
233
|
and a "data" key with the message data as a dict.
|
|
239
234
|
"""
|
|
240
|
-
return {"type": message.type, "data": message.
|
|
235
|
+
return {"type": message.type, "data": message.model_dump()}
|
|
241
236
|
|
|
242
237
|
|
|
243
238
|
def messages_to_dict(messages: Sequence[BaseMessage]) -> List[dict]:
|
|
@@ -29,6 +29,9 @@ from typing import (
|
|
|
29
29
|
overload,
|
|
30
30
|
)
|
|
31
31
|
|
|
32
|
+
from pydantic import Discriminator, Field
|
|
33
|
+
from typing_extensions import Annotated
|
|
34
|
+
|
|
32
35
|
from langchain_core.messages.ai import AIMessage, AIMessageChunk
|
|
33
36
|
from langchain_core.messages.base import BaseMessage, BaseMessageChunk
|
|
34
37
|
from langchain_core.messages.chat import ChatMessage, ChatMessageChunk
|
|
@@ -45,19 +48,23 @@ if TYPE_CHECKING:
|
|
|
45
48
|
from langchain_core.prompt_values import PromptValue
|
|
46
49
|
from langchain_core.runnables.base import Runnable
|
|
47
50
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
51
|
+
|
|
52
|
+
AnyMessage = Annotated[
|
|
53
|
+
Union[
|
|
54
|
+
AIMessage,
|
|
55
|
+
HumanMessage,
|
|
56
|
+
ChatMessage,
|
|
57
|
+
SystemMessage,
|
|
58
|
+
FunctionMessage,
|
|
59
|
+
ToolMessage,
|
|
60
|
+
AIMessageChunk,
|
|
61
|
+
HumanMessageChunk,
|
|
62
|
+
ChatMessageChunk,
|
|
63
|
+
SystemMessageChunk,
|
|
64
|
+
FunctionMessageChunk,
|
|
65
|
+
ToolMessageChunk,
|
|
66
|
+
],
|
|
67
|
+
Field(discriminator=Discriminator("type")),
|
|
61
68
|
]
|
|
62
69
|
|
|
63
70
|
|
|
@@ -521,7 +528,7 @@ def merge_message_runs(
|
|
|
521
528
|
messages = convert_to_messages(messages)
|
|
522
529
|
merged: List[BaseMessage] = []
|
|
523
530
|
for msg in messages:
|
|
524
|
-
curr = msg.
|
|
531
|
+
curr = msg.model_copy(deep=True)
|
|
525
532
|
last = merged.pop() if merged else None
|
|
526
533
|
if not last:
|
|
527
534
|
merged.append(curr)
|
|
@@ -872,7 +879,7 @@ def _first_max_tokens(
|
|
|
872
879
|
if idx < len(messages) - 1 and partial_strategy:
|
|
873
880
|
included_partial = False
|
|
874
881
|
if isinstance(messages[idx].content, list):
|
|
875
|
-
excluded = messages[idx].
|
|
882
|
+
excluded = messages[idx].model_copy(deep=True)
|
|
876
883
|
num_block = len(excluded.content)
|
|
877
884
|
if partial_strategy == "last":
|
|
878
885
|
excluded.content = list(reversed(excluded.content))
|
|
@@ -886,7 +893,7 @@ def _first_max_tokens(
|
|
|
886
893
|
if included_partial and partial_strategy == "last":
|
|
887
894
|
excluded.content = list(reversed(excluded.content))
|
|
888
895
|
if not included_partial:
|
|
889
|
-
excluded = messages[idx].
|
|
896
|
+
excluded = messages[idx].model_copy(deep=True)
|
|
890
897
|
if isinstance(excluded.content, list) and any(
|
|
891
898
|
isinstance(block, str) or block["type"] == "text"
|
|
892
899
|
for block in messages[idx].content
|
|
@@ -977,11 +984,11 @@ _CHUNK_MSG_MAP = {v: k for k, v in _MSG_CHUNK_MAP.items()}
|
|
|
977
984
|
|
|
978
985
|
def _msg_to_chunk(message: BaseMessage) -> BaseMessageChunk:
|
|
979
986
|
if message.__class__ in _MSG_CHUNK_MAP:
|
|
980
|
-
return _MSG_CHUNK_MAP[message.__class__](**message.
|
|
987
|
+
return _MSG_CHUNK_MAP[message.__class__](**message.model_dump(exclude={"type"}))
|
|
981
988
|
|
|
982
989
|
for msg_cls, chunk_cls in _MSG_CHUNK_MAP.items():
|
|
983
990
|
if isinstance(message, msg_cls):
|
|
984
|
-
return chunk_cls(**message.
|
|
991
|
+
return chunk_cls(**message.model_dump(exclude={"type"}))
|
|
985
992
|
|
|
986
993
|
raise ValueError(
|
|
987
994
|
f"Unrecognized message class {message.__class__}. Supported classes are "
|
|
@@ -992,11 +999,11 @@ def _msg_to_chunk(message: BaseMessage) -> BaseMessageChunk:
|
|
|
992
999
|
def _chunk_to_msg(chunk: BaseMessageChunk) -> BaseMessage:
|
|
993
1000
|
if chunk.__class__ in _CHUNK_MSG_MAP:
|
|
994
1001
|
return _CHUNK_MSG_MAP[chunk.__class__](
|
|
995
|
-
**chunk.
|
|
1002
|
+
**chunk.model_dump(exclude={"type", "tool_call_chunks"})
|
|
996
1003
|
)
|
|
997
1004
|
for chunk_cls, msg_cls in _CHUNK_MSG_MAP.items():
|
|
998
1005
|
if isinstance(chunk, chunk_cls):
|
|
999
|
-
return msg_cls(**chunk.
|
|
1006
|
+
return msg_cls(**chunk.model_dump(exclude={"type", "tool_call_chunks"}))
|
|
1000
1007
|
|
|
1001
1008
|
raise ValueError(
|
|
1002
1009
|
f"Unrecognized message chunk class {chunk.__class__}. Supported classes are "
|
{langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/output_parsers/json.py
RENAMED
|
@@ -54,8 +54,8 @@ class JsonOutputParser(BaseCumulativeTransformOutputParser[Any]):
|
|
|
54
54
|
if issubclass(pydantic_object, pydantic.BaseModel):
|
|
55
55
|
return pydantic_object.model_json_schema()
|
|
56
56
|
elif issubclass(pydantic_object, pydantic.v1.BaseModel):
|
|
57
|
-
return pydantic_object.
|
|
58
|
-
return pydantic_object.
|
|
57
|
+
return pydantic_object.model_json_schema()
|
|
58
|
+
return pydantic_object.model_json_schema()
|
|
59
59
|
|
|
60
60
|
def parse_result(self, result: List[Generation], *, partial: bool = False) -> Any:
|
|
61
61
|
"""Parse the result of an LLM call to a JSON object.
|
|
@@ -275,10 +275,14 @@ class PydanticOutputFunctionsParser(OutputFunctionsParser):
|
|
|
275
275
|
else:
|
|
276
276
|
fn_name = _result["name"]
|
|
277
277
|
_args = _result["arguments"]
|
|
278
|
-
if
|
|
279
|
-
|
|
278
|
+
if isinstance(self.pydantic_schema, dict):
|
|
279
|
+
pydantic_schema = self.pydantic_schema[fn_name]
|
|
280
|
+
else:
|
|
281
|
+
pydantic_schema = self.pydantic_schema
|
|
282
|
+
if hasattr(pydantic_schema, "model_validate_json"):
|
|
283
|
+
pydantic_args = pydantic_schema.model_validate_json(_args) # type: ignore
|
|
280
284
|
else:
|
|
281
|
-
pydantic_args =
|
|
285
|
+
pydantic_args = pydantic_schema.parse_raw(_args) # type: ignore
|
|
282
286
|
return pydantic_args
|
|
283
287
|
|
|
284
288
|
|
{langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/output_parsers/pydantic.py
RENAMED
|
@@ -90,7 +90,7 @@ class PydanticOutputParser(JsonOutputParser, Generic[TBaseModel]):
|
|
|
90
90
|
The format instructions for the JSON output.
|
|
91
91
|
"""
|
|
92
92
|
# Copy schema to avoid altering original Pydantic schema.
|
|
93
|
-
schema = {k: v for k, v in self.pydantic_object.
|
|
93
|
+
schema = {k: v for k, v in self.pydantic_object.model_json_schema().items()}
|
|
94
94
|
|
|
95
95
|
# Remove extraneous fields.
|
|
96
96
|
reduced_schema = schema
|
|
@@ -310,7 +310,7 @@ class BasePromptTemplate(
|
|
|
310
310
|
Raises:
|
|
311
311
|
NotImplementedError: If the prompt type is not implemented.
|
|
312
312
|
"""
|
|
313
|
-
prompt_dict = super().
|
|
313
|
+
prompt_dict = super().model_dump(**kwargs)
|
|
314
314
|
try:
|
|
315
315
|
prompt_dict["_type"] = self._prompt_type
|
|
316
316
|
except NotImplementedError:
|
|
@@ -204,8 +204,8 @@ class Runnable(Generic[Input, Output], ABC):
|
|
|
204
204
|
)
|
|
205
205
|
)
|
|
206
206
|
|
|
207
|
-
print(sequence.input_schema.
|
|
208
|
-
print(sequence.output_schema.
|
|
207
|
+
print(sequence.input_schema.model_json_schema()) # Show inferred input schema
|
|
208
|
+
print(sequence.output_schema.model_json_schema()) # Show inferred output schema
|
|
209
209
|
print(sequence.invoke(2)) # invoke the sequence (note the retry above!!)
|
|
210
210
|
|
|
211
211
|
Debugging and tracing
|
|
@@ -350,6 +350,34 @@ class Runnable(Generic[Input, Output], ABC):
|
|
|
350
350
|
__root__=root_type,
|
|
351
351
|
)
|
|
352
352
|
|
|
353
|
+
def get_input_jsonschema(
|
|
354
|
+
self, config: Optional[RunnableConfig] = None
|
|
355
|
+
) -> Dict[str, Any]:
|
|
356
|
+
"""Get a JSON schema that represents the input to the Runnable.
|
|
357
|
+
|
|
358
|
+
Args:
|
|
359
|
+
config: A config to use when generating the schema.
|
|
360
|
+
|
|
361
|
+
Returns:
|
|
362
|
+
A JSON schema that represents the input to the Runnable.
|
|
363
|
+
|
|
364
|
+
Example:
|
|
365
|
+
|
|
366
|
+
.. code-block:: python
|
|
367
|
+
|
|
368
|
+
from langchain_core.runnables import RunnableLambda
|
|
369
|
+
|
|
370
|
+
def add_one(x: int) -> int:
|
|
371
|
+
return x + 1
|
|
372
|
+
|
|
373
|
+
runnable = RunnableLambda(add_one)
|
|
374
|
+
|
|
375
|
+
print(runnable.get_input_jsonschema())
|
|
376
|
+
|
|
377
|
+
.. versionadded:: 0.3.0
|
|
378
|
+
"""
|
|
379
|
+
return self.get_input_schema(config).model_json_schema()
|
|
380
|
+
|
|
353
381
|
@property
|
|
354
382
|
def output_schema(self) -> Type[BaseModel]:
|
|
355
383
|
"""The type of output this Runnable produces specified as a pydantic model."""
|
|
@@ -382,6 +410,34 @@ class Runnable(Generic[Input, Output], ABC):
|
|
|
382
410
|
__root__=root_type,
|
|
383
411
|
)
|
|
384
412
|
|
|
413
|
+
def get_output_jsonschema(
|
|
414
|
+
self, config: Optional[RunnableConfig] = None
|
|
415
|
+
) -> Dict[str, Any]:
|
|
416
|
+
"""Get a JSON schema that represents the output of the Runnable.
|
|
417
|
+
|
|
418
|
+
Args:
|
|
419
|
+
config: A config to use when generating the schema.
|
|
420
|
+
|
|
421
|
+
Returns:
|
|
422
|
+
A JSON schema that represents the output of the Runnable.
|
|
423
|
+
|
|
424
|
+
Example:
|
|
425
|
+
|
|
426
|
+
.. code-block:: python
|
|
427
|
+
|
|
428
|
+
from langchain_core.runnables import RunnableLambda
|
|
429
|
+
|
|
430
|
+
def add_one(x: int) -> int:
|
|
431
|
+
return x + 1
|
|
432
|
+
|
|
433
|
+
runnable = RunnableLambda(add_one)
|
|
434
|
+
|
|
435
|
+
print(runnable.get_output_jsonschema())
|
|
436
|
+
|
|
437
|
+
.. versionadded:: 0.3.0
|
|
438
|
+
"""
|
|
439
|
+
return self.get_output_schema(config).model_json_schema()
|
|
440
|
+
|
|
385
441
|
@property
|
|
386
442
|
def config_specs(self) -> List[ConfigurableFieldSpec]:
|
|
387
443
|
"""List configurable fields for this Runnable."""
|
|
@@ -435,6 +491,21 @@ class Runnable(Generic[Input, Output], ABC):
|
|
|
435
491
|
)
|
|
436
492
|
return model
|
|
437
493
|
|
|
494
|
+
def get_config_jsonschema(
|
|
495
|
+
self, *, include: Optional[Sequence[str]] = None
|
|
496
|
+
) -> Dict[str, Any]:
|
|
497
|
+
"""Get a JSON schema that represents the output of the Runnable.
|
|
498
|
+
|
|
499
|
+
Args:
|
|
500
|
+
include: A list of fields to include in the config schema.
|
|
501
|
+
|
|
502
|
+
Returns:
|
|
503
|
+
A JSON schema that represents the output of the Runnable.
|
|
504
|
+
|
|
505
|
+
.. versionadded:: 0.3.0
|
|
506
|
+
"""
|
|
507
|
+
return self.config_schema(include=include).model_json_schema()
|
|
508
|
+
|
|
438
509
|
def get_graph(self, config: Optional[RunnableConfig] = None) -> Graph:
|
|
439
510
|
"""Return a graph representation of this Runnable."""
|
|
440
511
|
from langchain_core.runnables.graph import Graph
|
|
@@ -612,10 +683,10 @@ class Runnable(Generic[Input, Output], ABC):
|
|
|
612
683
|
|
|
613
684
|
chain_with_assign = chain.assign(hello=itemgetter("str") | llm)
|
|
614
685
|
|
|
615
|
-
print(chain_with_assign.input_schema.
|
|
686
|
+
print(chain_with_assign.input_schema.model_json_schema())
|
|
616
687
|
# {'title': 'PromptInput', 'type': 'object', 'properties':
|
|
617
688
|
{'question': {'title': 'Question', 'type': 'string'}}}
|
|
618
|
-
print(chain_with_assign.output_schema.
|
|
689
|
+
print(chain_with_assign.output_schema.model_json_schema()) #
|
|
619
690
|
{'title': 'RunnableSequenceOutput', 'type': 'object', 'properties':
|
|
620
691
|
{'str': {'title': 'Str',
|
|
621
692
|
'type': 'string'}, 'hello': {'title': 'Hello', 'type': 'string'}}}
|
|
@@ -3491,7 +3562,8 @@ class RunnableParallel(RunnableSerializable[Input, Dict[str, Any]]):
|
|
|
3491
3562
|
The input schema of the Runnable.
|
|
3492
3563
|
"""
|
|
3493
3564
|
if all(
|
|
3494
|
-
s.get_input_schema(config).
|
|
3565
|
+
s.get_input_schema(config).model_json_schema().get("type", "object")
|
|
3566
|
+
== "object"
|
|
3495
3567
|
for s in self.steps__.values()
|
|
3496
3568
|
):
|
|
3497
3569
|
# This is correct, but pydantic typings/mypy don't think so.
|
|
@@ -171,7 +171,10 @@ class RunnableBranch(RunnableSerializable[Input, Output]):
|
|
|
171
171
|
)
|
|
172
172
|
|
|
173
173
|
for runnable in runnables:
|
|
174
|
-
if
|
|
174
|
+
if (
|
|
175
|
+
runnable.get_input_schema(config).model_json_schema().get("type")
|
|
176
|
+
is not None
|
|
177
|
+
):
|
|
175
178
|
return runnable.get_input_schema(config)
|
|
176
179
|
|
|
177
180
|
return super().get_input_schema(config)
|
{langchain_core-0.3.0.dev1 → langchain_core-0.3.0.dev3}/langchain_core/runnables/configurable.py
RENAMED
|
@@ -18,6 +18,7 @@ from typing import (
|
|
|
18
18
|
Union,
|
|
19
19
|
cast,
|
|
20
20
|
)
|
|
21
|
+
from typing import Mapping as Mapping
|
|
21
22
|
from weakref import WeakValueDictionary
|
|
22
23
|
|
|
23
24
|
from pydantic import BaseModel, ConfigDict
|
|
@@ -453,6 +454,9 @@ class RunnableConfigurableFields(DynamicRunnable[Input, Output]):
|
|
|
453
454
|
return (self.default, config)
|
|
454
455
|
|
|
455
456
|
|
|
457
|
+
RunnableConfigurableFields.model_rebuild()
|
|
458
|
+
|
|
459
|
+
|
|
456
460
|
# Before Python 3.11 native StrEnum is not available
|
|
457
461
|
class StrEnum(str, enum.Enum):
|
|
458
462
|
"""String enum."""
|
|
@@ -6,6 +6,7 @@ import ast
|
|
|
6
6
|
import asyncio
|
|
7
7
|
import inspect
|
|
8
8
|
import textwrap
|
|
9
|
+
import warnings
|
|
9
10
|
from functools import lru_cache
|
|
10
11
|
from inspect import signature
|
|
11
12
|
from itertools import groupby
|
|
@@ -31,13 +32,14 @@ from typing import (
|
|
|
31
32
|
cast,
|
|
32
33
|
)
|
|
33
34
|
|
|
34
|
-
from pydantic import BaseModel, ConfigDict, RootModel
|
|
35
|
+
from pydantic import BaseModel, ConfigDict, PydanticDeprecationWarning, RootModel
|
|
35
36
|
from pydantic import create_model as _create_model_base # pydantic :ignore
|
|
36
37
|
from pydantic.json_schema import (
|
|
37
38
|
DEFAULT_REF_TEMPLATE,
|
|
38
39
|
GenerateJsonSchema,
|
|
39
40
|
JsonSchemaMode,
|
|
40
41
|
)
|
|
42
|
+
from pydantic.v1 import BaseModel as BaseModelV1
|
|
41
43
|
from typing_extensions import TypeGuard
|
|
42
44
|
|
|
43
45
|
from langchain_core.runnables.schema import StreamEvent
|
|
@@ -710,7 +712,7 @@ _SchemaConfig = ConfigDict(arbitrary_types_allowed=True, frozen=True)
|
|
|
710
712
|
NO_DEFAULT = object()
|
|
711
713
|
|
|
712
714
|
|
|
713
|
-
def
|
|
715
|
+
def _create_root_model(
|
|
714
716
|
name: str, type_: Any, default_: object = NO_DEFAULT
|
|
715
717
|
) -> Type[BaseModel]:
|
|
716
718
|
"""Create a base class."""
|
|
@@ -754,10 +756,24 @@ def create_base_class(
|
|
|
754
756
|
|
|
755
757
|
if default_ is not NO_DEFAULT:
|
|
756
758
|
base_class_attributes["root"] = default_
|
|
757
|
-
|
|
759
|
+
with warnings.catch_warnings():
|
|
760
|
+
if isinstance(type_, type) and issubclass(type_, BaseModelV1):
|
|
761
|
+
warnings.filterwarnings(
|
|
762
|
+
action="ignore", category=PydanticDeprecationWarning
|
|
763
|
+
)
|
|
764
|
+
custom_root_type = type(name, (RootModel,), base_class_attributes)
|
|
758
765
|
return cast(Type[BaseModel], custom_root_type)
|
|
759
766
|
|
|
760
767
|
|
|
768
|
+
@lru_cache(maxsize=256)
|
|
769
|
+
def _create_root_model_cached(
|
|
770
|
+
__model_name: str,
|
|
771
|
+
type_: Any,
|
|
772
|
+
default_: object = NO_DEFAULT,
|
|
773
|
+
) -> Type[BaseModel]:
|
|
774
|
+
return _create_root_model(__model_name, type_, default_)
|
|
775
|
+
|
|
776
|
+
|
|
761
777
|
def create_model(
|
|
762
778
|
__model_name: str,
|
|
763
779
|
**field_definitions: Any,
|
|
@@ -782,9 +798,15 @@ def create_model(
|
|
|
782
798
|
|
|
783
799
|
arg = field_definitions["__root__"]
|
|
784
800
|
if isinstance(arg, tuple):
|
|
785
|
-
|
|
801
|
+
kwargs = {"type_": arg[0], "default_": arg[1]}
|
|
786
802
|
else:
|
|
787
|
-
|
|
803
|
+
kwargs = {"type_": arg}
|
|
804
|
+
|
|
805
|
+
try:
|
|
806
|
+
named_root_model = _create_root_model_cached(__model_name, **kwargs)
|
|
807
|
+
except TypeError:
|
|
808
|
+
# something in the arguments into _create_root_model_cached is not hashable
|
|
809
|
+
named_root_model = _create_root_model(__model_name, **kwargs)
|
|
788
810
|
return named_root_model
|
|
789
811
|
try:
|
|
790
812
|
return _create_model_cached(__model_name, **field_definitions)
|