langchain 1.0.0-alpha.5 → 1.0.0-alpha.7
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.
- package/dist/agents/ReactAgent.cjs +5 -5
- package/dist/agents/ReactAgent.cjs.map +1 -1
- package/dist/agents/ReactAgent.d.cts +2 -5
- package/dist/agents/ReactAgent.d.cts.map +1 -1
- package/dist/agents/ReactAgent.d.ts +2 -5
- package/dist/agents/ReactAgent.d.ts.map +1 -1
- package/dist/agents/ReactAgent.js +6 -6
- package/dist/agents/ReactAgent.js.map +1 -1
- package/dist/agents/annotation.cjs.map +1 -1
- package/dist/agents/annotation.d.cts +13 -8
- package/dist/agents/annotation.d.cts.map +1 -1
- package/dist/agents/annotation.d.ts +13 -8
- package/dist/agents/annotation.d.ts.map +1 -1
- package/dist/agents/annotation.js.map +1 -1
- package/dist/agents/createAgent.cjs.map +1 -1
- package/dist/agents/createAgent.js.map +1 -1
- package/dist/agents/index.cjs +2 -2
- package/dist/agents/index.cjs.map +1 -1
- package/dist/agents/index.d.cts +50 -50
- package/dist/agents/index.d.cts.map +1 -1
- package/dist/agents/index.d.ts +50 -50
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js +2 -2
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/interrupt.d.cts +14 -1
- package/dist/agents/interrupt.d.cts.map +1 -1
- package/dist/agents/interrupt.d.ts +14 -1
- package/dist/agents/interrupt.d.ts.map +1 -1
- package/dist/agents/middlewareAgent/ReactAgent.cjs +273 -66
- package/dist/agents/middlewareAgent/ReactAgent.cjs.map +1 -1
- package/dist/agents/middlewareAgent/ReactAgent.d.cts +102 -16
- package/dist/agents/middlewareAgent/ReactAgent.d.cts.map +1 -1
- package/dist/agents/middlewareAgent/ReactAgent.d.ts +102 -16
- package/dist/agents/middlewareAgent/ReactAgent.d.ts.map +1 -1
- package/dist/agents/middlewareAgent/ReactAgent.js +275 -68
- package/dist/agents/middlewareAgent/ReactAgent.js.map +1 -1
- package/dist/agents/middlewareAgent/annotation.cjs +12 -6
- package/dist/agents/middlewareAgent/annotation.cjs.map +1 -1
- package/dist/agents/middlewareAgent/annotation.js +12 -6
- package/dist/agents/middlewareAgent/annotation.js.map +1 -1
- package/dist/agents/middlewareAgent/constants.d.cts +5 -0
- package/dist/agents/middlewareAgent/constants.d.cts.map +1 -0
- package/dist/agents/middlewareAgent/constants.d.ts +5 -0
- package/dist/agents/middlewareAgent/constants.d.ts.map +1 -0
- package/dist/agents/middlewareAgent/index.cjs.map +1 -1
- package/dist/agents/middlewareAgent/index.js.map +1 -1
- package/dist/agents/middlewareAgent/middleware/bigTool.cjs +162 -0
- package/dist/agents/middlewareAgent/middleware/bigTool.cjs.map +1 -0
- package/dist/agents/middlewareAgent/middleware/bigTool.d.cts +113 -0
- package/dist/agents/middlewareAgent/middleware/bigTool.d.cts.map +1 -0
- package/dist/agents/middlewareAgent/middleware/bigTool.d.ts +113 -0
- package/dist/agents/middlewareAgent/middleware/bigTool.d.ts.map +1 -0
- package/dist/agents/middlewareAgent/middleware/bigTool.js +161 -0
- package/dist/agents/middlewareAgent/middleware/bigTool.js.map +1 -0
- package/dist/agents/middlewareAgent/middleware/dynamicSystemPrompt.cjs +58 -0
- package/dist/agents/middlewareAgent/middleware/dynamicSystemPrompt.cjs.map +1 -0
- package/dist/agents/middlewareAgent/middleware/dynamicSystemPrompt.d.cts +46 -0
- package/dist/agents/middlewareAgent/middleware/dynamicSystemPrompt.d.cts.map +1 -0
- package/dist/agents/middlewareAgent/middleware/dynamicSystemPrompt.d.ts +46 -0
- package/dist/agents/middlewareAgent/middleware/dynamicSystemPrompt.d.ts.map +1 -0
- package/dist/agents/middlewareAgent/middleware/dynamicSystemPrompt.js +58 -0
- package/dist/agents/middlewareAgent/middleware/dynamicSystemPrompt.js.map +1 -0
- package/dist/agents/middlewareAgent/middleware/hitl.cjs +311 -0
- package/dist/agents/middlewareAgent/middleware/hitl.cjs.map +1 -0
- package/dist/agents/middlewareAgent/middleware/hitl.d.cts +419 -0
- package/dist/agents/middlewareAgent/middleware/hitl.d.cts.map +1 -0
- package/dist/agents/middlewareAgent/middleware/hitl.d.ts +419 -0
- package/dist/agents/middlewareAgent/middleware/hitl.d.ts.map +1 -0
- package/dist/agents/middlewareAgent/middleware/hitl.js +310 -0
- package/dist/agents/middlewareAgent/middleware/hitl.js.map +1 -0
- package/dist/agents/middlewareAgent/middleware/index.cjs +32 -0
- package/dist/agents/middlewareAgent/middleware/index.cjs.map +1 -0
- package/dist/agents/middlewareAgent/middleware/index.d.cts +6 -0
- package/dist/agents/middlewareAgent/middleware/index.d.ts +6 -0
- package/dist/agents/middlewareAgent/middleware/index.js +21 -0
- package/dist/agents/middlewareAgent/middleware/index.js.map +1 -0
- package/dist/agents/middlewareAgent/{middlewares → middleware}/promptCaching.cjs +72 -27
- package/dist/agents/middlewareAgent/middleware/promptCaching.cjs.map +1 -0
- package/dist/agents/middlewareAgent/{middlewares → middleware}/promptCaching.d.cts +60 -15
- package/dist/agents/middlewareAgent/middleware/promptCaching.d.cts.map +1 -0
- package/dist/agents/middlewareAgent/{middlewares → middleware}/promptCaching.d.ts +60 -15
- package/dist/agents/middlewareAgent/middleware/promptCaching.d.ts.map +1 -0
- package/dist/agents/middlewareAgent/{middlewares → middleware}/promptCaching.js +71 -26
- package/dist/agents/middlewareAgent/middleware/promptCaching.js.map +1 -0
- package/dist/agents/middlewareAgent/{middlewares → middleware}/summarization.cjs +35 -23
- package/dist/agents/middlewareAgent/middleware/summarization.cjs.map +1 -0
- package/dist/agents/middlewareAgent/{middlewares → middleware}/summarization.d.cts +7 -5
- package/dist/agents/middlewareAgent/middleware/summarization.d.cts.map +1 -0
- package/dist/agents/middlewareAgent/{middlewares → middleware}/summarization.d.ts +7 -5
- package/dist/agents/middlewareAgent/middleware/summarization.d.ts.map +1 -0
- package/dist/agents/middlewareAgent/{middlewares → middleware}/summarization.js +29 -17
- package/dist/agents/middlewareAgent/middleware/summarization.js.map +1 -0
- package/dist/agents/middlewareAgent/middleware.cjs +8 -5
- package/dist/agents/middlewareAgent/middleware.cjs.map +1 -1
- package/dist/agents/middlewareAgent/middleware.d.cts +67 -7
- package/dist/agents/middlewareAgent/middleware.d.cts.map +1 -1
- package/dist/agents/middlewareAgent/middleware.d.ts +67 -7
- package/dist/agents/middlewareAgent/middleware.d.ts.map +1 -1
- package/dist/agents/middlewareAgent/middleware.js +8 -5
- package/dist/agents/middlewareAgent/middleware.js.map +1 -1
- package/dist/agents/middlewareAgent/nodes/AfterModalNode.cjs +2 -2
- package/dist/agents/middlewareAgent/nodes/AfterModalNode.cjs.map +1 -1
- package/dist/agents/middlewareAgent/nodes/AfterModalNode.js +2 -2
- package/dist/agents/middlewareAgent/nodes/AfterModalNode.js.map +1 -1
- package/dist/agents/middlewareAgent/nodes/AgentNode.cjs +125 -83
- package/dist/agents/middlewareAgent/nodes/AgentNode.cjs.map +1 -1
- package/dist/agents/middlewareAgent/nodes/AgentNode.js +128 -86
- package/dist/agents/middlewareAgent/nodes/AgentNode.js.map +1 -1
- package/dist/agents/middlewareAgent/nodes/BeforeModalNode.cjs +2 -2
- package/dist/agents/middlewareAgent/nodes/BeforeModalNode.cjs.map +1 -1
- package/dist/agents/middlewareAgent/nodes/BeforeModalNode.js +2 -2
- package/dist/agents/middlewareAgent/nodes/BeforeModalNode.js.map +1 -1
- package/dist/agents/middlewareAgent/nodes/middleware.cjs +42 -17
- package/dist/agents/middlewareAgent/nodes/middleware.cjs.map +1 -1
- package/dist/agents/middlewareAgent/nodes/middleware.js +42 -18
- package/dist/agents/middlewareAgent/nodes/middleware.js.map +1 -1
- package/dist/agents/middlewareAgent/nodes/utils.cjs +30 -16
- package/dist/agents/middlewareAgent/nodes/utils.cjs.map +1 -1
- package/dist/agents/middlewareAgent/nodes/utils.js +28 -14
- package/dist/agents/middlewareAgent/nodes/utils.js.map +1 -1
- package/dist/agents/middlewareAgent/types.d.cts +162 -88
- package/dist/agents/middlewareAgent/types.d.cts.map +1 -1
- package/dist/agents/middlewareAgent/types.d.ts +162 -88
- package/dist/agents/middlewareAgent/types.d.ts.map +1 -1
- package/dist/agents/model.cjs +13 -0
- package/dist/agents/model.cjs.map +1 -0
- package/dist/agents/model.js +11 -0
- package/dist/agents/model.js.map +1 -0
- package/dist/agents/nodes/AgentNode.cjs +60 -32
- package/dist/agents/nodes/AgentNode.cjs.map +1 -1
- package/dist/agents/nodes/AgentNode.js +61 -33
- package/dist/agents/nodes/AgentNode.js.map +1 -1
- package/dist/agents/nodes/ToolNode.cjs +4 -4
- package/dist/agents/nodes/ToolNode.cjs.map +1 -1
- package/dist/agents/nodes/ToolNode.d.cts +2 -3
- package/dist/agents/nodes/ToolNode.d.cts.map +1 -1
- package/dist/agents/nodes/ToolNode.d.ts +1 -2
- package/dist/agents/nodes/ToolNode.d.ts.map +1 -1
- package/dist/agents/nodes/ToolNode.js +5 -5
- package/dist/agents/nodes/ToolNode.js.map +1 -1
- package/dist/agents/responses.cjs +53 -11
- package/dist/agents/responses.cjs.map +1 -1
- package/dist/agents/responses.d.cts +12 -20
- package/dist/agents/responses.d.cts.map +1 -1
- package/dist/agents/responses.d.ts +12 -20
- package/dist/agents/responses.d.ts.map +1 -1
- package/dist/agents/responses.js +53 -12
- package/dist/agents/responses.js.map +1 -1
- package/dist/agents/types.d.cts +3 -6
- package/dist/agents/types.d.cts.map +1 -1
- package/dist/agents/types.d.ts +3 -6
- package/dist/agents/types.d.ts.map +1 -1
- package/dist/agents/utils.cjs +11 -29
- package/dist/agents/utils.cjs.map +1 -1
- package/dist/agents/utils.js +9 -26
- package/dist/agents/utils.js.map +1 -1
- package/dist/agents/withAgentName.cjs.map +1 -1
- package/dist/agents/withAgentName.js.map +1 -1
- package/dist/chains/api/prompts.cjs.map +1 -1
- package/dist/chains/api/prompts.js.map +1 -1
- package/dist/chains/constitutional_ai/constitutional_chain.cjs.map +1 -1
- package/dist/chains/constitutional_ai/constitutional_chain.js.map +1 -1
- package/dist/chains/index.cjs +0 -3
- package/dist/chains/index.cjs.map +1 -1
- package/dist/chains/index.d.cts +1 -2
- package/dist/chains/index.d.ts +1 -2
- package/dist/chains/index.js +1 -3
- package/dist/chains/index.js.map +1 -1
- package/dist/chains/openai_functions/extraction.cjs.map +1 -1
- package/dist/chains/openai_functions/extraction.d.cts +1 -3
- package/dist/chains/openai_functions/extraction.d.cts.map +1 -1
- package/dist/chains/openai_functions/extraction.d.ts +1 -3
- package/dist/chains/openai_functions/extraction.d.ts.map +1 -1
- package/dist/chains/openai_functions/extraction.js.map +1 -1
- package/dist/chains/openai_functions/index.cjs +0 -5
- package/dist/chains/openai_functions/index.cjs.map +1 -1
- package/dist/chains/openai_functions/index.d.cts +1 -2
- package/dist/chains/openai_functions/index.d.ts +1 -2
- package/dist/chains/openai_functions/index.js +1 -4
- package/dist/chains/openai_functions/index.js.map +1 -1
- package/dist/chains/openai_functions/openapi.cjs +4 -4
- package/dist/chains/openai_functions/openapi.cjs.map +1 -1
- package/dist/chains/openai_functions/openapi.d.cts +1 -1
- package/dist/chains/openai_functions/openapi.js +4 -4
- package/dist/chains/openai_functions/openapi.js.map +1 -1
- package/dist/chains/openai_functions/tagging.cjs.map +1 -1
- package/dist/chains/openai_functions/tagging.d.cts +1 -3
- package/dist/chains/openai_functions/tagging.d.cts.map +1 -1
- package/dist/chains/openai_functions/tagging.d.ts +1 -3
- package/dist/chains/openai_functions/tagging.d.ts.map +1 -1
- package/dist/chains/openai_functions/tagging.js.map +1 -1
- package/dist/chains/query_constructor/index.cjs +4 -4
- package/dist/chains/query_constructor/index.cjs.map +1 -1
- package/dist/chains/query_constructor/index.d.cts +4 -2
- package/dist/chains/query_constructor/index.d.cts.map +1 -1
- package/dist/chains/query_constructor/index.d.ts +4 -2
- package/dist/chains/query_constructor/index.d.ts.map +1 -1
- package/dist/chains/query_constructor/index.js +1 -1
- package/dist/chains/query_constructor/index.js.map +1 -1
- package/dist/chains/question_answering/load.d.ts +2 -2
- package/dist/chains/question_answering/load.d.ts.map +1 -1
- package/dist/chains/question_answering/map_reduce_prompts.cjs.map +1 -1
- package/dist/chains/question_answering/map_reduce_prompts.js.map +1 -1
- package/dist/chains/question_answering/refine_prompts.cjs.map +1 -1
- package/dist/chains/question_answering/refine_prompts.js.map +1 -1
- package/dist/chains/question_answering/stuff_prompts.cjs.map +1 -1
- package/dist/chains/question_answering/stuff_prompts.js.map +1 -1
- package/dist/chains/router/multi_prompt.cjs +4 -4
- package/dist/chains/router/multi_prompt.cjs.map +1 -1
- package/dist/chains/router/multi_prompt.js +1 -1
- package/dist/chains/router/multi_prompt.js.map +1 -1
- package/dist/chains/router/multi_retrieval_qa.cjs +4 -4
- package/dist/chains/router/multi_retrieval_qa.cjs.map +1 -1
- package/dist/chains/router/multi_retrieval_qa.js +1 -1
- package/dist/chains/router/multi_retrieval_qa.js.map +1 -1
- package/dist/chains/sql_db/sql_db_prompt.cjs.map +1 -1
- package/dist/chains/sql_db/sql_db_prompt.d.cts.map +1 -1
- package/dist/chains/sql_db/sql_db_prompt.d.ts.map +1 -1
- package/dist/chains/sql_db/sql_db_prompt.js.map +1 -1
- package/dist/chains/summarization/stuff_prompts.cjs.map +1 -1
- package/dist/chains/summarization/stuff_prompts.js.map +1 -1
- package/dist/chat_models/universal.cjs +8 -5
- package/dist/chat_models/universal.cjs.map +1 -1
- package/dist/chat_models/universal.d.cts +2 -2
- package/dist/chat_models/universal.d.cts.map +1 -1
- package/dist/chat_models/universal.d.ts +2 -2
- package/dist/chat_models/universal.d.ts.map +1 -1
- package/dist/chat_models/universal.js +8 -5
- package/dist/chat_models/universal.js.map +1 -1
- package/dist/document_loaders/fs/directory.cjs.map +1 -1
- package/dist/document_loaders/fs/directory.d.cts +0 -1
- package/dist/document_loaders/fs/directory.d.cts.map +1 -1
- package/dist/document_loaders/fs/directory.d.ts +0 -1
- package/dist/document_loaders/fs/directory.d.ts.map +1 -1
- package/dist/document_loaders/fs/directory.js.map +1 -1
- package/dist/document_loaders/fs/json.cjs +7 -1
- package/dist/document_loaders/fs/json.cjs.map +1 -1
- package/dist/document_loaders/fs/json.js +7 -1
- package/dist/document_loaders/fs/json.js.map +1 -1
- package/dist/embeddings/cache_backed.cjs +1 -1
- package/dist/embeddings/cache_backed.cjs.map +1 -1
- package/dist/embeddings/cache_backed.d.cts +1 -1
- package/dist/embeddings/cache_backed.d.ts +2 -2
- package/dist/embeddings/cache_backed.js +2 -2
- package/dist/embeddings/cache_backed.js.map +1 -1
- package/dist/evaluation/agents/trajectory.d.cts.map +1 -1
- package/dist/evaluation/comparison/pairwise.d.cts.map +1 -1
- package/dist/evaluation/criteria/criteria.d.cts.map +1 -1
- package/dist/evaluation/embedding_distance/base.cjs +2 -4
- package/dist/evaluation/embedding_distance/base.cjs.map +1 -1
- package/dist/evaluation/embedding_distance/base.js +2 -3
- package/dist/evaluation/embedding_distance/base.js.map +1 -1
- package/dist/evaluation/loader.cjs +7 -12
- package/dist/evaluation/loader.cjs.map +1 -1
- package/dist/evaluation/loader.d.cts +8 -2
- package/dist/evaluation/loader.d.cts.map +1 -1
- package/dist/evaluation/loader.d.ts +8 -2
- package/dist/evaluation/loader.d.ts.map +1 -1
- package/dist/evaluation/loader.js +7 -12
- package/dist/evaluation/loader.js.map +1 -1
- package/dist/hub/base.cjs.map +1 -1
- package/dist/hub/base.js.map +1 -1
- package/dist/index.cjs +38 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +11 -4
- package/dist/index.d.ts +11 -4
- package/dist/index.js +18 -4
- package/dist/index.js.map +1 -1
- package/dist/langchain-core/dist/load/serializable.d.cts.map +1 -1
- package/dist/langchain-core/dist/messages/base.d.cts +24 -33
- package/dist/langchain-core/dist/messages/base.d.cts.map +1 -1
- package/dist/langchain-core/dist/messages/content/index.d.cts +21 -2
- package/dist/langchain-core/dist/messages/content/index.d.cts.map +1 -1
- package/dist/langchain-core/dist/messages/content/tools.d.cts +67 -6
- package/dist/langchain-core/dist/messages/content/tools.d.cts.map +1 -1
- package/dist/langchain-core/dist/messages/message.d.cts +598 -0
- package/dist/langchain-core/dist/messages/message.d.cts.map +1 -0
- package/dist/langchain-core/dist/messages/metadata.d.cts +97 -0
- package/dist/langchain-core/dist/messages/metadata.d.cts.map +1 -0
- package/dist/langchain-core/dist/messages/utils.d.cts +75 -0
- package/dist/langchain-core/dist/messages/utils.d.cts.map +1 -0
- package/dist/langchain-core/dist/prompt_values.d.cts.map +1 -1
- package/dist/langchain-core/dist/utils/types/index.d.cts.map +1 -1
- package/dist/libs/langchain-core/dist/load/serializable.d.ts.map +1 -1
- package/dist/libs/langchain-core/dist/messages/base.d.ts +24 -33
- package/dist/libs/langchain-core/dist/messages/base.d.ts.map +1 -1
- package/dist/libs/langchain-core/dist/messages/content/index.d.ts +21 -2
- package/dist/libs/langchain-core/dist/messages/content/index.d.ts.map +1 -1
- package/dist/libs/langchain-core/dist/messages/content/tools.d.ts +67 -6
- package/dist/libs/langchain-core/dist/messages/content/tools.d.ts.map +1 -1
- package/dist/libs/langchain-core/dist/messages/message.d.ts +598 -0
- package/dist/libs/langchain-core/dist/messages/message.d.ts.map +1 -0
- package/dist/libs/langchain-core/dist/messages/metadata.d.ts +97 -0
- package/dist/libs/langchain-core/dist/messages/metadata.d.ts.map +1 -0
- package/dist/libs/langchain-core/dist/messages/utils.d.ts +75 -0
- package/dist/libs/langchain-core/dist/messages/utils.d.ts.map +1 -0
- package/dist/libs/langchain-core/dist/prompt_values.d.ts.map +1 -1
- package/dist/libs/langchain-core/dist/utils/types/index.d.ts +2 -0
- package/dist/libs/langchain-core/dist/utils/types/index.d.ts.map +1 -1
- package/dist/libs/langchain-core/dist/utils/types/zod.d.ts +1 -0
- package/dist/load/import_map.cjs +3 -14
- package/dist/load/import_map.cjs.map +1 -1
- package/dist/load/import_map.js +3 -14
- package/dist/load/import_map.js.map +1 -1
- package/dist/memory/prompt.cjs.map +1 -1
- package/dist/memory/prompt.d.cts.map +1 -1
- package/dist/memory/prompt.d.ts.map +1 -1
- package/dist/memory/prompt.js.map +1 -1
- package/dist/output_parsers/combining.cjs +1 -1
- package/dist/output_parsers/combining.cjs.map +1 -1
- package/dist/output_parsers/combining.js +1 -1
- package/dist/output_parsers/combining.js.map +1 -1
- package/dist/output_parsers/expression_type_handlers/array_literal_expression_handler.cjs.map +1 -1
- package/dist/output_parsers/expression_type_handlers/array_literal_expression_handler.js.map +1 -1
- package/dist/output_parsers/expression_type_handlers/base.cjs +1 -1
- package/dist/output_parsers/expression_type_handlers/base.cjs.map +1 -1
- package/dist/output_parsers/expression_type_handlers/base.js +1 -1
- package/dist/output_parsers/expression_type_handlers/base.js.map +1 -1
- package/dist/output_parsers/regex.cjs.map +1 -1
- package/dist/output_parsers/regex.js.map +1 -1
- package/dist/output_parsers/structured.cjs +4 -4
- package/dist/output_parsers/structured.cjs.map +1 -1
- package/dist/output_parsers/structured.d.cts +1 -1
- package/dist/output_parsers/structured.d.cts.map +1 -1
- package/dist/output_parsers/structured.d.ts +1 -1
- package/dist/output_parsers/structured.d.ts.map +1 -1
- package/dist/output_parsers/structured.js +2 -2
- package/dist/output_parsers/structured.js.map +1 -1
- package/dist/retrievers/ensemble.cjs.map +1 -1
- package/dist/retrievers/ensemble.js.map +1 -1
- package/dist/storage/file_system.cjs +1 -1
- package/dist/storage/file_system.cjs.map +1 -1
- package/dist/storage/file_system.js +1 -1
- package/dist/storage/file_system.js.map +1 -1
- package/dist/tools/fs.cjs +5 -5
- package/dist/tools/fs.cjs.map +1 -1
- package/dist/tools/fs.d.cts +1 -1
- package/dist/tools/fs.d.cts.map +1 -1
- package/dist/tools/fs.d.ts +1 -1
- package/dist/tools/fs.d.ts.map +1 -1
- package/dist/tools/fs.js +1 -1
- package/dist/tools/fs.js.map +1 -1
- package/dist/tools/retriever.cjs +2 -2
- package/dist/tools/retriever.cjs.map +1 -1
- package/dist/tools/retriever.d.cts +1 -1
- package/dist/tools/retriever.d.cts.map +1 -1
- package/dist/tools/retriever.d.ts +1 -1
- package/dist/tools/retriever.d.ts.map +1 -1
- package/dist/tools/retriever.js +1 -1
- package/dist/tools/retriever.js.map +1 -1
- package/dist/tools/sql.cjs +1 -2
- package/dist/tools/sql.cjs.map +1 -1
- package/dist/tools/sql.d.cts +1 -1
- package/dist/tools/sql.d.cts.map +1 -1
- package/dist/tools/sql.d.ts +1 -1
- package/dist/tools/sql.d.ts.map +1 -1
- package/dist/tools/sql.js +1 -2
- package/dist/tools/sql.js.map +1 -1
- package/dist/types/expression-parser.d.cts +2 -0
- package/dist/types/expression-parser.d.cts.map +1 -1
- package/dist/types/expression-parser.d.ts +2 -0
- package/dist/types/expression-parser.d.ts.map +1 -1
- package/dist/util/hub.cjs +1 -1
- package/dist/util/hub.js +1 -1
- package/dist/util/openapi.cjs +1 -1
- package/dist/util/openapi.cjs.map +1 -1
- package/dist/util/openapi.js +1 -1
- package/dist/util/openapi.js.map +1 -1
- package/package.json +15 -21
- package/dist/agents/middlewareAgent/middlewares/hitl.cjs +0 -235
- package/dist/agents/middlewareAgent/middlewares/hitl.cjs.map +0 -1
- package/dist/agents/middlewareAgent/middlewares/hitl.d.cts +0 -199
- package/dist/agents/middlewareAgent/middlewares/hitl.d.cts.map +0 -1
- package/dist/agents/middlewareAgent/middlewares/hitl.d.ts +0 -199
- package/dist/agents/middlewareAgent/middlewares/hitl.d.ts.map +0 -1
- package/dist/agents/middlewareAgent/middlewares/hitl.js +0 -234
- package/dist/agents/middlewareAgent/middlewares/hitl.js.map +0 -1
- package/dist/agents/middlewareAgent/middlewares/index.cjs +0 -8
- package/dist/agents/middlewareAgent/middlewares/index.d.cts +0 -4
- package/dist/agents/middlewareAgent/middlewares/index.d.ts +0 -4
- package/dist/agents/middlewareAgent/middlewares/index.js +0 -5
- package/dist/agents/middlewareAgent/middlewares/promptCaching.cjs.map +0 -1
- package/dist/agents/middlewareAgent/middlewares/promptCaching.d.cts.map +0 -1
- package/dist/agents/middlewareAgent/middlewares/promptCaching.d.ts.map +0 -1
- package/dist/agents/middlewareAgent/middlewares/promptCaching.js.map +0 -1
- package/dist/agents/middlewareAgent/middlewares/summarization.cjs.map +0 -1
- package/dist/agents/middlewareAgent/middlewares/summarization.d.cts.map +0 -1
- package/dist/agents/middlewareAgent/middlewares/summarization.d.ts.map +0 -1
- package/dist/agents/middlewareAgent/middlewares/summarization.js.map +0 -1
- package/dist/chains/openai_functions/structured_output.cjs +0 -107
- package/dist/chains/openai_functions/structured_output.cjs.map +0 -1
- package/dist/chains/openai_functions/structured_output.d.cts +0 -38
- package/dist/chains/openai_functions/structured_output.d.cts.map +0 -1
- package/dist/chains/openai_functions/structured_output.d.ts +0 -38
- package/dist/chains/openai_functions/structured_output.d.ts.map +0 -1
- package/dist/chains/openai_functions/structured_output.js +0 -105
- package/dist/chains/openai_functions/structured_output.js.map +0 -1
- package/dist/chains/openai_moderation.cjs +0 -107
- package/dist/chains/openai_moderation.cjs.map +0 -1
- package/dist/chains/openai_moderation.d.cts +0 -74
- package/dist/chains/openai_moderation.d.cts.map +0 -1
- package/dist/chains/openai_moderation.d.ts +0 -74
- package/dist/chains/openai_moderation.d.ts.map +0 -1
- package/dist/chains/openai_moderation.js +0 -106
- package/dist/chains/openai_moderation.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt.d.cts","names":["PromptTemplate","SUMMARY_PROMPT","_DEFAULT_ENTITY_MEMORY_CONVERSATION_TEMPLATE","ENTITY_MEMORY_CONVERSATION_TEMPLATE","_DEFAULT_ENTITY_EXTRACTION_TEMPLATE","ENTITY_EXTRACTION_PROMPT","_DEFAULT_ENTITY_SUMMARIZATION_TEMPLATE","ENTITY_SUMMARIZATION_PROMPT"],"sources":["../../src/memory/prompt.d.ts"],"sourcesContent":["import { PromptTemplate } from \"@langchain/core/prompts\";\
|
|
1
|
+
{"version":3,"file":"prompt.d.cts","names":["PromptTemplate","SUMMARY_PROMPT","_DEFAULT_ENTITY_MEMORY_CONVERSATION_TEMPLATE","ENTITY_MEMORY_CONVERSATION_TEMPLATE","_DEFAULT_ENTITY_EXTRACTION_TEMPLATE","ENTITY_EXTRACTION_PROMPT","_DEFAULT_ENTITY_SUMMARIZATION_TEMPLATE","ENTITY_SUMMARIZATION_PROMPT"],"sources":["../../src/memory/prompt.d.ts"],"sourcesContent":["import { PromptTemplate } from \"@langchain/core/prompts\";\nexport declare const SUMMARY_PROMPT: PromptTemplate<{\n new_lines: any;\n summary: any;\n}, any>;\nexport declare const _DEFAULT_ENTITY_MEMORY_CONVERSATION_TEMPLATE = \"You are an assistant to a human, powered by a large language model trained by OpenAI.\\n\\nYou are designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, you are able to generate human-like text based on the input you receive, allowing you to engage in natural-sounding conversations and provide responses that are coherent and relevant to the topic at hand.\\n\\nYou are constantly learning and improving, and your capabilities are constantly evolving. You are able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. You have access to some personalized information provided by the human in the Context section below. Additionally, you are able to generate your own text based on the input you receive, allowing you to engage in discussions and provide explanations and descriptions on a wide range of topics.\\n\\nOverall, you are a powerful tool that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether the human needs help with a specific question or just wants to have a conversation about a particular topic, you are here to assist.\\n\\nContext:\\n{entities}\\n\\nCurrent conversation:\\n{history}\\nLast line:\\nHuman: {input}\\nYou:\";\nexport declare const ENTITY_MEMORY_CONVERSATION_TEMPLATE: PromptTemplate<{\n entities: any;\n history: any;\n input: any;\n}, any>;\nexport declare const _DEFAULT_ENTITY_EXTRACTION_TEMPLATE = \"You are an AI assistant reading the transcript of a conversation between an AI and a human. Extract all of the proper nouns from the last line of conversation. As a guideline, a proper noun is generally capitalized. You should definitely extract all names and places.\\n\\nThe conversation history is provided just in case of a coreference (e.g. \\\"What do you know about him\\\" where \\\"him\\\" is defined in a previous line) -- ignore items mentioned there that are not in the last line.\\n\\nReturn the output as a single comma-separated list, or NONE if there is nothing of note to return (e.g. the user is just issuing a greeting or having a simple conversation).\\n\\nEXAMPLE\\nConversation history:\\nPerson #1: my name is Jacob. how's it going today?\\nAI: \\\"It's going great! How about you?\\\"\\nPerson #1: good! busy working on Langchain. lots to do.\\nAI: \\\"That sounds like a lot of work! What kind of things are you doing to make Langchain better?\\\"\\nLast line:\\nPerson #1: i'm trying to improve Langchain's interfaces, the UX, its integrations with various products the user might want ... a lot of stuff.\\nOutput: Jacob,Langchain\\nEND OF EXAMPLE\\n\\nEXAMPLE\\nConversation history:\\nPerson #1: how's it going today?\\nAI: \\\"It's going great! How about you?\\\"\\nPerson #1: good! busy working on Langchain. lots to do.\\nAI: \\\"That sounds like a lot of work! What kind of things are you doing to make Langchain better?\\\"\\nLast line:\\nPerson #1: i'm trying to improve Langchain's interfaces, the UX, its integrations with various products the user might want ... a lot of stuff. I'm working with Person #2.\\nOutput: Langchain, Person #2\\nEND OF EXAMPLE\\n\\nConversation history (for reference only):\\n{history}\\nLast line of conversation (for extraction):\\nHuman: {input}\\n\\nOutput:\";\nexport declare const ENTITY_EXTRACTION_PROMPT: PromptTemplate<{\n history: any;\n input: any;\n}, any>;\nexport declare const _DEFAULT_ENTITY_SUMMARIZATION_TEMPLATE = \"You are an AI assistant helping a human keep track of facts about relevant people, places, and concepts in their life. Update and add to the summary of the provided entity in the \\\"Entity\\\" section based on the last line of your conversation with the human. If you are writing the summary for the first time, return a single sentence.\\nThe update should only include facts that are relayed in the last line of conversation about the provided entity, and should only contain facts about the provided entity.\\n\\nIf there is no new information about the provided entity or the information is not worth noting (not an important or relevant fact to remember long-term), output the exact string \\\"UNCHANGED\\\" below.\\n\\nFull conversation history (for context):\\n{history}\\n\\nEntity to summarize:\\n{entity}\\n\\nExisting summary of {entity}:\\n{summary}\\n\\nLast line of conversation:\\nHuman: {input}\\nUpdated summary (or the exact string \\\"UNCHANGED\\\" if there is no new information about {entity} above):\";\nexport declare const ENTITY_SUMMARIZATION_PROMPT: PromptTemplate<{\n entity: any;\n history: any;\n input: any;\n summary: any;\n}, any>;\n"],"mappings":";;;;cAMqBG,qCAAqCH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt.d.ts","names":["PromptTemplate","SUMMARY_PROMPT","_DEFAULT_ENTITY_MEMORY_CONVERSATION_TEMPLATE","ENTITY_MEMORY_CONVERSATION_TEMPLATE","_DEFAULT_ENTITY_EXTRACTION_TEMPLATE","ENTITY_EXTRACTION_PROMPT","_DEFAULT_ENTITY_SUMMARIZATION_TEMPLATE","ENTITY_SUMMARIZATION_PROMPT"],"sources":["../../src/memory/prompt.d.ts"],"sourcesContent":["import { PromptTemplate } from \"@langchain/core/prompts\";\
|
|
1
|
+
{"version":3,"file":"prompt.d.ts","names":["PromptTemplate","SUMMARY_PROMPT","_DEFAULT_ENTITY_MEMORY_CONVERSATION_TEMPLATE","ENTITY_MEMORY_CONVERSATION_TEMPLATE","_DEFAULT_ENTITY_EXTRACTION_TEMPLATE","ENTITY_EXTRACTION_PROMPT","_DEFAULT_ENTITY_SUMMARIZATION_TEMPLATE","ENTITY_SUMMARIZATION_PROMPT"],"sources":["../../src/memory/prompt.d.ts"],"sourcesContent":["import { PromptTemplate } from \"@langchain/core/prompts\";\nexport declare const SUMMARY_PROMPT: PromptTemplate<{\n new_lines: any;\n summary: any;\n}, any>;\nexport declare const _DEFAULT_ENTITY_MEMORY_CONVERSATION_TEMPLATE = \"You are an assistant to a human, powered by a large language model trained by OpenAI.\\n\\nYou are designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, you are able to generate human-like text based on the input you receive, allowing you to engage in natural-sounding conversations and provide responses that are coherent and relevant to the topic at hand.\\n\\nYou are constantly learning and improving, and your capabilities are constantly evolving. You are able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. You have access to some personalized information provided by the human in the Context section below. Additionally, you are able to generate your own text based on the input you receive, allowing you to engage in discussions and provide explanations and descriptions on a wide range of topics.\\n\\nOverall, you are a powerful tool that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether the human needs help with a specific question or just wants to have a conversation about a particular topic, you are here to assist.\\n\\nContext:\\n{entities}\\n\\nCurrent conversation:\\n{history}\\nLast line:\\nHuman: {input}\\nYou:\";\nexport declare const ENTITY_MEMORY_CONVERSATION_TEMPLATE: PromptTemplate<{\n entities: any;\n history: any;\n input: any;\n}, any>;\nexport declare const _DEFAULT_ENTITY_EXTRACTION_TEMPLATE = \"You are an AI assistant reading the transcript of a conversation between an AI and a human. Extract all of the proper nouns from the last line of conversation. As a guideline, a proper noun is generally capitalized. You should definitely extract all names and places.\\n\\nThe conversation history is provided just in case of a coreference (e.g. \\\"What do you know about him\\\" where \\\"him\\\" is defined in a previous line) -- ignore items mentioned there that are not in the last line.\\n\\nReturn the output as a single comma-separated list, or NONE if there is nothing of note to return (e.g. the user is just issuing a greeting or having a simple conversation).\\n\\nEXAMPLE\\nConversation history:\\nPerson #1: my name is Jacob. how's it going today?\\nAI: \\\"It's going great! How about you?\\\"\\nPerson #1: good! busy working on Langchain. lots to do.\\nAI: \\\"That sounds like a lot of work! What kind of things are you doing to make Langchain better?\\\"\\nLast line:\\nPerson #1: i'm trying to improve Langchain's interfaces, the UX, its integrations with various products the user might want ... a lot of stuff.\\nOutput: Jacob,Langchain\\nEND OF EXAMPLE\\n\\nEXAMPLE\\nConversation history:\\nPerson #1: how's it going today?\\nAI: \\\"It's going great! How about you?\\\"\\nPerson #1: good! busy working on Langchain. lots to do.\\nAI: \\\"That sounds like a lot of work! What kind of things are you doing to make Langchain better?\\\"\\nLast line:\\nPerson #1: i'm trying to improve Langchain's interfaces, the UX, its integrations with various products the user might want ... a lot of stuff. I'm working with Person #2.\\nOutput: Langchain, Person #2\\nEND OF EXAMPLE\\n\\nConversation history (for reference only):\\n{history}\\nLast line of conversation (for extraction):\\nHuman: {input}\\n\\nOutput:\";\nexport declare const ENTITY_EXTRACTION_PROMPT: PromptTemplate<{\n history: any;\n input: any;\n}, any>;\nexport declare const _DEFAULT_ENTITY_SUMMARIZATION_TEMPLATE = \"You are an AI assistant helping a human keep track of facts about relevant people, places, and concepts in their life. Update and add to the summary of the provided entity in the \\\"Entity\\\" section based on the last line of your conversation with the human. If you are writing the summary for the first time, return a single sentence.\\nThe update should only include facts that are relayed in the last line of conversation about the provided entity, and should only contain facts about the provided entity.\\n\\nIf there is no new information about the provided entity or the information is not worth noting (not an important or relevant fact to remember long-term), output the exact string \\\"UNCHANGED\\\" below.\\n\\nFull conversation history (for context):\\n{history}\\n\\nEntity to summarize:\\n{entity}\\n\\nExisting summary of {entity}:\\n{summary}\\n\\nLast line of conversation:\\nHuman: {input}\\nUpdated summary (or the exact string \\\"UNCHANGED\\\" if there is no new information about {entity} above):\";\nexport declare const ENTITY_SUMMARIZATION_PROMPT: PromptTemplate<{\n entity: any;\n history: any;\n input: any;\n summary: any;\n}, any>;\n"],"mappings":";;;;cAMqBG,qCAAqCH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt.js","names":[],"sources":["../../src/memory/prompt.ts"],"sourcesContent":["import { PromptTemplate } from \"@langchain/core/prompts\";\n\nconst _DEFAULT_SUMMARIZER_TEMPLATE = `Progressively summarize the lines of conversation provided, adding onto the previous summary returning a new summary.\n\nEXAMPLE\nCurrent summary:\nThe human asks what the AI thinks of artificial intelligence. The AI thinks artificial intelligence is a force for good.\n\nNew lines of conversation:\nHuman: Why do you think artificial intelligence is a force for good?\nAI: Because artificial intelligence will help humans reach their full potential.\n\nNew summary:\nThe human asks what the AI thinks of artificial intelligence. The AI thinks artificial intelligence is a force for good because it will help humans reach their full potential.\nEND OF EXAMPLE\n\nCurrent summary:\n{summary}\n\nNew lines of conversation:\n{new_lines}\n\nNew summary:`;\n\
|
|
1
|
+
{"version":3,"file":"prompt.js","names":[],"sources":["../../src/memory/prompt.ts"],"sourcesContent":["import { PromptTemplate } from \"@langchain/core/prompts\";\n\nconst _DEFAULT_SUMMARIZER_TEMPLATE = `Progressively summarize the lines of conversation provided, adding onto the previous summary returning a new summary.\n\nEXAMPLE\nCurrent summary:\nThe human asks what the AI thinks of artificial intelligence. The AI thinks artificial intelligence is a force for good.\n\nNew lines of conversation:\nHuman: Why do you think artificial intelligence is a force for good?\nAI: Because artificial intelligence will help humans reach their full potential.\n\nNew summary:\nThe human asks what the AI thinks of artificial intelligence. The AI thinks artificial intelligence is a force for good because it will help humans reach their full potential.\nEND OF EXAMPLE\n\nCurrent summary:\n{summary}\n\nNew lines of conversation:\n{new_lines}\n\nNew summary:`;\n\nexport const SUMMARY_PROMPT = /*#__PURE__*/ new PromptTemplate({\n inputVariables: [\"summary\", \"new_lines\"],\n template: _DEFAULT_SUMMARIZER_TEMPLATE,\n});\n\nexport const _DEFAULT_ENTITY_MEMORY_CONVERSATION_TEMPLATE = `You are an assistant to a human, powered by a large language model trained by OpenAI.\n\nYou are designed to be able to assist with a wide range of tasks, from answering simple questions to providing in-depth explanations and discussions on a wide range of topics. As a language model, you are able to generate human-like text based on the input you receive, allowing you to engage in natural-sounding conversations and provide responses that are coherent and relevant to the topic at hand.\n\nYou are constantly learning and improving, and your capabilities are constantly evolving. You are able to process and understand large amounts of text, and can use this knowledge to provide accurate and informative responses to a wide range of questions. You have access to some personalized information provided by the human in the Context section below. Additionally, you are able to generate your own text based on the input you receive, allowing you to engage in discussions and provide explanations and descriptions on a wide range of topics.\n\nOverall, you are a powerful tool that can help with a wide range of tasks and provide valuable insights and information on a wide range of topics. Whether the human needs help with a specific question or just wants to have a conversation about a particular topic, you are here to assist.\n\nContext:\n{entities}\n\nCurrent conversation:\n{history}\nLast line:\nHuman: {input}\nYou:`;\n\nexport const ENTITY_MEMORY_CONVERSATION_TEMPLATE =\n /*#__PURE__*/ new PromptTemplate({\n inputVariables: [\"entities\", \"history\", \"input\"],\n template: _DEFAULT_ENTITY_MEMORY_CONVERSATION_TEMPLATE,\n });\n\nexport const _DEFAULT_ENTITY_EXTRACTION_TEMPLATE = `You are an AI assistant reading the transcript of a conversation between an AI and a human. Extract all of the proper nouns from the last line of conversation. As a guideline, a proper noun is generally capitalized. You should definitely extract all names and places.\n\nThe conversation history is provided just in case of a coreference (e.g. \"What do you know about him\" where \"him\" is defined in a previous line) -- ignore items mentioned there that are not in the last line.\n\nReturn the output as a single comma-separated list, or NONE if there is nothing of note to return (e.g. the user is just issuing a greeting or having a simple conversation).\n\nEXAMPLE\nConversation history:\nPerson #1: my name is Jacob. how's it going today?\nAI: \"It's going great! How about you?\"\nPerson #1: good! busy working on Langchain. lots to do.\nAI: \"That sounds like a lot of work! What kind of things are you doing to make Langchain better?\"\nLast line:\nPerson #1: i'm trying to improve Langchain's interfaces, the UX, its integrations with various products the user might want ... a lot of stuff.\nOutput: Jacob,Langchain\nEND OF EXAMPLE\n\nEXAMPLE\nConversation history:\nPerson #1: how's it going today?\nAI: \"It's going great! How about you?\"\nPerson #1: good! busy working on Langchain. lots to do.\nAI: \"That sounds like a lot of work! What kind of things are you doing to make Langchain better?\"\nLast line:\nPerson #1: i'm trying to improve Langchain's interfaces, the UX, its integrations with various products the user might want ... a lot of stuff. I'm working with Person #2.\nOutput: Langchain, Person #2\nEND OF EXAMPLE\n\nConversation history (for reference only):\n{history}\nLast line of conversation (for extraction):\nHuman: {input}\n\nOutput:`;\n\nexport const ENTITY_EXTRACTION_PROMPT = /*#__PURE__*/ new PromptTemplate({\n inputVariables: [\"history\", \"input\"],\n template: _DEFAULT_ENTITY_EXTRACTION_TEMPLATE,\n});\n\nexport const _DEFAULT_ENTITY_SUMMARIZATION_TEMPLATE = `You are an AI assistant helping a human keep track of facts about relevant people, places, and concepts in their life. Update and add to the summary of the provided entity in the \"Entity\" section based on the last line of your conversation with the human. If you are writing the summary for the first time, return a single sentence.\nThe update should only include facts that are relayed in the last line of conversation about the provided entity, and should only contain facts about the provided entity.\n\nIf there is no new information about the provided entity or the information is not worth noting (not an important or relevant fact to remember long-term), output the exact string \"UNCHANGED\" below.\n\nFull conversation history (for context):\n{history}\n\nEntity to summarize:\n{entity}\n\nExisting summary of {entity}:\n{summary}\n\nLast line of conversation:\nHuman: {input}\nUpdated summary (or the exact string \"UNCHANGED\" if there is no new information about {entity} above):`;\n\nexport const ENTITY_SUMMARIZATION_PROMPT = /*#__PURE__*/ new PromptTemplate({\n inputVariables: [\"entity\", \"summary\", \"history\", \"input\"],\n template: _DEFAULT_ENTITY_SUMMARIZATION_TEMPLATE,\n});\n"],"mappings":";;;AAEA,MAAM,+BAA+B,CAAC;;;;;;;;;;;;;;;;;;;;YAoB1B,CAAC;AAEb,MAAa,iCAA+B,IAAI,eAAe;CAC7D,gBAAgB,CAAC,WAAW,WAAY;CACxC,UAAU;AACX;AAED,MAAa,+CAA+C,CAAC;;;;;;;;;;;;;;;IAezD,CAAC;AAEL,MAAa,sDACG,IAAI,eAAe;CAC/B,gBAAgB;EAAC;EAAY;EAAW;CAAQ;CAChD,UAAU;AACX;AAEH,MAAa,sCAAsC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAiC7C,CAAC;AAER,MAAa,2CAAyC,IAAI,eAAe;CACvE,gBAAgB,CAAC,WAAW,OAAQ;CACpC,UAAU;AACX;AAED,MAAa,yCAAyC,CAAC;;;;;;;;;;;;;;;;sGAgB+C,CAAC;AAEvG,MAAa,8CAA4C,IAAI,eAAe;CAC1E,gBAAgB;EAAC;EAAU;EAAW;EAAW;CAAQ;CACzD,UAAU;AACX"}
|
|
@@ -39,7 +39,7 @@ var CombiningOutputParser = class extends __langchain_core_output_parsers.BaseOu
|
|
|
39
39
|
let extracted = inputs[i].includes("```") ? inputs[i].trim().split(/```/)[1] : inputs[i].trim();
|
|
40
40
|
if (extracted.endsWith(this.outputDelimiter)) extracted = extracted.slice(0, -this.outputDelimiter.length);
|
|
41
41
|
parsed = await p.parse(extracted, callbacks);
|
|
42
|
-
} catch
|
|
42
|
+
} catch {
|
|
43
43
|
parsed = await p.parse(input.trim(), callbacks);
|
|
44
44
|
}
|
|
45
45
|
Object.assign(ret, parsed);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combining.cjs","names":["BaseOutputParser","fields: BaseOutputParser | CombiningOutputParserFields","input: string","callbacks?: Callbacks","ret: CombinedOutput"],"sources":["../../src/output_parsers/combining.ts"],"sourcesContent":["import { Callbacks } from \"@langchain/core/callbacks/manager\";\nimport { BaseOutputParser } from \"@langchain/core/output_parsers\";\n\n/**\n * Type for the combined output of the CombiningOutputParser class.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type CombinedOutput = Record<string, any>;\n\n/**\n * Interface for the fields required by the CombiningOutputParser class.\n */\nexport interface CombiningOutputParserFields {\n parsers: BaseOutputParser[];\n}\n\n/**\n * Class to combine multiple output parsers\n * @augments BaseOutputParser\n */\nexport class CombiningOutputParser extends BaseOutputParser<object> {\n static lc_name() {\n return \"CombiningOutputParser\";\n }\n\n lc_namespace = [\"langchain\", \"output_parsers\", \"combining\"];\n\n lc_serializable = true;\n\n parsers: BaseOutputParser[];\n\n outputDelimiter = \"-----\";\n\n constructor(fields: CombiningOutputParserFields);\n\n constructor(...parsers: BaseOutputParser[]);\n\n constructor(\n fields: BaseOutputParser | CombiningOutputParserFields,\n ...parsers: BaseOutputParser[]\n ) {\n if (parsers.length > 0 || !(\"parsers\" in fields)) {\n // eslint-disable-next-line no-param-reassign\n fields = {\n parsers: [fields as BaseOutputParser, ...parsers],\n };\n }\n super(fields);\n this.parsers = fields.parsers;\n }\n\n /**\n * Method to parse an input string using the parsers in the parsers array.\n * The parsed outputs are combined into a single object and returned.\n * @param input The input string to parse.\n * @param callbacks Optional Callbacks object.\n * @returns A Promise that resolves to a CombinedOutput object.\n */\n async parse(input: string, callbacks?: Callbacks): Promise<CombinedOutput> {\n const inputs = input\n .trim()\n .split(\n new RegExp(`${this.outputDelimiter}Output \\\\d+${this.outputDelimiter}`)\n )\n .slice(1);\n const ret: CombinedOutput = {};\n for (const [i, p] of this.parsers.entries()) {\n let parsed;\n try {\n let extracted = inputs[i].includes(\"```\")\n ? inputs[i].trim().split(/```/)[1]\n : inputs[i].trim();\n if (extracted.endsWith(this.outputDelimiter)) {\n extracted = extracted.slice(0, -this.outputDelimiter.length);\n }\n parsed = await p.parse(extracted, callbacks);\n } catch
|
|
1
|
+
{"version":3,"file":"combining.cjs","names":["BaseOutputParser","fields: BaseOutputParser | CombiningOutputParserFields","input: string","callbacks?: Callbacks","ret: CombinedOutput"],"sources":["../../src/output_parsers/combining.ts"],"sourcesContent":["import { Callbacks } from \"@langchain/core/callbacks/manager\";\nimport { BaseOutputParser } from \"@langchain/core/output_parsers\";\n\n/**\n * Type for the combined output of the CombiningOutputParser class.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type CombinedOutput = Record<string, any>;\n\n/**\n * Interface for the fields required by the CombiningOutputParser class.\n */\nexport interface CombiningOutputParserFields {\n parsers: BaseOutputParser[];\n}\n\n/**\n * Class to combine multiple output parsers\n * @augments BaseOutputParser\n */\nexport class CombiningOutputParser extends BaseOutputParser<object> {\n static lc_name() {\n return \"CombiningOutputParser\";\n }\n\n lc_namespace = [\"langchain\", \"output_parsers\", \"combining\"];\n\n lc_serializable = true;\n\n parsers: BaseOutputParser[];\n\n outputDelimiter = \"-----\";\n\n constructor(fields: CombiningOutputParserFields);\n\n constructor(...parsers: BaseOutputParser[]);\n\n constructor(\n fields: BaseOutputParser | CombiningOutputParserFields,\n ...parsers: BaseOutputParser[]\n ) {\n if (parsers.length > 0 || !(\"parsers\" in fields)) {\n // eslint-disable-next-line no-param-reassign\n fields = {\n parsers: [fields as BaseOutputParser, ...parsers],\n };\n }\n super(fields);\n this.parsers = fields.parsers;\n }\n\n /**\n * Method to parse an input string using the parsers in the parsers array.\n * The parsed outputs are combined into a single object and returned.\n * @param input The input string to parse.\n * @param callbacks Optional Callbacks object.\n * @returns A Promise that resolves to a CombinedOutput object.\n */\n async parse(input: string, callbacks?: Callbacks): Promise<CombinedOutput> {\n const inputs = input\n .trim()\n .split(\n new RegExp(`${this.outputDelimiter}Output \\\\d+${this.outputDelimiter}`)\n )\n .slice(1);\n const ret: CombinedOutput = {};\n for (const [i, p] of this.parsers.entries()) {\n let parsed;\n try {\n let extracted = inputs[i].includes(\"```\")\n ? inputs[i].trim().split(/```/)[1]\n : inputs[i].trim();\n if (extracted.endsWith(this.outputDelimiter)) {\n extracted = extracted.slice(0, -this.outputDelimiter.length);\n }\n parsed = await p.parse(extracted, callbacks);\n } catch {\n parsed = await p.parse(input.trim(), callbacks);\n }\n Object.assign(ret, parsed);\n }\n return ret;\n }\n\n /**\n * Method to get instructions on how to format the LLM output. The\n * instructions are based on the parsers array and the outputDelimiter.\n * @returns A string with format instructions.\n */\n getFormatInstructions(): string {\n return `${[\n `Return the following ${this.parsers.length} outputs, each formatted as described below. Include the delimiter characters \"${this.outputDelimiter}\" in your response:`,\n ...this.parsers.map(\n (p, i) =>\n `${this.outputDelimiter}Output ${i + 1}${this.outputDelimiter}\\n${p\n .getFormatInstructions()\n .trim()}\\n${this.outputDelimiter}`\n ),\n ].join(\"\\n\\n\")}\\n`;\n }\n}\n"],"mappings":";;;;;;;;AAoBA,IAAa,wBAAb,cAA2CA,iDAAyB;CAClE,OAAO,UAAU;AACf,SAAO;CACR;CAED,eAAe;EAAC;EAAa;EAAkB;CAAY;CAE3D,kBAAkB;CAElB;CAEA,kBAAkB;CAMlB,YACEC,QACA,GAAG,SACH;AACA,MAAI,QAAQ,SAAS,KAAK,EAAE,aAAa,SAEvC,SAAS,EACP,SAAS,CAAC,QAA4B,GAAG,OAAQ,EAClD;EAEH,MAAM,OAAO;EACb,KAAK,UAAU,OAAO;CACvB;;;;;;;;CASD,MAAM,MAAMC,OAAeC,WAAgD;EACzE,MAAM,SAAS,MACZ,MAAM,CACN,sBACC,IAAI,OAAO,GAAG,KAAK,gBAAgB,WAAW,EAAE,KAAK,iBAAiB,EACvE,CACA,MAAM,EAAE;EACX,MAAMC,MAAsB,CAAE;AAC9B,OAAK,MAAM,CAAC,GAAG,EAAE,IAAI,KAAK,QAAQ,SAAS,EAAE;GAC3C,IAAI;AACJ,OAAI;IACF,IAAI,YAAY,OAAO,GAAG,SAAS,MAAM,GACrC,OAAO,GAAG,MAAM,CAAC,MAAM,MAAM,CAAC,KAC9B,OAAO,GAAG,MAAM;AACpB,QAAI,UAAU,SAAS,KAAK,gBAAgB,EAC1C,YAAY,UAAU,MAAM,GAAG,CAAC,KAAK,gBAAgB,OAAO;IAE9D,SAAS,MAAM,EAAE,MAAM,WAAW,UAAU;GAC7C,QAAO;IACN,SAAS,MAAM,EAAE,MAAM,MAAM,MAAM,EAAE,UAAU;GAChD;GACD,OAAO,OAAO,KAAK,OAAO;EAC3B;AACD,SAAO;CACR;;;;;;CAOD,wBAAgC;AAC9B,SAAO,GAAG,CACR,CAAC,qBAAqB,EAAE,KAAK,QAAQ,OAAO,+EAA+E,EAAE,KAAK,gBAAgB,mBAAmB,CAAC,EACtK,GAAG,KAAK,QAAQ,IACd,CAAC,GAAG,MACF,GAAG,KAAK,gBAAgB,OAAO,EAAE,IAAI,IAAI,KAAK,gBAAgB,EAAE,EAAE,EAC/D,uBAAuB,CACvB,MAAM,CAAC,EAAE,EAAE,KAAK,iBAAiB,CACvC,AACF,EAAC,KAAK,OAAO,CAAC,EAAE,CAAC;CACnB;AACF"}
|
|
@@ -38,7 +38,7 @@ var CombiningOutputParser = class extends BaseOutputParser {
|
|
|
38
38
|
let extracted = inputs[i].includes("```") ? inputs[i].trim().split(/```/)[1] : inputs[i].trim();
|
|
39
39
|
if (extracted.endsWith(this.outputDelimiter)) extracted = extracted.slice(0, -this.outputDelimiter.length);
|
|
40
40
|
parsed = await p.parse(extracted, callbacks);
|
|
41
|
-
} catch
|
|
41
|
+
} catch {
|
|
42
42
|
parsed = await p.parse(input.trim(), callbacks);
|
|
43
43
|
}
|
|
44
44
|
Object.assign(ret, parsed);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combining.js","names":["fields: BaseOutputParser | CombiningOutputParserFields","input: string","callbacks?: Callbacks","ret: CombinedOutput"],"sources":["../../src/output_parsers/combining.ts"],"sourcesContent":["import { Callbacks } from \"@langchain/core/callbacks/manager\";\nimport { BaseOutputParser } from \"@langchain/core/output_parsers\";\n\n/**\n * Type for the combined output of the CombiningOutputParser class.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type CombinedOutput = Record<string, any>;\n\n/**\n * Interface for the fields required by the CombiningOutputParser class.\n */\nexport interface CombiningOutputParserFields {\n parsers: BaseOutputParser[];\n}\n\n/**\n * Class to combine multiple output parsers\n * @augments BaseOutputParser\n */\nexport class CombiningOutputParser extends BaseOutputParser<object> {\n static lc_name() {\n return \"CombiningOutputParser\";\n }\n\n lc_namespace = [\"langchain\", \"output_parsers\", \"combining\"];\n\n lc_serializable = true;\n\n parsers: BaseOutputParser[];\n\n outputDelimiter = \"-----\";\n\n constructor(fields: CombiningOutputParserFields);\n\n constructor(...parsers: BaseOutputParser[]);\n\n constructor(\n fields: BaseOutputParser | CombiningOutputParserFields,\n ...parsers: BaseOutputParser[]\n ) {\n if (parsers.length > 0 || !(\"parsers\" in fields)) {\n // eslint-disable-next-line no-param-reassign\n fields = {\n parsers: [fields as BaseOutputParser, ...parsers],\n };\n }\n super(fields);\n this.parsers = fields.parsers;\n }\n\n /**\n * Method to parse an input string using the parsers in the parsers array.\n * The parsed outputs are combined into a single object and returned.\n * @param input The input string to parse.\n * @param callbacks Optional Callbacks object.\n * @returns A Promise that resolves to a CombinedOutput object.\n */\n async parse(input: string, callbacks?: Callbacks): Promise<CombinedOutput> {\n const inputs = input\n .trim()\n .split(\n new RegExp(`${this.outputDelimiter}Output \\\\d+${this.outputDelimiter}`)\n )\n .slice(1);\n const ret: CombinedOutput = {};\n for (const [i, p] of this.parsers.entries()) {\n let parsed;\n try {\n let extracted = inputs[i].includes(\"```\")\n ? inputs[i].trim().split(/```/)[1]\n : inputs[i].trim();\n if (extracted.endsWith(this.outputDelimiter)) {\n extracted = extracted.slice(0, -this.outputDelimiter.length);\n }\n parsed = await p.parse(extracted, callbacks);\n } catch
|
|
1
|
+
{"version":3,"file":"combining.js","names":["fields: BaseOutputParser | CombiningOutputParserFields","input: string","callbacks?: Callbacks","ret: CombinedOutput"],"sources":["../../src/output_parsers/combining.ts"],"sourcesContent":["import { Callbacks } from \"@langchain/core/callbacks/manager\";\nimport { BaseOutputParser } from \"@langchain/core/output_parsers\";\n\n/**\n * Type for the combined output of the CombiningOutputParser class.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type CombinedOutput = Record<string, any>;\n\n/**\n * Interface for the fields required by the CombiningOutputParser class.\n */\nexport interface CombiningOutputParserFields {\n parsers: BaseOutputParser[];\n}\n\n/**\n * Class to combine multiple output parsers\n * @augments BaseOutputParser\n */\nexport class CombiningOutputParser extends BaseOutputParser<object> {\n static lc_name() {\n return \"CombiningOutputParser\";\n }\n\n lc_namespace = [\"langchain\", \"output_parsers\", \"combining\"];\n\n lc_serializable = true;\n\n parsers: BaseOutputParser[];\n\n outputDelimiter = \"-----\";\n\n constructor(fields: CombiningOutputParserFields);\n\n constructor(...parsers: BaseOutputParser[]);\n\n constructor(\n fields: BaseOutputParser | CombiningOutputParserFields,\n ...parsers: BaseOutputParser[]\n ) {\n if (parsers.length > 0 || !(\"parsers\" in fields)) {\n // eslint-disable-next-line no-param-reassign\n fields = {\n parsers: [fields as BaseOutputParser, ...parsers],\n };\n }\n super(fields);\n this.parsers = fields.parsers;\n }\n\n /**\n * Method to parse an input string using the parsers in the parsers array.\n * The parsed outputs are combined into a single object and returned.\n * @param input The input string to parse.\n * @param callbacks Optional Callbacks object.\n * @returns A Promise that resolves to a CombinedOutput object.\n */\n async parse(input: string, callbacks?: Callbacks): Promise<CombinedOutput> {\n const inputs = input\n .trim()\n .split(\n new RegExp(`${this.outputDelimiter}Output \\\\d+${this.outputDelimiter}`)\n )\n .slice(1);\n const ret: CombinedOutput = {};\n for (const [i, p] of this.parsers.entries()) {\n let parsed;\n try {\n let extracted = inputs[i].includes(\"```\")\n ? inputs[i].trim().split(/```/)[1]\n : inputs[i].trim();\n if (extracted.endsWith(this.outputDelimiter)) {\n extracted = extracted.slice(0, -this.outputDelimiter.length);\n }\n parsed = await p.parse(extracted, callbacks);\n } catch {\n parsed = await p.parse(input.trim(), callbacks);\n }\n Object.assign(ret, parsed);\n }\n return ret;\n }\n\n /**\n * Method to get instructions on how to format the LLM output. The\n * instructions are based on the parsers array and the outputDelimiter.\n * @returns A string with format instructions.\n */\n getFormatInstructions(): string {\n return `${[\n `Return the following ${this.parsers.length} outputs, each formatted as described below. Include the delimiter characters \"${this.outputDelimiter}\" in your response:`,\n ...this.parsers.map(\n (p, i) =>\n `${this.outputDelimiter}Output ${i + 1}${this.outputDelimiter}\\n${p\n .getFormatInstructions()\n .trim()}\\n${this.outputDelimiter}`\n ),\n ].join(\"\\n\\n\")}\\n`;\n }\n}\n"],"mappings":";;;;;;;AAoBA,IAAa,wBAAb,cAA2C,iBAAyB;CAClE,OAAO,UAAU;AACf,SAAO;CACR;CAED,eAAe;EAAC;EAAa;EAAkB;CAAY;CAE3D,kBAAkB;CAElB;CAEA,kBAAkB;CAMlB,YACEA,QACA,GAAG,SACH;AACA,MAAI,QAAQ,SAAS,KAAK,EAAE,aAAa,SAEvC,SAAS,EACP,SAAS,CAAC,QAA4B,GAAG,OAAQ,EAClD;EAEH,MAAM,OAAO;EACb,KAAK,UAAU,OAAO;CACvB;;;;;;;;CASD,MAAM,MAAMC,OAAeC,WAAgD;EACzE,MAAM,SAAS,MACZ,MAAM,CACN,sBACC,IAAI,OAAO,GAAG,KAAK,gBAAgB,WAAW,EAAE,KAAK,iBAAiB,EACvE,CACA,MAAM,EAAE;EACX,MAAMC,MAAsB,CAAE;AAC9B,OAAK,MAAM,CAAC,GAAG,EAAE,IAAI,KAAK,QAAQ,SAAS,EAAE;GAC3C,IAAI;AACJ,OAAI;IACF,IAAI,YAAY,OAAO,GAAG,SAAS,MAAM,GACrC,OAAO,GAAG,MAAM,CAAC,MAAM,MAAM,CAAC,KAC9B,OAAO,GAAG,MAAM;AACpB,QAAI,UAAU,SAAS,KAAK,gBAAgB,EAC1C,YAAY,UAAU,MAAM,GAAG,CAAC,KAAK,gBAAgB,OAAO;IAE9D,SAAS,MAAM,EAAE,MAAM,WAAW,UAAU;GAC7C,QAAO;IACN,SAAS,MAAM,EAAE,MAAM,MAAM,MAAM,EAAE,UAAU;GAChD;GACD,OAAO,OAAO,KAAK,OAAO;EAC3B;AACD,SAAO;CACR;;;;;;CAOD,wBAAgC;AAC9B,SAAO,GAAG,CACR,CAAC,qBAAqB,EAAE,KAAK,QAAQ,OAAO,+EAA+E,EAAE,KAAK,gBAAgB,mBAAmB,CAAC,EACtK,GAAG,KAAK,QAAQ,IACd,CAAC,GAAG,MACF,GAAG,KAAK,gBAAgB,OAAO,EAAE,IAAI,IAAI,KAAK,gBAAgB,EAAE,EAAE,EAC/D,uBAAuB,CACvB,MAAM,CAAC,EAAE,EAAE,KAAK,iBAAiB,CACvC,AACF,EAAC,KAAK,OAAO,CAAC,EAAE,CAAC;CACnB;AACF"}
|
package/dist/output_parsers/expression_type_handlers/array_literal_expression_handler.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array_literal_expression_handler.cjs","names":["NodeHandler","node: ExpressionNode","ASTParser","node: ArrayExpression"],"sources":["../../../src/output_parsers/expression_type_handlers/array_literal_expression_handler.ts"],"sourcesContent":["import { NodeHandler, ASTParser } from \"./base.js\";\nimport { ArrayLiteralType } from \"./types.js\";\nimport type {\n ExpressionNode,\n ArrayExpression,\n} from \"../../types/expression-parser.js\";\n\n/**\n * Handles array expressions in the LangChain Expression Language (LCEL).\n * It extends the NodeHandler base class, providing functionality to\n * accept and handle array expressions.\n */\nexport class ArrayLiteralExpressionHandler extends NodeHandler {\n /**\n * Checks if the given node is an array expression. If it is, the method\n * returns the node; otherwise, it returns false.\n * @param node The ExpressionNode to check.\n * @returns A Promise that resolves to either the ArrayExpression node if the node is an array expression, or false otherwise.\n */\n async accepts(node: ExpressionNode): Promise<ArrayExpression | boolean> {\n if (ASTParser.isArrayExpression(node)) {\n return node;\n } else {\n return false;\n }\n }\n\n /**\n * Handles the given array expression node. If the handler doesn't have a\n * parent handler, it throws an error. Otherwise, it returns an object\n * representing the array literal.\n * @param node The ArrayExpression node to handle.\n * @returns A Promise that resolves to an object representing the array literal.\n */\n async handle(node: ArrayExpression): Promise<ArrayLiteralType> {\n if (!this.parentHandler) {\n throw new Error(\n \"ArrayLiteralExpressionHandler must have a parent handler\"\n );\n }\n return {\n type: \"array_literal\",\n values: await Promise.all(\n node.elements.map((innerNode) =>\n
|
|
1
|
+
{"version":3,"file":"array_literal_expression_handler.cjs","names":["NodeHandler","node: ExpressionNode","ASTParser","node: ArrayExpression"],"sources":["../../../src/output_parsers/expression_type_handlers/array_literal_expression_handler.ts"],"sourcesContent":["import { NodeHandler, ASTParser } from \"./base.js\";\nimport { ArrayLiteralType } from \"./types.js\";\nimport type {\n ExpressionNode,\n ArrayExpression,\n} from \"../../types/expression-parser.js\";\n\n/**\n * Handles array expressions in the LangChain Expression Language (LCEL).\n * It extends the NodeHandler base class, providing functionality to\n * accept and handle array expressions.\n */\nexport class ArrayLiteralExpressionHandler extends NodeHandler {\n /**\n * Checks if the given node is an array expression. If it is, the method\n * returns the node; otherwise, it returns false.\n * @param node The ExpressionNode to check.\n * @returns A Promise that resolves to either the ArrayExpression node if the node is an array expression, or false otherwise.\n */\n async accepts(node: ExpressionNode): Promise<ArrayExpression | boolean> {\n if (ASTParser.isArrayExpression(node)) {\n return node;\n } else {\n return false;\n }\n }\n\n /**\n * Handles the given array expression node. If the handler doesn't have a\n * parent handler, it throws an error. Otherwise, it returns an object\n * representing the array literal.\n * @param node The ArrayExpression node to handle.\n * @returns A Promise that resolves to an object representing the array literal.\n */\n async handle(node: ArrayExpression): Promise<ArrayLiteralType> {\n if (!this.parentHandler) {\n throw new Error(\n \"ArrayLiteralExpressionHandler must have a parent handler\"\n );\n }\n return {\n type: \"array_literal\",\n values: await Promise.all(\n node.elements.map((innerNode) =>\n this.parentHandler!.handle(innerNode as ExpressionNode)\n )\n ),\n };\n }\n}\n"],"mappings":";;;;;;;;AAYA,IAAa,gCAAb,cAAmDA,yBAAY;;;;;;;CAO7D,MAAM,QAAQC,MAA0D;AACtE,MAAIC,uBAAU,kBAAkB,KAAK,CACnC,QAAO;MAEP,QAAO;CAEV;;;;;;;;CASD,MAAM,OAAOC,MAAkD;AAC7D,MAAI,CAAC,KAAK,cACR,OAAM,IAAI,MACR;AAGJ,SAAO;GACL,MAAM;GACN,QAAQ,MAAM,QAAQ,IACpB,KAAK,SAAS,IAAI,CAAC,cACjB,KAAK,cAAe,OAAO,UAA4B,CACxD,CACF;EACF;CACF;AACF"}
|
package/dist/output_parsers/expression_type_handlers/array_literal_expression_handler.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array_literal_expression_handler.js","names":["node: ExpressionNode","node: ArrayExpression"],"sources":["../../../src/output_parsers/expression_type_handlers/array_literal_expression_handler.ts"],"sourcesContent":["import { NodeHandler, ASTParser } from \"./base.js\";\nimport { ArrayLiteralType } from \"./types.js\";\nimport type {\n ExpressionNode,\n ArrayExpression,\n} from \"../../types/expression-parser.js\";\n\n/**\n * Handles array expressions in the LangChain Expression Language (LCEL).\n * It extends the NodeHandler base class, providing functionality to\n * accept and handle array expressions.\n */\nexport class ArrayLiteralExpressionHandler extends NodeHandler {\n /**\n * Checks if the given node is an array expression. If it is, the method\n * returns the node; otherwise, it returns false.\n * @param node The ExpressionNode to check.\n * @returns A Promise that resolves to either the ArrayExpression node if the node is an array expression, or false otherwise.\n */\n async accepts(node: ExpressionNode): Promise<ArrayExpression | boolean> {\n if (ASTParser.isArrayExpression(node)) {\n return node;\n } else {\n return false;\n }\n }\n\n /**\n * Handles the given array expression node. If the handler doesn't have a\n * parent handler, it throws an error. Otherwise, it returns an object\n * representing the array literal.\n * @param node The ArrayExpression node to handle.\n * @returns A Promise that resolves to an object representing the array literal.\n */\n async handle(node: ArrayExpression): Promise<ArrayLiteralType> {\n if (!this.parentHandler) {\n throw new Error(\n \"ArrayLiteralExpressionHandler must have a parent handler\"\n );\n }\n return {\n type: \"array_literal\",\n values: await Promise.all(\n node.elements.map((innerNode) =>\n
|
|
1
|
+
{"version":3,"file":"array_literal_expression_handler.js","names":["node: ExpressionNode","node: ArrayExpression"],"sources":["../../../src/output_parsers/expression_type_handlers/array_literal_expression_handler.ts"],"sourcesContent":["import { NodeHandler, ASTParser } from \"./base.js\";\nimport { ArrayLiteralType } from \"./types.js\";\nimport type {\n ExpressionNode,\n ArrayExpression,\n} from \"../../types/expression-parser.js\";\n\n/**\n * Handles array expressions in the LangChain Expression Language (LCEL).\n * It extends the NodeHandler base class, providing functionality to\n * accept and handle array expressions.\n */\nexport class ArrayLiteralExpressionHandler extends NodeHandler {\n /**\n * Checks if the given node is an array expression. If it is, the method\n * returns the node; otherwise, it returns false.\n * @param node The ExpressionNode to check.\n * @returns A Promise that resolves to either the ArrayExpression node if the node is an array expression, or false otherwise.\n */\n async accepts(node: ExpressionNode): Promise<ArrayExpression | boolean> {\n if (ASTParser.isArrayExpression(node)) {\n return node;\n } else {\n return false;\n }\n }\n\n /**\n * Handles the given array expression node. If the handler doesn't have a\n * parent handler, it throws an error. Otherwise, it returns an object\n * representing the array literal.\n * @param node The ArrayExpression node to handle.\n * @returns A Promise that resolves to an object representing the array literal.\n */\n async handle(node: ArrayExpression): Promise<ArrayLiteralType> {\n if (!this.parentHandler) {\n throw new Error(\n \"ArrayLiteralExpressionHandler must have a parent handler\"\n );\n }\n return {\n type: \"array_literal\",\n values: await Promise.all(\n node.elements.map((innerNode) =>\n this.parentHandler!.handle(innerNode as ExpressionNode)\n )\n ),\n };\n }\n}\n"],"mappings":";;;;;;;;AAYA,IAAa,gCAAb,cAAmD,YAAY;;;;;;;CAO7D,MAAM,QAAQA,MAA0D;AACtE,MAAI,UAAU,kBAAkB,KAAK,CACnC,QAAO;MAEP,QAAO;CAEV;;;;;;;;CASD,MAAM,OAAOC,MAAkD;AAC7D,MAAI,CAAC,KAAK,cACR,OAAM,IAAI,MACR;AAGJ,SAAO;GACL,MAAM;GACN,QAAQ,MAAM,QAAQ,IACpB,KAAK,SAAS,IAAI,CAAC,cACjB,KAAK,cAAe,OAAO,UAA4B,CACxD,CACF;EACF;CACF;AACF"}
|
|
@@ -30,7 +30,7 @@ var ASTParser = class ASTParser {
|
|
|
30
30
|
ASTParser.astParseInstance = parse;
|
|
31
31
|
}
|
|
32
32
|
return ASTParser.astParseInstance;
|
|
33
|
-
} catch
|
|
33
|
+
} catch {
|
|
34
34
|
throw new Error(`Failed to import peggy. Please install peggy (i.e. "npm install peggy" or "pnpm install peggy").`);
|
|
35
35
|
}
|
|
36
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.cjs","names":["parentHandler?: NodeHandler","GRAMMAR","node: ExpressionNode"],"sources":["../../../src/output_parsers/expression_type_handlers/base.ts"],"sourcesContent":["import { GRAMMAR } from \"./grammar/parser_grammar.js\";\nimport type {\n ExpressionNode,\n Program,\n ExpressionStatement,\n CallExpression,\n StringLiteral,\n NumericLiteral,\n BooleanLiteral,\n Identifier,\n ObjectExpression,\n ArrayExpression,\n PropertyAssignment,\n MemberExpression,\n ParseFunction,\n} from \"../../types/expression-parser.js\";\n\n/**\n * Abstract class for handling nodes in an expression language. Subclasses\n * must implement the `accepts` and `handle` methods.\n */\nexport abstract class NodeHandler {\n constructor(protected parentHandler?: NodeHandler) {}\n\n /**\n * Determines whether the given node is acceptable.\n * @param node The node to be checked.\n * @returns A Promise that resolves to either the node itself or a boolean indicating whether the node is acceptable.\n */\n abstract accepts(node: ExpressionNode): Promise<ExpressionNode | boolean>;\n\n /**\n * Handles the given node. The specifics of how the node is handled are\n * determined by the subclass implementation.\n * @param node The node to be handled.\n * @returns A Promise that resolves to the result of handling the node.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n abstract handle(node: ExpressionNode): Promise<any>;\n}\n\n/**\n * Utility class for parsing Abstract Syntax Trees (ASTs). Contains\n * methods for identifying the type of a given node and a method for\n * importing and generating a parser using the Peggy library.\n */\nexport class ASTParser {\n static astParseInstance: ParseFunction;\n\n /**\n * Imports and generates a parser using the Peggy library.\n * @returns A Promise that resolves to the parser instance.\n */\n static async importASTParser() {\n try {\n if (!ASTParser.astParseInstance) {\n const { default: peggy } = await import(\"peggy\");\n const parser = peggy.generate(GRAMMAR);\n const { parse } = parser;\n ASTParser.astParseInstance = parse as ParseFunction;\n }\n return ASTParser.astParseInstance;\n } catch
|
|
1
|
+
{"version":3,"file":"base.cjs","names":["parentHandler?: NodeHandler","GRAMMAR","node: ExpressionNode"],"sources":["../../../src/output_parsers/expression_type_handlers/base.ts"],"sourcesContent":["import { GRAMMAR } from \"./grammar/parser_grammar.js\";\nimport type {\n ExpressionNode,\n Program,\n ExpressionStatement,\n CallExpression,\n StringLiteral,\n NumericLiteral,\n BooleanLiteral,\n Identifier,\n ObjectExpression,\n ArrayExpression,\n PropertyAssignment,\n MemberExpression,\n ParseFunction,\n} from \"../../types/expression-parser.js\";\n\n/**\n * Abstract class for handling nodes in an expression language. Subclasses\n * must implement the `accepts` and `handle` methods.\n */\nexport abstract class NodeHandler {\n constructor(protected parentHandler?: NodeHandler) {}\n\n /**\n * Determines whether the given node is acceptable.\n * @param node The node to be checked.\n * @returns A Promise that resolves to either the node itself or a boolean indicating whether the node is acceptable.\n */\n abstract accepts(node: ExpressionNode): Promise<ExpressionNode | boolean>;\n\n /**\n * Handles the given node. The specifics of how the node is handled are\n * determined by the subclass implementation.\n * @param node The node to be handled.\n * @returns A Promise that resolves to the result of handling the node.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n abstract handle(node: ExpressionNode): Promise<any>;\n}\n\n/**\n * Utility class for parsing Abstract Syntax Trees (ASTs). Contains\n * methods for identifying the type of a given node and a method for\n * importing and generating a parser using the Peggy library.\n */\nexport class ASTParser {\n static astParseInstance: ParseFunction;\n\n /**\n * Imports and generates a parser using the Peggy library.\n * @returns A Promise that resolves to the parser instance.\n */\n static async importASTParser() {\n try {\n if (!ASTParser.astParseInstance) {\n const { default: peggy } = await import(\"peggy\");\n const parser = peggy.generate(GRAMMAR);\n const { parse } = parser;\n ASTParser.astParseInstance = parse as ParseFunction;\n }\n return ASTParser.astParseInstance;\n } catch {\n throw new Error(\n `Failed to import peggy. Please install peggy (i.e. \"npm install peggy\" or \"pnpm install peggy\").`\n );\n }\n }\n\n /**\n * Checks if the given node is a Program node.\n * @param node The node to be checked.\n * @returns A boolean indicating whether the node is a Program node.\n */\n static isProgram(node: ExpressionNode): node is Program {\n return node.type === \"Program\";\n }\n\n /**\n * Checks if the given node is an ExpressionStatement node.\n * @param node The node to be checked.\n * @returns A boolean indicating whether the node is an ExpressionStatement node.\n */\n static isExpressionStatement(\n node: ExpressionNode\n ): node is ExpressionStatement {\n return node.type === \"ExpressionStatement\";\n }\n\n /**\n * Checks if the given node is a CallExpression node.\n * @param node The node to be checked.\n * @returns A boolean indicating whether the node is a CallExpression node.\n */\n static isCallExpression(node: ExpressionNode): node is CallExpression {\n return node.type === \"CallExpression\";\n }\n\n /**\n * Checks if the given node is a StringLiteral node.\n * @param node The node to be checked.\n * @returns A boolean indicating whether the node is a StringLiteral node.\n */\n static isStringLiteral(node: ExpressionNode): node is StringLiteral {\n return node.type === \"StringLiteral\" && typeof node.value === \"string\";\n }\n\n /**\n * Checks if the given node is a NumericLiteral node.\n * @param node The node to be checked.\n * @returns A boolean indicating whether the node is a NumericLiteral node.\n */\n static isNumericLiteral(node: ExpressionNode): node is NumericLiteral {\n return node.type === \"NumericLiteral\" && typeof node.value === \"number\";\n }\n\n /**\n * Checks if the given node is a BooleanLiteral node.\n * @param node The node to be checked.\n * @returns A boolean indicating whether the node is a BooleanLiteral node.\n */\n static isBooleanLiteral(node: ExpressionNode): node is BooleanLiteral {\n return node.type === \"BooleanLiteral\" && typeof node.value === \"boolean\";\n }\n\n /**\n * Checks if the given node is an Identifier node.\n * @param node The node to be checked.\n * @returns A boolean indicating whether the node is an Identifier node.\n */\n static isIdentifier(node: ExpressionNode): node is Identifier {\n return node.type === \"Identifier\";\n }\n\n /**\n * Checks if the given node is an ObjectExpression node.\n * @param node The node to be checked.\n * @returns A boolean indicating whether the node is an ObjectExpression node.\n */\n static isObjectExpression(node: ExpressionNode): node is ObjectExpression {\n return node.type === \"ObjectExpression\";\n }\n\n /**\n * Checks if the given node is an ArrayExpression node.\n * @param node The node to be checked.\n * @returns A boolean indicating whether the node is an ArrayExpression node.\n */\n static isArrayExpression(node: ExpressionNode): node is ArrayExpression {\n return node.type === \"ArrayExpression\";\n }\n\n /**\n * Checks if the given node is a PropertyAssignment node.\n * @param node The node to be checked.\n * @returns A boolean indicating whether the node is a PropertyAssignment node.\n */\n static isPropertyAssignment(\n node: ExpressionNode\n ): node is PropertyAssignment {\n return node.type === \"PropertyAssignment\";\n }\n\n /**\n * Checks if the given node is a MemberExpression node.\n * @param node The node to be checked.\n * @returns A boolean indicating whether the node is a MemberExpression node.\n */\n static isMemberExpression(node: ExpressionNode): node is MemberExpression {\n return node.type === \"MemberExpression\";\n }\n}\n"],"mappings":";;;;;;;AAqBA,IAAsB,cAAtB,MAAkC;CAChC,YAAsBA,eAA6B;EAA7B;CAA+B;AAiBtD;;;;;;AAOD,IAAa,YAAb,MAAa,UAAU;CACrB,OAAO;;;;;CAMP,aAAa,kBAAkB;AAC7B,MAAI;AACF,OAAI,CAAC,UAAU,kBAAkB;IAC/B,MAAM,EAAE,SAAS,OAAO,GAAG,MAAM,OAAO;IACxC,MAAM,SAAS,MAAM,SAASC,+BAAQ;IACtC,MAAM,EAAE,OAAO,GAAG;IAClB,UAAU,mBAAmB;GAC9B;AACD,UAAO,UAAU;EAClB,QAAO;AACN,SAAM,IAAI,MACR,CAAC,gGAAgG,CAAC;EAErG;CACF;;;;;;CAOD,OAAO,UAAUC,MAAuC;AACtD,SAAO,KAAK,SAAS;CACtB;;;;;;CAOD,OAAO,sBACLA,MAC6B;AAC7B,SAAO,KAAK,SAAS;CACtB;;;;;;CAOD,OAAO,iBAAiBA,MAA8C;AACpE,SAAO,KAAK,SAAS;CACtB;;;;;;CAOD,OAAO,gBAAgBA,MAA6C;AAClE,SAAO,KAAK,SAAS,mBAAmB,OAAO,KAAK,UAAU;CAC/D;;;;;;CAOD,OAAO,iBAAiBA,MAA8C;AACpE,SAAO,KAAK,SAAS,oBAAoB,OAAO,KAAK,UAAU;CAChE;;;;;;CAOD,OAAO,iBAAiBA,MAA8C;AACpE,SAAO,KAAK,SAAS,oBAAoB,OAAO,KAAK,UAAU;CAChE;;;;;;CAOD,OAAO,aAAaA,MAA0C;AAC5D,SAAO,KAAK,SAAS;CACtB;;;;;;CAOD,OAAO,mBAAmBA,MAAgD;AACxE,SAAO,KAAK,SAAS;CACtB;;;;;;CAOD,OAAO,kBAAkBA,MAA+C;AACtE,SAAO,KAAK,SAAS;CACtB;;;;;;CAOD,OAAO,qBACLA,MAC4B;AAC5B,SAAO,KAAK,SAAS;CACtB;;;;;;CAOD,OAAO,mBAAmBA,MAAgD;AACxE,SAAO,KAAK,SAAS;CACtB;AACF"}
|
|
@@ -30,7 +30,7 @@ var ASTParser = class ASTParser {
|
|
|
30
30
|
ASTParser.astParseInstance = parse;
|
|
31
31
|
}
|
|
32
32
|
return ASTParser.astParseInstance;
|
|
33
|
-
} catch
|
|
33
|
+
} catch {
|
|
34
34
|
throw new Error(`Failed to import peggy. Please install peggy (i.e. "npm install peggy" or "pnpm install peggy").`);
|
|
35
35
|
}
|
|
36
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","names":["parentHandler?: NodeHandler","node: ExpressionNode"],"sources":["../../../src/output_parsers/expression_type_handlers/base.ts"],"sourcesContent":["import { GRAMMAR } from \"./grammar/parser_grammar.js\";\nimport type {\n ExpressionNode,\n Program,\n ExpressionStatement,\n CallExpression,\n StringLiteral,\n NumericLiteral,\n BooleanLiteral,\n Identifier,\n ObjectExpression,\n ArrayExpression,\n PropertyAssignment,\n MemberExpression,\n ParseFunction,\n} from \"../../types/expression-parser.js\";\n\n/**\n * Abstract class for handling nodes in an expression language. Subclasses\n * must implement the `accepts` and `handle` methods.\n */\nexport abstract class NodeHandler {\n constructor(protected parentHandler?: NodeHandler) {}\n\n /**\n * Determines whether the given node is acceptable.\n * @param node The node to be checked.\n * @returns A Promise that resolves to either the node itself or a boolean indicating whether the node is acceptable.\n */\n abstract accepts(node: ExpressionNode): Promise<ExpressionNode | boolean>;\n\n /**\n * Handles the given node. The specifics of how the node is handled are\n * determined by the subclass implementation.\n * @param node The node to be handled.\n * @returns A Promise that resolves to the result of handling the node.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n abstract handle(node: ExpressionNode): Promise<any>;\n}\n\n/**\n * Utility class for parsing Abstract Syntax Trees (ASTs). Contains\n * methods for identifying the type of a given node and a method for\n * importing and generating a parser using the Peggy library.\n */\nexport class ASTParser {\n static astParseInstance: ParseFunction;\n\n /**\n * Imports and generates a parser using the Peggy library.\n * @returns A Promise that resolves to the parser instance.\n */\n static async importASTParser() {\n try {\n if (!ASTParser.astParseInstance) {\n const { default: peggy } = await import(\"peggy\");\n const parser = peggy.generate(GRAMMAR);\n const { parse } = parser;\n ASTParser.astParseInstance = parse as ParseFunction;\n }\n return ASTParser.astParseInstance;\n } catch
|
|
1
|
+
{"version":3,"file":"base.js","names":["parentHandler?: NodeHandler","node: ExpressionNode"],"sources":["../../../src/output_parsers/expression_type_handlers/base.ts"],"sourcesContent":["import { GRAMMAR } from \"./grammar/parser_grammar.js\";\nimport type {\n ExpressionNode,\n Program,\n ExpressionStatement,\n CallExpression,\n StringLiteral,\n NumericLiteral,\n BooleanLiteral,\n Identifier,\n ObjectExpression,\n ArrayExpression,\n PropertyAssignment,\n MemberExpression,\n ParseFunction,\n} from \"../../types/expression-parser.js\";\n\n/**\n * Abstract class for handling nodes in an expression language. Subclasses\n * must implement the `accepts` and `handle` methods.\n */\nexport abstract class NodeHandler {\n constructor(protected parentHandler?: NodeHandler) {}\n\n /**\n * Determines whether the given node is acceptable.\n * @param node The node to be checked.\n * @returns A Promise that resolves to either the node itself or a boolean indicating whether the node is acceptable.\n */\n abstract accepts(node: ExpressionNode): Promise<ExpressionNode | boolean>;\n\n /**\n * Handles the given node. The specifics of how the node is handled are\n * determined by the subclass implementation.\n * @param node The node to be handled.\n * @returns A Promise that resolves to the result of handling the node.\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n abstract handle(node: ExpressionNode): Promise<any>;\n}\n\n/**\n * Utility class for parsing Abstract Syntax Trees (ASTs). Contains\n * methods for identifying the type of a given node and a method for\n * importing and generating a parser using the Peggy library.\n */\nexport class ASTParser {\n static astParseInstance: ParseFunction;\n\n /**\n * Imports and generates a parser using the Peggy library.\n * @returns A Promise that resolves to the parser instance.\n */\n static async importASTParser() {\n try {\n if (!ASTParser.astParseInstance) {\n const { default: peggy } = await import(\"peggy\");\n const parser = peggy.generate(GRAMMAR);\n const { parse } = parser;\n ASTParser.astParseInstance = parse as ParseFunction;\n }\n return ASTParser.astParseInstance;\n } catch {\n throw new Error(\n `Failed to import peggy. Please install peggy (i.e. \"npm install peggy\" or \"pnpm install peggy\").`\n );\n }\n }\n\n /**\n * Checks if the given node is a Program node.\n * @param node The node to be checked.\n * @returns A boolean indicating whether the node is a Program node.\n */\n static isProgram(node: ExpressionNode): node is Program {\n return node.type === \"Program\";\n }\n\n /**\n * Checks if the given node is an ExpressionStatement node.\n * @param node The node to be checked.\n * @returns A boolean indicating whether the node is an ExpressionStatement node.\n */\n static isExpressionStatement(\n node: ExpressionNode\n ): node is ExpressionStatement {\n return node.type === \"ExpressionStatement\";\n }\n\n /**\n * Checks if the given node is a CallExpression node.\n * @param node The node to be checked.\n * @returns A boolean indicating whether the node is a CallExpression node.\n */\n static isCallExpression(node: ExpressionNode): node is CallExpression {\n return node.type === \"CallExpression\";\n }\n\n /**\n * Checks if the given node is a StringLiteral node.\n * @param node The node to be checked.\n * @returns A boolean indicating whether the node is a StringLiteral node.\n */\n static isStringLiteral(node: ExpressionNode): node is StringLiteral {\n return node.type === \"StringLiteral\" && typeof node.value === \"string\";\n }\n\n /**\n * Checks if the given node is a NumericLiteral node.\n * @param node The node to be checked.\n * @returns A boolean indicating whether the node is a NumericLiteral node.\n */\n static isNumericLiteral(node: ExpressionNode): node is NumericLiteral {\n return node.type === \"NumericLiteral\" && typeof node.value === \"number\";\n }\n\n /**\n * Checks if the given node is a BooleanLiteral node.\n * @param node The node to be checked.\n * @returns A boolean indicating whether the node is a BooleanLiteral node.\n */\n static isBooleanLiteral(node: ExpressionNode): node is BooleanLiteral {\n return node.type === \"BooleanLiteral\" && typeof node.value === \"boolean\";\n }\n\n /**\n * Checks if the given node is an Identifier node.\n * @param node The node to be checked.\n * @returns A boolean indicating whether the node is an Identifier node.\n */\n static isIdentifier(node: ExpressionNode): node is Identifier {\n return node.type === \"Identifier\";\n }\n\n /**\n * Checks if the given node is an ObjectExpression node.\n * @param node The node to be checked.\n * @returns A boolean indicating whether the node is an ObjectExpression node.\n */\n static isObjectExpression(node: ExpressionNode): node is ObjectExpression {\n return node.type === \"ObjectExpression\";\n }\n\n /**\n * Checks if the given node is an ArrayExpression node.\n * @param node The node to be checked.\n * @returns A boolean indicating whether the node is an ArrayExpression node.\n */\n static isArrayExpression(node: ExpressionNode): node is ArrayExpression {\n return node.type === \"ArrayExpression\";\n }\n\n /**\n * Checks if the given node is a PropertyAssignment node.\n * @param node The node to be checked.\n * @returns A boolean indicating whether the node is a PropertyAssignment node.\n */\n static isPropertyAssignment(\n node: ExpressionNode\n ): node is PropertyAssignment {\n return node.type === \"PropertyAssignment\";\n }\n\n /**\n * Checks if the given node is a MemberExpression node.\n * @param node The node to be checked.\n * @returns A boolean indicating whether the node is a MemberExpression node.\n */\n static isMemberExpression(node: ExpressionNode): node is MemberExpression {\n return node.type === \"MemberExpression\";\n }\n}\n"],"mappings":";;;;;;;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
|
|
|
1
|
-
{"version":3,"file":"regex.cjs","names":["BaseOutputParser","fields: string | RegExp | RegexParserFields","outputKeys?: string[]","defaultOutputKey?: string","text: string","OutputParserException"],"sources":["../../src/output_parsers/regex.ts"],"sourcesContent":["import {\n BaseOutputParser,\n OutputParserException,\n} from \"@langchain/core/output_parsers\";\nimport type { SerializedFields } from \"../load/map_keys.js\";\n\nexport interface RegExpFields {\n pattern: string;\n flags?: string;\n}\n\n/**\n * Interface for the fields required to create a RegexParser instance.\n */\nexport interface RegexParserFields {\n regex: string | RegExp | RegExpFields;\n outputKeys: string[];\n defaultOutputKey?: string;\n}\n\n/**\n * Class to parse the output of an LLM call into a dictionary.\n * @augments BaseOutputParser\n */\nexport class RegexParser extends BaseOutputParser<Record<string, string>> {\n static lc_name() {\n return \"RegexParser\";\n }\n\n lc_namespace = [\"langchain\", \"output_parsers\", \"regex\"];\n\n lc_serializable = true;\n\n get lc_attributes(): SerializedFields | undefined {\n return {\n regex: this.lc_kwargs.regex,\n };\n }\n\n regex: string | RegExp;\n\n outputKeys: string[];\n\n defaultOutputKey?: string;\n\n constructor(fields: RegexParserFields);\n\n constructor(\n regex: string | RegExp,\n outputKeys: string[],\n defaultOutputKey?: string\n );\n\n constructor(\n fields: string | RegExp | RegexParserFields,\n outputKeys?: string[],\n defaultOutputKey?: string\n ) {\n // eslint-disable-next-line no-instanceof/no-instanceof\n if (typeof fields === \"string\" || fields instanceof RegExp) {\n // eslint-disable-next-line no-param-reassign
|
|
1
|
+
{"version":3,"file":"regex.cjs","names":["BaseOutputParser","fields: string | RegExp | RegexParserFields","outputKeys?: string[]","defaultOutputKey?: string","text: string","OutputParserException"],"sources":["../../src/output_parsers/regex.ts"],"sourcesContent":["import {\n BaseOutputParser,\n OutputParserException,\n} from \"@langchain/core/output_parsers\";\nimport type { SerializedFields } from \"../load/map_keys.js\";\n\nexport interface RegExpFields {\n pattern: string;\n flags?: string;\n}\n\n/**\n * Interface for the fields required to create a RegexParser instance.\n */\nexport interface RegexParserFields {\n regex: string | RegExp | RegExpFields;\n outputKeys: string[];\n defaultOutputKey?: string;\n}\n\n/**\n * Class to parse the output of an LLM call into a dictionary.\n * @augments BaseOutputParser\n */\nexport class RegexParser extends BaseOutputParser<Record<string, string>> {\n static lc_name() {\n return \"RegexParser\";\n }\n\n lc_namespace = [\"langchain\", \"output_parsers\", \"regex\"];\n\n lc_serializable = true;\n\n get lc_attributes(): SerializedFields | undefined {\n return {\n regex: this.lc_kwargs.regex,\n };\n }\n\n regex: string | RegExp;\n\n outputKeys: string[];\n\n defaultOutputKey?: string;\n\n constructor(fields: RegexParserFields);\n\n constructor(\n regex: string | RegExp,\n outputKeys: string[],\n defaultOutputKey?: string\n );\n\n constructor(\n fields: string | RegExp | RegexParserFields,\n outputKeys?: string[],\n defaultOutputKey?: string\n ) {\n // eslint-disable-next-line no-instanceof/no-instanceof\n if (typeof fields === \"string\" || fields instanceof RegExp) {\n // eslint-disable-next-line no-param-reassign\n fields = { regex: fields, outputKeys: outputKeys!, defaultOutputKey };\n }\n // eslint-disable-next-line no-instanceof/no-instanceof\n if (fields.regex instanceof RegExp) {\n fields.regex = {\n pattern: fields.regex.source,\n flags: fields.regex.flags,\n };\n }\n super(fields);\n this.regex =\n typeof fields.regex === \"string\"\n ? new RegExp(fields.regex)\n : \"pattern\" in fields.regex\n ? new RegExp(fields.regex.pattern, fields.regex.flags)\n : fields.regex;\n this.outputKeys = fields.outputKeys;\n this.defaultOutputKey = fields.defaultOutputKey;\n }\n\n _type() {\n return \"regex_parser\";\n }\n\n /**\n * Parses the given text using the regex pattern and returns a dictionary\n * with the parsed output. If the regex pattern does not match the text\n * and no defaultOutputKey is provided, throws an OutputParserException.\n * @param text The text to be parsed.\n * @returns A dictionary with the parsed output.\n */\n async parse(text: string): Promise<Record<string, string>> {\n const match = text.match(this.regex);\n if (match) {\n return this.outputKeys.reduce((acc, key, index) => {\n acc[key] = match[index + 1];\n return acc;\n }, {} as Record<string, string>);\n }\n\n if (this.defaultOutputKey === undefined) {\n throw new OutputParserException(`Could not parse output: ${text}`, text);\n }\n\n return this.outputKeys.reduce((acc, key) => {\n acc[key] = key === this.defaultOutputKey ? text : \"\";\n return acc;\n }, {} as Record<string, string>);\n }\n\n /**\n * Returns a string with instructions on how the LLM output should be\n * formatted to match the regex pattern.\n * @returns A string with formatting instructions.\n */\n getFormatInstructions(): string {\n return `Your response should match the following regex: ${this.regex}`;\n }\n}\n"],"mappings":";;;;;;;;AAwBA,IAAa,cAAb,cAAiCA,iDAAyC;CACxE,OAAO,UAAU;AACf,SAAO;CACR;CAED,eAAe;EAAC;EAAa;EAAkB;CAAQ;CAEvD,kBAAkB;CAElB,IAAI,gBAA8C;AAChD,SAAO,EACL,OAAO,KAAK,UAAU,MACvB;CACF;CAED;CAEA;CAEA;CAUA,YACEC,QACAC,YACAC,kBACA;AAEA,MAAI,OAAO,WAAW,YAAY,kBAAkB,QAElD,SAAS;GAAE,OAAO;GAAoB;GAAa;EAAkB;AAGvE,MAAI,OAAO,iBAAiB,QAC1B,OAAO,QAAQ;GACb,SAAS,OAAO,MAAM;GACtB,OAAO,OAAO,MAAM;EACrB;EAEH,MAAM,OAAO;EACb,KAAK,QACH,OAAO,OAAO,UAAU,WACpB,IAAI,OAAO,OAAO,SAClB,aAAa,OAAO,QACpB,IAAI,OAAO,OAAO,MAAM,SAAS,OAAO,MAAM,SAC9C,OAAO;EACb,KAAK,aAAa,OAAO;EACzB,KAAK,mBAAmB,OAAO;CAChC;CAED,QAAQ;AACN,SAAO;CACR;;;;;;;;CASD,MAAM,MAAMC,MAA+C;EACzD,MAAM,QAAQ,KAAK,MAAM,KAAK,MAAM;AACpC,MAAI,MACF,QAAO,KAAK,WAAW,OAAO,CAAC,KAAK,KAAK,UAAU;GACjD,IAAI,OAAO,MAAM,QAAQ;AACzB,UAAO;EACR,GAAE,CAAE,EAA2B;AAGlC,MAAI,KAAK,qBAAqB,OAC5B,OAAM,IAAIC,sDAAsB,CAAC,wBAAwB,EAAE,MAAM,EAAE;AAGrE,SAAO,KAAK,WAAW,OAAO,CAAC,KAAK,QAAQ;GAC1C,IAAI,OAAO,QAAQ,KAAK,mBAAmB,OAAO;AAClD,UAAO;EACR,GAAE,CAAE,EAA2B;CACjC;;;;;;CAOD,wBAAgC;AAC9B,SAAO,CAAC,gDAAgD,EAAE,KAAK,OAAO;CACvE;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"regex.js","names":["fields: string | RegExp | RegexParserFields","outputKeys?: string[]","defaultOutputKey?: string","text: string"],"sources":["../../src/output_parsers/regex.ts"],"sourcesContent":["import {\n BaseOutputParser,\n OutputParserException,\n} from \"@langchain/core/output_parsers\";\nimport type { SerializedFields } from \"../load/map_keys.js\";\n\nexport interface RegExpFields {\n pattern: string;\n flags?: string;\n}\n\n/**\n * Interface for the fields required to create a RegexParser instance.\n */\nexport interface RegexParserFields {\n regex: string | RegExp | RegExpFields;\n outputKeys: string[];\n defaultOutputKey?: string;\n}\n\n/**\n * Class to parse the output of an LLM call into a dictionary.\n * @augments BaseOutputParser\n */\nexport class RegexParser extends BaseOutputParser<Record<string, string>> {\n static lc_name() {\n return \"RegexParser\";\n }\n\n lc_namespace = [\"langchain\", \"output_parsers\", \"regex\"];\n\n lc_serializable = true;\n\n get lc_attributes(): SerializedFields | undefined {\n return {\n regex: this.lc_kwargs.regex,\n };\n }\n\n regex: string | RegExp;\n\n outputKeys: string[];\n\n defaultOutputKey?: string;\n\n constructor(fields: RegexParserFields);\n\n constructor(\n regex: string | RegExp,\n outputKeys: string[],\n defaultOutputKey?: string\n );\n\n constructor(\n fields: string | RegExp | RegexParserFields,\n outputKeys?: string[],\n defaultOutputKey?: string\n ) {\n // eslint-disable-next-line no-instanceof/no-instanceof\n if (typeof fields === \"string\" || fields instanceof RegExp) {\n // eslint-disable-next-line no-param-reassign
|
|
1
|
+
{"version":3,"file":"regex.js","names":["fields: string | RegExp | RegexParserFields","outputKeys?: string[]","defaultOutputKey?: string","text: string"],"sources":["../../src/output_parsers/regex.ts"],"sourcesContent":["import {\n BaseOutputParser,\n OutputParserException,\n} from \"@langchain/core/output_parsers\";\nimport type { SerializedFields } from \"../load/map_keys.js\";\n\nexport interface RegExpFields {\n pattern: string;\n flags?: string;\n}\n\n/**\n * Interface for the fields required to create a RegexParser instance.\n */\nexport interface RegexParserFields {\n regex: string | RegExp | RegExpFields;\n outputKeys: string[];\n defaultOutputKey?: string;\n}\n\n/**\n * Class to parse the output of an LLM call into a dictionary.\n * @augments BaseOutputParser\n */\nexport class RegexParser extends BaseOutputParser<Record<string, string>> {\n static lc_name() {\n return \"RegexParser\";\n }\n\n lc_namespace = [\"langchain\", \"output_parsers\", \"regex\"];\n\n lc_serializable = true;\n\n get lc_attributes(): SerializedFields | undefined {\n return {\n regex: this.lc_kwargs.regex,\n };\n }\n\n regex: string | RegExp;\n\n outputKeys: string[];\n\n defaultOutputKey?: string;\n\n constructor(fields: RegexParserFields);\n\n constructor(\n regex: string | RegExp,\n outputKeys: string[],\n defaultOutputKey?: string\n );\n\n constructor(\n fields: string | RegExp | RegexParserFields,\n outputKeys?: string[],\n defaultOutputKey?: string\n ) {\n // eslint-disable-next-line no-instanceof/no-instanceof\n if (typeof fields === \"string\" || fields instanceof RegExp) {\n // eslint-disable-next-line no-param-reassign\n fields = { regex: fields, outputKeys: outputKeys!, defaultOutputKey };\n }\n // eslint-disable-next-line no-instanceof/no-instanceof\n if (fields.regex instanceof RegExp) {\n fields.regex = {\n pattern: fields.regex.source,\n flags: fields.regex.flags,\n };\n }\n super(fields);\n this.regex =\n typeof fields.regex === \"string\"\n ? new RegExp(fields.regex)\n : \"pattern\" in fields.regex\n ? new RegExp(fields.regex.pattern, fields.regex.flags)\n : fields.regex;\n this.outputKeys = fields.outputKeys;\n this.defaultOutputKey = fields.defaultOutputKey;\n }\n\n _type() {\n return \"regex_parser\";\n }\n\n /**\n * Parses the given text using the regex pattern and returns a dictionary\n * with the parsed output. If the regex pattern does not match the text\n * and no defaultOutputKey is provided, throws an OutputParserException.\n * @param text The text to be parsed.\n * @returns A dictionary with the parsed output.\n */\n async parse(text: string): Promise<Record<string, string>> {\n const match = text.match(this.regex);\n if (match) {\n return this.outputKeys.reduce((acc, key, index) => {\n acc[key] = match[index + 1];\n return acc;\n }, {} as Record<string, string>);\n }\n\n if (this.defaultOutputKey === undefined) {\n throw new OutputParserException(`Could not parse output: ${text}`, text);\n }\n\n return this.outputKeys.reduce((acc, key) => {\n acc[key] = key === this.defaultOutputKey ? text : \"\";\n return acc;\n }, {} as Record<string, string>);\n }\n\n /**\n * Returns a string with instructions on how the LLM output should be\n * formatted to match the regex pattern.\n * @returns A string with formatting instructions.\n */\n getFormatInstructions(): string {\n return `Your response should match the following regex: ${this.regex}`;\n }\n}\n"],"mappings":";;;;;;;AAwBA,IAAa,cAAb,cAAiC,iBAAyC;CACxE,OAAO,UAAU;AACf,SAAO;CACR;CAED,eAAe;EAAC;EAAa;EAAkB;CAAQ;CAEvD,kBAAkB;CAElB,IAAI,gBAA8C;AAChD,SAAO,EACL,OAAO,KAAK,UAAU,MACvB;CACF;CAED;CAEA;CAEA;CAUA,YACEA,QACAC,YACAC,kBACA;AAEA,MAAI,OAAO,WAAW,YAAY,kBAAkB,QAElD,SAAS;GAAE,OAAO;GAAoB;GAAa;EAAkB;AAGvE,MAAI,OAAO,iBAAiB,QAC1B,OAAO,QAAQ;GACb,SAAS,OAAO,MAAM;GACtB,OAAO,OAAO,MAAM;EACrB;EAEH,MAAM,OAAO;EACb,KAAK,QACH,OAAO,OAAO,UAAU,WACpB,IAAI,OAAO,OAAO,SAClB,aAAa,OAAO,QACpB,IAAI,OAAO,OAAO,MAAM,SAAS,OAAO,MAAM,SAC9C,OAAO;EACb,KAAK,aAAa,OAAO;EACzB,KAAK,mBAAmB,OAAO;CAChC;CAED,QAAQ;AACN,SAAO;CACR;;;;;;;;CASD,MAAM,MAAMC,MAA+C;EACzD,MAAM,QAAQ,KAAK,MAAM,KAAK,MAAM;AACpC,MAAI,MACF,QAAO,KAAK,WAAW,OAAO,CAAC,KAAK,KAAK,UAAU;GACjD,IAAI,OAAO,MAAM,QAAQ;AACzB,UAAO;EACR,GAAE,CAAE,EAA2B;AAGlC,MAAI,KAAK,qBAAqB,OAC5B,OAAM,IAAI,sBAAsB,CAAC,wBAAwB,EAAE,MAAM,EAAE;AAGrE,SAAO,KAAK,WAAW,OAAO,CAAC,KAAK,QAAQ;GAC1C,IAAI,OAAO,QAAQ,KAAK,mBAAmB,OAAO;AAClD,UAAO;EACR,GAAE,CAAE,EAA2B;CACjC;;;;;;CAOD,wBAAgC;AAC9B,SAAO,CAAC,gDAAgD,EAAE,KAAK,OAAO;CACvE;AACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
2
|
const __langchain_core_utils_types = require_rolldown_runtime.__toESM(require("@langchain/core/utils/types"));
|
|
3
3
|
const __langchain_core_utils_json_schema = require_rolldown_runtime.__toESM(require("@langchain/core/utils/json_schema"));
|
|
4
|
-
const
|
|
4
|
+
const zod_v3 = require_rolldown_runtime.__toESM(require("zod/v3"));
|
|
5
5
|
const __langchain_core_output_parsers = require_rolldown_runtime.__toESM(require("@langchain/core/output_parsers"));
|
|
6
6
|
|
|
7
7
|
//#region src/output_parsers/structured.ts
|
|
@@ -36,7 +36,7 @@ var StructuredOutputParser = class extends __langchain_core_output_parsers.BaseO
|
|
|
36
36
|
* @returns A new instance of StructuredOutputParser.
|
|
37
37
|
*/
|
|
38
38
|
static fromNamesAndDescriptions(schemas) {
|
|
39
|
-
const zodSchema =
|
|
39
|
+
const zodSchema = zod_v3.z.object(Object.fromEntries(Object.entries(schemas).map(([name, description]) => [name, zod_v3.z.string().describe(description)])));
|
|
40
40
|
return new this(zodSchema);
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
@@ -71,7 +71,7 @@ ${JSON.stringify((0, __langchain_core_utils_json_schema.toJsonSchema)(this.schem
|
|
|
71
71
|
try {
|
|
72
72
|
const json = text.includes("```") ? text.trim().split(/```(?:json)?/)[1] : text.trim();
|
|
73
73
|
return await (0, __langchain_core_utils_types.interopParseAsync)(this.schema, JSON.parse(json));
|
|
74
|
-
} catch
|
|
74
|
+
} catch {
|
|
75
75
|
try {
|
|
76
76
|
return await (0, __langchain_core_utils_types.interopParseAsync)(this.schema, JSON.parse(text.trim()));
|
|
77
77
|
} catch (e2) {
|
|
@@ -129,7 +129,7 @@ var JsonMarkdownStructuredOutputParser = class extends StructuredOutputParser {
|
|
|
129
129
|
return new this(schema);
|
|
130
130
|
}
|
|
131
131
|
static fromNamesAndDescriptions(schemas) {
|
|
132
|
-
const zodSchema =
|
|
132
|
+
const zodSchema = zod_v3.z.object(Object.fromEntries(Object.entries(schemas).map(([name, description]) => [name, zod_v3.z.string().describe(description)])));
|
|
133
133
|
return new this(zodSchema);
|
|
134
134
|
}
|
|
135
135
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"structured.cjs","names":["BaseOutputParser","schema: T","schemas: S","z","text: string","OutputParserException","options?: JsonMarkdownFormatInstructionsOptions","schemaInput: JsonSchema7Type","type: string","type","description"],"sources":["../../src/output_parsers/structured.ts"],"sourcesContent":["import { z } from \"zod\";\nimport {\n toJsonSchema,\n type JsonSchema7Type,\n type JsonSchema7ArrayType,\n type JsonSchema7ObjectType,\n type JsonSchema7StringType,\n type JsonSchema7NumberType,\n type JsonSchema7NullableType,\n} from \"@langchain/core/utils/json_schema\";\nimport {\n BaseOutputParser,\n FormatInstructionsOptions,\n OutputParserException,\n} from \"@langchain/core/output_parsers\";\nimport {\n interopParseAsync,\n type InferInteropZodOutput,\n type InteropZodType,\n} from \"@langchain/core/utils/types\";\n\nexport type JsonMarkdownStructuredOutputParserInput = {\n interpolationDepth?: number;\n};\n\nexport interface JsonMarkdownFormatInstructionsOptions\n extends FormatInstructionsOptions {\n interpolationDepth?: number;\n}\n\nexport class StructuredOutputParser<\n T extends InteropZodType\n> extends BaseOutputParser<InferInteropZodOutput<T>> {\n static lc_name() {\n return \"StructuredOutputParser\";\n }\n\n lc_namespace = [\"langchain\", \"output_parsers\", \"structured\"];\n\n toJSON() {\n return this.toJSONNotImplemented();\n }\n\n constructor(public schema: T) {\n super(schema);\n }\n\n /**\n * Creates a new StructuredOutputParser from a Zod schema.\n * @param schema The Zod schema which the output should match\n * @returns A new instance of StructuredOutputParser.\n */\n static fromZodSchema<T extends InteropZodType>(schema: T) {\n return new this(schema);\n }\n\n /**\n * Creates a new StructuredOutputParser from a set of names and\n * descriptions.\n * @param schemas An object where each key is a name and each value is a description\n * @returns A new instance of StructuredOutputParser.\n */\n static fromNamesAndDescriptions<S extends { [key: string]: string }>(\n schemas: S\n ) {\n const zodSchema = z.object(\n Object.fromEntries(\n Object.entries(schemas).map(\n ([name, description]) =>\n [name, z.string().describe(description)] as const\n )\n )\n );\n\n return new this(zodSchema);\n }\n\n /**\n * Returns a markdown code snippet with a JSON object formatted according\n * to the schema.\n * @param options Optional. The options for formatting the instructions\n * @returns A markdown code snippet with a JSON object formatted according to the schema.\n */\n getFormatInstructions(): string {\n return `You must format your output as a JSON value that adheres to a given \"JSON Schema\" instance.\n\n\"JSON Schema\" is a declarative language that allows you to annotate and validate JSON documents.\n\nFor example, the example \"JSON Schema\" instance {{\"properties\": {{\"foo\": {{\"description\": \"a list of test words\", \"type\": \"array\", \"items\": {{\"type\": \"string\"}}}}}}, \"required\": [\"foo\"]}}}}\nwould match an object with one required property, \"foo\". The \"type\" property specifies \"foo\" must be an \"array\", and the \"description\" property semantically describes it as \"a list of test words\". The items within \"foo\" must be strings.\nThus, the object {{\"foo\": [\"bar\", \"baz\"]}} is a well-formatted instance of this example \"JSON Schema\". The object {{\"properties\": {{\"foo\": [\"bar\", \"baz\"]}}}} is not well-formatted.\n\nYour output will be parsed and type-checked according to the provided schema instance, so make sure all fields in your output match the schema exactly and there are no trailing commas!\n\nHere is the JSON Schema instance your output must adhere to. Include the enclosing markdown codeblock:\n\\`\\`\\`json\n${JSON.stringify(toJsonSchema(this.schema))}\n\\`\\`\\`\n`;\n }\n\n /**\n * Parses the given text according to the schema.\n * @param text The text to parse\n * @returns The parsed output.\n */\n async parse(text: string): Promise<InferInteropZodOutput<T>> {\n try {\n const json = text.includes(\"```\")\n ? text.trim().split(/```(?:json)?/)[1]\n : text.trim();\n return await interopParseAsync(this.schema, JSON.parse(json));\n } catch (e) {\n try {\n return await interopParseAsync(this.schema, JSON.parse(text.trim()));\n } catch (e2) {\n throw new OutputParserException(\n `Failed to parse. Text: \"${text}\". Error: ${e2}`,\n text\n );\n }\n }\n }\n}\n\n/**\n * A specific type of `StructuredOutputParser` that parses JSON data\n * formatted as a markdown code snippet.\n */\nexport class JsonMarkdownStructuredOutputParser<\n T extends InteropZodType\n> extends StructuredOutputParser<T> {\n static lc_name() {\n return \"JsonMarkdownStructuredOutputParser\";\n }\n\n getFormatInstructions(\n options?: JsonMarkdownFormatInstructionsOptions\n ): string {\n const interpolationDepth = options?.interpolationDepth ?? 1;\n if (interpolationDepth < 1) {\n throw new Error(\"f string interpolation depth must be at least 1\");\n }\n\n return `Return a markdown code snippet with a JSON object formatted to look like:\\n\\`\\`\\`json\\n${this._schemaToInstruction(\n toJsonSchema(this.schema)\n )\n .replaceAll(\"{\", \"{\".repeat(interpolationDepth))\n .replaceAll(\"}\", \"}\".repeat(interpolationDepth))}\\n\\`\\`\\``;\n }\n\n private _schemaToInstruction(\n schemaInput: JsonSchema7Type,\n indent = 2\n ): string {\n const schema = schemaInput as Extract<\n JsonSchema7Type,\n | JsonSchema7ObjectType\n | JsonSchema7ArrayType\n | JsonSchema7StringType\n | JsonSchema7NumberType\n | JsonSchema7NullableType\n >;\n\n if (\"type\" in schema) {\n let nullable = false;\n let type: string;\n if (Array.isArray(schema.type)) {\n const nullIdx = schema.type.findIndex((type) => type === \"null\");\n if (nullIdx !== -1) {\n nullable = true;\n schema.type.splice(nullIdx, 1);\n }\n type = schema.type.join(\" | \") as string;\n } else {\n type = schema.type;\n }\n\n if (schema.type === \"object\" && schema.properties) {\n const description = schema.description\n ? ` // ${schema.description}`\n : \"\";\n const properties = Object.entries(schema.properties)\n .map(([key, value]) => {\n const isOptional = schema.required?.includes(key)\n ? \"\"\n : \" (optional)\";\n return `${\" \".repeat(indent)}\"${key}\": ${this._schemaToInstruction(\n value,\n indent + 2\n )}${isOptional}`;\n })\n .join(\"\\n\");\n return `{\\n${properties}\\n${\" \".repeat(indent - 2)}}${description}`;\n }\n if (schema.type === \"array\" && schema.items) {\n const description = schema.description\n ? ` // ${schema.description}`\n : \"\";\n return `array[\\n${\" \".repeat(indent)}${this._schemaToInstruction(\n schema.items,\n indent + 2\n )}\\n${\" \".repeat(indent - 2)}] ${description}`;\n }\n const isNullable = nullable ? \" (nullable)\" : \"\";\n const description = schema.description ? ` // ${schema.description}` : \"\";\n return `${type}${description}${isNullable}`;\n }\n\n if (\"anyOf\" in schema) {\n return schema.anyOf\n .map((s) => this._schemaToInstruction(s, indent))\n .join(`\\n${\" \".repeat(indent - 2)}`);\n }\n\n throw new Error(\"unsupported schema type\");\n }\n\n static fromZodSchema<T extends InteropZodType>(schema: T) {\n return new this<T>(schema);\n }\n\n static fromNamesAndDescriptions<S extends { [key: string]: string }>(\n schemas: S\n ) {\n const zodSchema = z.object(\n Object.fromEntries(\n Object.entries(schemas).map(\n ([name, description]) =>\n [name, z.string().describe(description)] as const\n )\n )\n );\n\n return new this<typeof zodSchema>(zodSchema);\n }\n}\n\nexport interface AsymmetricStructuredOutputParserFields<\n T extends InteropZodType\n> {\n inputSchema: T;\n}\n\n/**\n * A type of `StructuredOutputParser` that handles asymmetric input and\n * output schemas.\n */\nexport abstract class AsymmetricStructuredOutputParser<\n T extends InteropZodType,\n Y = unknown\n> extends BaseOutputParser<Y> {\n private structuredInputParser: JsonMarkdownStructuredOutputParser<T>;\n\n constructor({ inputSchema }: AsymmetricStructuredOutputParserFields<T>) {\n super(...arguments);\n this.structuredInputParser = new JsonMarkdownStructuredOutputParser(\n inputSchema\n );\n }\n\n /**\n * Processes the parsed input into the desired output format. Must be\n * implemented by subclasses.\n * @param input The parsed input\n * @returns The processed output.\n */\n abstract outputProcessor(input: InferInteropZodOutput<T>): Promise<Y>;\n\n async parse(text: string): Promise<Y> {\n let parsedInput;\n try {\n parsedInput = await this.structuredInputParser.parse(text);\n } catch (e) {\n throw new OutputParserException(\n `Failed to parse. Text: \"${text}\". Error: ${e}`,\n text\n );\n }\n\n return this.outputProcessor(parsedInput);\n }\n\n getFormatInstructions(): string {\n return this.structuredInputParser.getFormatInstructions();\n }\n}\n"],"mappings":";;;;;;;AA8BA,IAAa,yBAAb,cAEUA,iDAA2C;CACnD,OAAO,UAAU;AACf,SAAO;CACR;CAED,eAAe;EAAC;EAAa;EAAkB;CAAa;CAE5D,SAAS;AACP,SAAO,KAAK,sBAAsB;CACnC;CAED,YAAmBC,QAAW;EAC5B,MAAM,OAAO;EADI;CAElB;;;;;;CAOD,OAAO,cAAwCA,QAAW;AACxD,SAAO,IAAI,KAAK;CACjB;;;;;;;CAQD,OAAO,yBACLC,SACA;EACA,MAAM,YAAYC,MAAE,OAClB,OAAO,YACL,OAAO,QAAQ,QAAQ,CAAC,IACtB,CAAC,CAAC,MAAM,YAAY,KAClB,CAAC,MAAMA,MAAE,QAAQ,CAAC,SAAS,YAAY,AAAC,EAC3C,CACF,CACF;AAED,SAAO,IAAI,KAAK;CACjB;;;;;;;CAQD,wBAAgC;AAC9B,SAAO,CAAC;;;;;;;;;;;;AAYZ,EAAE,KAAK,+DAAuB,KAAK,OAAO,CAAC,CAAC;;AAE5C,CAAC;CACE;;;;;;CAOD,MAAM,MAAMC,MAAiD;AAC3D,MAAI;GACF,MAAM,OAAO,KAAK,SAAS,MAAM,GAC7B,KAAK,MAAM,CAAC,MAAM,eAAe,CAAC,KAClC,KAAK,MAAM;AACf,UAAO,0DAAwB,KAAK,QAAQ,KAAK,MAAM,KAAK,CAAC;EAC9D,SAAQ,GAAG;A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,IAAI;AACJ,MAAI;GACF,cAAc,MAAM,KAAK,sBAAsB,MAAM,KAAK;EAC3D,SAAQ,GAAG;AACV,SAAM,IAAIC,sDACR,CAAC,wBAAwB,EAAE,KAAK,UAAU,EAAE,GAAG,EAC/C;EAEH;AAED,SAAO,KAAK,gBAAgB,YAAY;CACzC;CAED,wBAAgC;AAC9B,SAAO,KAAK,sBAAsB,uBAAuB;CAC1D;AACF"}
|
|
1
|
+
{"version":3,"file":"structured.cjs","names":["BaseOutputParser","schema: T","schemas: S","z","text: string","OutputParserException","options?: JsonMarkdownFormatInstructionsOptions","schemaInput: JsonSchema7Type","type: string","type","description"],"sources":["../../src/output_parsers/structured.ts"],"sourcesContent":["import { z } from \"zod/v3\";\nimport {\n toJsonSchema,\n type JsonSchema7Type,\n type JsonSchema7ArrayType,\n type JsonSchema7ObjectType,\n type JsonSchema7StringType,\n type JsonSchema7NumberType,\n type JsonSchema7NullableType,\n} from \"@langchain/core/utils/json_schema\";\nimport {\n BaseOutputParser,\n FormatInstructionsOptions,\n OutputParserException,\n} from \"@langchain/core/output_parsers\";\nimport {\n interopParseAsync,\n type InferInteropZodOutput,\n type InteropZodType,\n} from \"@langchain/core/utils/types\";\n\nexport type JsonMarkdownStructuredOutputParserInput = {\n interpolationDepth?: number;\n};\n\nexport interface JsonMarkdownFormatInstructionsOptions\n extends FormatInstructionsOptions {\n interpolationDepth?: number;\n}\n\nexport class StructuredOutputParser<\n T extends InteropZodType\n> extends BaseOutputParser<InferInteropZodOutput<T>> {\n static lc_name() {\n return \"StructuredOutputParser\";\n }\n\n lc_namespace = [\"langchain\", \"output_parsers\", \"structured\"];\n\n toJSON() {\n return this.toJSONNotImplemented();\n }\n\n constructor(public schema: T) {\n super(schema);\n }\n\n /**\n * Creates a new StructuredOutputParser from a Zod schema.\n * @param schema The Zod schema which the output should match\n * @returns A new instance of StructuredOutputParser.\n */\n static fromZodSchema<T extends InteropZodType>(schema: T) {\n return new this(schema);\n }\n\n /**\n * Creates a new StructuredOutputParser from a set of names and\n * descriptions.\n * @param schemas An object where each key is a name and each value is a description\n * @returns A new instance of StructuredOutputParser.\n */\n static fromNamesAndDescriptions<S extends { [key: string]: string }>(\n schemas: S\n ) {\n const zodSchema = z.object(\n Object.fromEntries(\n Object.entries(schemas).map(\n ([name, description]) =>\n [name, z.string().describe(description)] as const\n )\n )\n );\n\n return new this(zodSchema);\n }\n\n /**\n * Returns a markdown code snippet with a JSON object formatted according\n * to the schema.\n * @param options Optional. The options for formatting the instructions\n * @returns A markdown code snippet with a JSON object formatted according to the schema.\n */\n getFormatInstructions(): string {\n return `You must format your output as a JSON value that adheres to a given \"JSON Schema\" instance.\n\n\"JSON Schema\" is a declarative language that allows you to annotate and validate JSON documents.\n\nFor example, the example \"JSON Schema\" instance {{\"properties\": {{\"foo\": {{\"description\": \"a list of test words\", \"type\": \"array\", \"items\": {{\"type\": \"string\"}}}}}}, \"required\": [\"foo\"]}}}}\nwould match an object with one required property, \"foo\". The \"type\" property specifies \"foo\" must be an \"array\", and the \"description\" property semantically describes it as \"a list of test words\". The items within \"foo\" must be strings.\nThus, the object {{\"foo\": [\"bar\", \"baz\"]}} is a well-formatted instance of this example \"JSON Schema\". The object {{\"properties\": {{\"foo\": [\"bar\", \"baz\"]}}}} is not well-formatted.\n\nYour output will be parsed and type-checked according to the provided schema instance, so make sure all fields in your output match the schema exactly and there are no trailing commas!\n\nHere is the JSON Schema instance your output must adhere to. Include the enclosing markdown codeblock:\n\\`\\`\\`json\n${JSON.stringify(toJsonSchema(this.schema))}\n\\`\\`\\`\n`;\n }\n\n /**\n * Parses the given text according to the schema.\n * @param text The text to parse\n * @returns The parsed output.\n */\n async parse(text: string): Promise<InferInteropZodOutput<T>> {\n try {\n const json = text.includes(\"```\")\n ? text.trim().split(/```(?:json)?/)[1]\n : text.trim();\n return await interopParseAsync(this.schema, JSON.parse(json));\n } catch {\n try {\n return await interopParseAsync(this.schema, JSON.parse(text.trim()));\n } catch (e2) {\n throw new OutputParserException(\n `Failed to parse. Text: \"${text}\". Error: ${e2}`,\n text\n );\n }\n }\n }\n}\n\n/**\n * A specific type of `StructuredOutputParser` that parses JSON data\n * formatted as a markdown code snippet.\n */\nexport class JsonMarkdownStructuredOutputParser<\n T extends InteropZodType\n> extends StructuredOutputParser<T> {\n static lc_name() {\n return \"JsonMarkdownStructuredOutputParser\";\n }\n\n getFormatInstructions(\n options?: JsonMarkdownFormatInstructionsOptions\n ): string {\n const interpolationDepth = options?.interpolationDepth ?? 1;\n if (interpolationDepth < 1) {\n throw new Error(\"f string interpolation depth must be at least 1\");\n }\n\n return `Return a markdown code snippet with a JSON object formatted to look like:\\n\\`\\`\\`json\\n${this._schemaToInstruction(\n toJsonSchema(this.schema)\n )\n .replaceAll(\"{\", \"{\".repeat(interpolationDepth))\n .replaceAll(\"}\", \"}\".repeat(interpolationDepth))}\\n\\`\\`\\``;\n }\n\n private _schemaToInstruction(\n schemaInput: JsonSchema7Type,\n indent = 2\n ): string {\n const schema = schemaInput as Extract<\n JsonSchema7Type,\n | JsonSchema7ObjectType\n | JsonSchema7ArrayType\n | JsonSchema7StringType\n | JsonSchema7NumberType\n | JsonSchema7NullableType\n >;\n\n if (\"type\" in schema) {\n let nullable = false;\n let type: string;\n if (Array.isArray(schema.type)) {\n const nullIdx = schema.type.findIndex((type) => type === \"null\");\n if (nullIdx !== -1) {\n nullable = true;\n schema.type.splice(nullIdx, 1);\n }\n type = schema.type.join(\" | \") as string;\n } else {\n type = schema.type;\n }\n\n if (schema.type === \"object\" && schema.properties) {\n const description = schema.description\n ? ` // ${schema.description}`\n : \"\";\n const properties = Object.entries(schema.properties)\n .map(([key, value]) => {\n const isOptional = schema.required?.includes(key)\n ? \"\"\n : \" (optional)\";\n return `${\" \".repeat(indent)}\"${key}\": ${this._schemaToInstruction(\n value,\n indent + 2\n )}${isOptional}`;\n })\n .join(\"\\n\");\n return `{\\n${properties}\\n${\" \".repeat(indent - 2)}}${description}`;\n }\n if (schema.type === \"array\" && schema.items) {\n const description = schema.description\n ? ` // ${schema.description}`\n : \"\";\n return `array[\\n${\" \".repeat(indent)}${this._schemaToInstruction(\n schema.items,\n indent + 2\n )}\\n${\" \".repeat(indent - 2)}] ${description}`;\n }\n const isNullable = nullable ? \" (nullable)\" : \"\";\n const description = schema.description ? ` // ${schema.description}` : \"\";\n return `${type}${description}${isNullable}`;\n }\n\n if (\"anyOf\" in schema) {\n return schema.anyOf\n .map((s) => this._schemaToInstruction(s, indent))\n .join(`\\n${\" \".repeat(indent - 2)}`);\n }\n\n throw new Error(\"unsupported schema type\");\n }\n\n static fromZodSchema<T extends InteropZodType>(schema: T) {\n return new this<T>(schema);\n }\n\n static fromNamesAndDescriptions<S extends { [key: string]: string }>(\n schemas: S\n ) {\n const zodSchema = z.object(\n Object.fromEntries(\n Object.entries(schemas).map(\n ([name, description]) =>\n [name, z.string().describe(description)] as const\n )\n )\n );\n\n return new this<typeof zodSchema>(zodSchema);\n }\n}\n\nexport interface AsymmetricStructuredOutputParserFields<\n T extends InteropZodType\n> {\n inputSchema: T;\n}\n\n/**\n * A type of `StructuredOutputParser` that handles asymmetric input and\n * output schemas.\n */\nexport abstract class AsymmetricStructuredOutputParser<\n T extends InteropZodType,\n Y = unknown\n> extends BaseOutputParser<Y> {\n private structuredInputParser: JsonMarkdownStructuredOutputParser<T>;\n\n constructor({ inputSchema }: AsymmetricStructuredOutputParserFields<T>) {\n super(...arguments);\n this.structuredInputParser = new JsonMarkdownStructuredOutputParser(\n inputSchema\n );\n }\n\n /**\n * Processes the parsed input into the desired output format. Must be\n * implemented by subclasses.\n * @param input The parsed input\n * @returns The processed output.\n */\n abstract outputProcessor(input: InferInteropZodOutput<T>): Promise<Y>;\n\n async parse(text: string): Promise<Y> {\n let parsedInput;\n try {\n parsedInput = await this.structuredInputParser.parse(text);\n } catch (e) {\n throw new OutputParserException(\n `Failed to parse. Text: \"${text}\". Error: ${e}`,\n text\n );\n }\n\n return this.outputProcessor(parsedInput);\n }\n\n getFormatInstructions(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-
import { z } from "zod";
|
|
3
2
|
import { InferInteropZodOutput, InteropZodType } from "@langchain/core/utils/types";
|
|
3
|
+
import { z } from "zod/v3";
|
|
4
4
|
import { BaseOutputParser, FormatInstructionsOptions } from "@langchain/core/output_parsers";
|
|
5
5
|
|
|
6
6
|
//#region src/output_parsers/structured.d.ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"structured.d.cts","names":["z","BaseOutputParser","FormatInstructionsOptions","InferInteropZodOutput","InteropZodType","JsonMarkdownStructuredOutputParserInput","JsonMarkdownFormatInstructionsOptions","StructuredOutputParser","T","___load_serializable0","SerializedNotImplemented","S","ZodString","ZodTypeAny","ZodObject","Promise","JsonMarkdownStructuredOutputParser","AsymmetricStructuredOutputParserFields","AsymmetricStructuredOutputParser","Y","inputSchema"],"sources":["../../src/output_parsers/structured.d.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { BaseOutputParser, FormatInstructionsOptions } from \"@langchain/core/output_parsers\";\nimport { type InferInteropZodOutput, type InteropZodType } from \"@langchain/core/utils/types\";\nexport type JsonMarkdownStructuredOutputParserInput = {\n interpolationDepth?: number;\n};\nexport interface JsonMarkdownFormatInstructionsOptions extends FormatInstructionsOptions {\n interpolationDepth?: number;\n}\nexport declare class StructuredOutputParser<T extends InteropZodType> extends BaseOutputParser<InferInteropZodOutput<T>> {\n schema: T;\n static lc_name(): string;\n lc_namespace: string[];\n toJSON(): import(\"../load/serializable\").SerializedNotImplemented;\n constructor(schema: T);\n /**\n * Creates a new StructuredOutputParser from a Zod schema.\n * @param schema The Zod schema which the output should match\n * @returns A new instance of StructuredOutputParser.\n */\n static fromZodSchema<T extends InteropZodType>(schema: T): StructuredOutputParser<T>;\n /**\n * Creates a new StructuredOutputParser from a set of names and\n * descriptions.\n * @param schemas An object where each key is a name and each value is a description\n * @returns A new instance of StructuredOutputParser.\n */\n static fromNamesAndDescriptions<S extends {\n [key: string]: string;\n }>(schemas: S): StructuredOutputParser<z.ZodObject<{\n [k: string]: z.ZodString;\n }, \"strip\", z.ZodTypeAny, {\n [x: string]: string;\n }, {\n [x: string]: string;\n }>>;\n /**\n * Returns a markdown code snippet with a JSON object formatted according\n * to the schema.\n * @param options Optional. The options for formatting the instructions\n * @returns A markdown code snippet with a JSON object formatted according to the schema.\n */\n getFormatInstructions(): string;\n /**\n * Parses the given text according to the schema.\n * @param text The text to parse\n * @returns The parsed output.\n */\n parse(text: string): Promise<InferInteropZodOutput<T>>;\n}\n/**\n * A specific type of `StructuredOutputParser` that parses JSON data\n * formatted as a markdown code snippet.\n */\nexport declare class JsonMarkdownStructuredOutputParser<T extends InteropZodType> extends StructuredOutputParser<T> {\n static lc_name(): string;\n getFormatInstructions(options?: JsonMarkdownFormatInstructionsOptions): string;\n private _schemaToInstruction;\n static fromZodSchema<T extends InteropZodType>(schema: T): JsonMarkdownStructuredOutputParser<T>;\n static fromNamesAndDescriptions<S extends {\n [key: string]: string;\n }>(schemas: S): JsonMarkdownStructuredOutputParser<z.ZodObject<{\n [k: string]: z.ZodString;\n }, \"strip\", z.ZodTypeAny, {\n [x: string]: string;\n }, {\n [x: string]: string;\n }>>;\n}\nexport interface AsymmetricStructuredOutputParserFields<T extends InteropZodType> {\n inputSchema: T;\n}\n/**\n * A type of `StructuredOutputParser` that handles asymmetric input and\n * output schemas.\n */\nexport declare abstract class AsymmetricStructuredOutputParser<T extends InteropZodType, Y = unknown> extends BaseOutputParser<Y> {\n private structuredInputParser;\n constructor({ inputSchema }: AsymmetricStructuredOutputParserFields<T>);\n /**\n * Processes the parsed input into the desired output format. Must be\n * implemented by subclasses.\n * @param input The parsed input\n * @returns The processed output.\n */\n abstract outputProcessor(input: InferInteropZodOutput<T>): Promise<Y>;\n parse(text: string): Promise<Y>;\n getFormatInstructions(): string;\n}\n"],"mappings":";;;;;;KAGYK,uCAAAA;;;AAAAA,UAGKC,qCAAAA,SAA8CJ,yBAHZ,CAAA;EAGlCI,kBAAAA,CAAAA,EAAAA,MAAAA;AAGjB;AAA2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GH,kCAsB0GG,CAAAA,UAtB7Df,cAsB6De,CAAAA,SAtBrCZ,sBAsBqCY,CAtBdX,CAsBcW,CAAAA,CAAAA;EAAC,OAE9GC,OAAAA,CAAAA,CAAAA,EAAAA,MAAAA;EAAW,qBAA2CZ,CAAAA,OAAAA,CAAAA,EAtBpCF,qCAsBoCE,CAAAA,EAAAA,MAAAA;EAAC,QAAxCS,oBAAAA;EAAsC,OAObT,aAAAA,CAAAA,UA3BvBJ,cA2BuBI,CAAAA,CAAAA,MAAAA,EA3BCA,CA2BDA,CAAAA,EA3BKQ,kCA2BLR,CA3BwCA,CA2BxCA,CAAAA;EAAC,OAAvBL,wBAAAA,CAAAA,UAAAA;IAAmCgB,CAAAA,GAAAA,EAAAA,MAAAA,CAAAA,EAAAA,MAAAA;EAAC,CAAA,CAAA,CAATJ,OAAAA,EAxB/CJ,CAwB+CI,CAAAA,EAxB3CC,kCAwB2CD,CAxBRf,CAAAA,CAAEc,SAwBMC,CAAAA;IAC9BI,CAAAA,CAAAA,EAAAA,MAAAA,CAAAA,EAxBZnB,CAAAA,CAAEY,SAwBUO;EAAC,CAAA,EAATJ,OAAAA,EAvBTf,CAAAA,CAAEa,UAuBOE,EAAAA;IAVqFd,CAAAA,CAAAA,EAAAA,MAAAA,CAAAA,EAAAA,MAAAA;EAAgB,CAAA,EAAA;;;;UAP7GgB,iDAAiDb;eACjDI;;;;;;uBAMaU,2CAA2Cd,qCAAqCH,iBAAiBkB;;;;KAE9FF,uCAAuCT;;;;;;;kCAOpCL,sBAAsBK,KAAKO,QAAQI;uBAC9CJ,QAAQI"}
|
|
1
|
+
{"version":3,"file":"structured.d.cts","names":["z","BaseOutputParser","FormatInstructionsOptions","InferInteropZodOutput","InteropZodType","JsonMarkdownStructuredOutputParserInput","JsonMarkdownFormatInstructionsOptions","StructuredOutputParser","T","___load_serializable0","SerializedNotImplemented","S","ZodString","ZodTypeAny","ZodObject","Promise","JsonMarkdownStructuredOutputParser","AsymmetricStructuredOutputParserFields","AsymmetricStructuredOutputParser","Y","inputSchema"],"sources":["../../src/output_parsers/structured.d.ts"],"sourcesContent":["import { z } from \"zod/v3\";\nimport { BaseOutputParser, FormatInstructionsOptions } from \"@langchain/core/output_parsers\";\nimport { type InferInteropZodOutput, type InteropZodType } from \"@langchain/core/utils/types\";\nexport type JsonMarkdownStructuredOutputParserInput = {\n interpolationDepth?: number;\n};\nexport interface JsonMarkdownFormatInstructionsOptions extends FormatInstructionsOptions {\n interpolationDepth?: number;\n}\nexport declare class StructuredOutputParser<T extends InteropZodType> extends BaseOutputParser<InferInteropZodOutput<T>> {\n schema: T;\n static lc_name(): string;\n lc_namespace: string[];\n toJSON(): import(\"../load/serializable\").SerializedNotImplemented;\n constructor(schema: T);\n /**\n * Creates a new StructuredOutputParser from a Zod schema.\n * @param schema The Zod schema which the output should match\n * @returns A new instance of StructuredOutputParser.\n */\n static fromZodSchema<T extends InteropZodType>(schema: T): StructuredOutputParser<T>;\n /**\n * Creates a new StructuredOutputParser from a set of names and\n * descriptions.\n * @param schemas An object where each key is a name and each value is a description\n * @returns A new instance of StructuredOutputParser.\n */\n static fromNamesAndDescriptions<S extends {\n [key: string]: string;\n }>(schemas: S): StructuredOutputParser<z.ZodObject<{\n [k: string]: z.ZodString;\n }, \"strip\", z.ZodTypeAny, {\n [x: string]: string;\n }, {\n [x: string]: string;\n }>>;\n /**\n * Returns a markdown code snippet with a JSON object formatted according\n * to the schema.\n * @param options Optional. The options for formatting the instructions\n * @returns A markdown code snippet with a JSON object formatted according to the schema.\n */\n getFormatInstructions(): string;\n /**\n * Parses the given text according to the schema.\n * @param text The text to parse\n * @returns The parsed output.\n */\n parse(text: string): Promise<InferInteropZodOutput<T>>;\n}\n/**\n * A specific type of `StructuredOutputParser` that parses JSON data\n * formatted as a markdown code snippet.\n */\nexport declare class JsonMarkdownStructuredOutputParser<T extends InteropZodType> extends StructuredOutputParser<T> {\n static lc_name(): string;\n getFormatInstructions(options?: JsonMarkdownFormatInstructionsOptions): string;\n private _schemaToInstruction;\n static fromZodSchema<T extends InteropZodType>(schema: T): JsonMarkdownStructuredOutputParser<T>;\n static fromNamesAndDescriptions<S extends {\n [key: string]: string;\n }>(schemas: S): JsonMarkdownStructuredOutputParser<z.ZodObject<{\n [k: string]: z.ZodString;\n }, \"strip\", z.ZodTypeAny, {\n [x: string]: string;\n }, {\n [x: string]: string;\n }>>;\n}\nexport interface AsymmetricStructuredOutputParserFields<T extends InteropZodType> {\n inputSchema: T;\n}\n/**\n * A type of `StructuredOutputParser` that handles asymmetric input and\n * output schemas.\n */\nexport declare abstract class AsymmetricStructuredOutputParser<T extends InteropZodType, Y = unknown> extends BaseOutputParser<Y> {\n private structuredInputParser;\n constructor({ inputSchema }: AsymmetricStructuredOutputParserFields<T>);\n /**\n * Processes the parsed input into the desired output format. Must be\n * implemented by subclasses.\n * @param input The parsed input\n * @returns The processed output.\n */\n abstract outputProcessor(input: InferInteropZodOutput<T>): Promise<Y>;\n parse(text: string): Promise<Y>;\n getFormatInstructions(): string;\n}\n"],"mappings":";;;;;;KAGYK,uCAAAA;;;AAAAA,UAGKC,qCAAAA,SAA8CJ,yBAHZ,CAAA;EAGlCI,kBAAAA,CAAAA,EAAAA,MAAAA;AAGjB;AAA2C,cAAtBC,sBAAsB,CAAA,UAAWH,cAAX,CAAA,SAAmCH,gBAAnC,CAAoDE,qBAApD,CAA0EK,CAA1E,CAAA,CAAA,CAAA;EAAA,MAAWJ,EAC1CI,CAD0CJ;EAAc,OAAiDI,OAAAA,CAAAA,CAAAA,EAAAA,MAAAA;EAAC,YAAvBL,EAAAA,MAAAA,EAAAA;EAAqB,MACxGK,CAAAA,CAAAA,EAACC,sBAAAA,CAGgCC,wBAHjCF;EAAC,WAAAC,CAAAA,MAAAA,EAIWD,CAJXC;EAGwD;;;;;EAOgB,OASrEE,aAAAA,CAAAA,UATmBP,cASnBO,CAAAA,CAAAA,MAAAA,EAT2CH,CAS3CG,CAAAA,EAT+CJ,sBAS/CI,CATsEH,CA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AAAA,CAAAA,EAAAA,MAAAA;EAAC,CAAA,CAAA,CAATJ,OAAAA,EAxB/CJ,CAwB+CI,CAAAA,EAxB3CC,kCAwB2CD,CAxBRf,CAAAA,CAAEc,SAwBMC,CAAAA;IAC9BI,CAAAA,CAAAA,EAAAA,MAAAA,CAAAA,EAxBZnB,CAAAA,CAAEY,SAwBUO;EAAC,CAAA,EAATJ,OAAAA,EAvBTf,CAAAA,CAAEa,UAuBOE,EAAAA;IAVqFd,CAAAA,CAAAA,EAAAA,MAAAA,CAAAA,EAAAA,MAAAA;EAAgB,CAAA,EAAA;;;;UAP7GgB,iDAAiDb;eACjDI;;;;;;uBAMaU,2CAA2Cd,qCAAqCH,iBAAiBkB;;;;KAE9FF,uCAAuCT;;;;;;;kCAOpCL,sBAAsBK,KAAKO,QAAQI;uBAC9CJ,QAAQI"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { serializable_d_exports } from "../load/serializable.js";
|
|
2
2
|
import { InferInteropZodOutput, InteropZodType } from "@langchain/core/utils/types";
|
|
3
|
-
import { z } from "zod";
|
|
3
|
+
import { z } from "zod/v3";
|
|
4
4
|
import { BaseOutputParser, FormatInstructionsOptions } from "@langchain/core/output_parsers";
|
|
5
5
|
|
|
6
6
|
//#region src/output_parsers/structured.d.ts
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"structured.d.ts","names":["z","BaseOutputParser","FormatInstructionsOptions","InferInteropZodOutput","InteropZodType","JsonMarkdownStructuredOutputParserInput","JsonMarkdownFormatInstructionsOptions","StructuredOutputParser","T","___load_serializable0","SerializedNotImplemented","S","ZodString","ZodTypeAny","ZodObject","Promise","JsonMarkdownStructuredOutputParser","AsymmetricStructuredOutputParserFields","AsymmetricStructuredOutputParser","Y","inputSchema"],"sources":["../../src/output_parsers/structured.d.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { BaseOutputParser, FormatInstructionsOptions } from \"@langchain/core/output_parsers\";\nimport { type InferInteropZodOutput, type InteropZodType } from \"@langchain/core/utils/types\";\nexport type JsonMarkdownStructuredOutputParserInput = {\n interpolationDepth?: number;\n};\nexport interface JsonMarkdownFormatInstructionsOptions extends FormatInstructionsOptions {\n interpolationDepth?: number;\n}\nexport declare class StructuredOutputParser<T extends InteropZodType> extends BaseOutputParser<InferInteropZodOutput<T>> {\n schema: T;\n static lc_name(): string;\n lc_namespace: string[];\n toJSON(): import(\"../load/serializable\").SerializedNotImplemented;\n constructor(schema: T);\n /**\n * Creates a new StructuredOutputParser from a Zod schema.\n * @param schema The Zod schema which the output should match\n * @returns A new instance of StructuredOutputParser.\n */\n static fromZodSchema<T extends InteropZodType>(schema: T): StructuredOutputParser<T>;\n /**\n * Creates a new StructuredOutputParser from a set of names and\n * descriptions.\n * @param schemas An object where each key is a name and each value is a description\n * @returns A new instance of StructuredOutputParser.\n */\n static fromNamesAndDescriptions<S extends {\n [key: string]: string;\n }>(schemas: S): StructuredOutputParser<z.ZodObject<{\n [k: string]: z.ZodString;\n }, \"strip\", z.ZodTypeAny, {\n [x: string]: string;\n }, {\n [x: string]: string;\n }>>;\n /**\n * Returns a markdown code snippet with a JSON object formatted according\n * to the schema.\n * @param options Optional. The options for formatting the instructions\n * @returns A markdown code snippet with a JSON object formatted according to the schema.\n */\n getFormatInstructions(): string;\n /**\n * Parses the given text according to the schema.\n * @param text The text to parse\n * @returns The parsed output.\n */\n parse(text: string): Promise<InferInteropZodOutput<T>>;\n}\n/**\n * A specific type of `StructuredOutputParser` that parses JSON data\n * formatted as a markdown code snippet.\n */\nexport declare class JsonMarkdownStructuredOutputParser<T extends InteropZodType> extends StructuredOutputParser<T> {\n static lc_name(): string;\n getFormatInstructions(options?: JsonMarkdownFormatInstructionsOptions): string;\n private _schemaToInstruction;\n static fromZodSchema<T extends InteropZodType>(schema: T): JsonMarkdownStructuredOutputParser<T>;\n static fromNamesAndDescriptions<S extends {\n [key: string]: string;\n }>(schemas: S): JsonMarkdownStructuredOutputParser<z.ZodObject<{\n [k: string]: z.ZodString;\n }, \"strip\", z.ZodTypeAny, {\n [x: string]: string;\n }, {\n [x: string]: string;\n }>>;\n}\nexport interface AsymmetricStructuredOutputParserFields<T extends InteropZodType> {\n inputSchema: T;\n}\n/**\n * A type of `StructuredOutputParser` that handles asymmetric input and\n * output schemas.\n */\nexport declare abstract class AsymmetricStructuredOutputParser<T extends InteropZodType, Y = unknown> extends BaseOutputParser<Y> {\n private structuredInputParser;\n constructor({ inputSchema }: AsymmetricStructuredOutputParserFields<T>);\n /**\n * Processes the parsed input into the desired output format. Must be\n * implemented by subclasses.\n * @param input The parsed input\n * @returns The processed output.\n */\n abstract outputProcessor(input: InferInteropZodOutput<T>): Promise<Y>;\n parse(text: string): Promise<Y>;\n getFormatInstructions(): string;\n}\n"],"mappings":";;;;;;KAGYK,uCAAAA;;;AAAAA,UAGKC,qCAAAA,SAA8CJ,yBAHZ,CAAA;EAGlCI,kBAAAA,CAAAA,EAAAA,MAAAA;AAGjB;AAA2C,cAAtBC,sBAAsB,CAAA,UAAWH,cAAX,CAAA,SAAmCH,gBAAnC,CAAoDE,qBAApD,CAA0EK,CAA1E,CAAA,CAAA,CAAA;EAAA,MAAWJ,EAC1CI,CAD0CJ;EAAc,OAAiDI,OAAAA,CAAAA,CAAAA,EAAAA,MAAAA;EAAC,YAAvBL,EAAAA,MAAAA,EAAAA;EAAqB,MACxGK,CAAAA,CAAAA,EAACC,sBAAAA,CAGgCC,wBAHjCF;EAAC,WAAAC,CAAAA,MAAAA,EAIWD,CAJXC;EAGwD;;;;;EAOgB,OASrEE,aAAAA,CAAAA,UATmBP,cASnBO,CAAAA,CAAAA,MAAAA,EAT2CH,CAS3CG,CAAAA,EAT+CJ,sBAS/CI,CATsEH,CAStEG,CAAAA;EAAC;;;;;;EAmBqC,OAA7BI,wBAAAA,CAAAA,UAAAA;IAvCqDd,CAAAA,GAAAA,EAAAA,MAAAA,CAAAA,EAAAA,MAAAA;EAAgB,CAAA,CAAA,CAAA,OAAA,EAoB9EU,CAp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A,EAAAA,MAAAA,CAAAA,EAxBZnB,CAAAA,CAAEY,SAwBUO;EAAC,CAAA,EAATJ,OAAAA,EAvBTf,CAAAA,CAAEa,UAuBOE,EAAAA;IAVqFd,CAAAA,CAAAA,EAAAA,MAAAA,CAAAA,EAAAA,MAAAA;EAAgB,CAAA,EAAA;;;;UAP7GgB,iDAAiDb;eACjDI;;;;;;uBAMaU,2CAA2Cd,qCAAqCH,iBAAiBkB;;;;KAE9FF,uCAAuCT;;;;;;;kCAOpCL,sBAAsBK,KAAKO,QAAQI;uBAC9CJ,QAAQI"}
|
|
1
|
+
{"version":3,"file":"structured.d.ts","names":["z","BaseOutputParser","FormatInstructionsOptions","InferInteropZodOutput","InteropZodType","JsonMarkdownStructuredOutputParserInput","JsonMarkdownFormatInstructionsOptions","StructuredOutputParser","T","___load_serializable0","SerializedNotImplemented","S","ZodString","ZodTypeAny","ZodObject","Promise","JsonMarkdownStructuredOutputParser","AsymmetricStructuredOutputParserFields","AsymmetricStructuredOutputParser","Y","inputSchema"],"sources":["../../src/output_parsers/structured.d.ts"],"sourcesContent":["import { z } from \"zod/v3\";\nimport { BaseOutputParser, FormatInstructionsOptions } from \"@langchain/core/output_parsers\";\nimport { type InferInteropZodOutput, type InteropZodType } from \"@langchain/core/utils/types\";\nexport type JsonMarkdownStructuredOutputParserInput = {\n interpolationDepth?: number;\n};\nexport interface JsonMarkdownFormatInstructionsOptions extends FormatInstructionsOptions {\n interpolationDepth?: number;\n}\nexport declare class StructuredOutputParser<T extends InteropZodType> extends BaseOutputParser<InferInteropZodOutput<T>> {\n schema: T;\n static lc_name(): string;\n lc_namespace: string[];\n toJSON(): import(\"../load/serializable\").SerializedNotImplemented;\n constructor(schema: T);\n /**\n * Creates a new StructuredOutputParser from a Zod schema.\n * @param schema The Zod schema which the output should match\n * @returns A new instance of StructuredOutputParser.\n */\n static fromZodSchema<T extends InteropZodType>(schema: T): StructuredOutputParser<T>;\n /**\n * Creates a new StructuredOutputParser from a set of names and\n * descriptions.\n * @param schemas An object where each key is a name and each value is a description\n * @returns A new instance of StructuredOutputParser.\n */\n static fromNamesAndDescriptions<S extends {\n [key: string]: string;\n }>(schemas: S): StructuredOutputParser<z.ZodObject<{\n [k: string]: z.ZodString;\n }, \"strip\", z.ZodTypeAny, {\n [x: string]: string;\n }, {\n [x: string]: string;\n }>>;\n /**\n * Returns a markdown code snippet with a JSON object formatted according\n * to the schema.\n * @param options Optional. The options for formatting the instructions\n * @returns A markdown code snippet with a JSON object formatted according to the schema.\n */\n getFormatInstructions(): string;\n /**\n * Parses the given text according to the schema.\n * @param text The text to parse\n * @returns The parsed output.\n */\n parse(text: string): Promise<InferInteropZodOutput<T>>;\n}\n/**\n * A specific type of `StructuredOutputParser` that parses JSON data\n * formatted as a markdown code snippet.\n */\nexport declare class JsonMarkdownStructuredOutputParser<T extends InteropZodType> extends StructuredOutputParser<T> {\n static lc_name(): string;\n getFormatInstructions(options?: JsonMarkdownFormatInstructionsOptions): string;\n private _schemaToInstruction;\n static fromZodSchema<T extends InteropZodType>(schema: T): JsonMarkdownStructuredOutputParser<T>;\n static fromNamesAndDescriptions<S extends {\n [key: string]: string;\n }>(schemas: S): JsonMarkdownStructuredOutputParser<z.ZodObject<{\n [k: string]: z.ZodString;\n }, \"strip\", z.ZodTypeAny, {\n [x: string]: string;\n }, {\n [x: string]: string;\n }>>;\n}\nexport interface AsymmetricStructuredOutputParserFields<T extends InteropZodType> {\n inputSchema: T;\n}\n/**\n * A type of `StructuredOutputParser` that handles asymmetric input and\n * output schemas.\n */\nexport declare abstract class AsymmetricStructuredOutputParser<T extends InteropZodType, Y = unknown> extends BaseOutputParser<Y> {\n private structuredInputParser;\n constructor({ inputSchema }: AsymmetricStructuredOutputParserFields<T>);\n /**\n * Processes the parsed input into the desired output format. Must be\n * implemented by subclasses.\n * @param input The parsed input\n * @returns The processed output.\n */\n abstract outputProcessor(input: InferInteropZodOutput<T>): Promise<Y>;\n parse(text: string): Promise<Y>;\n getFormatInstructions(): string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ils/json_schema";
|
|
3
|
-
import { z } from "zod";
|
|
3
|
+
import { z } from "zod/v3";
|
|
4
4
|
import { BaseOutputParser, OutputParserException } from "@langchain/core/output_parsers";
|
|
5
5
|
|
|
6
6
|
//#region src/output_parsers/structured.ts
|
|
@@ -70,7 +70,7 @@ ${JSON.stringify(toJsonSchema(this.schema))}
|
|
|
70
70
|
try {
|
|
71
71
|
const json = text.includes("```") ? text.trim().split(/```(?:json)?/)[1] : text.trim();
|
|
72
72
|
return await interopParseAsync(this.schema, JSON.parse(json));
|
|
73
|
-
} catch
|
|
73
|
+
} catch {
|
|
74
74
|
try {
|
|
75
75
|
return await interopParseAsync(this.schema, JSON.parse(text.trim()));
|
|
76
76
|
} catch (e2) {
|