langchain-core 0.3.75__tar.gz → 1.0.0a1__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.
Potentially problematic release.
This version of langchain-core might be problematic. Click here for more details.
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/PKG-INFO +2 -2
- langchain_core-1.0.0a1/langchain_core/language_models/_utils.py +305 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/language_models/base.py +2 -1
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/language_models/chat_models.py +196 -33
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/language_models/fake_chat_models.py +22 -6
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/messages/__init__.py +74 -4
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/messages/ai.py +191 -26
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/messages/base.py +164 -25
- langchain_core-1.0.0a1/langchain_core/messages/block_translators/__init__.py +89 -0
- langchain_core-1.0.0a1/langchain_core/messages/block_translators/anthropic.py +451 -0
- langchain_core-1.0.0a1/langchain_core/messages/block_translators/bedrock.py +45 -0
- langchain_core-1.0.0a1/langchain_core/messages/block_translators/bedrock_converse.py +47 -0
- langchain_core-1.0.0a1/langchain_core/messages/block_translators/google_genai.py +45 -0
- langchain_core-1.0.0a1/langchain_core/messages/block_translators/google_vertexai.py +47 -0
- langchain_core-1.0.0a1/langchain_core/messages/block_translators/groq.py +45 -0
- langchain_core-1.0.0a1/langchain_core/messages/block_translators/langchain_v0.py +297 -0
- langchain_core-1.0.0a1/langchain_core/messages/block_translators/ollama.py +45 -0
- langchain_core-1.0.0a1/langchain_core/messages/block_translators/openai.py +586 -0
- langchain_core-1.0.0a1/langchain_core/messages/content.py +1568 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/messages/human.py +29 -9
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/messages/system.py +29 -9
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/messages/tool.py +30 -27
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/messages/utils.py +12 -5
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/prompt_values.py +1 -1
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/runnables/base.py +1 -1
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/utils/_merge.py +44 -6
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/utils/utils.py +29 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/version.py +1 -1
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/pyproject.toml +2 -2
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/fake/test_fake_chat_model.py +13 -7
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/language_models/chat_models/test_base.py +437 -134
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/language_models/chat_models/test_rate_limiting.py +5 -3
- langchain_core-1.0.0a1/tests/unit_tests/messages/block_translators/test_anthropic.py +439 -0
- langchain_core-1.0.0a1/tests/unit_tests/messages/block_translators/test_langchain_v0.py +79 -0
- langchain_core-1.0.0a1/tests/unit_tests/messages/block_translators/test_openai.py +444 -0
- langchain_core-1.0.0a1/tests/unit_tests/messages/block_translators/test_registration.py +29 -0
- langchain_core-1.0.0a1/tests/unit_tests/messages/test_ai.py +461 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/messages/test_imports.py +25 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/messages/test_utils.py +33 -5
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/prompts/__snapshots__/test_chat.ambr +62 -4
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/runnables/__snapshots__/test_graph.ambr +31 -2
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/runnables/__snapshots__/test_runnable.ambr +240 -16
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/runnables/test_fallbacks.py +3 -3
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/runnables/test_runnable.py +2 -2
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/runnables/test_runnable_events_v1.py +81 -16
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/runnables/test_runnable_events_v2.py +77 -16
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/test_messages.py +229 -80
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/test_tools.py +6 -6
- langchain_core-1.0.0a1/tests/unit_tests/vectorstores/__init__.py +0 -0
- langchain_core-0.3.75/langchain_core/language_models/_utils.py +0 -140
- langchain_core-0.3.75/langchain_core/messages/content_blocks.py +0 -155
- langchain_core-0.3.75/tests/unit_tests/messages/test_ai.py +0 -198
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/README.md +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/__init__.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/_api/__init__.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/_api/beta_decorator.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/_api/deprecation.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/_api/internal.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/_api/path.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/_import_utils.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/agents.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/beta/__init__.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/beta/runnables/__init__.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/beta/runnables/context.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/caches.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/callbacks/__init__.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/callbacks/base.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/callbacks/file.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/callbacks/manager.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/callbacks/stdout.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/callbacks/streaming_stdout.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/callbacks/usage.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/chat_history.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/chat_loaders.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/chat_sessions.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/document_loaders/__init__.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/document_loaders/base.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/document_loaders/blob_loaders.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/document_loaders/langsmith.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/documents/__init__.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/documents/base.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/documents/compressor.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/documents/transformers.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/embeddings/__init__.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/embeddings/embeddings.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/embeddings/fake.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/env.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/example_selectors/__init__.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/example_selectors/base.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/example_selectors/length_based.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/example_selectors/semantic_similarity.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/exceptions.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/globals.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/indexing/__init__.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/indexing/api.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/indexing/base.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/indexing/in_memory.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/language_models/__init__.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/language_models/fake.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/language_models/llms.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/load/__init__.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/load/dump.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/load/load.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/load/mapping.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/load/serializable.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/memory.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/messages/chat.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/messages/function.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/messages/modifier.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/output_parsers/__init__.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/output_parsers/base.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/output_parsers/format_instructions.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/output_parsers/json.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/output_parsers/list.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/output_parsers/openai_functions.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/output_parsers/openai_tools.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/output_parsers/pydantic.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/output_parsers/string.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/output_parsers/transform.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/output_parsers/xml.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/outputs/__init__.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/outputs/chat_generation.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/outputs/chat_result.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/outputs/generation.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/outputs/llm_result.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/outputs/run_info.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/prompts/__init__.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/prompts/base.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/prompts/chat.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/prompts/dict.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/prompts/few_shot.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/prompts/few_shot_with_templates.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/prompts/image.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/prompts/loading.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/prompts/message.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/prompts/pipeline.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/prompts/prompt.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/prompts/string.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/prompts/structured.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/py.typed +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/pydantic_v1/__init__.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/pydantic_v1/dataclasses.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/pydantic_v1/main.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/rate_limiters.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/retrievers.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/runnables/__init__.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/runnables/branch.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/runnables/config.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/runnables/configurable.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/runnables/fallbacks.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/runnables/graph.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/runnables/graph_ascii.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/runnables/graph_mermaid.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/runnables/graph_png.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/runnables/history.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/runnables/passthrough.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/runnables/retry.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/runnables/router.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/runnables/schema.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/runnables/utils.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/stores.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/structured_query.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/sys_info.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/tools/__init__.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/tools/base.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/tools/convert.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/tools/render.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/tools/retriever.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/tools/simple.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/tools/structured.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/tracers/__init__.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/tracers/_streaming.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/tracers/base.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/tracers/context.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/tracers/core.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/tracers/evaluation.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/tracers/event_stream.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/tracers/langchain.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/tracers/langchain_v1.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/tracers/log_stream.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/tracers/memory_stream.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/tracers/root_listeners.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/tracers/run_collector.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/tracers/schemas.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/tracers/stdout.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/utils/__init__.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/utils/aiter.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/utils/env.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/utils/formatting.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/utils/function_calling.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/utils/html.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/utils/image.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/utils/input.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/utils/interactive_env.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/utils/iter.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/utils/json.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/utils/json_schema.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/utils/loading.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/utils/mustache.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/utils/pydantic.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/utils/strings.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/utils/usage.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/vectorstores/__init__.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/vectorstores/base.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/vectorstores/in_memory.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/langchain_core/vectorstores/utils.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/__init__.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/benchmarks/__init__.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/benchmarks/test_async_callbacks.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/benchmarks/test_imports.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/integration_tests/__init__.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/integration_tests/test_compile.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/__init__.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/_api/__init__.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/_api/test_beta_decorator.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/_api/test_deprecation.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/_api/test_imports.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/_api/test_path.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/caches/__init__.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/caches/test_in_memory_cache.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/callbacks/__init__.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/callbacks/test_async_callback_manager.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/callbacks/test_dispatch_custom_event.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/callbacks/test_imports.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/callbacks/test_sync_callback_manager.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/callbacks/test_usage_callback.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/chat_history/__init__.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/chat_history/test_chat_history.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/conftest.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/data/prompt_file.txt +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/data/prompts/prompt_extra_args.json +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/data/prompts/prompt_missing_args.json +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/data/prompts/simple_prompt.json +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/dependencies/__init__.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/dependencies/test_dependencies.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/document_loaders/__init__.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/document_loaders/test_base.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/document_loaders/test_langsmith.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/documents/__init__.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/documents/test_document.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/documents/test_imports.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/documents/test_str.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/embeddings/__init__.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/embeddings/test_deterministic_embedding.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/example_selectors/__init__.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/example_selectors/test_base.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/example_selectors/test_imports.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/example_selectors/test_length_based_example_selector.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/example_selectors/test_similarity.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/examples/example-non-utf8.csv +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/examples/example-non-utf8.txt +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/examples/example-utf8.csv +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/examples/example-utf8.txt +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/examples/example_prompt.json +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/examples/examples.json +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/examples/examples.yaml +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/examples/few_shot_prompt.json +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/examples/few_shot_prompt.yaml +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/examples/few_shot_prompt_example_prompt.json +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/examples/few_shot_prompt_examples_in.json +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/examples/few_shot_prompt_yaml_examples.yaml +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/examples/jinja_injection_prompt.json +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/examples/jinja_injection_prompt.yaml +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/examples/prompt_with_output_parser.json +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/examples/simple_prompt.json +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/examples/simple_prompt.yaml +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/examples/simple_prompt_with_template_file.json +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/examples/simple_template.txt +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/fake/__init__.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/fake/callbacks.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/indexing/__init__.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/indexing/test_hashed_document.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/indexing/test_in_memory_indexer.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/indexing/test_in_memory_record_manager.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/indexing/test_indexing.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/indexing/test_public_api.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/language_models/__init__.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/language_models/chat_models/__init__.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/language_models/chat_models/test_benchmark.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/language_models/chat_models/test_cache.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/language_models/llms/__init__.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/language_models/llms/test_base.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/language_models/llms/test_cache.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/language_models/test_imports.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/load/__init__.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/load/test_imports.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/load/test_serializable.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/messages/__init__.py +0 -0
- {langchain_core-0.3.75/tests/unit_tests/output_parsers → langchain_core-1.0.0a1/tests/unit_tests/messages/block_translators}/__init__.py +0 -0
- {langchain_core-0.3.75/tests/unit_tests/outputs → langchain_core-1.0.0a1/tests/unit_tests/output_parsers}/__init__.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/output_parsers/test_base_parsers.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/output_parsers/test_imports.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/output_parsers/test_json.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/output_parsers/test_list_parser.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/output_parsers/test_openai_functions.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/output_parsers/test_openai_tools.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/output_parsers/test_pydantic_parser.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/output_parsers/test_xml_parser.py +0 -0
- {langchain_core-0.3.75/tests/unit_tests/rate_limiters → langchain_core-1.0.0a1/tests/unit_tests/outputs}/__init__.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/outputs/test_chat_generation.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/outputs/test_imports.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/prompt_file.txt +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/prompts/__init__.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/prompts/__snapshots__/test_prompt.ambr +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/prompts/prompt_extra_args.json +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/prompts/prompt_missing_args.json +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/prompts/simple_prompt.json +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/prompts/test_chat.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/prompts/test_dict.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/prompts/test_few_shot.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/prompts/test_few_shot_with_templates.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/prompts/test_image.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/prompts/test_imports.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/prompts/test_loading.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/prompts/test_pipeline_prompt.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/prompts/test_prompt.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/prompts/test_structured.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/prompts/test_utils.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/pydantic_utils.py +0 -0
- {langchain_core-0.3.75/tests/unit_tests/runnables → langchain_core-1.0.0a1/tests/unit_tests/rate_limiters}/__init__.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/rate_limiters/test_in_memory_rate_limiter.py +0 -0
- {langchain_core-0.3.75/tests/unit_tests/stores → langchain_core-1.0.0a1/tests/unit_tests/runnables}/__init__.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/runnables/__snapshots__/test_fallbacks.ambr +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/runnables/test_concurrency.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/runnables/test_config.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/runnables/test_configurable.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/runnables/test_context.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/runnables/test_graph.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/runnables/test_history.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/runnables/test_imports.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/runnables/test_tracing_interops.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/runnables/test_utils.py +0 -0
- {langchain_core-0.3.75/tests/unit_tests/tracers → langchain_core-1.0.0a1/tests/unit_tests/stores}/__init__.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/stores/test_in_memory.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/stubs.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/test_globals.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/test_imports.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/test_outputs.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/test_prompt_values.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/test_pydantic_imports.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/test_pydantic_serde.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/test_retrievers.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/test_setup.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/test_sys_info.py +0 -0
- {langchain_core-0.3.75/tests/unit_tests/utils → langchain_core-1.0.0a1/tests/unit_tests/tracers}/__init__.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/tracers/test_async_base_tracer.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/tracers/test_base_tracer.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/tracers/test_imports.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/tracers/test_langchain.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/tracers/test_memory_stream.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/tracers/test_run_collector.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/tracers/test_schemas.py +0 -0
- {langchain_core-0.3.75/tests/unit_tests/vectorstores → langchain_core-1.0.0a1/tests/unit_tests/utils}/__init__.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/utils/test_aiter.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/utils/test_env.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/utils/test_function_calling.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/utils/test_html.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/utils/test_imports.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/utils/test_iter.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/utils/test_json_schema.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/utils/test_pydantic.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/utils/test_rm_titles.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/utils/test_strings.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/utils/test_usage.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/utils/test_utils.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/vectorstores/test_in_memory.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/vectorstores/test_utils.py +0 -0
- {langchain_core-0.3.75 → langchain_core-1.0.0a1}/tests/unit_tests/vectorstores/test_vectorstore.py +0 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: langchain-core
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 1.0.0a1
|
|
4
4
|
Summary: Building applications with LLMs through composability
|
|
5
5
|
License: MIT
|
|
6
6
|
Project-URL: Source Code, https://github.com/langchain-ai/langchain/tree/master/libs/core
|
|
7
7
|
Project-URL: Release Notes, https://github.com/langchain-ai/langchain/releases?q=tag%3A%22langchain-core%3D%3D0%22&expanded=true
|
|
8
8
|
Project-URL: repository, https://github.com/langchain-ai/langchain
|
|
9
|
-
Requires-Python: >=3.
|
|
9
|
+
Requires-Python: >=3.10
|
|
10
10
|
Requires-Dist: langsmith>=0.3.45
|
|
11
11
|
Requires-Dist: tenacity!=8.4.0,<10.0.0,>=8.1.0
|
|
12
12
|
Requires-Dist: jsonpatch<2.0,>=1.33
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
import re
|
|
2
|
+
from collections.abc import Sequence
|
|
3
|
+
from typing import (
|
|
4
|
+
TYPE_CHECKING,
|
|
5
|
+
Literal,
|
|
6
|
+
Optional,
|
|
7
|
+
TypedDict,
|
|
8
|
+
TypeVar,
|
|
9
|
+
Union,
|
|
10
|
+
)
|
|
11
|
+
|
|
12
|
+
if TYPE_CHECKING:
|
|
13
|
+
from langchain_core.messages import BaseMessage
|
|
14
|
+
from langchain_core.messages.content import (
|
|
15
|
+
ContentBlock,
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def _is_openai_data_block(block: dict) -> bool:
|
|
20
|
+
"""Check if the block contains multimodal data in OpenAI Chat Completions format.
|
|
21
|
+
|
|
22
|
+
Supports both data and ID-style blocks (e.g. ``'file_data'`` and ``'file_id'``)
|
|
23
|
+
|
|
24
|
+
If additional keys are present, they are ignored / will not affect outcome as long
|
|
25
|
+
as the required keys are present and valid.
|
|
26
|
+
|
|
27
|
+
"""
|
|
28
|
+
if block.get("type") == "image_url":
|
|
29
|
+
if (
|
|
30
|
+
(set(block.keys()) <= {"type", "image_url", "detail"})
|
|
31
|
+
and (image_url := block.get("image_url"))
|
|
32
|
+
and isinstance(image_url, dict)
|
|
33
|
+
):
|
|
34
|
+
url = image_url.get("url")
|
|
35
|
+
if isinstance(url, str):
|
|
36
|
+
# Required per OpenAI spec
|
|
37
|
+
return True
|
|
38
|
+
# Ignore `'detail'` since it's optional and specific to OpenAI
|
|
39
|
+
|
|
40
|
+
elif block.get("type") == "input_audio":
|
|
41
|
+
if (audio := block.get("input_audio")) and isinstance(audio, dict):
|
|
42
|
+
audio_data = audio.get("data")
|
|
43
|
+
audio_format = audio.get("format")
|
|
44
|
+
# Both required per OpenAI spec
|
|
45
|
+
if isinstance(audio_data, str) and isinstance(audio_format, str):
|
|
46
|
+
return True
|
|
47
|
+
|
|
48
|
+
elif block.get("type") == "file":
|
|
49
|
+
if (file := block.get("file")) and isinstance(file, dict):
|
|
50
|
+
file_data = file.get("file_data")
|
|
51
|
+
file_id = file.get("file_id")
|
|
52
|
+
# Files can be either base64-encoded or pre-uploaded with an ID
|
|
53
|
+
if isinstance(file_data, str) or isinstance(file_id, str):
|
|
54
|
+
return True
|
|
55
|
+
|
|
56
|
+
else:
|
|
57
|
+
return False
|
|
58
|
+
|
|
59
|
+
# Has no `'type'` key
|
|
60
|
+
return False
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
class ParsedDataUri(TypedDict):
|
|
64
|
+
source_type: Literal["base64"]
|
|
65
|
+
data: str
|
|
66
|
+
mime_type: str
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
def _parse_data_uri(uri: str) -> Optional[ParsedDataUri]:
|
|
70
|
+
"""Parse a data URI into its components.
|
|
71
|
+
|
|
72
|
+
If parsing fails, return None. If either MIME type or data is missing, return None.
|
|
73
|
+
|
|
74
|
+
Example:
|
|
75
|
+
|
|
76
|
+
.. code-block:: python
|
|
77
|
+
|
|
78
|
+
data_uri = "data:image/jpeg;base64,/9j/4AAQSkZJRg..."
|
|
79
|
+
parsed = _parse_data_uri(data_uri)
|
|
80
|
+
|
|
81
|
+
assert parsed == {
|
|
82
|
+
"source_type": "base64",
|
|
83
|
+
"mime_type": "image/jpeg",
|
|
84
|
+
"data": "/9j/4AAQSkZJRg...",
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
"""
|
|
88
|
+
regex = r"^data:(?P<mime_type>[^;]+);base64,(?P<data>.+)$"
|
|
89
|
+
match = re.match(regex, uri)
|
|
90
|
+
if match is None:
|
|
91
|
+
return None
|
|
92
|
+
|
|
93
|
+
mime_type = match.group("mime_type")
|
|
94
|
+
data = match.group("data")
|
|
95
|
+
if not mime_type or not data:
|
|
96
|
+
return None
|
|
97
|
+
|
|
98
|
+
return {
|
|
99
|
+
"source_type": "base64",
|
|
100
|
+
"data": data,
|
|
101
|
+
"mime_type": mime_type,
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def _normalize_messages(
|
|
106
|
+
messages: Sequence["BaseMessage"],
|
|
107
|
+
) -> list["BaseMessage"]:
|
|
108
|
+
"""Normalize message formats to LangChain v1 standard content blocks.
|
|
109
|
+
|
|
110
|
+
Chat models already implement support for:
|
|
111
|
+
- Images in OpenAI Chat Completions format
|
|
112
|
+
These will be passed through unchanged
|
|
113
|
+
- LangChain v1 standard content blocks
|
|
114
|
+
|
|
115
|
+
This function extends support to:
|
|
116
|
+
- `Audio <https://platform.openai.com/docs/api-reference/chat/create>`__ and
|
|
117
|
+
`file <https://platform.openai.com/docs/api-reference/files>`__ data in OpenAI
|
|
118
|
+
Chat Completions format
|
|
119
|
+
- Images are technically supported but we expect chat models to handle them
|
|
120
|
+
directly; this may change in the future
|
|
121
|
+
- LangChain v0 standard content blocks for backward compatibility
|
|
122
|
+
|
|
123
|
+
.. versionchanged:: 1.0.0
|
|
124
|
+
In previous versions, this function returned messages in LangChain v0 format.
|
|
125
|
+
Now, it returns messages in LangChain v1 format, which upgraded chat models now
|
|
126
|
+
expect to receive when passing back in message history. For backward
|
|
127
|
+
compatibility, this function will convert v0 message content to v1 format.
|
|
128
|
+
|
|
129
|
+
.. dropdown:: v0 Content Block Schemas
|
|
130
|
+
|
|
131
|
+
``URLContentBlock``:
|
|
132
|
+
|
|
133
|
+
.. codeblock::
|
|
134
|
+
|
|
135
|
+
{
|
|
136
|
+
mime_type: NotRequired[str]
|
|
137
|
+
type: Literal['image', 'audio', 'file'],
|
|
138
|
+
source_type: Literal['url'],
|
|
139
|
+
url: str,
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
``Base64ContentBlock``:
|
|
143
|
+
|
|
144
|
+
.. codeblock::
|
|
145
|
+
|
|
146
|
+
{
|
|
147
|
+
mime_type: NotRequired[str]
|
|
148
|
+
type: Literal['image', 'audio', 'file'],
|
|
149
|
+
source_type: Literal['base64'],
|
|
150
|
+
data: str,
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
``IDContentBlock``:
|
|
154
|
+
|
|
155
|
+
(In practice, this was never used)
|
|
156
|
+
|
|
157
|
+
.. codeblock::
|
|
158
|
+
|
|
159
|
+
{
|
|
160
|
+
type: Literal['image', 'audio', 'file'],
|
|
161
|
+
source_type: Literal['id'],
|
|
162
|
+
id: str,
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
``PlainTextContentBlock``:
|
|
166
|
+
|
|
167
|
+
.. codeblock::
|
|
168
|
+
|
|
169
|
+
{
|
|
170
|
+
mime_type: NotRequired[str]
|
|
171
|
+
type: Literal['file'],
|
|
172
|
+
source_type: Literal['text'],
|
|
173
|
+
url: str,
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
If a v1 message is passed in, it will be returned as-is, meaning it is safe to
|
|
177
|
+
always pass in v1 messages to this function for assurance.
|
|
178
|
+
|
|
179
|
+
For posterity, here are the OpenAI Chat Completions schemas we expect:
|
|
180
|
+
|
|
181
|
+
Chat Completions image. Can be URL-based or base64-encoded. Supports MIME types
|
|
182
|
+
png, jpeg/jpg, webp, static gif:
|
|
183
|
+
{
|
|
184
|
+
"type": Literal['image_url'],
|
|
185
|
+
"image_url": {
|
|
186
|
+
"url": Union["data:$MIME_TYPE;base64,$BASE64_ENCODED_IMAGE", "$IMAGE_URL"],
|
|
187
|
+
"detail": Literal['low', 'high', 'auto'] = 'auto', # Supported by OpenAI
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
Chat Completions audio:
|
|
192
|
+
{
|
|
193
|
+
"type": Literal['input_audio'],
|
|
194
|
+
"input_audio": {
|
|
195
|
+
"format": Literal['wav', 'mp3'],
|
|
196
|
+
"data": str = "$BASE64_ENCODED_AUDIO",
|
|
197
|
+
},
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
Chat Completions files: either base64 or pre-uploaded file ID
|
|
201
|
+
{
|
|
202
|
+
"type": Literal['file'],
|
|
203
|
+
"file": Union[
|
|
204
|
+
{
|
|
205
|
+
"filename": Optional[str] = "$FILENAME",
|
|
206
|
+
"file_data": str = "$BASE64_ENCODED_FILE",
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
"file_id": str = "$FILE_ID", # For pre-uploaded files to OpenAI
|
|
210
|
+
},
|
|
211
|
+
],
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
"""
|
|
215
|
+
from langchain_core.messages.block_translators.langchain_v0 import (
|
|
216
|
+
_convert_legacy_v0_content_block_to_v1,
|
|
217
|
+
_convert_openai_format_to_data_block,
|
|
218
|
+
)
|
|
219
|
+
|
|
220
|
+
formatted_messages = []
|
|
221
|
+
for message in messages:
|
|
222
|
+
# We preserve input messages - the caller may reuse them elsewhere and expects
|
|
223
|
+
# them to remain unchanged. We only create a copy if we need to translate.
|
|
224
|
+
formatted_message = message
|
|
225
|
+
|
|
226
|
+
if isinstance(message.content, list):
|
|
227
|
+
for idx, block in enumerate(message.content):
|
|
228
|
+
# OpenAI Chat Completions multimodal data blocks to v1 standard
|
|
229
|
+
if (
|
|
230
|
+
isinstance(block, dict)
|
|
231
|
+
and block.get("type") in {"input_audio", "file"}
|
|
232
|
+
# Discriminate between OpenAI/LC format since they share `'type'`
|
|
233
|
+
and _is_openai_data_block(block)
|
|
234
|
+
):
|
|
235
|
+
formatted_message = _ensure_message_copy(message, formatted_message)
|
|
236
|
+
|
|
237
|
+
converted_block = _convert_openai_format_to_data_block(block)
|
|
238
|
+
_update_content_block(formatted_message, idx, converted_block)
|
|
239
|
+
|
|
240
|
+
# Convert multimodal LangChain v0 to v1 standard content blocks
|
|
241
|
+
elif (
|
|
242
|
+
isinstance(block, dict)
|
|
243
|
+
and block.get("type")
|
|
244
|
+
in {
|
|
245
|
+
"image",
|
|
246
|
+
"audio",
|
|
247
|
+
"file",
|
|
248
|
+
}
|
|
249
|
+
and block.get("source_type") # v1 doesn't have `source_type`
|
|
250
|
+
in {
|
|
251
|
+
"url",
|
|
252
|
+
"base64",
|
|
253
|
+
"id",
|
|
254
|
+
"text",
|
|
255
|
+
}
|
|
256
|
+
):
|
|
257
|
+
formatted_message = _ensure_message_copy(message, formatted_message)
|
|
258
|
+
|
|
259
|
+
converted_block = _convert_legacy_v0_content_block_to_v1(block)
|
|
260
|
+
_update_content_block(formatted_message, idx, converted_block)
|
|
261
|
+
continue
|
|
262
|
+
|
|
263
|
+
# else, pass through blocks that look like they have v1 format unchanged
|
|
264
|
+
|
|
265
|
+
formatted_messages.append(formatted_message)
|
|
266
|
+
|
|
267
|
+
return formatted_messages
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
T = TypeVar("T", bound="BaseMessage")
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
def _ensure_message_copy(message: T, formatted_message: T) -> T:
|
|
274
|
+
"""Create a copy of the message if it hasn't been copied yet."""
|
|
275
|
+
if formatted_message is message:
|
|
276
|
+
formatted_message = message.model_copy()
|
|
277
|
+
# Shallow-copy content list to allow modifications
|
|
278
|
+
formatted_message.content = list(formatted_message.content)
|
|
279
|
+
return formatted_message
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
def _update_content_block(
|
|
283
|
+
formatted_message: "BaseMessage", idx: int, new_block: Union[ContentBlock, dict]
|
|
284
|
+
) -> None:
|
|
285
|
+
"""Update a content block at the given index, handling type issues."""
|
|
286
|
+
# Type ignore needed because:
|
|
287
|
+
# - `BaseMessage.content` is typed as `Union[str, list[Union[str, dict]]]`
|
|
288
|
+
# - When content is str, indexing fails (index error)
|
|
289
|
+
# - When content is list, the items are `Union[str, dict]` but we're assigning
|
|
290
|
+
# `Union[ContentBlock, dict]` where ContentBlock is richer than dict
|
|
291
|
+
# - This is safe because we only call this when we've verified content is a list and
|
|
292
|
+
# we're doing content block conversions
|
|
293
|
+
formatted_message.content[idx] = new_block # type: ignore[index, assignment]
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
def _update_message_content_to_blocks(message: T, output_version: str) -> T:
|
|
297
|
+
return message.model_copy(
|
|
298
|
+
update={
|
|
299
|
+
"content": message.content_blocks,
|
|
300
|
+
"response_metadata": {
|
|
301
|
+
**message.response_metadata,
|
|
302
|
+
"output_version": output_version,
|
|
303
|
+
},
|
|
304
|
+
}
|
|
305
|
+
)
|
|
@@ -23,6 +23,7 @@ from langchain_core._api import deprecated
|
|
|
23
23
|
from langchain_core.caches import BaseCache
|
|
24
24
|
from langchain_core.callbacks import Callbacks
|
|
25
25
|
from langchain_core.messages import (
|
|
26
|
+
AIMessage,
|
|
26
27
|
AnyMessage,
|
|
27
28
|
BaseMessage,
|
|
28
29
|
MessageLikeRepresentation,
|
|
@@ -85,7 +86,7 @@ def _get_token_ids_default_method(text: str) -> list[int]:
|
|
|
85
86
|
LanguageModelInput = Union[PromptValue, str, Sequence[MessageLikeRepresentation]]
|
|
86
87
|
LanguageModelOutput = Union[BaseMessage, str]
|
|
87
88
|
LanguageModelLike = Runnable[LanguageModelInput, LanguageModelOutput]
|
|
88
|
-
LanguageModelOutputVar = TypeVar("LanguageModelOutputVar",
|
|
89
|
+
LanguageModelOutputVar = TypeVar("LanguageModelOutputVar", AIMessage, str)
|
|
89
90
|
|
|
90
91
|
|
|
91
92
|
def _get_verbosity() -> bool:
|