@langchain/classic 1.0.40 → 1.0.41
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/CHANGELOG.md +7 -0
- package/dist/agents/agent.cjs +1 -1
- package/dist/agents/agent.cjs.map +1 -1
- package/dist/agents/agent.d.cts +1 -2
- package/dist/agents/agent.d.cts.map +1 -1
- package/dist/agents/agent.d.ts +1 -2
- package/dist/agents/agent.d.ts.map +1 -1
- package/dist/agents/agent.js +1 -1
- package/dist/agents/agent.js.map +1 -1
- package/dist/agents/chat/index.cjs +8 -7
- package/dist/agents/chat/index.cjs.map +1 -1
- package/dist/agents/chat/index.d.cts +0 -1
- package/dist/agents/chat/index.d.cts.map +1 -1
- package/dist/agents/chat/index.d.ts +0 -1
- package/dist/agents/chat/index.d.ts.map +1 -1
- package/dist/agents/chat/index.js +8 -6
- package/dist/agents/chat/index.js.map +1 -1
- package/dist/agents/chat/outputParser.cjs +1 -1
- package/dist/agents/chat/outputParser.cjs.map +1 -1
- package/dist/agents/chat/outputParser.d.cts +2 -3
- package/dist/agents/chat/outputParser.d.cts.map +1 -1
- package/dist/agents/chat/outputParser.d.ts +2 -3
- package/dist/agents/chat/outputParser.d.ts.map +1 -1
- package/dist/agents/chat/outputParser.js +1 -1
- package/dist/agents/chat/outputParser.js.map +1 -1
- package/dist/agents/chat_convo/index.cjs +9 -9
- package/dist/agents/chat_convo/index.cjs.map +1 -1
- package/dist/agents/chat_convo/index.d.cts +0 -1
- package/dist/agents/chat_convo/index.d.cts.map +1 -1
- package/dist/agents/chat_convo/index.d.ts +0 -1
- package/dist/agents/chat_convo/index.d.ts.map +1 -1
- package/dist/agents/chat_convo/index.js +9 -8
- package/dist/agents/chat_convo/index.js.map +1 -1
- package/dist/agents/chat_convo/outputParser.cjs +2 -2
- package/dist/agents/chat_convo/outputParser.cjs.map +1 -1
- package/dist/agents/chat_convo/outputParser.d.cts +0 -1
- package/dist/agents/chat_convo/outputParser.d.cts.map +1 -1
- package/dist/agents/chat_convo/outputParser.d.ts +0 -1
- package/dist/agents/chat_convo/outputParser.d.ts.map +1 -1
- package/dist/agents/chat_convo/outputParser.js +2 -1
- package/dist/agents/chat_convo/outputParser.js.map +1 -1
- package/dist/agents/executor.cjs +2 -1
- package/dist/agents/executor.cjs.map +1 -1
- package/dist/agents/executor.d.cts +10 -10
- package/dist/agents/executor.d.cts.map +1 -1
- package/dist/agents/executor.d.ts +10 -10
- package/dist/agents/executor.d.ts.map +1 -1
- package/dist/agents/executor.js +1 -1
- package/dist/agents/executor.js.map +1 -1
- package/dist/agents/format_scratchpad/log.cjs.map +1 -1
- package/dist/agents/format_scratchpad/log.d.cts +0 -1
- package/dist/agents/format_scratchpad/log.d.cts.map +1 -1
- package/dist/agents/format_scratchpad/log.d.ts +0 -1
- package/dist/agents/format_scratchpad/log.d.ts.map +1 -1
- package/dist/agents/format_scratchpad/log.js.map +1 -1
- package/dist/agents/format_scratchpad/log_to_message.cjs.map +1 -1
- package/dist/agents/format_scratchpad/log_to_message.d.cts +0 -1
- package/dist/agents/format_scratchpad/log_to_message.d.cts.map +1 -1
- package/dist/agents/format_scratchpad/log_to_message.d.ts +0 -1
- package/dist/agents/format_scratchpad/log_to_message.d.ts.map +1 -1
- package/dist/agents/format_scratchpad/log_to_message.js.map +1 -1
- package/dist/agents/format_scratchpad/openai_functions.cjs.map +1 -1
- package/dist/agents/format_scratchpad/openai_functions.d.cts +0 -1
- package/dist/agents/format_scratchpad/openai_functions.d.cts.map +1 -1
- package/dist/agents/format_scratchpad/openai_functions.d.ts +0 -1
- package/dist/agents/format_scratchpad/openai_functions.d.ts.map +1 -1
- package/dist/agents/format_scratchpad/openai_functions.js.map +1 -1
- package/dist/agents/format_scratchpad/tool_calling.cjs +1 -1
- package/dist/agents/format_scratchpad/tool_calling.cjs.map +1 -1
- package/dist/agents/format_scratchpad/tool_calling.d.cts +0 -1
- package/dist/agents/format_scratchpad/tool_calling.d.cts.map +1 -1
- package/dist/agents/format_scratchpad/tool_calling.d.ts +0 -1
- package/dist/agents/format_scratchpad/tool_calling.d.ts.map +1 -1
- package/dist/agents/format_scratchpad/tool_calling.js +1 -1
- package/dist/agents/format_scratchpad/tool_calling.js.map +1 -1
- package/dist/agents/format_scratchpad/xml.cjs.map +1 -1
- package/dist/agents/format_scratchpad/xml.d.cts +0 -1
- package/dist/agents/format_scratchpad/xml.d.cts.map +1 -1
- package/dist/agents/format_scratchpad/xml.d.ts +0 -1
- package/dist/agents/format_scratchpad/xml.d.ts.map +1 -1
- package/dist/agents/format_scratchpad/xml.js.map +1 -1
- package/dist/agents/helpers.cjs.map +1 -1
- package/dist/agents/helpers.js.map +1 -1
- package/dist/agents/index.d.cts +1 -0
- package/dist/agents/index.d.ts +1 -0
- package/dist/agents/initialize.cjs.map +1 -1
- package/dist/agents/initialize.d.cts +0 -1
- package/dist/agents/initialize.d.cts.map +1 -1
- package/dist/agents/initialize.d.ts +0 -1
- package/dist/agents/initialize.d.ts.map +1 -1
- package/dist/agents/initialize.js.map +1 -1
- package/dist/agents/load.cjs +1 -1
- package/dist/agents/load.cjs.map +1 -1
- package/dist/agents/load.d.cts +0 -1
- package/dist/agents/load.d.cts.map +1 -1
- package/dist/agents/load.d.ts +0 -1
- package/dist/agents/load.d.ts.map +1 -1
- package/dist/agents/load.js +1 -1
- package/dist/agents/load.js.map +1 -1
- package/dist/agents/mrkl/index.cjs +6 -6
- package/dist/agents/mrkl/index.cjs.map +1 -1
- package/dist/agents/mrkl/index.d.cts +0 -1
- package/dist/agents/mrkl/index.d.cts.map +1 -1
- package/dist/agents/mrkl/index.d.ts +0 -1
- package/dist/agents/mrkl/index.d.ts.map +1 -1
- package/dist/agents/mrkl/index.js +6 -5
- package/dist/agents/mrkl/index.js.map +1 -1
- package/dist/agents/mrkl/outputParser.cjs +3 -1
- package/dist/agents/mrkl/outputParser.cjs.map +1 -1
- package/dist/agents/mrkl/outputParser.d.cts +0 -1
- package/dist/agents/mrkl/outputParser.d.cts.map +1 -1
- package/dist/agents/mrkl/outputParser.d.ts +0 -1
- package/dist/agents/mrkl/outputParser.d.ts.map +1 -1
- package/dist/agents/mrkl/outputParser.js +3 -1
- package/dist/agents/mrkl/outputParser.js.map +1 -1
- package/dist/agents/openai/output_parser.d.cts +1 -1
- package/dist/agents/openai/output_parser.d.ts +1 -1
- package/dist/agents/openai_functions/index.cjs +6 -6
- package/dist/agents/openai_functions/index.cjs.map +1 -1
- package/dist/agents/openai_functions/index.d.cts +6 -9
- package/dist/agents/openai_functions/index.d.cts.map +1 -1
- package/dist/agents/openai_functions/index.d.ts +6 -9
- package/dist/agents/openai_functions/index.d.ts.map +1 -1
- package/dist/agents/openai_functions/index.js +6 -5
- package/dist/agents/openai_functions/index.js.map +1 -1
- package/dist/agents/openai_functions/output_parser.cjs +0 -1
- package/dist/agents/openai_functions/output_parser.cjs.map +1 -1
- package/dist/agents/openai_functions/output_parser.d.cts +0 -1
- package/dist/agents/openai_functions/output_parser.d.cts.map +1 -1
- package/dist/agents/openai_functions/output_parser.d.ts +0 -1
- package/dist/agents/openai_functions/output_parser.d.ts.map +1 -1
- package/dist/agents/openai_functions/output_parser.js.map +1 -1
- package/dist/agents/openai_tools/index.cjs +1 -1
- package/dist/agents/openai_tools/index.cjs.map +1 -1
- package/dist/agents/openai_tools/index.d.cts +7 -12
- package/dist/agents/openai_tools/index.d.cts.map +1 -1
- package/dist/agents/openai_tools/index.d.ts +7 -12
- package/dist/agents/openai_tools/index.d.ts.map +1 -1
- package/dist/agents/openai_tools/index.js +1 -1
- package/dist/agents/openai_tools/index.js.map +1 -1
- package/dist/agents/openai_tools/output_parser.cjs +0 -1
- package/dist/agents/openai_tools/output_parser.cjs.map +1 -1
- package/dist/agents/openai_tools/output_parser.d.cts +1 -2
- package/dist/agents/openai_tools/output_parser.d.cts.map +1 -1
- package/dist/agents/openai_tools/output_parser.d.ts +1 -2
- package/dist/agents/openai_tools/output_parser.d.ts.map +1 -1
- package/dist/agents/openai_tools/output_parser.js.map +1 -1
- package/dist/agents/react/index.cjs +0 -1
- package/dist/agents/react/index.cjs.map +1 -1
- package/dist/agents/react/index.d.cts +5 -10
- package/dist/agents/react/index.d.cts.map +1 -1
- package/dist/agents/react/index.d.ts +5 -10
- package/dist/agents/react/index.d.ts.map +1 -1
- package/dist/agents/react/index.js.map +1 -1
- package/dist/agents/react/output_parser.cjs.map +1 -1
- package/dist/agents/react/output_parser.d.cts +0 -1
- package/dist/agents/react/output_parser.d.cts.map +1 -1
- package/dist/agents/react/output_parser.d.ts +0 -1
- package/dist/agents/react/output_parser.d.ts.map +1 -1
- package/dist/agents/react/output_parser.js.map +1 -1
- package/dist/agents/structured_chat/index.cjs +6 -6
- package/dist/agents/structured_chat/index.cjs.map +1 -1
- package/dist/agents/structured_chat/index.d.cts +5 -10
- package/dist/agents/structured_chat/index.d.cts.map +1 -1
- package/dist/agents/structured_chat/index.d.ts +5 -10
- package/dist/agents/structured_chat/index.d.ts.map +1 -1
- package/dist/agents/structured_chat/index.js +6 -5
- package/dist/agents/structured_chat/index.js.map +1 -1
- package/dist/agents/structured_chat/outputParser.cjs +2 -2
- package/dist/agents/structured_chat/outputParser.cjs.map +1 -1
- package/dist/agents/structured_chat/outputParser.d.cts +0 -1
- package/dist/agents/structured_chat/outputParser.d.cts.map +1 -1
- package/dist/agents/structured_chat/outputParser.d.ts +0 -1
- package/dist/agents/structured_chat/outputParser.d.ts.map +1 -1
- package/dist/agents/structured_chat/outputParser.js +2 -1
- package/dist/agents/structured_chat/outputParser.js.map +1 -1
- package/dist/agents/tool_calling/index.cjs +0 -1
- package/dist/agents/tool_calling/index.cjs.map +1 -1
- package/dist/agents/tool_calling/index.d.cts +6 -11
- package/dist/agents/tool_calling/index.d.cts.map +1 -1
- package/dist/agents/tool_calling/index.d.ts +6 -11
- package/dist/agents/tool_calling/index.d.ts.map +1 -1
- package/dist/agents/tool_calling/index.js.map +1 -1
- package/dist/agents/tool_calling/output_parser.cjs +1 -1
- package/dist/agents/tool_calling/output_parser.cjs.map +1 -1
- package/dist/agents/tool_calling/output_parser.d.cts +1 -1
- package/dist/agents/tool_calling/output_parser.d.cts.map +1 -1
- package/dist/agents/tool_calling/output_parser.d.ts +1 -1
- package/dist/agents/tool_calling/output_parser.d.ts.map +1 -1
- package/dist/agents/tool_calling/output_parser.js +1 -1
- package/dist/agents/tool_calling/output_parser.js.map +1 -1
- package/dist/agents/toolkits/base.cjs +0 -1
- package/dist/agents/toolkits/conversational_retrieval/openai_functions.cjs.map +1 -1
- package/dist/agents/toolkits/conversational_retrieval/openai_functions.d.cts +0 -1
- package/dist/agents/toolkits/conversational_retrieval/openai_functions.d.cts.map +1 -1
- package/dist/agents/toolkits/conversational_retrieval/openai_functions.d.ts +0 -1
- package/dist/agents/toolkits/conversational_retrieval/openai_functions.d.ts.map +1 -1
- package/dist/agents/toolkits/conversational_retrieval/openai_functions.js.map +1 -1
- package/dist/agents/toolkits/conversational_retrieval/token_buffer_memory.cjs +0 -1
- package/dist/agents/toolkits/conversational_retrieval/token_buffer_memory.cjs.map +1 -1
- package/dist/agents/toolkits/conversational_retrieval/token_buffer_memory.d.cts +2 -4
- package/dist/agents/toolkits/conversational_retrieval/token_buffer_memory.d.cts.map +1 -1
- package/dist/agents/toolkits/conversational_retrieval/token_buffer_memory.d.ts +2 -4
- package/dist/agents/toolkits/conversational_retrieval/token_buffer_memory.d.ts.map +1 -1
- package/dist/agents/toolkits/conversational_retrieval/token_buffer_memory.js.map +1 -1
- package/dist/agents/toolkits/conversational_retrieval/tool.cjs +0 -1
- package/dist/agents/toolkits/conversational_retrieval/tool.cjs.map +1 -1
- package/dist/agents/toolkits/conversational_retrieval/tool.d.cts +0 -1
- package/dist/agents/toolkits/conversational_retrieval/tool.d.cts.map +1 -1
- package/dist/agents/toolkits/conversational_retrieval/tool.d.ts +0 -1
- package/dist/agents/toolkits/conversational_retrieval/tool.d.ts.map +1 -1
- package/dist/agents/toolkits/conversational_retrieval/tool.js.map +1 -1
- package/dist/agents/toolkits/json/json.cjs +1 -1
- package/dist/agents/toolkits/json/json.cjs.map +1 -1
- package/dist/agents/toolkits/json/json.d.cts +0 -1
- package/dist/agents/toolkits/json/json.d.cts.map +1 -1
- package/dist/agents/toolkits/json/json.d.ts +0 -1
- package/dist/agents/toolkits/json/json.d.ts.map +1 -1
- package/dist/agents/toolkits/json/json.js +1 -0
- package/dist/agents/toolkits/json/json.js.map +1 -1
- package/dist/agents/toolkits/openapi/openapi.cjs +0 -1
- package/dist/agents/toolkits/openapi/openapi.cjs.map +1 -1
- package/dist/agents/toolkits/openapi/openapi.d.cts +0 -1
- package/dist/agents/toolkits/openapi/openapi.d.cts.map +1 -1
- package/dist/agents/toolkits/openapi/openapi.d.ts +0 -1
- package/dist/agents/toolkits/openapi/openapi.d.ts.map +1 -1
- package/dist/agents/toolkits/openapi/openapi.js.map +1 -1
- package/dist/agents/toolkits/sql/prompt.d.cts.map +1 -1
- package/dist/agents/toolkits/sql/prompt.d.ts.map +1 -1
- package/dist/agents/toolkits/sql/sql.cjs +0 -1
- package/dist/agents/toolkits/sql/sql.cjs.map +1 -1
- package/dist/agents/toolkits/sql/sql.d.cts +0 -1
- package/dist/agents/toolkits/sql/sql.d.cts.map +1 -1
- package/dist/agents/toolkits/sql/sql.d.ts +0 -1
- package/dist/agents/toolkits/sql/sql.d.ts.map +1 -1
- package/dist/agents/toolkits/sql/sql.js.map +1 -1
- package/dist/agents/toolkits/vectorstore/vectorstore.cjs +0 -1
- package/dist/agents/toolkits/vectorstore/vectorstore.cjs.map +1 -1
- package/dist/agents/toolkits/vectorstore/vectorstore.d.cts +0 -1
- package/dist/agents/toolkits/vectorstore/vectorstore.d.cts.map +1 -1
- package/dist/agents/toolkits/vectorstore/vectorstore.d.ts +0 -1
- package/dist/agents/toolkits/vectorstore/vectorstore.d.ts.map +1 -1
- package/dist/agents/toolkits/vectorstore/vectorstore.js.map +1 -1
- package/dist/agents/types.cjs +0 -1
- package/dist/agents/types.cjs.map +1 -1
- package/dist/agents/types.d.cts +1 -2
- package/dist/agents/types.d.cts.map +1 -1
- package/dist/agents/types.d.ts +1 -2
- package/dist/agents/types.d.ts.map +1 -1
- package/dist/agents/types.js.map +1 -1
- package/dist/agents/xml/index.cjs +6 -6
- package/dist/agents/xml/index.cjs.map +1 -1
- package/dist/agents/xml/index.d.cts +4 -8
- package/dist/agents/xml/index.d.cts.map +1 -1
- package/dist/agents/xml/index.d.ts +4 -8
- package/dist/agents/xml/index.d.ts.map +1 -1
- package/dist/agents/xml/index.js +6 -5
- package/dist/agents/xml/index.js.map +1 -1
- package/dist/agents/xml/output_parser.cjs.map +1 -1
- package/dist/agents/xml/output_parser.d.cts +0 -1
- package/dist/agents/xml/output_parser.d.cts.map +1 -1
- package/dist/agents/xml/output_parser.d.ts +0 -1
- package/dist/agents/xml/output_parser.d.ts.map +1 -1
- package/dist/agents/xml/output_parser.js.map +1 -1
- package/dist/cache/file_system.cjs.map +1 -1
- package/dist/cache/file_system.d.cts +0 -1
- package/dist/cache/file_system.d.cts.map +1 -1
- package/dist/cache/file_system.d.ts +0 -1
- package/dist/cache/file_system.d.ts.map +1 -1
- package/dist/cache/file_system.js.map +1 -1
- package/dist/callbacks/handlers/console.d.cts +0 -3
- package/dist/callbacks/handlers/console.d.ts +0 -3
- package/dist/callbacks/handlers/run_collector.d.cts +0 -3
- package/dist/callbacks/handlers/run_collector.d.ts +0 -3
- package/dist/callbacks/handlers/tracer.d.cts +0 -3
- package/dist/callbacks/handlers/tracer.d.ts +0 -3
- package/dist/callbacks/handlers/tracer_langchain.d.cts +0 -3
- package/dist/callbacks/handlers/tracer_langchain.d.ts +0 -3
- package/dist/callbacks/promises.d.cts +0 -3
- package/dist/callbacks/promises.d.ts +0 -3
- package/dist/chains/analyze_documents_chain.cjs +0 -1
- package/dist/chains/analyze_documents_chain.cjs.map +1 -1
- package/dist/chains/analyze_documents_chain.d.cts +1 -2
- package/dist/chains/analyze_documents_chain.d.cts.map +1 -1
- package/dist/chains/analyze_documents_chain.d.ts +1 -2
- package/dist/chains/analyze_documents_chain.d.ts.map +1 -1
- package/dist/chains/analyze_documents_chain.js.map +1 -1
- package/dist/chains/api/api_chain.cjs.map +1 -1
- package/dist/chains/api/api_chain.d.cts +0 -1
- package/dist/chains/api/api_chain.d.cts.map +1 -1
- package/dist/chains/api/api_chain.d.ts +0 -1
- package/dist/chains/api/api_chain.d.ts.map +1 -1
- package/dist/chains/api/api_chain.js.map +1 -1
- package/dist/chains/api/prompts.cjs +4 -3
- package/dist/chains/api/prompts.cjs.map +1 -1
- package/dist/chains/api/prompts.js +12 -11
- package/dist/chains/api/prompts.js.map +1 -1
- package/dist/chains/base.cjs +0 -1
- package/dist/chains/base.cjs.map +1 -1
- package/dist/chains/base.d.cts +7 -8
- package/dist/chains/base.d.cts.map +1 -1
- package/dist/chains/base.d.ts +7 -8
- package/dist/chains/base.d.ts.map +1 -1
- package/dist/chains/base.js.map +1 -1
- package/dist/chains/chat_vector_db_chain.cjs +0 -1
- package/dist/chains/chat_vector_db_chain.cjs.map +1 -1
- package/dist/chains/chat_vector_db_chain.d.cts +1 -2
- package/dist/chains/chat_vector_db_chain.d.cts.map +1 -1
- package/dist/chains/chat_vector_db_chain.d.ts +1 -2
- package/dist/chains/chat_vector_db_chain.d.ts.map +1 -1
- package/dist/chains/chat_vector_db_chain.js.map +1 -1
- package/dist/chains/combine_docs_chain.cjs +1 -2
- package/dist/chains/combine_docs_chain.cjs.map +1 -1
- package/dist/chains/combine_docs_chain.d.cts +1 -3
- package/dist/chains/combine_docs_chain.d.cts.map +1 -1
- package/dist/chains/combine_docs_chain.d.ts +1 -3
- package/dist/chains/combine_docs_chain.d.ts.map +1 -1
- package/dist/chains/combine_docs_chain.js +1 -1
- package/dist/chains/combine_docs_chain.js.map +1 -1
- package/dist/chains/combine_documents/base.cjs +1 -2
- package/dist/chains/combine_documents/base.cjs.map +1 -1
- package/dist/chains/combine_documents/base.js +1 -1
- package/dist/chains/combine_documents/base.js.map +1 -1
- package/dist/chains/combine_documents/reduce.cjs.map +1 -1
- package/dist/chains/combine_documents/reduce.d.cts +0 -1
- package/dist/chains/combine_documents/reduce.d.cts.map +1 -1
- package/dist/chains/combine_documents/reduce.d.ts +0 -1
- package/dist/chains/combine_documents/reduce.d.ts.map +1 -1
- package/dist/chains/combine_documents/reduce.js.map +1 -1
- package/dist/chains/combine_documents/stuff.cjs +0 -1
- package/dist/chains/combine_documents/stuff.cjs.map +1 -1
- package/dist/chains/combine_documents/stuff.d.cts +1 -8
- package/dist/chains/combine_documents/stuff.d.cts.map +1 -1
- package/dist/chains/combine_documents/stuff.d.ts +1 -8
- package/dist/chains/combine_documents/stuff.d.ts.map +1 -1
- package/dist/chains/combine_documents/stuff.js.map +1 -1
- package/dist/chains/constitutional_ai/constitutional_chain.cjs.map +1 -1
- package/dist/chains/constitutional_ai/constitutional_chain.d.cts +0 -1
- package/dist/chains/constitutional_ai/constitutional_chain.d.cts.map +1 -1
- package/dist/chains/constitutional_ai/constitutional_chain.d.ts +0 -1
- package/dist/chains/constitutional_ai/constitutional_chain.d.ts.map +1 -1
- package/dist/chains/constitutional_ai/constitutional_chain.js.map +1 -1
- package/dist/chains/constitutional_ai/constitutional_principle.cjs +54 -54
- package/dist/chains/constitutional_ai/constitutional_principle.cjs.map +1 -1
- package/dist/chains/constitutional_ai/constitutional_principle.d.cts +1 -6
- package/dist/chains/constitutional_ai/constitutional_principle.d.cts.map +1 -1
- package/dist/chains/constitutional_ai/constitutional_principle.d.ts +1 -6
- package/dist/chains/constitutional_ai/constitutional_principle.d.ts.map +1 -1
- package/dist/chains/constitutional_ai/constitutional_principle.js +54 -54
- package/dist/chains/constitutional_ai/constitutional_principle.js.map +1 -1
- package/dist/chains/constitutional_ai/constitutional_prompts.cjs +5 -4
- package/dist/chains/constitutional_ai/constitutional_prompts.cjs.map +1 -1
- package/dist/chains/constitutional_ai/constitutional_prompts.js +4 -4
- package/dist/chains/constitutional_ai/constitutional_prompts.js.map +1 -1
- package/dist/chains/conversation.cjs +0 -1
- package/dist/chains/conversation.cjs.map +1 -1
- package/dist/chains/conversation.d.cts +1 -7
- package/dist/chains/conversation.d.cts.map +1 -1
- package/dist/chains/conversation.d.ts +1 -7
- package/dist/chains/conversation.d.ts.map +1 -1
- package/dist/chains/conversation.js.map +1 -1
- package/dist/chains/conversational_retrieval_chain.cjs +0 -1
- package/dist/chains/conversational_retrieval_chain.cjs.map +1 -1
- package/dist/chains/conversational_retrieval_chain.d.cts +5 -4
- package/dist/chains/conversational_retrieval_chain.d.cts.map +1 -1
- package/dist/chains/conversational_retrieval_chain.d.ts +5 -4
- package/dist/chains/conversational_retrieval_chain.d.ts.map +1 -1
- package/dist/chains/conversational_retrieval_chain.js.map +1 -1
- package/dist/chains/graph_qa/cypher.cjs +5 -4
- package/dist/chains/graph_qa/cypher.cjs.map +1 -1
- package/dist/chains/graph_qa/cypher.d.cts +0 -1
- package/dist/chains/graph_qa/cypher.d.cts.map +1 -1
- package/dist/chains/graph_qa/cypher.d.ts +0 -1
- package/dist/chains/graph_qa/cypher.d.ts.map +1 -1
- package/dist/chains/graph_qa/cypher.js +5 -4
- package/dist/chains/graph_qa/cypher.js.map +1 -1
- package/dist/chains/graph_qa/prompts.cjs +2 -3
- package/dist/chains/graph_qa/prompts.cjs.map +1 -1
- package/dist/chains/graph_qa/prompts.js +2 -2
- package/dist/chains/graph_qa/prompts.js.map +1 -1
- package/dist/chains/history_aware_retriever.cjs.map +1 -1
- package/dist/chains/history_aware_retriever.d.cts +1 -6
- package/dist/chains/history_aware_retriever.d.cts.map +1 -1
- package/dist/chains/history_aware_retriever.d.ts +1 -6
- package/dist/chains/history_aware_retriever.d.ts.map +1 -1
- package/dist/chains/history_aware_retriever.js.map +1 -1
- package/dist/chains/llm_chain.cjs +0 -1
- package/dist/chains/llm_chain.cjs.map +1 -1
- package/dist/chains/llm_chain.d.cts +0 -1
- package/dist/chains/llm_chain.d.cts.map +1 -1
- package/dist/chains/llm_chain.d.ts +0 -1
- package/dist/chains/llm_chain.d.ts.map +1 -1
- package/dist/chains/llm_chain.js.map +1 -1
- package/dist/chains/load.cjs +1 -1
- package/dist/chains/load.cjs.map +1 -1
- package/dist/chains/load.d.cts +0 -1
- package/dist/chains/load.d.cts.map +1 -1
- package/dist/chains/load.d.ts +0 -1
- package/dist/chains/load.d.ts.map +1 -1
- package/dist/chains/load.js +1 -1
- package/dist/chains/load.js.map +1 -1
- package/dist/chains/openai_functions/base.cjs +0 -1
- package/dist/chains/openai_functions/base.cjs.map +1 -1
- package/dist/chains/openai_functions/base.d.cts +6 -4
- package/dist/chains/openai_functions/base.d.cts.map +1 -1
- package/dist/chains/openai_functions/base.d.ts +6 -4
- package/dist/chains/openai_functions/base.d.ts.map +1 -1
- package/dist/chains/openai_functions/base.js.map +1 -1
- package/dist/chains/openai_functions/extraction.cjs +0 -1
- package/dist/chains/openai_functions/extraction.cjs.map +1 -1
- package/dist/chains/openai_functions/extraction.d.cts +0 -1
- package/dist/chains/openai_functions/extraction.d.cts.map +1 -1
- package/dist/chains/openai_functions/extraction.d.ts +0 -1
- 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/openapi.cjs +1 -1
- package/dist/chains/openai_functions/openapi.cjs.map +1 -1
- package/dist/chains/openai_functions/openapi.d.cts +0 -7
- package/dist/chains/openai_functions/openapi.d.cts.map +1 -1
- package/dist/chains/openai_functions/openapi.d.ts +0 -7
- package/dist/chains/openai_functions/openapi.d.ts.map +1 -1
- package/dist/chains/openai_functions/openapi.js +1 -1
- package/dist/chains/openai_functions/openapi.js.map +1 -1
- package/dist/chains/openai_functions/tagging.cjs +0 -1
- package/dist/chains/openai_functions/tagging.cjs.map +1 -1
- package/dist/chains/openai_functions/tagging.d.cts +0 -1
- package/dist/chains/openai_functions/tagging.d.cts.map +1 -1
- package/dist/chains/openai_functions/tagging.d.ts +0 -1
- package/dist/chains/openai_functions/tagging.d.ts.map +1 -1
- package/dist/chains/openai_functions/tagging.js.map +1 -1
- package/dist/chains/openai_moderation.cjs +0 -1
- package/dist/chains/openai_moderation.cjs.map +1 -1
- package/dist/chains/openai_moderation.d.cts +0 -1
- package/dist/chains/openai_moderation.d.cts.map +1 -1
- package/dist/chains/openai_moderation.d.ts +0 -1
- package/dist/chains/openai_moderation.d.ts.map +1 -1
- package/dist/chains/openai_moderation.js.map +1 -1
- package/dist/chains/query_constructor/index.cjs +6 -3
- package/dist/chains/query_constructor/index.cjs.map +1 -1
- package/dist/chains/query_constructor/index.d.cts +1 -5
- package/dist/chains/query_constructor/index.d.cts.map +1 -1
- package/dist/chains/query_constructor/index.d.ts +1 -5
- package/dist/chains/query_constructor/index.d.ts.map +1 -1
- package/dist/chains/query_constructor/index.js +6 -3
- package/dist/chains/query_constructor/index.js.map +1 -1
- package/dist/chains/query_constructor/parser.cjs +2 -1
- package/dist/chains/query_constructor/parser.cjs.map +1 -1
- package/dist/chains/query_constructor/parser.d.cts +0 -1
- package/dist/chains/query_constructor/parser.d.cts.map +1 -1
- package/dist/chains/query_constructor/parser.d.ts +0 -1
- package/dist/chains/query_constructor/parser.d.ts.map +1 -1
- package/dist/chains/query_constructor/parser.js +2 -0
- package/dist/chains/query_constructor/parser.js.map +1 -1
- package/dist/chains/query_constructor/prompt.cjs +28 -22
- package/dist/chains/query_constructor/prompt.cjs.map +1 -1
- package/dist/chains/query_constructor/prompt.d.cts +0 -1
- package/dist/chains/query_constructor/prompt.d.cts.map +1 -1
- package/dist/chains/query_constructor/prompt.d.ts +0 -1
- package/dist/chains/query_constructor/prompt.d.ts.map +1 -1
- package/dist/chains/query_constructor/prompt.js +25 -22
- package/dist/chains/query_constructor/prompt.js.map +1 -1
- package/dist/chains/question_answering/load.cjs.map +1 -1
- package/dist/chains/question_answering/load.d.cts +0 -1
- package/dist/chains/question_answering/load.d.cts.map +1 -1
- package/dist/chains/question_answering/load.d.ts +0 -1
- package/dist/chains/question_answering/load.d.ts.map +1 -1
- package/dist/chains/question_answering/load.js.map +1 -1
- package/dist/chains/question_answering/map_reduce_prompts.cjs +12 -11
- package/dist/chains/question_answering/map_reduce_prompts.cjs.map +1 -1
- package/dist/chains/question_answering/map_reduce_prompts.js +9 -9
- package/dist/chains/question_answering/map_reduce_prompts.js.map +1 -1
- package/dist/chains/question_answering/refine_prompts.cjs +30 -22
- package/dist/chains/question_answering/refine_prompts.cjs.map +1 -1
- package/dist/chains/question_answering/refine_prompts.js +25 -20
- package/dist/chains/question_answering/refine_prompts.js.map +1 -1
- package/dist/chains/question_answering/stuff_prompts.cjs +6 -6
- package/dist/chains/question_answering/stuff_prompts.cjs.map +1 -1
- package/dist/chains/question_answering/stuff_prompts.js +5 -5
- package/dist/chains/question_answering/stuff_prompts.js.map +1 -1
- package/dist/chains/retrieval.cjs.map +1 -1
- package/dist/chains/retrieval.d.cts +1 -5
- package/dist/chains/retrieval.d.cts.map +1 -1
- package/dist/chains/retrieval.d.ts +1 -5
- package/dist/chains/retrieval.d.ts.map +1 -1
- package/dist/chains/retrieval.js.map +1 -1
- package/dist/chains/retrieval_qa.cjs.map +1 -1
- package/dist/chains/retrieval_qa.d.cts +1 -2
- package/dist/chains/retrieval_qa.d.cts.map +1 -1
- package/dist/chains/retrieval_qa.d.ts +1 -2
- package/dist/chains/retrieval_qa.d.ts.map +1 -1
- package/dist/chains/retrieval_qa.js.map +1 -1
- package/dist/chains/router/llm_router.cjs.map +1 -1
- package/dist/chains/router/llm_router.d.cts +0 -1
- package/dist/chains/router/llm_router.d.cts.map +1 -1
- package/dist/chains/router/llm_router.d.ts +0 -1
- package/dist/chains/router/llm_router.d.ts.map +1 -1
- package/dist/chains/router/llm_router.js.map +1 -1
- package/dist/chains/router/multi_prompt.cjs +0 -1
- package/dist/chains/router/multi_prompt.cjs.map +1 -1
- package/dist/chains/router/multi_prompt.d.cts +1 -10
- package/dist/chains/router/multi_prompt.d.cts.map +1 -1
- package/dist/chains/router/multi_prompt.d.ts +1 -10
- package/dist/chains/router/multi_prompt.d.ts.map +1 -1
- package/dist/chains/router/multi_prompt.js.map +1 -1
- package/dist/chains/router/multi_retrieval_qa.cjs +0 -1
- package/dist/chains/router/multi_retrieval_qa.cjs.map +1 -1
- package/dist/chains/router/multi_retrieval_qa.d.cts +2 -11
- package/dist/chains/router/multi_retrieval_qa.d.cts.map +1 -1
- package/dist/chains/router/multi_retrieval_qa.d.ts +2 -11
- package/dist/chains/router/multi_retrieval_qa.d.ts.map +1 -1
- package/dist/chains/router/multi_retrieval_qa.js.map +1 -1
- package/dist/chains/router/multi_route.cjs.map +1 -1
- package/dist/chains/router/multi_route.d.cts +1 -2
- package/dist/chains/router/multi_route.d.cts.map +1 -1
- package/dist/chains/router/multi_route.d.ts +1 -2
- package/dist/chains/router/multi_route.d.ts.map +1 -1
- package/dist/chains/router/multi_route.js.map +1 -1
- package/dist/chains/router/utils.cjs.map +1 -1
- package/dist/chains/router/utils.js.map +1 -1
- package/dist/chains/sequential_chain.cjs.map +1 -1
- package/dist/chains/sequential_chain.d.cts +0 -4
- package/dist/chains/sequential_chain.d.cts.map +1 -1
- package/dist/chains/sequential_chain.d.ts +0 -4
- package/dist/chains/sequential_chain.d.ts.map +1 -1
- package/dist/chains/sequential_chain.js.map +1 -1
- package/dist/chains/serde.d.cts +1 -2
- package/dist/chains/serde.d.cts.map +1 -1
- package/dist/chains/serde.d.ts +1 -2
- package/dist/chains/serde.d.ts.map +1 -1
- package/dist/chains/sql_db/sql_db_chain.cjs +1 -2
- package/dist/chains/sql_db/sql_db_chain.cjs.map +1 -1
- package/dist/chains/sql_db/sql_db_chain.d.cts +9 -8
- package/dist/chains/sql_db/sql_db_chain.d.cts.map +1 -1
- package/dist/chains/sql_db/sql_db_chain.d.ts +9 -8
- package/dist/chains/sql_db/sql_db_chain.d.ts.map +1 -1
- package/dist/chains/sql_db/sql_db_chain.js +1 -1
- package/dist/chains/sql_db/sql_db_chain.js.map +1 -1
- package/dist/chains/sql_db/sql_db_prompt.cjs +7 -8
- package/dist/chains/sql_db/sql_db_prompt.cjs.map +1 -1
- package/dist/chains/sql_db/sql_db_prompt.d.cts +0 -1
- package/dist/chains/sql_db/sql_db_prompt.d.cts.map +1 -1
- package/dist/chains/sql_db/sql_db_prompt.d.ts +0 -1
- package/dist/chains/sql_db/sql_db_prompt.d.ts.map +1 -1
- package/dist/chains/sql_db/sql_db_prompt.js +7 -7
- package/dist/chains/sql_db/sql_db_prompt.js.map +1 -1
- package/dist/chains/summarization/load.cjs.map +1 -1
- package/dist/chains/summarization/load.d.cts +0 -1
- package/dist/chains/summarization/load.d.cts.map +1 -1
- package/dist/chains/summarization/load.d.ts +0 -1
- package/dist/chains/summarization/load.d.ts.map +1 -1
- package/dist/chains/summarization/load.js.map +1 -1
- package/dist/chains/summarization/refine_prompts.cjs +1 -2
- package/dist/chains/summarization/refine_prompts.cjs.map +1 -1
- package/dist/chains/summarization/refine_prompts.js +1 -1
- package/dist/chains/summarization/refine_prompts.js.map +1 -1
- package/dist/chains/summarization/stuff_prompts.cjs +1 -2
- package/dist/chains/summarization/stuff_prompts.cjs.map +1 -1
- package/dist/chains/summarization/stuff_prompts.js +1 -1
- package/dist/chains/summarization/stuff_prompts.js.map +1 -1
- package/dist/chains/transform.cjs.map +1 -1
- package/dist/chains/transform.d.cts +0 -1
- package/dist/chains/transform.d.cts.map +1 -1
- package/dist/chains/transform.d.ts +0 -1
- package/dist/chains/transform.d.ts.map +1 -1
- package/dist/chains/transform.js.map +1 -1
- package/dist/chains/vector_db_qa.cjs.map +1 -1
- package/dist/chains/vector_db_qa.d.cts +1 -2
- package/dist/chains/vector_db_qa.d.cts.map +1 -1
- package/dist/chains/vector_db_qa.d.ts +1 -2
- package/dist/chains/vector_db_qa.d.ts.map +1 -1
- package/dist/chains/vector_db_qa.js.map +1 -1
- package/dist/chat_models/universal.cjs.map +1 -1
- package/dist/chat_models/universal.d.cts +0 -1
- package/dist/chat_models/universal.d.cts.map +1 -1
- package/dist/chat_models/universal.d.ts +0 -1
- package/dist/chat_models/universal.d.ts.map +1 -1
- package/dist/chat_models/universal.js.map +1 -1
- package/dist/document_loaders/fs/buffer.cjs +1 -0
- package/dist/document_loaders/fs/buffer.cjs.map +1 -1
- package/dist/document_loaders/fs/buffer.d.cts +0 -1
- package/dist/document_loaders/fs/buffer.d.cts.map +1 -1
- package/dist/document_loaders/fs/buffer.d.ts +0 -1
- package/dist/document_loaders/fs/buffer.d.ts.map +1 -1
- package/dist/document_loaders/fs/buffer.js +1 -0
- package/dist/document_loaders/fs/buffer.js.map +1 -1
- package/dist/document_loaders/fs/directory.cjs +4 -0
- 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 +4 -0
- package/dist/document_loaders/fs/directory.js.map +1 -1
- package/dist/document_loaders/fs/json.cjs +1 -0
- package/dist/document_loaders/fs/json.cjs.map +1 -1
- package/dist/document_loaders/fs/json.d.cts +0 -1
- package/dist/document_loaders/fs/json.d.cts.map +1 -1
- package/dist/document_loaders/fs/json.d.ts +0 -1
- package/dist/document_loaders/fs/json.d.ts.map +1 -1
- package/dist/document_loaders/fs/json.js +1 -0
- package/dist/document_loaders/fs/json.js.map +1 -1
- package/dist/document_loaders/fs/multi_file.cjs +3 -0
- package/dist/document_loaders/fs/multi_file.cjs.map +1 -1
- package/dist/document_loaders/fs/multi_file.d.cts +0 -1
- package/dist/document_loaders/fs/multi_file.d.cts.map +1 -1
- package/dist/document_loaders/fs/multi_file.d.ts +0 -1
- package/dist/document_loaders/fs/multi_file.d.ts.map +1 -1
- package/dist/document_loaders/fs/multi_file.js +3 -0
- package/dist/document_loaders/fs/multi_file.js.map +1 -1
- package/dist/document_loaders/fs/text.cjs +1 -0
- package/dist/document_loaders/fs/text.cjs.map +1 -1
- package/dist/document_loaders/fs/text.d.cts +0 -1
- package/dist/document_loaders/fs/text.d.cts.map +1 -1
- package/dist/document_loaders/fs/text.d.ts +0 -1
- package/dist/document_loaders/fs/text.d.ts.map +1 -1
- package/dist/document_loaders/fs/text.js +1 -0
- package/dist/document_loaders/fs/text.js.map +1 -1
- package/dist/document_transformers/openai_functions.cjs.map +1 -1
- package/dist/document_transformers/openai_functions.d.cts +1 -1
- package/dist/document_transformers/openai_functions.d.cts.map +1 -1
- package/dist/document_transformers/openai_functions.d.ts +1 -1
- package/dist/document_transformers/openai_functions.d.ts.map +1 -1
- package/dist/document_transformers/openai_functions.js.map +1 -1
- package/dist/embeddings/cache_backed.cjs.map +1 -1
- package/dist/embeddings/cache_backed.d.cts +0 -1
- package/dist/embeddings/cache_backed.d.cts.map +1 -1
- package/dist/embeddings/cache_backed.d.ts +0 -1
- package/dist/embeddings/cache_backed.d.ts.map +1 -1
- package/dist/embeddings/cache_backed.js.map +1 -1
- package/dist/evaluation/agents/index.cjs +3 -1
- package/dist/evaluation/agents/index.d.cts +2 -1
- package/dist/evaluation/agents/index.d.ts +2 -1
- package/dist/evaluation/agents/index.js +2 -2
- package/dist/evaluation/agents/prompt.cjs +10 -11
- package/dist/evaluation/agents/prompt.cjs.map +1 -1
- package/dist/evaluation/agents/prompt.js +10 -10
- package/dist/evaluation/agents/prompt.js.map +1 -1
- package/dist/evaluation/agents/trajectory.cjs +0 -1
- package/dist/evaluation/agents/trajectory.cjs.map +1 -1
- package/dist/evaluation/agents/trajectory.d.cts +1 -3
- package/dist/evaluation/agents/trajectory.d.cts.map +1 -1
- package/dist/evaluation/agents/trajectory.d.ts +1 -3
- package/dist/evaluation/agents/trajectory.d.ts.map +1 -1
- package/dist/evaluation/agents/trajectory.js.map +1 -1
- package/dist/evaluation/base.cjs +2 -0
- package/dist/evaluation/base.cjs.map +1 -1
- package/dist/evaluation/base.d.cts +2 -2
- package/dist/evaluation/base.d.cts.map +1 -1
- package/dist/evaluation/base.d.ts +2 -2
- package/dist/evaluation/base.d.ts.map +1 -1
- package/dist/evaluation/base.js +1 -1
- package/dist/evaluation/base.js.map +1 -1
- package/dist/evaluation/comparison/index.cjs +4 -1
- package/dist/evaluation/comparison/index.d.cts +2 -1
- package/dist/evaluation/comparison/index.d.ts +2 -1
- package/dist/evaluation/comparison/index.js +2 -2
- package/dist/evaluation/comparison/pairwise.cjs +2 -3
- package/dist/evaluation/comparison/pairwise.cjs.map +1 -1
- package/dist/evaluation/comparison/pairwise.d.cts +2 -4
- package/dist/evaluation/comparison/pairwise.d.cts.map +1 -1
- package/dist/evaluation/comparison/pairwise.d.ts +2 -4
- package/dist/evaluation/comparison/pairwise.d.ts.map +1 -1
- package/dist/evaluation/comparison/pairwise.js +2 -2
- package/dist/evaluation/comparison/pairwise.js.map +1 -1
- package/dist/evaluation/comparison/prompt.cjs +2 -3
- package/dist/evaluation/comparison/prompt.cjs.map +1 -1
- package/dist/evaluation/comparison/prompt.js +2 -2
- package/dist/evaluation/comparison/prompt.js.map +1 -1
- package/dist/evaluation/criteria/criteria.cjs +2 -3
- package/dist/evaluation/criteria/criteria.cjs.map +1 -1
- package/dist/evaluation/criteria/criteria.d.cts +3 -9
- package/dist/evaluation/criteria/criteria.d.cts.map +1 -1
- package/dist/evaluation/criteria/criteria.d.ts +3 -9
- package/dist/evaluation/criteria/criteria.d.ts.map +1 -1
- package/dist/evaluation/criteria/criteria.js +2 -2
- package/dist/evaluation/criteria/criteria.js.map +1 -1
- package/dist/evaluation/criteria/index.cjs +4 -1
- package/dist/evaluation/criteria/index.d.cts +2 -1
- package/dist/evaluation/criteria/index.d.ts +2 -1
- package/dist/evaluation/criteria/index.js +2 -2
- package/dist/evaluation/criteria/prompt.cjs +2 -3
- package/dist/evaluation/criteria/prompt.cjs.map +1 -1
- package/dist/evaluation/criteria/prompt.js +2 -2
- package/dist/evaluation/criteria/prompt.js.map +1 -1
- package/dist/evaluation/embedding_distance/base.cjs.map +1 -1
- package/dist/evaluation/embedding_distance/base.d.cts +0 -1
- package/dist/evaluation/embedding_distance/base.d.cts.map +1 -1
- package/dist/evaluation/embedding_distance/base.d.ts +0 -1
- package/dist/evaluation/embedding_distance/base.d.ts.map +1 -1
- package/dist/evaluation/embedding_distance/base.js.map +1 -1
- package/dist/evaluation/embedding_distance/index.cjs +5 -1
- package/dist/evaluation/embedding_distance/index.d.cts +2 -1
- package/dist/evaluation/embedding_distance/index.d.ts +2 -1
- package/dist/evaluation/embedding_distance/index.js +2 -2
- package/dist/evaluation/index.d.cts +5 -0
- package/dist/evaluation/index.d.ts +5 -0
- package/dist/evaluation/loader.cjs +0 -1
- package/dist/evaluation/loader.cjs.map +1 -1
- package/dist/evaluation/loader.d.cts +2 -1
- package/dist/evaluation/loader.d.cts.map +1 -1
- package/dist/evaluation/loader.d.ts +2 -1
- package/dist/evaluation/loader.d.ts.map +1 -1
- package/dist/evaluation/loader.js.map +1 -1
- package/dist/evaluation/qa/eval_chain.cjs +3 -2
- package/dist/evaluation/qa/eval_chain.cjs.map +1 -1
- package/dist/evaluation/qa/eval_chain.d.cts +1 -2
- package/dist/evaluation/qa/eval_chain.d.cts.map +1 -1
- package/dist/evaluation/qa/eval_chain.d.ts +1 -2
- package/dist/evaluation/qa/eval_chain.d.ts.map +1 -1
- package/dist/evaluation/qa/eval_chain.js +3 -2
- package/dist/evaluation/qa/eval_chain.js.map +1 -1
- package/dist/evaluation/qa/index.cjs +2 -1
- package/dist/evaluation/qa/index.d.cts +2 -1
- package/dist/evaluation/qa/index.d.ts +2 -1
- package/dist/evaluation/qa/index.js +2 -2
- package/dist/evaluation/qa/prompt.cjs +1 -2
- package/dist/evaluation/qa/prompt.cjs.map +1 -1
- package/dist/evaluation/qa/prompt.js +1 -1
- package/dist/evaluation/qa/prompt.js.map +1 -1
- package/dist/evaluation/types.d.cts +0 -1
- package/dist/evaluation/types.d.cts.map +1 -1
- package/dist/evaluation/types.d.ts +0 -1
- package/dist/evaluation/types.d.ts.map +1 -1
- package/dist/experimental/autogpt/agent.cjs +11 -11
- package/dist/experimental/autogpt/agent.cjs.map +1 -1
- package/dist/experimental/autogpt/agent.d.cts +2 -17
- package/dist/experimental/autogpt/agent.d.cts.map +1 -1
- package/dist/experimental/autogpt/agent.d.ts +2 -17
- package/dist/experimental/autogpt/agent.d.ts.map +1 -1
- package/dist/experimental/autogpt/agent.js +11 -10
- package/dist/experimental/autogpt/agent.js.map +1 -1
- package/dist/experimental/autogpt/output_parser.cjs +0 -1
- package/dist/experimental/autogpt/output_parser.cjs.map +1 -1
- package/dist/experimental/autogpt/output_parser.d.cts +0 -1
- package/dist/experimental/autogpt/output_parser.d.cts.map +1 -1
- package/dist/experimental/autogpt/output_parser.d.ts +0 -1
- package/dist/experimental/autogpt/output_parser.d.ts.map +1 -1
- package/dist/experimental/autogpt/output_parser.js.map +1 -1
- package/dist/experimental/autogpt/prompt.cjs +0 -1
- package/dist/experimental/autogpt/prompt.cjs.map +1 -1
- package/dist/experimental/autogpt/prompt.d.cts +2 -9
- package/dist/experimental/autogpt/prompt.d.cts.map +1 -1
- package/dist/experimental/autogpt/prompt.d.ts +2 -9
- package/dist/experimental/autogpt/prompt.d.ts.map +1 -1
- package/dist/experimental/autogpt/prompt.js.map +1 -1
- package/dist/experimental/autogpt/prompt_generator.cjs +1 -1
- package/dist/experimental/autogpt/prompt_generator.cjs.map +1 -1
- package/dist/experimental/autogpt/prompt_generator.js +1 -1
- package/dist/experimental/autogpt/prompt_generator.js.map +1 -1
- package/dist/experimental/autogpt/schema.d.cts +0 -1
- package/dist/experimental/autogpt/schema.d.cts.map +1 -1
- package/dist/experimental/autogpt/schema.d.ts +0 -1
- package/dist/experimental/autogpt/schema.d.ts.map +1 -1
- package/dist/experimental/babyagi/agent.cjs +12 -11
- package/dist/experimental/babyagi/agent.cjs.map +1 -1
- package/dist/experimental/babyagi/agent.d.cts +3 -22
- package/dist/experimental/babyagi/agent.d.cts.map +1 -1
- package/dist/experimental/babyagi/agent.d.ts +3 -22
- package/dist/experimental/babyagi/agent.d.ts.map +1 -1
- package/dist/experimental/babyagi/agent.js +12 -10
- package/dist/experimental/babyagi/agent.js.map +1 -1
- package/dist/experimental/babyagi/task_creation.cjs +10 -10
- package/dist/experimental/babyagi/task_creation.cjs.map +1 -1
- package/dist/experimental/babyagi/task_creation.d.cts +0 -1
- package/dist/experimental/babyagi/task_creation.d.cts.map +1 -1
- package/dist/experimental/babyagi/task_creation.d.ts +0 -1
- package/dist/experimental/babyagi/task_creation.d.ts.map +1 -1
- package/dist/experimental/babyagi/task_creation.js +10 -9
- package/dist/experimental/babyagi/task_creation.js.map +1 -1
- package/dist/experimental/babyagi/task_execution.cjs +9 -9
- package/dist/experimental/babyagi/task_execution.cjs.map +1 -1
- package/dist/experimental/babyagi/task_execution.d.cts +0 -1
- package/dist/experimental/babyagi/task_execution.d.cts.map +1 -1
- package/dist/experimental/babyagi/task_execution.d.ts +0 -1
- package/dist/experimental/babyagi/task_execution.d.ts.map +1 -1
- package/dist/experimental/babyagi/task_execution.js +9 -8
- package/dist/experimental/babyagi/task_execution.js.map +1 -1
- package/dist/experimental/babyagi/task_prioritization.cjs +9 -9
- package/dist/experimental/babyagi/task_prioritization.cjs.map +1 -1
- package/dist/experimental/babyagi/task_prioritization.d.cts +0 -1
- package/dist/experimental/babyagi/task_prioritization.d.cts.map +1 -1
- package/dist/experimental/babyagi/task_prioritization.d.ts +0 -1
- package/dist/experimental/babyagi/task_prioritization.d.ts.map +1 -1
- package/dist/experimental/babyagi/task_prioritization.js +9 -8
- package/dist/experimental/babyagi/task_prioritization.js.map +1 -1
- package/dist/experimental/chains/violation_of_expectations/types.cjs.map +1 -1
- package/dist/experimental/chains/violation_of_expectations/types.d.cts +0 -1
- package/dist/experimental/chains/violation_of_expectations/types.d.cts.map +1 -1
- package/dist/experimental/chains/violation_of_expectations/types.d.ts +0 -1
- package/dist/experimental/chains/violation_of_expectations/types.d.ts.map +1 -1
- package/dist/experimental/chains/violation_of_expectations/types.js.map +1 -1
- package/dist/experimental/chains/violation_of_expectations/violation_of_expectations_chain.cjs +0 -1
- package/dist/experimental/chains/violation_of_expectations/violation_of_expectations_chain.cjs.map +1 -1
- package/dist/experimental/chains/violation_of_expectations/violation_of_expectations_chain.d.cts +53 -1
- package/dist/experimental/chains/violation_of_expectations/violation_of_expectations_chain.d.cts.map +1 -1
- package/dist/experimental/chains/violation_of_expectations/violation_of_expectations_chain.d.ts +53 -1
- package/dist/experimental/chains/violation_of_expectations/violation_of_expectations_chain.d.ts.map +1 -1
- package/dist/experimental/chains/violation_of_expectations/violation_of_expectations_chain.js.map +1 -1
- package/dist/experimental/chains/violation_of_expectations/violation_of_expectations_prompt.cjs +4 -5
- package/dist/experimental/chains/violation_of_expectations/violation_of_expectations_prompt.cjs.map +1 -1
- package/dist/experimental/chains/violation_of_expectations/violation_of_expectations_prompt.js +4 -4
- package/dist/experimental/chains/violation_of_expectations/violation_of_expectations_prompt.js.map +1 -1
- package/dist/experimental/generative_agents/generative_agent.cjs +0 -1
- package/dist/experimental/generative_agents/generative_agent.cjs.map +1 -1
- package/dist/experimental/generative_agents/generative_agent.d.cts +1 -2
- package/dist/experimental/generative_agents/generative_agent.d.cts.map +1 -1
- package/dist/experimental/generative_agents/generative_agent.d.ts +1 -2
- package/dist/experimental/generative_agents/generative_agent.d.ts.map +1 -1
- package/dist/experimental/generative_agents/generative_agent.js.map +1 -1
- package/dist/experimental/generative_agents/generative_agent_memory.cjs +0 -1
- package/dist/experimental/generative_agents/generative_agent_memory.cjs.map +1 -1
- package/dist/experimental/generative_agents/generative_agent_memory.d.cts +1 -2
- package/dist/experimental/generative_agents/generative_agent_memory.d.cts.map +1 -1
- package/dist/experimental/generative_agents/generative_agent_memory.d.ts +1 -2
- package/dist/experimental/generative_agents/generative_agent_memory.d.ts.map +1 -1
- package/dist/experimental/generative_agents/generative_agent_memory.js.map +1 -1
- package/dist/experimental/masking/parser.cjs.map +1 -1
- package/dist/experimental/masking/parser.d.cts +0 -1
- package/dist/experimental/masking/parser.d.cts.map +1 -1
- package/dist/experimental/masking/parser.d.ts +0 -1
- package/dist/experimental/masking/parser.d.ts.map +1 -1
- package/dist/experimental/masking/parser.js.map +1 -1
- package/dist/experimental/masking/regex_masking_transformer.cjs.map +1 -1
- package/dist/experimental/masking/regex_masking_transformer.d.cts +0 -1
- package/dist/experimental/masking/regex_masking_transformer.d.cts.map +1 -1
- package/dist/experimental/masking/regex_masking_transformer.d.ts +0 -1
- package/dist/experimental/masking/regex_masking_transformer.d.ts.map +1 -1
- package/dist/experimental/masking/regex_masking_transformer.js.map +1 -1
- package/dist/experimental/masking/transformer.cjs.map +1 -1
- package/dist/experimental/masking/transformer.d.cts.map +1 -1
- package/dist/experimental/masking/transformer.d.ts.map +1 -1
- package/dist/experimental/masking/transformer.js.map +1 -1
- package/dist/experimental/masking/types.d.cts +0 -1
- package/dist/experimental/masking/types.d.cts.map +1 -1
- package/dist/experimental/masking/types.d.ts +0 -1
- package/dist/experimental/masking/types.d.ts.map +1 -1
- package/dist/experimental/openai_assistant/index.cjs.map +1 -1
- package/dist/experimental/openai_assistant/index.d.cts +2 -18
- package/dist/experimental/openai_assistant/index.d.cts.map +1 -1
- package/dist/experimental/openai_assistant/index.d.ts +2 -18
- package/dist/experimental/openai_assistant/index.d.ts.map +1 -1
- package/dist/experimental/openai_assistant/index.js.map +1 -1
- package/dist/experimental/openai_assistant/schema.d.cts +0 -1
- package/dist/experimental/openai_assistant/schema.d.cts.map +1 -1
- package/dist/experimental/openai_assistant/schema.d.ts +0 -1
- package/dist/experimental/openai_assistant/schema.d.ts.map +1 -1
- package/dist/experimental/openai_files/index.cjs.map +1 -1
- package/dist/experimental/openai_files/index.d.cts +4 -18
- package/dist/experimental/openai_files/index.d.cts.map +1 -1
- package/dist/experimental/openai_files/index.d.ts +4 -18
- package/dist/experimental/openai_files/index.d.ts.map +1 -1
- package/dist/experimental/openai_files/index.js.map +1 -1
- package/dist/experimental/plan_and_execute/agent_executor.cjs +1 -0
- package/dist/experimental/plan_and_execute/agent_executor.cjs.map +1 -1
- package/dist/experimental/plan_and_execute/agent_executor.d.cts +4 -16
- package/dist/experimental/plan_and_execute/agent_executor.d.cts.map +1 -1
- package/dist/experimental/plan_and_execute/agent_executor.d.ts +4 -16
- package/dist/experimental/plan_and_execute/agent_executor.d.ts.map +1 -1
- package/dist/experimental/plan_and_execute/agent_executor.js +1 -1
- package/dist/experimental/plan_and_execute/agent_executor.js.map +1 -1
- package/dist/experimental/plan_and_execute/base.cjs +3 -0
- package/dist/experimental/plan_and_execute/base.cjs.map +1 -1
- package/dist/experimental/plan_and_execute/base.d.cts +0 -1
- package/dist/experimental/plan_and_execute/base.d.cts.map +1 -1
- package/dist/experimental/plan_and_execute/base.d.ts +0 -1
- package/dist/experimental/plan_and_execute/base.d.ts.map +1 -1
- package/dist/experimental/plan_and_execute/base.js +3 -0
- package/dist/experimental/plan_and_execute/base.js.map +1 -1
- package/dist/experimental/plan_and_execute/outputParser.cjs +0 -1
- package/dist/experimental/plan_and_execute/outputParser.cjs.map +1 -1
- package/dist/experimental/plan_and_execute/outputParser.d.cts +0 -1
- package/dist/experimental/plan_and_execute/outputParser.d.cts.map +1 -1
- package/dist/experimental/plan_and_execute/outputParser.d.ts +0 -1
- package/dist/experimental/plan_and_execute/outputParser.d.ts.map +1 -1
- package/dist/experimental/plan_and_execute/outputParser.js.map +1 -1
- package/dist/experimental/plan_and_execute/prompt.cjs +1 -2
- package/dist/experimental/plan_and_execute/prompt.cjs.map +1 -1
- package/dist/experimental/plan_and_execute/prompt.js +1 -1
- package/dist/experimental/plan_and_execute/prompt.js.map +1 -1
- package/dist/experimental/prompts/custom_format.cjs.map +1 -1
- package/dist/experimental/prompts/custom_format.d.cts +1 -5
- package/dist/experimental/prompts/custom_format.d.cts.map +1 -1
- package/dist/experimental/prompts/custom_format.d.ts +1 -5
- package/dist/experimental/prompts/custom_format.d.ts.map +1 -1
- package/dist/experimental/prompts/custom_format.js.map +1 -1
- package/dist/experimental/prompts/handlebars.cjs.map +1 -1
- package/dist/experimental/prompts/handlebars.d.cts +0 -1
- package/dist/experimental/prompts/handlebars.d.cts.map +1 -1
- package/dist/experimental/prompts/handlebars.d.ts +0 -1
- package/dist/experimental/prompts/handlebars.d.ts.map +1 -1
- package/dist/experimental/prompts/handlebars.js.map +1 -1
- package/dist/hub/base.cjs.map +1 -1
- package/dist/hub/base.d.cts +5 -2
- package/dist/hub/base.d.cts.map +1 -1
- package/dist/hub/base.d.ts +5 -2
- package/dist/hub/base.d.ts.map +1 -1
- package/dist/hub/base.js.map +1 -1
- package/dist/hub/index.cjs.map +1 -1
- package/dist/hub/index.d.cts +0 -1
- package/dist/hub/index.d.cts.map +1 -1
- package/dist/hub/index.d.ts +0 -1
- package/dist/hub/index.d.ts.map +1 -1
- package/dist/hub/index.js.map +1 -1
- package/dist/hub/node.cjs.map +1 -1
- package/dist/hub/node.d.cts +0 -1
- package/dist/hub/node.d.cts.map +1 -1
- package/dist/hub/node.d.ts +0 -1
- package/dist/hub/node.d.ts.map +1 -1
- package/dist/hub/node.js.map +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js.map +1 -1
- package/dist/load/import_constants.cjs.map +1 -1
- package/dist/load/import_constants.js.map +1 -1
- package/dist/load/import_map.cjs +547 -0
- package/dist/load/import_map.cjs.map +1 -1
- package/dist/load/import_map.js +1 -1
- package/dist/load/import_map.js.map +1 -1
- package/dist/load/import_type.d.cts.map +1 -1
- package/dist/load/import_type.d.ts.map +1 -1
- package/dist/load/index.cjs +0 -1
- package/dist/load/index.cjs.map +1 -1
- package/dist/load/index.d.cts +0 -1
- package/dist/load/index.d.cts.map +1 -1
- package/dist/load/index.d.ts +0 -1
- package/dist/load/index.d.ts.map +1 -1
- package/dist/load/index.js.map +1 -1
- package/dist/load/map_keys.d.cts.map +1 -1
- package/dist/load/map_keys.d.ts.map +1 -1
- package/dist/memory/buffer_memory.cjs +0 -1
- package/dist/memory/buffer_memory.cjs.map +1 -1
- package/dist/memory/buffer_memory.d.cts +0 -1
- package/dist/memory/buffer_memory.d.cts.map +1 -1
- package/dist/memory/buffer_memory.d.ts +0 -1
- package/dist/memory/buffer_memory.d.ts.map +1 -1
- package/dist/memory/buffer_memory.js.map +1 -1
- package/dist/memory/buffer_token_memory.cjs +0 -1
- package/dist/memory/buffer_token_memory.cjs.map +1 -1
- package/dist/memory/buffer_token_memory.d.cts +0 -1
- package/dist/memory/buffer_token_memory.d.cts.map +1 -1
- package/dist/memory/buffer_token_memory.d.ts +0 -1
- package/dist/memory/buffer_token_memory.d.ts.map +1 -1
- package/dist/memory/buffer_token_memory.js.map +1 -1
- package/dist/memory/buffer_window_memory.cjs +0 -1
- package/dist/memory/buffer_window_memory.cjs.map +1 -1
- package/dist/memory/buffer_window_memory.d.cts +0 -1
- package/dist/memory/buffer_window_memory.d.cts.map +1 -1
- package/dist/memory/buffer_window_memory.d.ts +0 -1
- package/dist/memory/buffer_window_memory.d.ts.map +1 -1
- package/dist/memory/buffer_window_memory.js.map +1 -1
- package/dist/memory/chat_memory.cjs.map +1 -1
- package/dist/memory/chat_memory.d.cts +0 -1
- package/dist/memory/chat_memory.d.cts.map +1 -1
- package/dist/memory/chat_memory.d.ts +0 -1
- package/dist/memory/chat_memory.d.ts.map +1 -1
- package/dist/memory/chat_memory.js.map +1 -1
- package/dist/memory/combined_memory.cjs.map +1 -1
- package/dist/memory/combined_memory.d.cts +0 -1
- package/dist/memory/combined_memory.d.cts.map +1 -1
- package/dist/memory/combined_memory.d.ts +0 -1
- package/dist/memory/combined_memory.d.ts.map +1 -1
- package/dist/memory/combined_memory.js.map +1 -1
- package/dist/memory/entity_memory.cjs +0 -1
- package/dist/memory/entity_memory.cjs.map +1 -1
- package/dist/memory/entity_memory.d.cts +1 -2
- package/dist/memory/entity_memory.d.cts.map +1 -1
- package/dist/memory/entity_memory.d.ts +1 -2
- package/dist/memory/entity_memory.d.ts.map +1 -1
- package/dist/memory/entity_memory.js.map +1 -1
- package/dist/memory/prompt.cjs +28 -23
- package/dist/memory/prompt.cjs.map +1 -1
- package/dist/memory/prompt.d.cts +0 -1
- package/dist/memory/prompt.d.cts.map +1 -1
- package/dist/memory/prompt.d.ts +0 -1
- package/dist/memory/prompt.d.ts.map +1 -1
- package/dist/memory/prompt.js +26 -23
- package/dist/memory/prompt.js.map +1 -1
- package/dist/memory/stores/entity/base.cjs +0 -1
- package/dist/memory/stores/entity/base.cjs.map +1 -1
- package/dist/memory/stores/entity/base.d.cts +0 -1
- package/dist/memory/stores/entity/base.d.cts.map +1 -1
- package/dist/memory/stores/entity/base.d.ts +0 -1
- package/dist/memory/stores/entity/base.d.ts.map +1 -1
- package/dist/memory/stores/entity/base.js.map +1 -1
- package/dist/memory/stores/entity/in_memory.cjs.map +1 -1
- package/dist/memory/stores/entity/in_memory.js.map +1 -1
- package/dist/memory/summary.cjs +0 -1
- package/dist/memory/summary.cjs.map +1 -1
- package/dist/memory/summary.d.cts +0 -1
- package/dist/memory/summary.d.cts.map +1 -1
- package/dist/memory/summary.d.ts +0 -1
- package/dist/memory/summary.d.ts.map +1 -1
- package/dist/memory/summary.js.map +1 -1
- package/dist/memory/summary_buffer.cjs +0 -1
- package/dist/memory/summary_buffer.cjs.map +1 -1
- package/dist/memory/summary_buffer.d.cts +0 -1
- package/dist/memory/summary_buffer.d.cts.map +1 -1
- package/dist/memory/summary_buffer.d.ts +0 -1
- package/dist/memory/summary_buffer.d.ts.map +1 -1
- package/dist/memory/summary_buffer.js.map +1 -1
- package/dist/memory/vector_store.cjs +0 -1
- package/dist/memory/vector_store.cjs.map +1 -1
- package/dist/memory/vector_store.d.cts +0 -1
- package/dist/memory/vector_store.d.cts.map +1 -1
- package/dist/memory/vector_store.d.ts +0 -1
- package/dist/memory/vector_store.d.ts.map +1 -1
- package/dist/memory/vector_store.js.map +1 -1
- package/dist/output_parsers/combining.cjs +0 -1
- package/dist/output_parsers/combining.cjs.map +1 -1
- package/dist/output_parsers/combining.d.cts +1 -2
- package/dist/output_parsers/combining.d.cts.map +1 -1
- package/dist/output_parsers/combining.d.ts +1 -2
- package/dist/output_parsers/combining.d.ts.map +1 -1
- package/dist/output_parsers/combining.js.map +1 -1
- package/dist/output_parsers/datetime.cjs +0 -1
- package/dist/output_parsers/datetime.cjs.map +1 -1
- package/dist/output_parsers/datetime.d.cts +0 -1
- package/dist/output_parsers/datetime.d.cts.map +1 -1
- package/dist/output_parsers/datetime.d.ts +0 -1
- package/dist/output_parsers/datetime.d.ts.map +1 -1
- package/dist/output_parsers/datetime.js.map +1 -1
- package/dist/output_parsers/expression.cjs.map +1 -1
- package/dist/output_parsers/expression.d.cts +0 -1
- package/dist/output_parsers/expression.d.cts.map +1 -1
- package/dist/output_parsers/expression.d.ts +0 -1
- package/dist/output_parsers/expression.d.ts.map +1 -1
- package/dist/output_parsers/expression.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 -0
- package/dist/output_parsers/expression_type_handlers/base.cjs.map +1 -1
- package/dist/output_parsers/expression_type_handlers/base.d.cts +0 -1
- package/dist/output_parsers/expression_type_handlers/base.d.cts.map +1 -1
- package/dist/output_parsers/expression_type_handlers/base.d.ts +0 -1
- package/dist/output_parsers/expression_type_handlers/base.d.ts.map +1 -1
- package/dist/output_parsers/expression_type_handlers/base.js +1 -0
- package/dist/output_parsers/expression_type_handlers/base.js.map +1 -1
- package/dist/output_parsers/expression_type_handlers/boolean_literal_handler.cjs.map +1 -1
- package/dist/output_parsers/expression_type_handlers/boolean_literal_handler.js.map +1 -1
- package/dist/output_parsers/expression_type_handlers/call_expression_handler.cjs.map +1 -1
- package/dist/output_parsers/expression_type_handlers/call_expression_handler.js.map +1 -1
- package/dist/output_parsers/expression_type_handlers/factory.cjs.map +1 -1
- package/dist/output_parsers/expression_type_handlers/factory.d.cts +0 -1
- package/dist/output_parsers/expression_type_handlers/factory.d.cts.map +1 -1
- package/dist/output_parsers/expression_type_handlers/factory.d.ts +0 -1
- package/dist/output_parsers/expression_type_handlers/factory.d.ts.map +1 -1
- package/dist/output_parsers/expression_type_handlers/factory.js.map +1 -1
- package/dist/output_parsers/expression_type_handlers/identifier_handler.cjs.map +1 -1
- package/dist/output_parsers/expression_type_handlers/identifier_handler.js.map +1 -1
- package/dist/output_parsers/expression_type_handlers/member_expression_handler.cjs.map +1 -1
- package/dist/output_parsers/expression_type_handlers/member_expression_handler.js.map +1 -1
- package/dist/output_parsers/expression_type_handlers/numeric_literal_handler.cjs.map +1 -1
- package/dist/output_parsers/expression_type_handlers/numeric_literal_handler.js.map +1 -1
- package/dist/output_parsers/expression_type_handlers/object_literal_expression_handler.cjs.map +1 -1
- package/dist/output_parsers/expression_type_handlers/object_literal_expression_handler.js.map +1 -1
- package/dist/output_parsers/expression_type_handlers/property_assignment_handler.cjs.map +1 -1
- package/dist/output_parsers/expression_type_handlers/property_assignment_handler.js.map +1 -1
- package/dist/output_parsers/expression_type_handlers/string_literal_handler.cjs.map +1 -1
- package/dist/output_parsers/expression_type_handlers/string_literal_handler.js.map +1 -1
- package/dist/output_parsers/expression_type_handlers/types.d.cts.map +1 -1
- package/dist/output_parsers/expression_type_handlers/types.d.ts.map +1 -1
- package/dist/output_parsers/fix.cjs +5 -5
- package/dist/output_parsers/fix.cjs.map +1 -1
- package/dist/output_parsers/fix.d.cts +1 -5
- package/dist/output_parsers/fix.d.cts.map +1 -1
- package/dist/output_parsers/fix.d.ts +1 -5
- package/dist/output_parsers/fix.d.ts.map +1 -1
- package/dist/output_parsers/fix.js +5 -4
- package/dist/output_parsers/fix.js.map +1 -1
- package/dist/output_parsers/http_response.cjs +0 -1
- package/dist/output_parsers/http_response.cjs.map +1 -1
- package/dist/output_parsers/http_response.d.cts +0 -1
- package/dist/output_parsers/http_response.d.cts.map +1 -1
- package/dist/output_parsers/http_response.d.ts +0 -1
- package/dist/output_parsers/http_response.d.ts.map +1 -1
- package/dist/output_parsers/http_response.js.map +1 -1
- package/dist/output_parsers/noop.cjs +0 -1
- package/dist/output_parsers/noop.cjs.map +1 -1
- package/dist/output_parsers/noop.js.map +1 -1
- package/dist/output_parsers/openai_functions.cjs +0 -1
- package/dist/output_parsers/openai_functions.cjs.map +1 -1
- package/dist/output_parsers/openai_functions.d.cts +0 -1
- package/dist/output_parsers/openai_functions.d.cts.map +1 -1
- package/dist/output_parsers/openai_functions.d.ts +0 -1
- package/dist/output_parsers/openai_functions.d.ts.map +1 -1
- package/dist/output_parsers/openai_functions.js.map +1 -1
- package/dist/output_parsers/openai_tools.cjs +0 -1
- package/dist/output_parsers/openai_tools.cjs.map +1 -1
- package/dist/output_parsers/openai_tools.d.cts +8 -5
- package/dist/output_parsers/openai_tools.d.cts.map +1 -1
- package/dist/output_parsers/openai_tools.d.ts +8 -5
- package/dist/output_parsers/openai_tools.d.ts.map +1 -1
- package/dist/output_parsers/openai_tools.js.map +1 -1
- package/dist/output_parsers/prompts.cjs +6 -3
- package/dist/output_parsers/prompts.cjs.map +1 -1
- package/dist/output_parsers/prompts.js +5 -3
- package/dist/output_parsers/prompts.js.map +1 -1
- package/dist/output_parsers/regex.cjs +0 -1
- package/dist/output_parsers/regex.cjs.map +1 -1
- package/dist/output_parsers/regex.d.cts +1 -2
- package/dist/output_parsers/regex.d.cts.map +1 -1
- package/dist/output_parsers/regex.d.ts +1 -2
- package/dist/output_parsers/regex.d.ts.map +1 -1
- package/dist/output_parsers/regex.js.map +1 -1
- package/dist/output_parsers/router.cjs +0 -1
- package/dist/output_parsers/router.cjs.map +1 -1
- package/dist/output_parsers/router.d.cts +0 -1
- package/dist/output_parsers/router.d.cts.map +1 -1
- package/dist/output_parsers/router.d.ts +0 -1
- package/dist/output_parsers/router.d.ts.map +1 -1
- package/dist/output_parsers/router.js.map +1 -1
- package/dist/output_parsers/structured.cjs +1 -1
- package/dist/output_parsers/structured.cjs.map +1 -1
- package/dist/output_parsers/structured.d.cts +3 -7
- package/dist/output_parsers/structured.d.cts.map +1 -1
- package/dist/output_parsers/structured.d.ts +3 -7
- package/dist/output_parsers/structured.d.ts.map +1 -1
- package/dist/output_parsers/structured.js +1 -0
- package/dist/output_parsers/structured.js.map +1 -1
- package/dist/retrievers/contextual_compression.cjs.map +1 -1
- package/dist/retrievers/contextual_compression.d.cts +0 -1
- package/dist/retrievers/contextual_compression.d.cts.map +1 -1
- package/dist/retrievers/contextual_compression.d.ts +0 -1
- package/dist/retrievers/contextual_compression.d.ts.map +1 -1
- package/dist/retrievers/contextual_compression.js.map +1 -1
- package/dist/retrievers/document_compressors/chain_extract.cjs +5 -4
- package/dist/retrievers/document_compressors/chain_extract.cjs.map +1 -1
- package/dist/retrievers/document_compressors/chain_extract.d.cts +1 -5
- package/dist/retrievers/document_compressors/chain_extract.d.cts.map +1 -1
- package/dist/retrievers/document_compressors/chain_extract.d.ts +1 -5
- package/dist/retrievers/document_compressors/chain_extract.d.ts.map +1 -1
- package/dist/retrievers/document_compressors/chain_extract.js +5 -4
- package/dist/retrievers/document_compressors/chain_extract.js.map +1 -1
- package/dist/retrievers/document_compressors/embeddings_filter.cjs.map +1 -1
- package/dist/retrievers/document_compressors/embeddings_filter.d.cts +0 -1
- package/dist/retrievers/document_compressors/embeddings_filter.d.cts.map +1 -1
- package/dist/retrievers/document_compressors/embeddings_filter.d.ts +0 -1
- package/dist/retrievers/document_compressors/embeddings_filter.d.ts.map +1 -1
- package/dist/retrievers/document_compressors/embeddings_filter.js.map +1 -1
- package/dist/retrievers/document_compressors/index.cjs.map +1 -1
- package/dist/retrievers/document_compressors/index.d.cts +0 -1
- package/dist/retrievers/document_compressors/index.d.cts.map +1 -1
- package/dist/retrievers/document_compressors/index.d.ts +0 -1
- package/dist/retrievers/document_compressors/index.d.ts.map +1 -1
- package/dist/retrievers/document_compressors/index.js.map +1 -1
- package/dist/retrievers/ensemble.cjs.map +1 -1
- package/dist/retrievers/ensemble.d.cts +0 -1
- package/dist/retrievers/ensemble.d.cts.map +1 -1
- package/dist/retrievers/ensemble.d.ts +0 -1
- package/dist/retrievers/ensemble.d.ts.map +1 -1
- package/dist/retrievers/ensemble.js.map +1 -1
- package/dist/retrievers/hyde.cjs.map +1 -1
- package/dist/retrievers/hyde.d.cts +0 -1
- package/dist/retrievers/hyde.d.cts.map +1 -1
- package/dist/retrievers/hyde.d.ts +0 -1
- package/dist/retrievers/hyde.d.ts.map +1 -1
- package/dist/retrievers/hyde.js.map +1 -1
- package/dist/retrievers/matryoshka_retriever.cjs.map +1 -1
- package/dist/retrievers/matryoshka_retriever.d.cts +0 -1
- package/dist/retrievers/matryoshka_retriever.d.cts.map +1 -1
- package/dist/retrievers/matryoshka_retriever.d.ts +0 -1
- package/dist/retrievers/matryoshka_retriever.d.ts.map +1 -1
- package/dist/retrievers/matryoshka_retriever.js.map +1 -1
- package/dist/retrievers/multi_query.cjs +1 -1
- package/dist/retrievers/multi_query.cjs.map +1 -1
- package/dist/retrievers/multi_query.d.cts +0 -1
- package/dist/retrievers/multi_query.d.cts.map +1 -1
- package/dist/retrievers/multi_query.d.ts +0 -1
- package/dist/retrievers/multi_query.d.ts.map +1 -1
- package/dist/retrievers/multi_query.js +1 -1
- package/dist/retrievers/multi_query.js.map +1 -1
- package/dist/retrievers/multi_vector.cjs.map +1 -1
- package/dist/retrievers/multi_vector.d.cts +0 -1
- package/dist/retrievers/multi_vector.d.cts.map +1 -1
- package/dist/retrievers/multi_vector.d.ts +0 -1
- package/dist/retrievers/multi_vector.d.ts.map +1 -1
- package/dist/retrievers/multi_vector.js.map +1 -1
- package/dist/retrievers/parent_document.cjs.map +1 -1
- package/dist/retrievers/parent_document.d.cts +0 -1
- package/dist/retrievers/parent_document.d.cts.map +1 -1
- package/dist/retrievers/parent_document.d.ts +0 -1
- package/dist/retrievers/parent_document.d.ts.map +1 -1
- package/dist/retrievers/parent_document.js.map +1 -1
- package/dist/retrievers/score_threshold.cjs.map +1 -1
- package/dist/retrievers/score_threshold.d.cts +0 -1
- package/dist/retrievers/score_threshold.d.cts.map +1 -1
- package/dist/retrievers/score_threshold.d.ts +0 -1
- package/dist/retrievers/score_threshold.d.ts.map +1 -1
- package/dist/retrievers/score_threshold.js.map +1 -1
- package/dist/retrievers/self_query/index.cjs.map +1 -1
- package/dist/retrievers/self_query/index.d.cts +0 -1
- package/dist/retrievers/self_query/index.d.cts.map +1 -1
- package/dist/retrievers/self_query/index.d.ts +0 -1
- package/dist/retrievers/self_query/index.d.ts.map +1 -1
- package/dist/retrievers/self_query/index.js.map +1 -1
- package/dist/retrievers/time_weighted.cjs.map +1 -1
- package/dist/retrievers/time_weighted.d.cts +5 -1
- package/dist/retrievers/time_weighted.d.cts.map +1 -1
- package/dist/retrievers/time_weighted.d.ts +5 -1
- package/dist/retrievers/time_weighted.d.ts.map +1 -1
- package/dist/retrievers/time_weighted.js.map +1 -1
- package/dist/schema/prompt_template.cjs.map +1 -1
- package/dist/schema/prompt_template.d.cts +0 -1
- package/dist/schema/prompt_template.d.cts.map +1 -1
- package/dist/schema/prompt_template.d.ts +0 -1
- package/dist/schema/prompt_template.d.ts.map +1 -1
- package/dist/schema/prompt_template.js.map +1 -1
- package/dist/schema/query_constructor.cjs +3 -0
- package/dist/schema/query_constructor.cjs.map +1 -1
- package/dist/schema/query_constructor.d.cts.map +1 -1
- package/dist/schema/query_constructor.d.ts.map +1 -1
- package/dist/schema/query_constructor.js +3 -0
- package/dist/schema/query_constructor.js.map +1 -1
- package/dist/smith/config.cjs.map +1 -1
- package/dist/smith/config.d.cts +2 -7
- package/dist/smith/config.d.cts.map +1 -1
- package/dist/smith/config.d.ts +2 -7
- package/dist/smith/config.d.ts.map +1 -1
- package/dist/smith/config.js.map +1 -1
- package/dist/smith/name_generation.cjs.map +1 -1
- package/dist/smith/name_generation.js.map +1 -1
- package/dist/smith/progress.cjs.map +1 -1
- package/dist/smith/progress.js.map +1 -1
- package/dist/smith/runner_utils.cjs +11 -8
- package/dist/smith/runner_utils.cjs.map +1 -1
- package/dist/smith/runner_utils.d.cts +1 -2
- package/dist/smith/runner_utils.d.cts.map +1 -1
- package/dist/smith/runner_utils.d.ts +1 -2
- package/dist/smith/runner_utils.d.ts.map +1 -1
- package/dist/smith/runner_utils.js +11 -7
- package/dist/smith/runner_utils.js.map +1 -1
- package/dist/sql_db.cjs.map +1 -1
- package/dist/sql_db.d.cts +1 -3
- package/dist/sql_db.d.cts.map +1 -1
- package/dist/sql_db.d.ts +1 -3
- package/dist/sql_db.d.ts.map +1 -1
- package/dist/sql_db.js.map +1 -1
- package/dist/storage/encoder_backed.cjs.map +1 -1
- package/dist/storage/encoder_backed.d.cts +0 -1
- package/dist/storage/encoder_backed.d.cts.map +1 -1
- package/dist/storage/encoder_backed.d.ts +0 -1
- package/dist/storage/encoder_backed.d.ts.map +1 -1
- package/dist/storage/encoder_backed.js.map +1 -1
- package/dist/storage/file_system.cjs.map +1 -1
- package/dist/storage/file_system.d.cts +20 -1
- package/dist/storage/file_system.d.cts.map +1 -1
- package/dist/storage/file_system.d.ts +20 -1
- package/dist/storage/file_system.d.ts.map +1 -1
- package/dist/storage/file_system.js.map +1 -1
- package/dist/stores/doc/base.cjs.map +1 -1
- package/dist/stores/doc/base.d.cts +0 -1
- package/dist/stores/doc/base.d.cts.map +1 -1
- package/dist/stores/doc/base.d.ts +0 -1
- package/dist/stores/doc/base.d.ts.map +1 -1
- package/dist/stores/doc/base.js.map +1 -1
- package/dist/stores/doc/in_memory.cjs.map +1 -1
- package/dist/stores/doc/in_memory.d.cts +0 -1
- package/dist/stores/doc/in_memory.d.cts.map +1 -1
- package/dist/stores/doc/in_memory.d.ts +0 -1
- package/dist/stores/doc/in_memory.d.ts.map +1 -1
- package/dist/stores/doc/in_memory.js.map +1 -1
- package/dist/stores/file/base.cjs +0 -1
- package/dist/stores/file/base.cjs.map +1 -1
- package/dist/stores/file/base.d.cts +0 -1
- package/dist/stores/file/base.d.cts.map +1 -1
- package/dist/stores/file/base.d.ts +0 -1
- package/dist/stores/file/base.d.ts.map +1 -1
- package/dist/stores/file/base.js.map +1 -1
- package/dist/stores/file/in_memory.cjs.map +1 -1
- package/dist/stores/file/in_memory.d.cts +0 -1
- package/dist/stores/file/in_memory.d.cts.map +1 -1
- package/dist/stores/file/in_memory.d.ts +0 -1
- package/dist/stores/file/in_memory.d.ts.map +1 -1
- package/dist/stores/file/in_memory.js.map +1 -1
- package/dist/stores/file/node.cjs +1 -0
- package/dist/stores/file/node.cjs.map +1 -1
- package/dist/stores/file/node.d.cts +0 -1
- package/dist/stores/file/node.d.cts.map +1 -1
- package/dist/stores/file/node.d.ts +0 -1
- package/dist/stores/file/node.d.ts.map +1 -1
- package/dist/stores/file/node.js +1 -0
- package/dist/stores/file/node.js.map +1 -1
- package/dist/text_splitter.d.cts +0 -3
- package/dist/text_splitter.d.ts +0 -3
- package/dist/tools/chain.cjs.map +1 -1
- package/dist/tools/chain.d.cts +1 -5
- package/dist/tools/chain.d.cts.map +1 -1
- package/dist/tools/chain.d.ts +1 -5
- package/dist/tools/chain.d.ts.map +1 -1
- package/dist/tools/chain.js.map +1 -1
- package/dist/tools/fs.cjs +0 -1
- package/dist/tools/fs.cjs.map +1 -1
- package/dist/tools/fs.d.cts +4 -15
- package/dist/tools/fs.d.cts.map +1 -1
- package/dist/tools/fs.d.ts +4 -15
- package/dist/tools/fs.d.ts.map +1 -1
- package/dist/tools/fs.js.map +1 -1
- package/dist/tools/json.cjs +1 -0
- package/dist/tools/json.cjs.map +1 -1
- package/dist/tools/json.d.cts +1 -2
- package/dist/tools/json.d.cts.map +1 -1
- package/dist/tools/json.d.ts +1 -2
- package/dist/tools/json.d.ts.map +1 -1
- package/dist/tools/json.js +1 -0
- package/dist/tools/json.js.map +1 -1
- package/dist/tools/render.cjs.map +1 -1
- package/dist/tools/render.d.cts +0 -1
- package/dist/tools/render.d.cts.map +1 -1
- package/dist/tools/render.d.ts +0 -1
- package/dist/tools/render.d.ts.map +1 -1
- package/dist/tools/render.js.map +1 -1
- package/dist/tools/requests.cjs +2 -1
- package/dist/tools/requests.cjs.map +1 -1
- package/dist/tools/requests.d.cts +3 -8
- package/dist/tools/requests.d.cts.map +1 -1
- package/dist/tools/requests.d.ts +3 -8
- package/dist/tools/requests.d.ts.map +1 -1
- package/dist/tools/requests.js +2 -0
- package/dist/tools/requests.js.map +1 -1
- package/dist/tools/retriever.cjs.map +1 -1
- package/dist/tools/retriever.d.cts +0 -1
- package/dist/tools/retriever.d.cts.map +1 -1
- package/dist/tools/retriever.d.ts +0 -1
- package/dist/tools/retriever.d.ts.map +1 -1
- package/dist/tools/retriever.js.map +1 -1
- package/dist/tools/sql.cjs.map +1 -1
- package/dist/tools/sql.d.cts +0 -1
- package/dist/tools/sql.d.cts.map +1 -1
- package/dist/tools/sql.d.ts +0 -1
- package/dist/tools/sql.d.ts.map +1 -1
- package/dist/tools/sql.js.map +1 -1
- package/dist/tools/vectorstore.cjs +0 -1
- package/dist/tools/vectorstore.cjs.map +1 -1
- package/dist/tools/vectorstore.d.cts +0 -1
- package/dist/tools/vectorstore.d.cts.map +1 -1
- package/dist/tools/vectorstore.d.ts +0 -1
- package/dist/tools/vectorstore.d.ts.map +1 -1
- package/dist/tools/vectorstore.js.map +1 -1
- package/dist/tools/webbrowser.cjs +2 -1
- package/dist/tools/webbrowser.cjs.map +1 -1
- package/dist/tools/webbrowser.d.cts +1 -8
- package/dist/tools/webbrowser.d.cts.map +1 -1
- package/dist/tools/webbrowser.d.ts +1 -8
- package/dist/tools/webbrowser.d.ts.map +1 -1
- package/dist/tools/webbrowser.js +2 -1
- package/dist/tools/webbrowser.js.map +1 -1
- package/dist/types/expression-parser.d.cts +1 -1
- package/dist/types/expression-parser.d.cts.map +1 -1
- package/dist/types/expression-parser.d.ts +1 -1
- package/dist/types/expression-parser.d.ts.map +1 -1
- package/dist/types/type-utils.d.cts.map +1 -1
- package/dist/types/type-utils.d.ts.map +1 -1
- package/dist/util/document.cjs.map +1 -1
- package/dist/util/document.d.cts +0 -1
- package/dist/util/document.d.cts.map +1 -1
- package/dist/util/document.d.ts +0 -1
- package/dist/util/document.d.ts.map +1 -1
- package/dist/util/document.js.map +1 -1
- package/dist/util/env.cjs +0 -1
- package/dist/util/extname.cjs.map +1 -1
- package/dist/util/extname.js.map +1 -1
- package/dist/util/hub.cjs +0 -1
- package/dist/util/hub.cjs.map +1 -1
- package/dist/util/hub.js.map +1 -1
- package/dist/util/is-network-error/index.cjs +1 -1
- package/dist/util/is-network-error/index.cjs.map +1 -1
- package/dist/util/is-network-error/index.js +1 -1
- package/dist/util/is-network-error/index.js.map +1 -1
- package/dist/util/load.cjs.map +1 -1
- package/dist/util/load.d.cts.map +1 -1
- package/dist/util/load.d.ts.map +1 -1
- package/dist/util/load.js.map +1 -1
- package/dist/util/ml-distance/distances.cjs.map +1 -1
- package/dist/util/ml-distance/distances.js.map +1 -1
- package/dist/util/ml-distance/similarities.cjs.map +1 -1
- package/dist/util/ml-distance/similarities.d.cts.map +1 -1
- package/dist/util/ml-distance/similarities.d.ts.map +1 -1
- package/dist/util/ml-distance/similarities.js.map +1 -1
- package/dist/util/ml-distance-euclidean/euclidean.cjs +1 -0
- package/dist/util/ml-distance-euclidean/euclidean.cjs.map +1 -1
- package/dist/util/ml-distance-euclidean/euclidean.js +1 -1
- package/dist/util/ml-distance-euclidean/euclidean.js.map +1 -1
- package/dist/util/openapi.cjs +1 -0
- package/dist/util/openapi.cjs.map +1 -1
- package/dist/util/openapi.d.cts +0 -1
- package/dist/util/openapi.d.cts.map +1 -1
- package/dist/util/openapi.d.ts +0 -1
- package/dist/util/openapi.d.ts.map +1 -1
- package/dist/util/openapi.js +1 -0
- package/dist/util/openapi.js.map +1 -1
- package/dist/util/p-retry/index.cjs +1 -0
- package/dist/util/p-retry/index.cjs.map +1 -1
- package/dist/util/p-retry/index.js +1 -1
- package/dist/util/p-retry/index.js.map +1 -1
- package/dist/util/parse.cjs +1 -0
- package/dist/util/parse.cjs.map +1 -1
- package/dist/util/parse.js +1 -1
- package/dist/util/parse.js.map +1 -1
- package/dist/util/set.cjs.map +1 -1
- package/dist/util/set.js.map +1 -1
- package/dist/util/sql_utils.cjs +12 -6
- package/dist/util/sql_utils.cjs.map +1 -1
- package/dist/util/sql_utils.d.cts +1 -2
- package/dist/util/sql_utils.d.cts.map +1 -1
- package/dist/util/sql_utils.d.ts +1 -2
- package/dist/util/sql_utils.d.ts.map +1 -1
- package/dist/util/sql_utils.js +12 -6
- package/dist/util/sql_utils.js.map +1 -1
- package/dist/util/time.cjs.map +1 -1
- package/dist/util/time.d.cts.map +1 -1
- package/dist/util/time.d.ts.map +1 -1
- package/dist/util/time.js.map +1 -1
- package/dist/vectorstores/memory.cjs.map +1 -1
- package/dist/vectorstores/memory.d.cts +1 -5
- package/dist/vectorstores/memory.d.cts.map +1 -1
- package/dist/vectorstores/memory.d.ts +1 -5
- package/dist/vectorstores/memory.d.ts.map +1 -1
- package/dist/vectorstores/memory.js.map +1 -1
- package/package.json +30 -30
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sql_db_chain.cjs","names":["BaseChain","DEFAULT_SQL_DATABASE_PROMPT","getPromptTemplateFromDataSource","LLMChain","SQL_PROMPTS_MAP","RunnableSequence","RunnablePassthrough","StringOutputParser"],"sources":["../../../src/chains/sql_db/sql_db_chain.ts"],"sourcesContent":["import type {\n BaseLanguageModel,\n BaseLanguageModelInterface,\n} from \"@langchain/core/language_models/base\";\nimport type { OpenAI, TiktokenModel } from \"@langchain/openai\";\nimport { ChainValues } from \"@langchain/core/utils/types\";\nimport { BasePromptTemplate, PromptTemplate } from \"@langchain/core/prompts\";\nimport {\n calculateMaxTokens,\n getModelContextSize,\n} from \"@langchain/core/language_models/base\";\nimport { CallbackManagerForChainRun } from \"@langchain/core/callbacks/manager\";\nimport {\n RunnablePassthrough,\n RunnableSequence,\n} from \"@langchain/core/runnables\";\nimport { StringOutputParser } from \"@langchain/core/output_parsers\";\nimport {\n DEFAULT_SQL_DATABASE_PROMPT,\n SQL_PROMPTS_MAP,\n SqlDialect,\n} from \"./sql_db_prompt.js\";\nimport { BaseChain, ChainInputs } from \"../base.js\";\nimport { LLMChain } from \"../llm_chain.js\";\nimport type { SqlDatabase } from \"../../sql_db.js\";\nimport { getPromptTemplateFromDataSource } from \"../../util/sql_utils.js\";\n\n/**\n * Interface that extends the ChainInputs interface and defines additional\n * fields specific to a SQL database chain. It represents the input fields\n * for a SQL database chain.\n */\nexport interface SqlDatabaseChainInput extends ChainInputs {\n llm: BaseLanguageModelInterface;\n database: SqlDatabase;\n topK?: number;\n inputKey?: string;\n outputKey?: string;\n sqlOutputKey?: string;\n prompt?: PromptTemplate;\n}\n\n/**\n * Class that represents a SQL database chain in the LangChain framework.\n * It extends the BaseChain class and implements the functionality\n * specific to a SQL database chain.\n *\n * @security **Security Notice**\n * This chain generates SQL queries for the given database.\n * The SQLDatabase class provides a getTableInfo method that can be used\n * to get column information as well as sample data from the table.\n * To mitigate risk of leaking sensitive data, limit permissions\n * to read and scope to the tables that are needed.\n * Optionally, use the includesTables or ignoreTables class parameters\n * to limit which tables can/cannot be accessed.\n *\n * @link See https://js.langchain.com/docs/security for more information.\n * @example\n * ```typescript\n * const chain = new SqlDatabaseChain({\n * llm: new OpenAI({ temperature: 0 }),\n * database: new SqlDatabase({ ...config }),\n * });\n *\n * const result = await chain.run(\"How many tracks are there?\");\n * ```\n */\nexport class SqlDatabaseChain extends BaseChain {\n static lc_name() {\n return \"SqlDatabaseChain\";\n }\n\n // LLM wrapper to use\n llm: BaseLanguageModelInterface;\n\n // SQL Database to connect to.\n database: SqlDatabase;\n\n // Prompt to use to translate natural language to SQL.\n prompt = DEFAULT_SQL_DATABASE_PROMPT;\n\n // Number of results to return from the query\n topK = 5;\n\n inputKey = \"query\";\n\n outputKey = \"result\";\n\n sqlOutputKey: string | undefined = undefined;\n\n // Whether to return the result of querying the SQL table directly.\n returnDirect = false;\n\n constructor(fields: SqlDatabaseChainInput) {\n super(fields);\n this.llm = fields.llm;\n this.database = fields.database;\n this.topK = fields.topK ?? this.topK;\n this.inputKey = fields.inputKey ?? this.inputKey;\n this.outputKey = fields.outputKey ?? this.outputKey;\n this.sqlOutputKey = fields.sqlOutputKey ?? this.sqlOutputKey;\n this.prompt =\n fields.prompt ??\n getPromptTemplateFromDataSource(this.database.appDataSource);\n }\n\n /** @ignore */\n async _call(\n values: ChainValues,\n runManager?: CallbackManagerForChainRun\n ): Promise<ChainValues> {\n const llmChain = new LLMChain({\n prompt: this.prompt,\n llm: this.llm,\n outputKey: this.outputKey,\n memory: this.memory,\n });\n if (!(this.inputKey in values)) {\n throw new Error(`Question key ${this.inputKey} not found.`);\n }\n const question: string = values[this.inputKey];\n let inputText = `${question}\\nSQLQuery:`;\n const tablesToUse = values.table_names_to_use;\n const tableInfo = await this.database.getTableInfo(tablesToUse);\n\n const llmInputs = {\n input: inputText,\n top_k: this.topK,\n dialect: this.database.appDataSourceOptions.type,\n table_info: tableInfo,\n stop: [\"\\nSQLResult:\"],\n };\n await this.verifyNumberOfTokens(inputText, tableInfo);\n\n const sqlCommand = await llmChain.predict(\n llmInputs,\n runManager?.getChild(\"sql_generation\")\n );\n let queryResult = \"\";\n try {\n queryResult = await this.database.appDataSource.query(sqlCommand);\n } catch (error) {\n console.error(error);\n }\n\n let finalResult;\n if (this.returnDirect) {\n finalResult = { [this.outputKey]: queryResult };\n } else {\n inputText += `${sqlCommand}\\nSQLResult: ${JSON.stringify(\n queryResult\n )}\\nAnswer:`;\n llmInputs.input = inputText;\n finalResult = {\n [this.outputKey]: await llmChain.predict(\n llmInputs,\n runManager?.getChild(\"result_generation\")\n ),\n };\n }\n\n if (this.sqlOutputKey != null) {\n finalResult[this.sqlOutputKey] = sqlCommand;\n }\n\n return finalResult;\n }\n\n _chainType() {\n return \"sql_database_chain\" as const;\n }\n\n get inputKeys(): string[] {\n return [this.inputKey];\n }\n\n get outputKeys(): string[] {\n if (this.sqlOutputKey != null) {\n return [this.outputKey, this.sqlOutputKey];\n }\n return [this.outputKey];\n }\n\n /**\n * Private method that verifies the number of tokens in the input text and\n * table information. It throws an error if the number of tokens exceeds\n * the maximum allowed by the language model.\n * @param inputText The input text.\n * @param tableinfo The table information.\n * @returns A promise that resolves when the verification is complete.\n */\n private async verifyNumberOfTokens(\n inputText: string,\n tableinfo: string\n ): Promise<void> {\n // We verify it only for OpenAI for the moment\n if (this.llm._llmType() !== \"openai\") {\n return;\n }\n const llm = this.llm as OpenAI;\n const promptTemplate = this.prompt.template;\n const stringWeSend = `${inputText}${promptTemplate}${tableinfo}`;\n\n const maxToken = await calculateMaxTokens({\n prompt: stringWeSend,\n // Cast here to allow for other models that may not fit the union\n modelName: llm.model as TiktokenModel,\n });\n\n if (maxToken < (llm.maxTokens ?? -1)) {\n throw new Error(`The combination of the database structure and your question is too big for the model ${\n llm.model\n } which can compute only a max tokens of ${getModelContextSize(\n llm.model\n )}.\n We suggest you to use the includeTables parameters when creating the SqlDatabase object to select only a subset of the tables. You can also use a model which can handle more tokens.`);\n }\n }\n}\n\nexport interface CreateSqlQueryChainFields {\n llm: BaseLanguageModel;\n db: SqlDatabase;\n prompt?: BasePromptTemplate;\n /**\n * @default 5\n */\n k?: number;\n dialect: SqlDialect;\n}\n\ntype SqlInput = {\n question: string;\n};\n\ntype SqlInoutWithTables = SqlInput & {\n tableNamesToUse: string[];\n};\n\nconst strip = (text: string) => {\n // Replace escaped quotes with actual quotes\n let newText = text.replace(/\\\\\"/g, '\"').trim();\n // Remove wrapping quotes if the entire string is wrapped in quotes\n if (newText.startsWith('\"') && newText.endsWith('\"')) {\n newText = newText.substring(1, newText.length - 1);\n }\n return newText;\n};\n\nconst difference = (setA: Set<string>, setB: Set<string>) =>\n new Set([...setA].filter((x) => !setB.has(x)));\n\n/**\n * Create a SQL query chain that can create SQL queries for the given database.\n * Returns a Runnable.\n *\n * @param {BaseLanguageModel} llm The language model to use in the chain.\n * @param {SqlDatabase} db The database to use in the chain.\n * @param {BasePromptTemplate | undefined} prompt The prompt to use in the chain.\n * @param {BaseLanguageModel | undefined} k The amount of docs/results to return. Passed through the prompt input value `top_k`.\n * @param {SqlDialect} dialect The SQL dialect to use in the chain.\n * @returns {Promise<RunnableSequence<Record<string, unknown>, string>>} A runnable sequence representing the chain.\n * @example ```typescript\n * const datasource = new DataSource({\n * type: \"sqlite\",\n * database: \"../../../../Chinook.db\",\n * });\n * const db = await SqlDatabase.fromDataSourceParams({\n * appDataSource: datasource,\n * });\n * const llm = new ChatOpenAI({ model: \"gpt-4o-mini\", temperature: 0 });\n * const chain = await createSqlQueryChain({\n * llm,\n * db,\n * dialect: \"sqlite\",\n * });\n * ```\n */\nexport async function createSqlQueryChain({\n llm,\n db,\n prompt,\n k = 5,\n dialect,\n}: CreateSqlQueryChainFields) {\n let promptToUse: BasePromptTemplate;\n if (prompt) {\n promptToUse = prompt;\n } else if (SQL_PROMPTS_MAP[dialect]) {\n promptToUse = SQL_PROMPTS_MAP[dialect];\n } else {\n promptToUse = DEFAULT_SQL_DATABASE_PROMPT;\n }\n\n if (\n difference(\n new Set([\"input\", \"top_k\", \"table_info\"]),\n new Set(promptToUse.inputVariables)\n ).size > 0\n ) {\n throw new Error(\n `Prompt must have input variables: 'input', 'top_k', 'table_info'. Received prompt with input variables: ` +\n `${promptToUse.inputVariables}. Full prompt:\\n\\n${promptToUse}`\n );\n }\n if (promptToUse.inputVariables.includes(\"dialect\")) {\n promptToUse = await promptToUse.partial({ dialect });\n }\n\n promptToUse = await promptToUse.partial({ top_k: k.toString() });\n\n const inputs = {\n input: (x: Record<string, unknown>) => {\n if (\"question\" in x) {\n return `${(x as SqlInput).question}\\nSQLQuery: `;\n }\n throw new Error(\"Input must include a question property.\");\n },\n table_info: async (x: Record<string, unknown>) =>\n db.getTableInfo((x as SqlInoutWithTables).tableNamesToUse),\n };\n\n return RunnableSequence.from([\n RunnablePassthrough.assign(inputs),\n (x) => {\n const newInputs = { ...x };\n delete newInputs.question;\n delete newInputs.tableNamesToUse;\n return newInputs;\n },\n promptToUse,\n llm.withConfig({ stop: [\"\\nSQLResult:\"] }),\n new StringOutputParser(),\n strip,\n ]);\n}\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"sql_db_chain.cjs","names":["BaseChain","DEFAULT_SQL_DATABASE_PROMPT","getPromptTemplateFromDataSource","LLMChain","SQL_PROMPTS_MAP","RunnableSequence","RunnablePassthrough","StringOutputParser"],"sources":["../../../src/chains/sql_db/sql_db_chain.ts"],"sourcesContent":["import type {\n BaseLanguageModel,\n BaseLanguageModelInterface,\n} from \"@langchain/core/language_models/base\";\nimport type { OpenAI, TiktokenModel } from \"@langchain/openai\";\nimport { ChainValues } from \"@langchain/core/utils/types\";\nimport { BasePromptTemplate, PromptTemplate } from \"@langchain/core/prompts\";\nimport {\n calculateMaxTokens,\n getModelContextSize,\n} from \"@langchain/core/language_models/base\";\nimport { CallbackManagerForChainRun } from \"@langchain/core/callbacks/manager\";\nimport {\n RunnablePassthrough,\n RunnableSequence,\n} from \"@langchain/core/runnables\";\nimport { StringOutputParser } from \"@langchain/core/output_parsers\";\nimport {\n DEFAULT_SQL_DATABASE_PROMPT,\n SQL_PROMPTS_MAP,\n SqlDialect,\n} from \"./sql_db_prompt.js\";\nimport { BaseChain, ChainInputs } from \"../base.js\";\nimport { LLMChain } from \"../llm_chain.js\";\nimport type { SqlDatabase } from \"../../sql_db.js\";\nimport { getPromptTemplateFromDataSource } from \"../../util/sql_utils.js\";\n\n/**\n * Interface that extends the ChainInputs interface and defines additional\n * fields specific to a SQL database chain. It represents the input fields\n * for a SQL database chain.\n */\nexport interface SqlDatabaseChainInput extends ChainInputs {\n llm: BaseLanguageModelInterface;\n database: SqlDatabase;\n topK?: number;\n inputKey?: string;\n outputKey?: string;\n sqlOutputKey?: string;\n prompt?: PromptTemplate;\n}\n\n/**\n * Class that represents a SQL database chain in the LangChain framework.\n * It extends the BaseChain class and implements the functionality\n * specific to a SQL database chain.\n *\n * @security **Security Notice**\n * This chain generates SQL queries for the given database.\n * The SQLDatabase class provides a getTableInfo method that can be used\n * to get column information as well as sample data from the table.\n * To mitigate risk of leaking sensitive data, limit permissions\n * to read and scope to the tables that are needed.\n * Optionally, use the includesTables or ignoreTables class parameters\n * to limit which tables can/cannot be accessed.\n *\n * @link See https://js.langchain.com/docs/security for more information.\n * @example\n * ```typescript\n * const chain = new SqlDatabaseChain({\n * llm: new OpenAI({ temperature: 0 }),\n * database: new SqlDatabase({ ...config }),\n * });\n *\n * const result = await chain.run(\"How many tracks are there?\");\n * ```\n */\nexport class SqlDatabaseChain extends BaseChain {\n static lc_name() {\n return \"SqlDatabaseChain\";\n }\n\n // LLM wrapper to use\n llm: BaseLanguageModelInterface;\n\n // SQL Database to connect to.\n database: SqlDatabase;\n\n // Prompt to use to translate natural language to SQL.\n prompt = DEFAULT_SQL_DATABASE_PROMPT;\n\n // Number of results to return from the query\n topK = 5;\n\n inputKey = \"query\";\n\n outputKey = \"result\";\n\n sqlOutputKey: string | undefined = undefined;\n\n // Whether to return the result of querying the SQL table directly.\n returnDirect = false;\n\n constructor(fields: SqlDatabaseChainInput) {\n super(fields);\n this.llm = fields.llm;\n this.database = fields.database;\n this.topK = fields.topK ?? this.topK;\n this.inputKey = fields.inputKey ?? this.inputKey;\n this.outputKey = fields.outputKey ?? this.outputKey;\n this.sqlOutputKey = fields.sqlOutputKey ?? this.sqlOutputKey;\n this.prompt =\n fields.prompt ??\n getPromptTemplateFromDataSource(this.database.appDataSource);\n }\n\n /** @ignore */\n async _call(\n values: ChainValues,\n runManager?: CallbackManagerForChainRun\n ): Promise<ChainValues> {\n const llmChain = new LLMChain({\n prompt: this.prompt,\n llm: this.llm,\n outputKey: this.outputKey,\n memory: this.memory,\n });\n if (!(this.inputKey in values)) {\n throw new Error(`Question key ${this.inputKey} not found.`);\n }\n const question: string = values[this.inputKey];\n let inputText = `${question}\\nSQLQuery:`;\n const tablesToUse = values.table_names_to_use;\n const tableInfo = await this.database.getTableInfo(tablesToUse);\n\n const llmInputs = {\n input: inputText,\n top_k: this.topK,\n dialect: this.database.appDataSourceOptions.type,\n table_info: tableInfo,\n stop: [\"\\nSQLResult:\"],\n };\n await this.verifyNumberOfTokens(inputText, tableInfo);\n\n const sqlCommand = await llmChain.predict(\n llmInputs,\n runManager?.getChild(\"sql_generation\")\n );\n let queryResult = \"\";\n try {\n queryResult = await this.database.appDataSource.query(sqlCommand);\n } catch (error) {\n console.error(error);\n }\n\n let finalResult;\n if (this.returnDirect) {\n finalResult = { [this.outputKey]: queryResult };\n } else {\n inputText += `${sqlCommand}\\nSQLResult: ${JSON.stringify(\n queryResult\n )}\\nAnswer:`;\n llmInputs.input = inputText;\n finalResult = {\n [this.outputKey]: await llmChain.predict(\n llmInputs,\n runManager?.getChild(\"result_generation\")\n ),\n };\n }\n\n if (this.sqlOutputKey != null) {\n finalResult[this.sqlOutputKey] = sqlCommand;\n }\n\n return finalResult;\n }\n\n _chainType() {\n return \"sql_database_chain\" as const;\n }\n\n get inputKeys(): string[] {\n return [this.inputKey];\n }\n\n get outputKeys(): string[] {\n if (this.sqlOutputKey != null) {\n return [this.outputKey, this.sqlOutputKey];\n }\n return [this.outputKey];\n }\n\n /**\n * Private method that verifies the number of tokens in the input text and\n * table information. It throws an error if the number of tokens exceeds\n * the maximum allowed by the language model.\n * @param inputText The input text.\n * @param tableinfo The table information.\n * @returns A promise that resolves when the verification is complete.\n */\n private async verifyNumberOfTokens(\n inputText: string,\n tableinfo: string\n ): Promise<void> {\n // We verify it only for OpenAI for the moment\n if (this.llm._llmType() !== \"openai\") {\n return;\n }\n const llm = this.llm as OpenAI;\n const promptTemplate = this.prompt.template;\n const stringWeSend = `${inputText}${promptTemplate}${tableinfo}`;\n\n const maxToken = await calculateMaxTokens({\n prompt: stringWeSend,\n // Cast here to allow for other models that may not fit the union\n modelName: llm.model as TiktokenModel,\n });\n\n if (maxToken < (llm.maxTokens ?? -1)) {\n throw new Error(`The combination of the database structure and your question is too big for the model ${\n llm.model\n } which can compute only a max tokens of ${getModelContextSize(\n llm.model\n )}.\n We suggest you to use the includeTables parameters when creating the SqlDatabase object to select only a subset of the tables. You can also use a model which can handle more tokens.`);\n }\n }\n}\n\nexport interface CreateSqlQueryChainFields {\n llm: BaseLanguageModel;\n db: SqlDatabase;\n prompt?: BasePromptTemplate;\n /**\n * @default 5\n */\n k?: number;\n dialect: SqlDialect;\n}\n\ntype SqlInput = {\n question: string;\n};\n\ntype SqlInoutWithTables = SqlInput & {\n tableNamesToUse: string[];\n};\n\nconst strip = (text: string) => {\n // Replace escaped quotes with actual quotes\n let newText = text.replace(/\\\\\"/g, '\"').trim();\n // Remove wrapping quotes if the entire string is wrapped in quotes\n if (newText.startsWith('\"') && newText.endsWith('\"')) {\n newText = newText.substring(1, newText.length - 1);\n }\n return newText;\n};\n\nconst difference = (setA: Set<string>, setB: Set<string>) =>\n new Set([...setA].filter((x) => !setB.has(x)));\n\n/**\n * Create a SQL query chain that can create SQL queries for the given database.\n * Returns a Runnable.\n *\n * @param {BaseLanguageModel} llm The language model to use in the chain.\n * @param {SqlDatabase} db The database to use in the chain.\n * @param {BasePromptTemplate | undefined} prompt The prompt to use in the chain.\n * @param {BaseLanguageModel | undefined} k The amount of docs/results to return. Passed through the prompt input value `top_k`.\n * @param {SqlDialect} dialect The SQL dialect to use in the chain.\n * @returns {Promise<RunnableSequence<Record<string, unknown>, string>>} A runnable sequence representing the chain.\n * @example ```typescript\n * const datasource = new DataSource({\n * type: \"sqlite\",\n * database: \"../../../../Chinook.db\",\n * });\n * const db = await SqlDatabase.fromDataSourceParams({\n * appDataSource: datasource,\n * });\n * const llm = new ChatOpenAI({ model: \"gpt-4o-mini\", temperature: 0 });\n * const chain = await createSqlQueryChain({\n * llm,\n * db,\n * dialect: \"sqlite\",\n * });\n * ```\n */\nexport async function createSqlQueryChain({\n llm,\n db,\n prompt,\n k = 5,\n dialect,\n}: CreateSqlQueryChainFields) {\n let promptToUse: BasePromptTemplate;\n if (prompt) {\n promptToUse = prompt;\n } else if (SQL_PROMPTS_MAP[dialect]) {\n promptToUse = SQL_PROMPTS_MAP[dialect];\n } else {\n promptToUse = DEFAULT_SQL_DATABASE_PROMPT;\n }\n\n if (\n difference(\n new Set([\"input\", \"top_k\", \"table_info\"]),\n new Set(promptToUse.inputVariables)\n ).size > 0\n ) {\n throw new Error(\n `Prompt must have input variables: 'input', 'top_k', 'table_info'. Received prompt with input variables: ` +\n `${promptToUse.inputVariables}. Full prompt:\\n\\n${promptToUse}`\n );\n }\n if (promptToUse.inputVariables.includes(\"dialect\")) {\n promptToUse = await promptToUse.partial({ dialect });\n }\n\n promptToUse = await promptToUse.partial({ top_k: k.toString() });\n\n const inputs = {\n input: (x: Record<string, unknown>) => {\n if (\"question\" in x) {\n return `${(x as SqlInput).question}\\nSQLQuery: `;\n }\n throw new Error(\"Input must include a question property.\");\n },\n table_info: async (x: Record<string, unknown>) =>\n db.getTableInfo((x as SqlInoutWithTables).tableNamesToUse),\n };\n\n return RunnableSequence.from([\n RunnablePassthrough.assign(inputs),\n (x) => {\n const newInputs = { ...x };\n delete newInputs.question;\n delete newInputs.tableNamesToUse;\n return newInputs;\n },\n promptToUse,\n llm.withConfig({ stop: [\"\\nSQLResult:\"] }),\n new StringOutputParser(),\n strip,\n ]);\n}\n"],"mappings":"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"}
|
|
@@ -6,7 +6,6 @@ import { ChainValues } from "@langchain/core/utils/types";
|
|
|
6
6
|
import { BasePromptTemplate, PromptTemplate } from "@langchain/core/prompts";
|
|
7
7
|
import { BaseLanguageModel, BaseLanguageModelInterface } from "@langchain/core/language_models/base";
|
|
8
8
|
import { CallbackManagerForChainRun } from "@langchain/core/callbacks/manager";
|
|
9
|
-
|
|
10
9
|
//#region src/chains/sql_db/sql_db_chain.d.ts
|
|
11
10
|
/**
|
|
12
11
|
* Interface that extends the ChainInputs interface and defines additional
|
|
@@ -68,6 +67,14 @@ declare class SqlDatabaseChain extends BaseChain {
|
|
|
68
67
|
_chainType(): "sql_database_chain";
|
|
69
68
|
get inputKeys(): string[];
|
|
70
69
|
get outputKeys(): string[];
|
|
70
|
+
/**
|
|
71
|
+
* Private method that verifies the number of tokens in the input text and
|
|
72
|
+
* table information. It throws an error if the number of tokens exceeds
|
|
73
|
+
* the maximum allowed by the language model.
|
|
74
|
+
* @param inputText The input text.
|
|
75
|
+
* @param tableinfo The table information.
|
|
76
|
+
* @returns A promise that resolves when the verification is complete.
|
|
77
|
+
*/
|
|
71
78
|
private verifyNumberOfTokens;
|
|
72
79
|
}
|
|
73
80
|
interface CreateSqlQueryChainFields {
|
|
@@ -106,13 +113,7 @@ interface CreateSqlQueryChainFields {
|
|
|
106
113
|
* });
|
|
107
114
|
* ```
|
|
108
115
|
*/
|
|
109
|
-
declare function createSqlQueryChain({
|
|
110
|
-
llm,
|
|
111
|
-
db,
|
|
112
|
-
prompt,
|
|
113
|
-
k,
|
|
114
|
-
dialect
|
|
115
|
-
}: CreateSqlQueryChainFields): Promise<RunnableSequence<Record<string, unknown>, string>>;
|
|
116
|
+
declare function createSqlQueryChain({ llm, db, prompt, k, dialect }: CreateSqlQueryChainFields): Promise<RunnableSequence<Record<string, unknown>, string>>;
|
|
116
117
|
//#endregion
|
|
117
118
|
export { CreateSqlQueryChainFields, SqlDatabaseChain, SqlDatabaseChainInput, createSqlQueryChain };
|
|
118
119
|
//# sourceMappingURL=sql_db_chain.d.cts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sql_db_chain.d.cts","names":[],"sources":["../../../src/chains/sql_db/sql_db_chain.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"sql_db_chain.d.cts","names":[],"sources":["../../../src/chains/sql_db/sql_db_chain.ts"],"mappings":";;;;;;;;;;;;;;UAgCiB,8BAA8B;EAC7C,KAAK;EACL,UAAU;EACV;EACA;EACA;EACA;EACA,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;cA4BE,yBAAyB;SAC7B;EAKP,KAAK;EAGL,UAAU;EAGV,QAAM;;;;;;EAGN;EAEA;EAEA;EAEA;EAGA;EAEA,YAAY,QAAQ;;EAcd,MACJ,QAAQ,aACR,aAAa,6BACZ,QAAQ;EA0DX;MAII;MAIA;;;;;;;;;UAeU;;UA6BC;EACf,KAAK;EACL,IAAI;EACJ,SAAS;;;;EAIT;EACA,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAkDW,sBACpB,KACA,IACA,QACA,GACA,WACC,4BAAyB,QAAA,iBAAA"}
|
|
@@ -6,7 +6,6 @@ import { RunnableSequence } from "@langchain/core/runnables";
|
|
|
6
6
|
import { BaseLanguageModel, BaseLanguageModelInterface } from "@langchain/core/language_models/base";
|
|
7
7
|
import { CallbackManagerForChainRun } from "@langchain/core/callbacks/manager";
|
|
8
8
|
import { ChainValues } from "@langchain/core/utils/types";
|
|
9
|
-
|
|
10
9
|
//#region src/chains/sql_db/sql_db_chain.d.ts
|
|
11
10
|
/**
|
|
12
11
|
* Interface that extends the ChainInputs interface and defines additional
|
|
@@ -68,6 +67,14 @@ declare class SqlDatabaseChain extends BaseChain {
|
|
|
68
67
|
_chainType(): "sql_database_chain";
|
|
69
68
|
get inputKeys(): string[];
|
|
70
69
|
get outputKeys(): string[];
|
|
70
|
+
/**
|
|
71
|
+
* Private method that verifies the number of tokens in the input text and
|
|
72
|
+
* table information. It throws an error if the number of tokens exceeds
|
|
73
|
+
* the maximum allowed by the language model.
|
|
74
|
+
* @param inputText The input text.
|
|
75
|
+
* @param tableinfo The table information.
|
|
76
|
+
* @returns A promise that resolves when the verification is complete.
|
|
77
|
+
*/
|
|
71
78
|
private verifyNumberOfTokens;
|
|
72
79
|
}
|
|
73
80
|
interface CreateSqlQueryChainFields {
|
|
@@ -106,13 +113,7 @@ interface CreateSqlQueryChainFields {
|
|
|
106
113
|
* });
|
|
107
114
|
* ```
|
|
108
115
|
*/
|
|
109
|
-
declare function createSqlQueryChain({
|
|
110
|
-
llm,
|
|
111
|
-
db,
|
|
112
|
-
prompt,
|
|
113
|
-
k,
|
|
114
|
-
dialect
|
|
115
|
-
}: CreateSqlQueryChainFields): Promise<RunnableSequence<Record<string, unknown>, string>>;
|
|
116
|
+
declare function createSqlQueryChain({ llm, db, prompt, k, dialect }: CreateSqlQueryChainFields): Promise<RunnableSequence<Record<string, unknown>, string>>;
|
|
116
117
|
//#endregion
|
|
117
118
|
export { CreateSqlQueryChainFields, SqlDatabaseChain, SqlDatabaseChainInput, createSqlQueryChain };
|
|
118
119
|
//# sourceMappingURL=sql_db_chain.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sql_db_chain.d.ts","names":[],"sources":["../../../src/chains/sql_db/sql_db_chain.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"sql_db_chain.d.ts","names":[],"sources":["../../../src/chains/sql_db/sql_db_chain.ts"],"mappings":";;;;;;;;;;;;;;UAgCiB,8BAA8B;EAC7C,KAAK;EACL,UAAU;EACV;EACA;EACA;EACA;EACA,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;cA4BE,yBAAyB;SAC7B;EAKP,KAAK;EAGL,UAAU;EAGV,QAAM;;;;;;EAGN;EAEA;EAEA;EAEA;EAGA;EAEA,YAAY,QAAQ;;EAcd,MACJ,QAAQ,aACR,aAAa,6BACZ,QAAQ;EA0DX;MAII;MAIA;;;;;;;;;UAeU;;UA6BC;EACf,KAAK;EACL,IAAI;EACJ,SAAS;;;;EAIT;EACA,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAkDW,sBACpB,KACA,IACA,QACA,GACA,WACC,4BAAyB,QAAA,iBAAA"}
|
|
@@ -155,7 +155,7 @@ async function createSqlQueryChain({ llm, db, prompt, k = 5, dialect }) {
|
|
|
155
155
|
if (prompt) promptToUse = prompt;
|
|
156
156
|
else if (SQL_PROMPTS_MAP[dialect]) promptToUse = SQL_PROMPTS_MAP[dialect];
|
|
157
157
|
else promptToUse = DEFAULT_SQL_DATABASE_PROMPT;
|
|
158
|
-
if (difference(new Set([
|
|
158
|
+
if (difference(/* @__PURE__ */ new Set([
|
|
159
159
|
"input",
|
|
160
160
|
"top_k",
|
|
161
161
|
"table_info"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sql_db_chain.js","names":[],"sources":["../../../src/chains/sql_db/sql_db_chain.ts"],"sourcesContent":["import type {\n BaseLanguageModel,\n BaseLanguageModelInterface,\n} from \"@langchain/core/language_models/base\";\nimport type { OpenAI, TiktokenModel } from \"@langchain/openai\";\nimport { ChainValues } from \"@langchain/core/utils/types\";\nimport { BasePromptTemplate, PromptTemplate } from \"@langchain/core/prompts\";\nimport {\n calculateMaxTokens,\n getModelContextSize,\n} from \"@langchain/core/language_models/base\";\nimport { CallbackManagerForChainRun } from \"@langchain/core/callbacks/manager\";\nimport {\n RunnablePassthrough,\n RunnableSequence,\n} from \"@langchain/core/runnables\";\nimport { StringOutputParser } from \"@langchain/core/output_parsers\";\nimport {\n DEFAULT_SQL_DATABASE_PROMPT,\n SQL_PROMPTS_MAP,\n SqlDialect,\n} from \"./sql_db_prompt.js\";\nimport { BaseChain, ChainInputs } from \"../base.js\";\nimport { LLMChain } from \"../llm_chain.js\";\nimport type { SqlDatabase } from \"../../sql_db.js\";\nimport { getPromptTemplateFromDataSource } from \"../../util/sql_utils.js\";\n\n/**\n * Interface that extends the ChainInputs interface and defines additional\n * fields specific to a SQL database chain. It represents the input fields\n * for a SQL database chain.\n */\nexport interface SqlDatabaseChainInput extends ChainInputs {\n llm: BaseLanguageModelInterface;\n database: SqlDatabase;\n topK?: number;\n inputKey?: string;\n outputKey?: string;\n sqlOutputKey?: string;\n prompt?: PromptTemplate;\n}\n\n/**\n * Class that represents a SQL database chain in the LangChain framework.\n * It extends the BaseChain class and implements the functionality\n * specific to a SQL database chain.\n *\n * @security **Security Notice**\n * This chain generates SQL queries for the given database.\n * The SQLDatabase class provides a getTableInfo method that can be used\n * to get column information as well as sample data from the table.\n * To mitigate risk of leaking sensitive data, limit permissions\n * to read and scope to the tables that are needed.\n * Optionally, use the includesTables or ignoreTables class parameters\n * to limit which tables can/cannot be accessed.\n *\n * @link See https://js.langchain.com/docs/security for more information.\n * @example\n * ```typescript\n * const chain = new SqlDatabaseChain({\n * llm: new OpenAI({ temperature: 0 }),\n * database: new SqlDatabase({ ...config }),\n * });\n *\n * const result = await chain.run(\"How many tracks are there?\");\n * ```\n */\nexport class SqlDatabaseChain extends BaseChain {\n static lc_name() {\n return \"SqlDatabaseChain\";\n }\n\n // LLM wrapper to use\n llm: BaseLanguageModelInterface;\n\n // SQL Database to connect to.\n database: SqlDatabase;\n\n // Prompt to use to translate natural language to SQL.\n prompt = DEFAULT_SQL_DATABASE_PROMPT;\n\n // Number of results to return from the query\n topK = 5;\n\n inputKey = \"query\";\n\n outputKey = \"result\";\n\n sqlOutputKey: string | undefined = undefined;\n\n // Whether to return the result of querying the SQL table directly.\n returnDirect = false;\n\n constructor(fields: SqlDatabaseChainInput) {\n super(fields);\n this.llm = fields.llm;\n this.database = fields.database;\n this.topK = fields.topK ?? this.topK;\n this.inputKey = fields.inputKey ?? this.inputKey;\n this.outputKey = fields.outputKey ?? this.outputKey;\n this.sqlOutputKey = fields.sqlOutputKey ?? this.sqlOutputKey;\n this.prompt =\n fields.prompt ??\n getPromptTemplateFromDataSource(this.database.appDataSource);\n }\n\n /** @ignore */\n async _call(\n values: ChainValues,\n runManager?: CallbackManagerForChainRun\n ): Promise<ChainValues> {\n const llmChain = new LLMChain({\n prompt: this.prompt,\n llm: this.llm,\n outputKey: this.outputKey,\n memory: this.memory,\n });\n if (!(this.inputKey in values)) {\n throw new Error(`Question key ${this.inputKey} not found.`);\n }\n const question: string = values[this.inputKey];\n let inputText = `${question}\\nSQLQuery:`;\n const tablesToUse = values.table_names_to_use;\n const tableInfo = await this.database.getTableInfo(tablesToUse);\n\n const llmInputs = {\n input: inputText,\n top_k: this.topK,\n dialect: this.database.appDataSourceOptions.type,\n table_info: tableInfo,\n stop: [\"\\nSQLResult:\"],\n };\n await this.verifyNumberOfTokens(inputText, tableInfo);\n\n const sqlCommand = await llmChain.predict(\n llmInputs,\n runManager?.getChild(\"sql_generation\")\n );\n let queryResult = \"\";\n try {\n queryResult = await this.database.appDataSource.query(sqlCommand);\n } catch (error) {\n console.error(error);\n }\n\n let finalResult;\n if (this.returnDirect) {\n finalResult = { [this.outputKey]: queryResult };\n } else {\n inputText += `${sqlCommand}\\nSQLResult: ${JSON.stringify(\n queryResult\n )}\\nAnswer:`;\n llmInputs.input = inputText;\n finalResult = {\n [this.outputKey]: await llmChain.predict(\n llmInputs,\n runManager?.getChild(\"result_generation\")\n ),\n };\n }\n\n if (this.sqlOutputKey != null) {\n finalResult[this.sqlOutputKey] = sqlCommand;\n }\n\n return finalResult;\n }\n\n _chainType() {\n return \"sql_database_chain\" as const;\n }\n\n get inputKeys(): string[] {\n return [this.inputKey];\n }\n\n get outputKeys(): string[] {\n if (this.sqlOutputKey != null) {\n return [this.outputKey, this.sqlOutputKey];\n }\n return [this.outputKey];\n }\n\n /**\n * Private method that verifies the number of tokens in the input text and\n * table information. It throws an error if the number of tokens exceeds\n * the maximum allowed by the language model.\n * @param inputText The input text.\n * @param tableinfo The table information.\n * @returns A promise that resolves when the verification is complete.\n */\n private async verifyNumberOfTokens(\n inputText: string,\n tableinfo: string\n ): Promise<void> {\n // We verify it only for OpenAI for the moment\n if (this.llm._llmType() !== \"openai\") {\n return;\n }\n const llm = this.llm as OpenAI;\n const promptTemplate = this.prompt.template;\n const stringWeSend = `${inputText}${promptTemplate}${tableinfo}`;\n\n const maxToken = await calculateMaxTokens({\n prompt: stringWeSend,\n // Cast here to allow for other models that may not fit the union\n modelName: llm.model as TiktokenModel,\n });\n\n if (maxToken < (llm.maxTokens ?? -1)) {\n throw new Error(`The combination of the database structure and your question is too big for the model ${\n llm.model\n } which can compute only a max tokens of ${getModelContextSize(\n llm.model\n )}.\n We suggest you to use the includeTables parameters when creating the SqlDatabase object to select only a subset of the tables. You can also use a model which can handle more tokens.`);\n }\n }\n}\n\nexport interface CreateSqlQueryChainFields {\n llm: BaseLanguageModel;\n db: SqlDatabase;\n prompt?: BasePromptTemplate;\n /**\n * @default 5\n */\n k?: number;\n dialect: SqlDialect;\n}\n\ntype SqlInput = {\n question: string;\n};\n\ntype SqlInoutWithTables = SqlInput & {\n tableNamesToUse: string[];\n};\n\nconst strip = (text: string) => {\n // Replace escaped quotes with actual quotes\n let newText = text.replace(/\\\\\"/g, '\"').trim();\n // Remove wrapping quotes if the entire string is wrapped in quotes\n if (newText.startsWith('\"') && newText.endsWith('\"')) {\n newText = newText.substring(1, newText.length - 1);\n }\n return newText;\n};\n\nconst difference = (setA: Set<string>, setB: Set<string>) =>\n new Set([...setA].filter((x) => !setB.has(x)));\n\n/**\n * Create a SQL query chain that can create SQL queries for the given database.\n * Returns a Runnable.\n *\n * @param {BaseLanguageModel} llm The language model to use in the chain.\n * @param {SqlDatabase} db The database to use in the chain.\n * @param {BasePromptTemplate | undefined} prompt The prompt to use in the chain.\n * @param {BaseLanguageModel | undefined} k The amount of docs/results to return. Passed through the prompt input value `top_k`.\n * @param {SqlDialect} dialect The SQL dialect to use in the chain.\n * @returns {Promise<RunnableSequence<Record<string, unknown>, string>>} A runnable sequence representing the chain.\n * @example ```typescript\n * const datasource = new DataSource({\n * type: \"sqlite\",\n * database: \"../../../../Chinook.db\",\n * });\n * const db = await SqlDatabase.fromDataSourceParams({\n * appDataSource: datasource,\n * });\n * const llm = new ChatOpenAI({ model: \"gpt-4o-mini\", temperature: 0 });\n * const chain = await createSqlQueryChain({\n * llm,\n * db,\n * dialect: \"sqlite\",\n * });\n * ```\n */\nexport async function createSqlQueryChain({\n llm,\n db,\n prompt,\n k = 5,\n dialect,\n}: CreateSqlQueryChainFields) {\n let promptToUse: BasePromptTemplate;\n if (prompt) {\n promptToUse = prompt;\n } else if (SQL_PROMPTS_MAP[dialect]) {\n promptToUse = SQL_PROMPTS_MAP[dialect];\n } else {\n promptToUse = DEFAULT_SQL_DATABASE_PROMPT;\n }\n\n if (\n difference(\n new Set([\"input\", \"top_k\", \"table_info\"]),\n new Set(promptToUse.inputVariables)\n ).size > 0\n ) {\n throw new Error(\n `Prompt must have input variables: 'input', 'top_k', 'table_info'. Received prompt with input variables: ` +\n `${promptToUse.inputVariables}. Full prompt:\\n\\n${promptToUse}`\n );\n }\n if (promptToUse.inputVariables.includes(\"dialect\")) {\n promptToUse = await promptToUse.partial({ dialect });\n }\n\n promptToUse = await promptToUse.partial({ top_k: k.toString() });\n\n const inputs = {\n input: (x: Record<string, unknown>) => {\n if (\"question\" in x) {\n return `${(x as SqlInput).question}\\nSQLQuery: `;\n }\n throw new Error(\"Input must include a question property.\");\n },\n table_info: async (x: Record<string, unknown>) =>\n db.getTableInfo((x as SqlInoutWithTables).tableNamesToUse),\n };\n\n return RunnableSequence.from([\n RunnablePassthrough.assign(inputs),\n (x) => {\n const newInputs = { ...x };\n delete newInputs.question;\n delete newInputs.tableNamesToUse;\n return newInputs;\n },\n promptToUse,\n llm.withConfig({ stop: [\"\\nSQLResult:\"] }),\n new StringOutputParser(),\n strip,\n ]);\n}\n"],"mappings":"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"}
|
|
1
|
+
{"version":3,"file":"sql_db_chain.js","names":[],"sources":["../../../src/chains/sql_db/sql_db_chain.ts"],"sourcesContent":["import type {\n BaseLanguageModel,\n BaseLanguageModelInterface,\n} from \"@langchain/core/language_models/base\";\nimport type { OpenAI, TiktokenModel } from \"@langchain/openai\";\nimport { ChainValues } from \"@langchain/core/utils/types\";\nimport { BasePromptTemplate, PromptTemplate } from \"@langchain/core/prompts\";\nimport {\n calculateMaxTokens,\n getModelContextSize,\n} from \"@langchain/core/language_models/base\";\nimport { CallbackManagerForChainRun } from \"@langchain/core/callbacks/manager\";\nimport {\n RunnablePassthrough,\n RunnableSequence,\n} from \"@langchain/core/runnables\";\nimport { StringOutputParser } from \"@langchain/core/output_parsers\";\nimport {\n DEFAULT_SQL_DATABASE_PROMPT,\n SQL_PROMPTS_MAP,\n SqlDialect,\n} from \"./sql_db_prompt.js\";\nimport { BaseChain, ChainInputs } from \"../base.js\";\nimport { LLMChain } from \"../llm_chain.js\";\nimport type { SqlDatabase } from \"../../sql_db.js\";\nimport { getPromptTemplateFromDataSource } from \"../../util/sql_utils.js\";\n\n/**\n * Interface that extends the ChainInputs interface and defines additional\n * fields specific to a SQL database chain. It represents the input fields\n * for a SQL database chain.\n */\nexport interface SqlDatabaseChainInput extends ChainInputs {\n llm: BaseLanguageModelInterface;\n database: SqlDatabase;\n topK?: number;\n inputKey?: string;\n outputKey?: string;\n sqlOutputKey?: string;\n prompt?: PromptTemplate;\n}\n\n/**\n * Class that represents a SQL database chain in the LangChain framework.\n * It extends the BaseChain class and implements the functionality\n * specific to a SQL database chain.\n *\n * @security **Security Notice**\n * This chain generates SQL queries for the given database.\n * The SQLDatabase class provides a getTableInfo method that can be used\n * to get column information as well as sample data from the table.\n * To mitigate risk of leaking sensitive data, limit permissions\n * to read and scope to the tables that are needed.\n * Optionally, use the includesTables or ignoreTables class parameters\n * to limit which tables can/cannot be accessed.\n *\n * @link See https://js.langchain.com/docs/security for more information.\n * @example\n * ```typescript\n * const chain = new SqlDatabaseChain({\n * llm: new OpenAI({ temperature: 0 }),\n * database: new SqlDatabase({ ...config }),\n * });\n *\n * const result = await chain.run(\"How many tracks are there?\");\n * ```\n */\nexport class SqlDatabaseChain extends BaseChain {\n static lc_name() {\n return \"SqlDatabaseChain\";\n }\n\n // LLM wrapper to use\n llm: BaseLanguageModelInterface;\n\n // SQL Database to connect to.\n database: SqlDatabase;\n\n // Prompt to use to translate natural language to SQL.\n prompt = DEFAULT_SQL_DATABASE_PROMPT;\n\n // Number of results to return from the query\n topK = 5;\n\n inputKey = \"query\";\n\n outputKey = \"result\";\n\n sqlOutputKey: string | undefined = undefined;\n\n // Whether to return the result of querying the SQL table directly.\n returnDirect = false;\n\n constructor(fields: SqlDatabaseChainInput) {\n super(fields);\n this.llm = fields.llm;\n this.database = fields.database;\n this.topK = fields.topK ?? this.topK;\n this.inputKey = fields.inputKey ?? this.inputKey;\n this.outputKey = fields.outputKey ?? this.outputKey;\n this.sqlOutputKey = fields.sqlOutputKey ?? this.sqlOutputKey;\n this.prompt =\n fields.prompt ??\n getPromptTemplateFromDataSource(this.database.appDataSource);\n }\n\n /** @ignore */\n async _call(\n values: ChainValues,\n runManager?: CallbackManagerForChainRun\n ): Promise<ChainValues> {\n const llmChain = new LLMChain({\n prompt: this.prompt,\n llm: this.llm,\n outputKey: this.outputKey,\n memory: this.memory,\n });\n if (!(this.inputKey in values)) {\n throw new Error(`Question key ${this.inputKey} not found.`);\n }\n const question: string = values[this.inputKey];\n let inputText = `${question}\\nSQLQuery:`;\n const tablesToUse = values.table_names_to_use;\n const tableInfo = await this.database.getTableInfo(tablesToUse);\n\n const llmInputs = {\n input: inputText,\n top_k: this.topK,\n dialect: this.database.appDataSourceOptions.type,\n table_info: tableInfo,\n stop: [\"\\nSQLResult:\"],\n };\n await this.verifyNumberOfTokens(inputText, tableInfo);\n\n const sqlCommand = await llmChain.predict(\n llmInputs,\n runManager?.getChild(\"sql_generation\")\n );\n let queryResult = \"\";\n try {\n queryResult = await this.database.appDataSource.query(sqlCommand);\n } catch (error) {\n console.error(error);\n }\n\n let finalResult;\n if (this.returnDirect) {\n finalResult = { [this.outputKey]: queryResult };\n } else {\n inputText += `${sqlCommand}\\nSQLResult: ${JSON.stringify(\n queryResult\n )}\\nAnswer:`;\n llmInputs.input = inputText;\n finalResult = {\n [this.outputKey]: await llmChain.predict(\n llmInputs,\n runManager?.getChild(\"result_generation\")\n ),\n };\n }\n\n if (this.sqlOutputKey != null) {\n finalResult[this.sqlOutputKey] = sqlCommand;\n }\n\n return finalResult;\n }\n\n _chainType() {\n return \"sql_database_chain\" as const;\n }\n\n get inputKeys(): string[] {\n return [this.inputKey];\n }\n\n get outputKeys(): string[] {\n if (this.sqlOutputKey != null) {\n return [this.outputKey, this.sqlOutputKey];\n }\n return [this.outputKey];\n }\n\n /**\n * Private method that verifies the number of tokens in the input text and\n * table information. It throws an error if the number of tokens exceeds\n * the maximum allowed by the language model.\n * @param inputText The input text.\n * @param tableinfo The table information.\n * @returns A promise that resolves when the verification is complete.\n */\n private async verifyNumberOfTokens(\n inputText: string,\n tableinfo: string\n ): Promise<void> {\n // We verify it only for OpenAI for the moment\n if (this.llm._llmType() !== \"openai\") {\n return;\n }\n const llm = this.llm as OpenAI;\n const promptTemplate = this.prompt.template;\n const stringWeSend = `${inputText}${promptTemplate}${tableinfo}`;\n\n const maxToken = await calculateMaxTokens({\n prompt: stringWeSend,\n // Cast here to allow for other models that may not fit the union\n modelName: llm.model as TiktokenModel,\n });\n\n if (maxToken < (llm.maxTokens ?? -1)) {\n throw new Error(`The combination of the database structure and your question is too big for the model ${\n llm.model\n } which can compute only a max tokens of ${getModelContextSize(\n llm.model\n )}.\n We suggest you to use the includeTables parameters when creating the SqlDatabase object to select only a subset of the tables. You can also use a model which can handle more tokens.`);\n }\n }\n}\n\nexport interface CreateSqlQueryChainFields {\n llm: BaseLanguageModel;\n db: SqlDatabase;\n prompt?: BasePromptTemplate;\n /**\n * @default 5\n */\n k?: number;\n dialect: SqlDialect;\n}\n\ntype SqlInput = {\n question: string;\n};\n\ntype SqlInoutWithTables = SqlInput & {\n tableNamesToUse: string[];\n};\n\nconst strip = (text: string) => {\n // Replace escaped quotes with actual quotes\n let newText = text.replace(/\\\\\"/g, '\"').trim();\n // Remove wrapping quotes if the entire string is wrapped in quotes\n if (newText.startsWith('\"') && newText.endsWith('\"')) {\n newText = newText.substring(1, newText.length - 1);\n }\n return newText;\n};\n\nconst difference = (setA: Set<string>, setB: Set<string>) =>\n new Set([...setA].filter((x) => !setB.has(x)));\n\n/**\n * Create a SQL query chain that can create SQL queries for the given database.\n * Returns a Runnable.\n *\n * @param {BaseLanguageModel} llm The language model to use in the chain.\n * @param {SqlDatabase} db The database to use in the chain.\n * @param {BasePromptTemplate | undefined} prompt The prompt to use in the chain.\n * @param {BaseLanguageModel | undefined} k The amount of docs/results to return. Passed through the prompt input value `top_k`.\n * @param {SqlDialect} dialect The SQL dialect to use in the chain.\n * @returns {Promise<RunnableSequence<Record<string, unknown>, string>>} A runnable sequence representing the chain.\n * @example ```typescript\n * const datasource = new DataSource({\n * type: \"sqlite\",\n * database: \"../../../../Chinook.db\",\n * });\n * const db = await SqlDatabase.fromDataSourceParams({\n * appDataSource: datasource,\n * });\n * const llm = new ChatOpenAI({ model: \"gpt-4o-mini\", temperature: 0 });\n * const chain = await createSqlQueryChain({\n * llm,\n * db,\n * dialect: \"sqlite\",\n * });\n * ```\n */\nexport async function createSqlQueryChain({\n llm,\n db,\n prompt,\n k = 5,\n dialect,\n}: CreateSqlQueryChainFields) {\n let promptToUse: BasePromptTemplate;\n if (prompt) {\n promptToUse = prompt;\n } else if (SQL_PROMPTS_MAP[dialect]) {\n promptToUse = SQL_PROMPTS_MAP[dialect];\n } else {\n promptToUse = DEFAULT_SQL_DATABASE_PROMPT;\n }\n\n if (\n difference(\n new Set([\"input\", \"top_k\", \"table_info\"]),\n new Set(promptToUse.inputVariables)\n ).size > 0\n ) {\n throw new Error(\n `Prompt must have input variables: 'input', 'top_k', 'table_info'. Received prompt with input variables: ` +\n `${promptToUse.inputVariables}. Full prompt:\\n\\n${promptToUse}`\n );\n }\n if (promptToUse.inputVariables.includes(\"dialect\")) {\n promptToUse = await promptToUse.partial({ dialect });\n }\n\n promptToUse = await promptToUse.partial({ top_k: k.toString() });\n\n const inputs = {\n input: (x: Record<string, unknown>) => {\n if (\"question\" in x) {\n return `${(x as SqlInput).question}\\nSQLQuery: `;\n }\n throw new Error(\"Input must include a question property.\");\n },\n table_info: async (x: Record<string, unknown>) =>\n db.getTableInfo((x as SqlInoutWithTables).tableNamesToUse),\n };\n\n return RunnableSequence.from([\n RunnablePassthrough.assign(inputs),\n (x) => {\n const newInputs = { ...x };\n delete newInputs.question;\n delete newInputs.tableNamesToUse;\n return newInputs;\n },\n promptToUse,\n llm.withConfig({ stop: [\"\\nSQLResult:\"] }),\n new StringOutputParser(),\n strip,\n ]);\n}\n"],"mappings":"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"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
require("../../_virtual/_rolldown/runtime.cjs");
|
|
2
1
|
let _langchain_core_prompts = require("@langchain/core/prompts");
|
|
3
2
|
//#region src/chains/sql_db/sql_db_prompt.ts
|
|
4
|
-
const DEFAULT_SQL_DATABASE_PROMPT =
|
|
3
|
+
const DEFAULT_SQL_DATABASE_PROMPT = /*#__PURE__*/ new _langchain_core_prompts.PromptTemplate({
|
|
5
4
|
template: `Given an input question, first create a syntactically correct {dialect} query to run, then look at the results of the query and return the answer. Unless the user specifies in his question a specific number of examples he wishes to obtain, always limit your query to at most {top_k} results. You can order the results by a relevant column to return the most interesting examples in the database.
|
|
6
5
|
|
|
7
6
|
Never query for all the columns from a specific table, only ask for a the few relevant columns given the question.
|
|
@@ -27,7 +26,7 @@ Question: {input}`,
|
|
|
27
26
|
"top_k"
|
|
28
27
|
]
|
|
29
28
|
});
|
|
30
|
-
const SQL_POSTGRES_PROMPT =
|
|
29
|
+
const SQL_POSTGRES_PROMPT = /*#__PURE__*/ new _langchain_core_prompts.PromptTemplate({
|
|
31
30
|
template: `You are a PostgreSQL expert. Given an input question, first create a syntactically correct PostgreSQL query to run, then look at the results of the query and return the answer to the input question.
|
|
32
31
|
Unless the user specifies in the question a specific number of examples to obtain, query for at most {top_k} results using the LIMIT clause as per PostgreSQL. You can order the results to return the most informative data in the database.
|
|
33
32
|
Never query for all columns from a table. You must query only the columns that are needed to answer the question. Wrap each column name in double quotes (") to denote them as delimited identifiers.
|
|
@@ -51,7 +50,7 @@ Question: {input}`,
|
|
|
51
50
|
"top_k"
|
|
52
51
|
]
|
|
53
52
|
});
|
|
54
|
-
const SQL_SQLITE_PROMPT =
|
|
53
|
+
const SQL_SQLITE_PROMPT = /*#__PURE__*/ new _langchain_core_prompts.PromptTemplate({
|
|
55
54
|
template: `You are a SQLite expert. Given an input question, first create a syntactically correct SQLite query to run, then look at the results of the query and return the answer to the input question.
|
|
56
55
|
Unless the user specifies in the question a specific number of examples to obtain, query for at most {top_k} results using the LIMIT clause as per SQLite. You can order the results to return the most informative data in the database.
|
|
57
56
|
Never query for all columns from a table. You must query only the columns that are needed to answer the question. Wrap each column name in double quotes (") to denote them as delimited identifiers.
|
|
@@ -75,7 +74,7 @@ Question: {input}`,
|
|
|
75
74
|
"top_k"
|
|
76
75
|
]
|
|
77
76
|
});
|
|
78
|
-
const SQL_MYSQL_PROMPT =
|
|
77
|
+
const SQL_MYSQL_PROMPT = /*#__PURE__*/ new _langchain_core_prompts.PromptTemplate({
|
|
79
78
|
template: `You are a MySQL expert. Given an input question, first create a syntactically correct MySQL query to run, then look at the results of the query and return the answer to the input question.
|
|
80
79
|
Unless the user specifies in the question a specific number of examples to obtain, query for at most {top_k} results using the LIMIT clause as per MySQL. You can order the results to return the most informative data in the database.
|
|
81
80
|
Never query for all columns from a table. You must query only the columns that are needed to answer the question. Wrap each column name in backticks (\`) to denote them as delimited identifiers.
|
|
@@ -99,7 +98,7 @@ Question: {input}`,
|
|
|
99
98
|
"top_k"
|
|
100
99
|
]
|
|
101
100
|
});
|
|
102
|
-
const SQL_MSSQL_PROMPT =
|
|
101
|
+
const SQL_MSSQL_PROMPT = /*#__PURE__*/ new _langchain_core_prompts.PromptTemplate({
|
|
103
102
|
template: `You are an MS SQL expert. Given an input question, first create a syntactically correct MS SQL query to run, then look at the results of the query and return the answer to the input question.
|
|
104
103
|
Unless the user specifies in the question a specific number of examples to obtain, query for at most {top_k} results using the TOP clause as per MS SQL. You can order the results to return the most informative data in the database.
|
|
105
104
|
Never query for all columns from a table. You must query only the columns that are needed to answer the question. Wrap each column name in square brackets ([]) to denote them as delimited identifiers.
|
|
@@ -123,7 +122,7 @@ Question: {input}`,
|
|
|
123
122
|
"top_k"
|
|
124
123
|
]
|
|
125
124
|
});
|
|
126
|
-
const SQL_SAP_HANA_PROMPT =
|
|
125
|
+
const SQL_SAP_HANA_PROMPT = /*#__PURE__*/ new _langchain_core_prompts.PromptTemplate({
|
|
127
126
|
template: `You are a SAP HANA expert. Given an input question, first create a syntactically correct SAP HANA query to run, then look at the results of the query and return the answer to the input question.
|
|
128
127
|
Unless the user specifies in the question a specific number of examples to obtain, query for at most {top_k} results using the LIMIT clause as per SAP HANA. You can order the results to return the most informative data in the database.
|
|
129
128
|
Never query for all columns from a table. You must query only the columns that are needed to answer the question. Wrap each column name in double quotes (") to denote them as delimited identifiers.
|
|
@@ -148,7 +147,7 @@ Question: {input}`,
|
|
|
148
147
|
"top_k"
|
|
149
148
|
]
|
|
150
149
|
});
|
|
151
|
-
const SQL_ORACLE_PROMPT =
|
|
150
|
+
const SQL_ORACLE_PROMPT = /*#__PURE__*/ new _langchain_core_prompts.PromptTemplate({
|
|
152
151
|
template: `You are a ORACLE expert. Given an input question, first create a syntactically correct ORACLE query to run, then look at the results of the query and return the answer to the input question.
|
|
153
152
|
Unless the user specifies in the question a specific number of examples to obtain, query for at most {top_k} results using the ROWNUM clause as per ORACLE. You can order the results to return the most informative data in the database.
|
|
154
153
|
Never query for all columns from a table. You must query only the columns that are needed to answer the question.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sql_db_prompt.cjs","names":["PromptTemplate"],"sources":["../../../src/chains/sql_db/sql_db_prompt.ts"],"sourcesContent":["import { BasePromptTemplate, PromptTemplate } from \"@langchain/core/prompts\";\n\nexport const DEFAULT_SQL_DATABASE_PROMPT = /*#__PURE__*/ new PromptTemplate({\n template: `Given an input question, first create a syntactically correct {dialect} query to run, then look at the results of the query and return the answer. Unless the user specifies in his question a specific number of examples he wishes to obtain, always limit your query to at most {top_k} results. You can order the results by a relevant column to return the most interesting examples in the database.\n\nNever query for all the columns from a specific table, only ask for a the few relevant columns given the question.\n\nPay attention to use only the column names that you can see in the schema description. Be careful to not query for columns that do not exist. Also, pay attention to which column is in which table.\n\nUse the following format:\n\nQuestion: \"Question here\"\nSQLQuery: \"SQL Query to run\"\nSQLResult: \"Result of the SQLQuery\"\nAnswer: \"Final answer here\"\n\nOnly use the tables listed below.\n\n{table_info}\n\nQuestion: {input}`,\n inputVariables: [\"dialect\", \"table_info\", \"input\", \"top_k\"],\n});\n\nexport const SQL_POSTGRES_PROMPT = /*#__PURE__*/ new PromptTemplate({\n template: `You are a PostgreSQL expert. Given an input question, first create a syntactically correct PostgreSQL query to run, then look at the results of the query and return the answer to the input question.\nUnless the user specifies in the question a specific number of examples to obtain, query for at most {top_k} results using the LIMIT clause as per PostgreSQL. You can order the results to return the most informative data in the database.\nNever query for all columns from a table. You must query only the columns that are needed to answer the question. Wrap each column name in double quotes (\") to denote them as delimited identifiers.\nPay attention to use only the column names you can see in the tables below. Be careful to not query for columns that do not exist. Also, pay attention to which column is in which table.\n\nUse the following format:\n\nQuestion: \"Question here\"\nSQLQuery: \"SQL Query to run\"\nSQLResult: \"Result of the SQLQuery\"\nAnswer: \"Final answer here\"\n\nOnly use the following tables:\n{table_info}\n\nQuestion: {input}`,\n inputVariables: [\"dialect\", \"table_info\", \"input\", \"top_k\"],\n});\n\nexport const SQL_SQLITE_PROMPT = /*#__PURE__*/ new PromptTemplate({\n template: `You are a SQLite expert. Given an input question, first create a syntactically correct SQLite query to run, then look at the results of the query and return the answer to the input question.\nUnless the user specifies in the question a specific number of examples to obtain, query for at most {top_k} results using the LIMIT clause as per SQLite. You can order the results to return the most informative data in the database.\nNever query for all columns from a table. You must query only the columns that are needed to answer the question. Wrap each column name in double quotes (\") to denote them as delimited identifiers.\nPay attention to use only the column names you can see in the tables below. Be careful to not query for columns that do not exist. Also, pay attention to which column is in which table.\n\nUse the following format:\n\nQuestion: \"Question here\"\nSQLQuery: \"SQL Query to run\"\nSQLResult: \"Result of the SQLQuery\"\nAnswer: \"Final answer here\"\n\nOnly use the following tables:\n{table_info}\n\nQuestion: {input}`,\n inputVariables: [\"dialect\", \"table_info\", \"input\", \"top_k\"],\n});\n\nexport const SQL_MYSQL_PROMPT = /*#__PURE__*/ new PromptTemplate({\n template: `You are a MySQL expert. Given an input question, first create a syntactically correct MySQL query to run, then look at the results of the query and return the answer to the input question.\nUnless the user specifies in the question a specific number of examples to obtain, query for at most {top_k} results using the LIMIT clause as per MySQL. You can order the results to return the most informative data in the database.\nNever query for all columns from a table. You must query only the columns that are needed to answer the question. Wrap each column name in backticks (\\`) to denote them as delimited identifiers.\nPay attention to use only the column names you can see in the tables below. Be careful to not query for columns that do not exist. Also, pay attention to which column is in which table.\n\nUse the following format:\n\nQuestion: \"Question here\"\nSQLQuery: \"SQL Query to run\"\nSQLResult: \"Result of the SQLQuery\"\nAnswer: \"Final answer here\"\n\nOnly use the following tables:\n{table_info}\n\nQuestion: {input}`,\n inputVariables: [\"dialect\", \"table_info\", \"input\", \"top_k\"],\n});\n\nexport const SQL_MSSQL_PROMPT = /*#__PURE__*/ new PromptTemplate({\n template: `You are an MS SQL expert. Given an input question, first create a syntactically correct MS SQL query to run, then look at the results of the query and return the answer to the input question.\nUnless the user specifies in the question a specific number of examples to obtain, query for at most {top_k} results using the TOP clause as per MS SQL. You can order the results to return the most informative data in the database.\nNever query for all columns from a table. You must query only the columns that are needed to answer the question. Wrap each column name in square brackets ([]) to denote them as delimited identifiers.\nPay attention to use only the column names you can see in the tables below. Be careful to not query for columns that do not exist. Also, pay attention to which column is in which table.\n\nUse the following format:\n\nQuestion: \"Question here\"\nSQLQuery: \"SQL Query to run\"\nSQLResult: \"Result of the SQLQuery\"\nAnswer: \"Final answer here\"\n\nOnly use the following tables:\n{table_info}\n\nQuestion: {input}`,\n inputVariables: [\"dialect\", \"table_info\", \"input\", \"top_k\"],\n});\n\nexport const SQL_SAP_HANA_PROMPT = /*#__PURE__*/ new PromptTemplate({\n template: `You are a SAP HANA expert. Given an input question, first create a syntactically correct SAP HANA query to run, then look at the results of the query and return the answer to the input question.\nUnless the user specifies in the question a specific number of examples to obtain, query for at most {top_k} results using the LIMIT clause as per SAP HANA. You can order the results to return the most informative data in the database.\nNever query for all columns from a table. You must query only the columns that are needed to answer the question. Wrap each column name in double quotes (\") to denote them as delimited identifiers.\nPay attention to use only the column names you can see in the tables below. Be careful to not query for columns that do not exist. Also, pay attention to which column is in which table.\nAlways use a schema name when executing a query.\n\nUse the following format:\n\nQuestion: \"Question here\"\nSQLQuery: \"SQL Query to run\"\nSQLResult: \"Result of the SQLQuery\"\nAnswer: \"Final answer here\"\n\nOnly use the following tables:\n{table_info}\n\nQuestion: {input}`,\n inputVariables: [\"dialect\", \"table_info\", \"input\", \"top_k\"],\n});\n\nexport const SQL_ORACLE_PROMPT = /*#__PURE__*/ new PromptTemplate({\n template: `You are a ORACLE expert. Given an input question, first create a syntactically correct ORACLE query to run, then look at the results of the query and return the answer to the input question.\nUnless the user specifies in the question a specific number of examples to obtain, query for at most {top_k} results using the ROWNUM clause as per ORACLE. You can order the results to return the most informative data in the database.\nNever query for all columns from a table. You must query only the columns that are needed to answer the question.\nPay attention to use only the column names you can see in the tables below. Be careful to not query for columns that do not exist. Also, pay attention to which column is in which table.\n\nUse the following format:\n\nQuestion: \"Question here\"\nSQLQuery: \"SQL Query to run\"\nSQLResult: \"Result of the SQLQuery\"\nAnswer: \"Final answer here\"\n\nOnly use the following tables:\n{table_info}\n\nQuestion: {input}`,\n inputVariables: [\"dialect\", \"table_info\", \"input\", \"top_k\"],\n});\n\nexport type SqlDialect =\n | \"oracle\"\n | \"postgres\"\n | \"sqlite\"\n | \"mysql\"\n | \"mssql\"\n | \"sap hana\";\n\nexport const SQL_PROMPTS_MAP: Record<SqlDialect, BasePromptTemplate> = {\n oracle: SQL_ORACLE_PROMPT,\n postgres: SQL_POSTGRES_PROMPT,\n sqlite: SQL_SQLITE_PROMPT,\n mysql: SQL_MYSQL_PROMPT,\n mssql: SQL_MSSQL_PROMPT,\n \"sap hana\": SQL_SAP_HANA_PROMPT,\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"sql_db_prompt.cjs","names":["PromptTemplate"],"sources":["../../../src/chains/sql_db/sql_db_prompt.ts"],"sourcesContent":["import { BasePromptTemplate, PromptTemplate } from \"@langchain/core/prompts\";\n\nexport const DEFAULT_SQL_DATABASE_PROMPT = /*#__PURE__*/ new PromptTemplate({\n template: `Given an input question, first create a syntactically correct {dialect} query to run, then look at the results of the query and return the answer. Unless the user specifies in his question a specific number of examples he wishes to obtain, always limit your query to at most {top_k} results. You can order the results by a relevant column to return the most interesting examples in the database.\n\nNever query for all the columns from a specific table, only ask for a the few relevant columns given the question.\n\nPay attention to use only the column names that you can see in the schema description. Be careful to not query for columns that do not exist. Also, pay attention to which column is in which table.\n\nUse the following format:\n\nQuestion: \"Question here\"\nSQLQuery: \"SQL Query to run\"\nSQLResult: \"Result of the SQLQuery\"\nAnswer: \"Final answer here\"\n\nOnly use the tables listed below.\n\n{table_info}\n\nQuestion: {input}`,\n inputVariables: [\"dialect\", \"table_info\", \"input\", \"top_k\"],\n});\n\nexport const SQL_POSTGRES_PROMPT = /*#__PURE__*/ new PromptTemplate({\n template: `You are a PostgreSQL expert. Given an input question, first create a syntactically correct PostgreSQL query to run, then look at the results of the query and return the answer to the input question.\nUnless the user specifies in the question a specific number of examples to obtain, query for at most {top_k} results using the LIMIT clause as per PostgreSQL. You can order the results to return the most informative data in the database.\nNever query for all columns from a table. You must query only the columns that are needed to answer the question. Wrap each column name in double quotes (\") to denote them as delimited identifiers.\nPay attention to use only the column names you can see in the tables below. Be careful to not query for columns that do not exist. Also, pay attention to which column is in which table.\n\nUse the following format:\n\nQuestion: \"Question here\"\nSQLQuery: \"SQL Query to run\"\nSQLResult: \"Result of the SQLQuery\"\nAnswer: \"Final answer here\"\n\nOnly use the following tables:\n{table_info}\n\nQuestion: {input}`,\n inputVariables: [\"dialect\", \"table_info\", \"input\", \"top_k\"],\n});\n\nexport const SQL_SQLITE_PROMPT = /*#__PURE__*/ new PromptTemplate({\n template: `You are a SQLite expert. Given an input question, first create a syntactically correct SQLite query to run, then look at the results of the query and return the answer to the input question.\nUnless the user specifies in the question a specific number of examples to obtain, query for at most {top_k} results using the LIMIT clause as per SQLite. You can order the results to return the most informative data in the database.\nNever query for all columns from a table. You must query only the columns that are needed to answer the question. Wrap each column name in double quotes (\") to denote them as delimited identifiers.\nPay attention to use only the column names you can see in the tables below. Be careful to not query for columns that do not exist. Also, pay attention to which column is in which table.\n\nUse the following format:\n\nQuestion: \"Question here\"\nSQLQuery: \"SQL Query to run\"\nSQLResult: \"Result of the SQLQuery\"\nAnswer: \"Final answer here\"\n\nOnly use the following tables:\n{table_info}\n\nQuestion: {input}`,\n inputVariables: [\"dialect\", \"table_info\", \"input\", \"top_k\"],\n});\n\nexport const SQL_MYSQL_PROMPT = /*#__PURE__*/ new PromptTemplate({\n template: `You are a MySQL expert. Given an input question, first create a syntactically correct MySQL query to run, then look at the results of the query and return the answer to the input question.\nUnless the user specifies in the question a specific number of examples to obtain, query for at most {top_k} results using the LIMIT clause as per MySQL. You can order the results to return the most informative data in the database.\nNever query for all columns from a table. You must query only the columns that are needed to answer the question. Wrap each column name in backticks (\\`) to denote them as delimited identifiers.\nPay attention to use only the column names you can see in the tables below. Be careful to not query for columns that do not exist. Also, pay attention to which column is in which table.\n\nUse the following format:\n\nQuestion: \"Question here\"\nSQLQuery: \"SQL Query to run\"\nSQLResult: \"Result of the SQLQuery\"\nAnswer: \"Final answer here\"\n\nOnly use the following tables:\n{table_info}\n\nQuestion: {input}`,\n inputVariables: [\"dialect\", \"table_info\", \"input\", \"top_k\"],\n});\n\nexport const SQL_MSSQL_PROMPT = /*#__PURE__*/ new PromptTemplate({\n template: `You are an MS SQL expert. Given an input question, first create a syntactically correct MS SQL query to run, then look at the results of the query and return the answer to the input question.\nUnless the user specifies in the question a specific number of examples to obtain, query for at most {top_k} results using the TOP clause as per MS SQL. You can order the results to return the most informative data in the database.\nNever query for all columns from a table. You must query only the columns that are needed to answer the question. Wrap each column name in square brackets ([]) to denote them as delimited identifiers.\nPay attention to use only the column names you can see in the tables below. Be careful to not query for columns that do not exist. Also, pay attention to which column is in which table.\n\nUse the following format:\n\nQuestion: \"Question here\"\nSQLQuery: \"SQL Query to run\"\nSQLResult: \"Result of the SQLQuery\"\nAnswer: \"Final answer here\"\n\nOnly use the following tables:\n{table_info}\n\nQuestion: {input}`,\n inputVariables: [\"dialect\", \"table_info\", \"input\", \"top_k\"],\n});\n\nexport const SQL_SAP_HANA_PROMPT = /*#__PURE__*/ new PromptTemplate({\n template: `You are a SAP HANA expert. Given an input question, first create a syntactically correct SAP HANA query to run, then look at the results of the query and return the answer to the input question.\nUnless the user specifies in the question a specific number of examples to obtain, query for at most {top_k} results using the LIMIT clause as per SAP HANA. You can order the results to return the most informative data in the database.\nNever query for all columns from a table. You must query only the columns that are needed to answer the question. Wrap each column name in double quotes (\") to denote them as delimited identifiers.\nPay attention to use only the column names you can see in the tables below. Be careful to not query for columns that do not exist. Also, pay attention to which column is in which table.\nAlways use a schema name when executing a query.\n\nUse the following format:\n\nQuestion: \"Question here\"\nSQLQuery: \"SQL Query to run\"\nSQLResult: \"Result of the SQLQuery\"\nAnswer: \"Final answer here\"\n\nOnly use the following tables:\n{table_info}\n\nQuestion: {input}`,\n inputVariables: [\"dialect\", \"table_info\", \"input\", \"top_k\"],\n});\n\nexport const SQL_ORACLE_PROMPT = /*#__PURE__*/ new PromptTemplate({\n template: `You are a ORACLE expert. Given an input question, first create a syntactically correct ORACLE query to run, then look at the results of the query and return the answer to the input question.\nUnless the user specifies in the question a specific number of examples to obtain, query for at most {top_k} results using the ROWNUM clause as per ORACLE. You can order the results to return the most informative data in the database.\nNever query for all columns from a table. You must query only the columns that are needed to answer the question.\nPay attention to use only the column names you can see in the tables below. Be careful to not query for columns that do not exist. Also, pay attention to which column is in which table.\n\nUse the following format:\n\nQuestion: \"Question here\"\nSQLQuery: \"SQL Query to run\"\nSQLResult: \"Result of the SQLQuery\"\nAnswer: \"Final answer here\"\n\nOnly use the following tables:\n{table_info}\n\nQuestion: {input}`,\n inputVariables: [\"dialect\", \"table_info\", \"input\", \"top_k\"],\n});\n\nexport type SqlDialect =\n | \"oracle\"\n | \"postgres\"\n | \"sqlite\"\n | \"mysql\"\n | \"mssql\"\n | \"sap hana\";\n\nexport const SQL_PROMPTS_MAP: Record<SqlDialect, BasePromptTemplate> = {\n oracle: SQL_ORACLE_PROMPT,\n postgres: SQL_POSTGRES_PROMPT,\n sqlite: SQL_SQLITE_PROMPT,\n mysql: SQL_MYSQL_PROMPT,\n mssql: SQL_MSSQL_PROMPT,\n \"sap hana\": SQL_SAP_HANA_PROMPT,\n};\n"],"mappings":";;AAEA,MAAa,4CAA4C,IAAIA,wBAAAA,eAAe;CAC1E,UAAU;;;;;;;;;;;;;;;;;;CAkBV,gBAAgB;EAAC;EAAW;EAAc;EAAS;CAAO;AAC5D,CAAC;AAED,MAAa,oCAAoC,IAAIA,wBAAAA,eAAe;CAClE,UAAU;;;;;;;;;;;;;;;;CAgBV,gBAAgB;EAAC;EAAW;EAAc;EAAS;CAAO;AAC5D,CAAC;AAED,MAAa,kCAAkC,IAAIA,wBAAAA,eAAe;CAChE,UAAU;;;;;;;;;;;;;;;;CAgBV,gBAAgB;EAAC;EAAW;EAAc;EAAS;CAAO;AAC5D,CAAC;AAED,MAAa,iCAAiC,IAAIA,wBAAAA,eAAe;CAC/D,UAAU;;;;;;;;;;;;;;;;CAgBV,gBAAgB;EAAC;EAAW;EAAc;EAAS;CAAO;AAC5D,CAAC;AAED,MAAa,iCAAiC,IAAIA,wBAAAA,eAAe;CAC/D,UAAU;;;;;;;;;;;;;;;;CAgBV,gBAAgB;EAAC;EAAW;EAAc;EAAS;CAAO;AAC5D,CAAC;AAED,MAAa,oCAAoC,IAAIA,wBAAAA,eAAe;CAClE,UAAU;;;;;;;;;;;;;;;;;CAiBV,gBAAgB;EAAC;EAAW;EAAc;EAAS;CAAO;AAC5D,CAAC;AAED,MAAa,kCAAkC,IAAIA,wBAAAA,eAAe;CAChE,UAAU;;;;;;;;;;;;;;;;CAgBV,gBAAgB;EAAC;EAAW;EAAc;EAAS;CAAO;AAC5D,CAAC;AAUD,MAAa,kBAA0D;CACrE,QAAQ;CACR,UAAU;CACV,QAAQ;CACR,OAAO;CACP,OAAO;CACP,YAAY;AACd"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sql_db_prompt.d.cts","names":[],"sources":["../../../src/chains/sql_db/sql_db_prompt.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"sql_db_prompt.d.cts","names":[],"sources":["../../../src/chains/sql_db/sql_db_prompt.ts"],"mappings":";;cAEa,6BAA2B;;;;;;cAsB3B,qBAAmB;;;;;;cAoBnB,mBAAiB;;;;;;cAoBjB,kBAAgB;;;;;;cAoBhB,kBAAgB;;;;;;cAoBhB,qBAAmB;;;;;;KAyCpB;cAQC,iBAAiB,OAAO,YAAY"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sql_db_prompt.d.ts","names":[],"sources":["../../../src/chains/sql_db/sql_db_prompt.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"sql_db_prompt.d.ts","names":[],"sources":["../../../src/chains/sql_db/sql_db_prompt.ts"],"mappings":";;cAEa,6BAA2B;;;;;;cAsB3B,qBAAmB;;;;;;cAoBnB,mBAAiB;;;;;;cAoBjB,kBAAgB;;;;;;cAoBhB,kBAAgB;;;;;;cAoBhB,qBAAmB;;;;;;KAyCpB;cAQC,iBAAiB,OAAO,YAAY"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PromptTemplate } from "@langchain/core/prompts";
|
|
2
2
|
//#region src/chains/sql_db/sql_db_prompt.ts
|
|
3
|
-
const DEFAULT_SQL_DATABASE_PROMPT =
|
|
3
|
+
const DEFAULT_SQL_DATABASE_PROMPT = /*#__PURE__*/ new PromptTemplate({
|
|
4
4
|
template: `Given an input question, first create a syntactically correct {dialect} query to run, then look at the results of the query and return the answer. Unless the user specifies in his question a specific number of examples he wishes to obtain, always limit your query to at most {top_k} results. You can order the results by a relevant column to return the most interesting examples in the database.
|
|
5
5
|
|
|
6
6
|
Never query for all the columns from a specific table, only ask for a the few relevant columns given the question.
|
|
@@ -26,7 +26,7 @@ Question: {input}`,
|
|
|
26
26
|
"top_k"
|
|
27
27
|
]
|
|
28
28
|
});
|
|
29
|
-
const SQL_POSTGRES_PROMPT =
|
|
29
|
+
const SQL_POSTGRES_PROMPT = /*#__PURE__*/ new PromptTemplate({
|
|
30
30
|
template: `You are a PostgreSQL expert. Given an input question, first create a syntactically correct PostgreSQL query to run, then look at the results of the query and return the answer to the input question.
|
|
31
31
|
Unless the user specifies in the question a specific number of examples to obtain, query for at most {top_k} results using the LIMIT clause as per PostgreSQL. You can order the results to return the most informative data in the database.
|
|
32
32
|
Never query for all columns from a table. You must query only the columns that are needed to answer the question. Wrap each column name in double quotes (") to denote them as delimited identifiers.
|
|
@@ -50,7 +50,7 @@ Question: {input}`,
|
|
|
50
50
|
"top_k"
|
|
51
51
|
]
|
|
52
52
|
});
|
|
53
|
-
const SQL_SQLITE_PROMPT =
|
|
53
|
+
const SQL_SQLITE_PROMPT = /*#__PURE__*/ new PromptTemplate({
|
|
54
54
|
template: `You are a SQLite expert. Given an input question, first create a syntactically correct SQLite query to run, then look at the results of the query and return the answer to the input question.
|
|
55
55
|
Unless the user specifies in the question a specific number of examples to obtain, query for at most {top_k} results using the LIMIT clause as per SQLite. You can order the results to return the most informative data in the database.
|
|
56
56
|
Never query for all columns from a table. You must query only the columns that are needed to answer the question. Wrap each column name in double quotes (") to denote them as delimited identifiers.
|
|
@@ -74,7 +74,7 @@ Question: {input}`,
|
|
|
74
74
|
"top_k"
|
|
75
75
|
]
|
|
76
76
|
});
|
|
77
|
-
const SQL_MYSQL_PROMPT =
|
|
77
|
+
const SQL_MYSQL_PROMPT = /*#__PURE__*/ new PromptTemplate({
|
|
78
78
|
template: `You are a MySQL expert. Given an input question, first create a syntactically correct MySQL query to run, then look at the results of the query and return the answer to the input question.
|
|
79
79
|
Unless the user specifies in the question a specific number of examples to obtain, query for at most {top_k} results using the LIMIT clause as per MySQL. You can order the results to return the most informative data in the database.
|
|
80
80
|
Never query for all columns from a table. You must query only the columns that are needed to answer the question. Wrap each column name in backticks (\`) to denote them as delimited identifiers.
|
|
@@ -98,7 +98,7 @@ Question: {input}`,
|
|
|
98
98
|
"top_k"
|
|
99
99
|
]
|
|
100
100
|
});
|
|
101
|
-
const SQL_MSSQL_PROMPT =
|
|
101
|
+
const SQL_MSSQL_PROMPT = /*#__PURE__*/ new PromptTemplate({
|
|
102
102
|
template: `You are an MS SQL expert. Given an input question, first create a syntactically correct MS SQL query to run, then look at the results of the query and return the answer to the input question.
|
|
103
103
|
Unless the user specifies in the question a specific number of examples to obtain, query for at most {top_k} results using the TOP clause as per MS SQL. You can order the results to return the most informative data in the database.
|
|
104
104
|
Never query for all columns from a table. You must query only the columns that are needed to answer the question. Wrap each column name in square brackets ([]) to denote them as delimited identifiers.
|
|
@@ -122,7 +122,7 @@ Question: {input}`,
|
|
|
122
122
|
"top_k"
|
|
123
123
|
]
|
|
124
124
|
});
|
|
125
|
-
const SQL_SAP_HANA_PROMPT =
|
|
125
|
+
const SQL_SAP_HANA_PROMPT = /*#__PURE__*/ new PromptTemplate({
|
|
126
126
|
template: `You are a SAP HANA expert. Given an input question, first create a syntactically correct SAP HANA query to run, then look at the results of the query and return the answer to the input question.
|
|
127
127
|
Unless the user specifies in the question a specific number of examples to obtain, query for at most {top_k} results using the LIMIT clause as per SAP HANA. You can order the results to return the most informative data in the database.
|
|
128
128
|
Never query for all columns from a table. You must query only the columns that are needed to answer the question. Wrap each column name in double quotes (") to denote them as delimited identifiers.
|
|
@@ -147,7 +147,7 @@ Question: {input}`,
|
|
|
147
147
|
"top_k"
|
|
148
148
|
]
|
|
149
149
|
});
|
|
150
|
-
const SQL_ORACLE_PROMPT =
|
|
150
|
+
const SQL_ORACLE_PROMPT = /*#__PURE__*/ new PromptTemplate({
|
|
151
151
|
template: `You are a ORACLE expert. Given an input question, first create a syntactically correct ORACLE query to run, then look at the results of the query and return the answer to the input question.
|
|
152
152
|
Unless the user specifies in the question a specific number of examples to obtain, query for at most {top_k} results using the ROWNUM clause as per ORACLE. You can order the results to return the most informative data in the database.
|
|
153
153
|
Never query for all columns from a table. You must query only the columns that are needed to answer the question.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sql_db_prompt.js","names":[],"sources":["../../../src/chains/sql_db/sql_db_prompt.ts"],"sourcesContent":["import { BasePromptTemplate, PromptTemplate } from \"@langchain/core/prompts\";\n\nexport const DEFAULT_SQL_DATABASE_PROMPT = /*#__PURE__*/ new PromptTemplate({\n template: `Given an input question, first create a syntactically correct {dialect} query to run, then look at the results of the query and return the answer. Unless the user specifies in his question a specific number of examples he wishes to obtain, always limit your query to at most {top_k} results. You can order the results by a relevant column to return the most interesting examples in the database.\n\nNever query for all the columns from a specific table, only ask for a the few relevant columns given the question.\n\nPay attention to use only the column names that you can see in the schema description. Be careful to not query for columns that do not exist. Also, pay attention to which column is in which table.\n\nUse the following format:\n\nQuestion: \"Question here\"\nSQLQuery: \"SQL Query to run\"\nSQLResult: \"Result of the SQLQuery\"\nAnswer: \"Final answer here\"\n\nOnly use the tables listed below.\n\n{table_info}\n\nQuestion: {input}`,\n inputVariables: [\"dialect\", \"table_info\", \"input\", \"top_k\"],\n});\n\nexport const SQL_POSTGRES_PROMPT = /*#__PURE__*/ new PromptTemplate({\n template: `You are a PostgreSQL expert. Given an input question, first create a syntactically correct PostgreSQL query to run, then look at the results of the query and return the answer to the input question.\nUnless the user specifies in the question a specific number of examples to obtain, query for at most {top_k} results using the LIMIT clause as per PostgreSQL. You can order the results to return the most informative data in the database.\nNever query for all columns from a table. You must query only the columns that are needed to answer the question. Wrap each column name in double quotes (\") to denote them as delimited identifiers.\nPay attention to use only the column names you can see in the tables below. Be careful to not query for columns that do not exist. Also, pay attention to which column is in which table.\n\nUse the following format:\n\nQuestion: \"Question here\"\nSQLQuery: \"SQL Query to run\"\nSQLResult: \"Result of the SQLQuery\"\nAnswer: \"Final answer here\"\n\nOnly use the following tables:\n{table_info}\n\nQuestion: {input}`,\n inputVariables: [\"dialect\", \"table_info\", \"input\", \"top_k\"],\n});\n\nexport const SQL_SQLITE_PROMPT = /*#__PURE__*/ new PromptTemplate({\n template: `You are a SQLite expert. Given an input question, first create a syntactically correct SQLite query to run, then look at the results of the query and return the answer to the input question.\nUnless the user specifies in the question a specific number of examples to obtain, query for at most {top_k} results using the LIMIT clause as per SQLite. You can order the results to return the most informative data in the database.\nNever query for all columns from a table. You must query only the columns that are needed to answer the question. Wrap each column name in double quotes (\") to denote them as delimited identifiers.\nPay attention to use only the column names you can see in the tables below. Be careful to not query for columns that do not exist. Also, pay attention to which column is in which table.\n\nUse the following format:\n\nQuestion: \"Question here\"\nSQLQuery: \"SQL Query to run\"\nSQLResult: \"Result of the SQLQuery\"\nAnswer: \"Final answer here\"\n\nOnly use the following tables:\n{table_info}\n\nQuestion: {input}`,\n inputVariables: [\"dialect\", \"table_info\", \"input\", \"top_k\"],\n});\n\nexport const SQL_MYSQL_PROMPT = /*#__PURE__*/ new PromptTemplate({\n template: `You are a MySQL expert. Given an input question, first create a syntactically correct MySQL query to run, then look at the results of the query and return the answer to the input question.\nUnless the user specifies in the question a specific number of examples to obtain, query for at most {top_k} results using the LIMIT clause as per MySQL. You can order the results to return the most informative data in the database.\nNever query for all columns from a table. You must query only the columns that are needed to answer the question. Wrap each column name in backticks (\\`) to denote them as delimited identifiers.\nPay attention to use only the column names you can see in the tables below. Be careful to not query for columns that do not exist. Also, pay attention to which column is in which table.\n\nUse the following format:\n\nQuestion: \"Question here\"\nSQLQuery: \"SQL Query to run\"\nSQLResult: \"Result of the SQLQuery\"\nAnswer: \"Final answer here\"\n\nOnly use the following tables:\n{table_info}\n\nQuestion: {input}`,\n inputVariables: [\"dialect\", \"table_info\", \"input\", \"top_k\"],\n});\n\nexport const SQL_MSSQL_PROMPT = /*#__PURE__*/ new PromptTemplate({\n template: `You are an MS SQL expert. Given an input question, first create a syntactically correct MS SQL query to run, then look at the results of the query and return the answer to the input question.\nUnless the user specifies in the question a specific number of examples to obtain, query for at most {top_k} results using the TOP clause as per MS SQL. You can order the results to return the most informative data in the database.\nNever query for all columns from a table. You must query only the columns that are needed to answer the question. Wrap each column name in square brackets ([]) to denote them as delimited identifiers.\nPay attention to use only the column names you can see in the tables below. Be careful to not query for columns that do not exist. Also, pay attention to which column is in which table.\n\nUse the following format:\n\nQuestion: \"Question here\"\nSQLQuery: \"SQL Query to run\"\nSQLResult: \"Result of the SQLQuery\"\nAnswer: \"Final answer here\"\n\nOnly use the following tables:\n{table_info}\n\nQuestion: {input}`,\n inputVariables: [\"dialect\", \"table_info\", \"input\", \"top_k\"],\n});\n\nexport const SQL_SAP_HANA_PROMPT = /*#__PURE__*/ new PromptTemplate({\n template: `You are a SAP HANA expert. Given an input question, first create a syntactically correct SAP HANA query to run, then look at the results of the query and return the answer to the input question.\nUnless the user specifies in the question a specific number of examples to obtain, query for at most {top_k} results using the LIMIT clause as per SAP HANA. You can order the results to return the most informative data in the database.\nNever query for all columns from a table. You must query only the columns that are needed to answer the question. Wrap each column name in double quotes (\") to denote them as delimited identifiers.\nPay attention to use only the column names you can see in the tables below. Be careful to not query for columns that do not exist. Also, pay attention to which column is in which table.\nAlways use a schema name when executing a query.\n\nUse the following format:\n\nQuestion: \"Question here\"\nSQLQuery: \"SQL Query to run\"\nSQLResult: \"Result of the SQLQuery\"\nAnswer: \"Final answer here\"\n\nOnly use the following tables:\n{table_info}\n\nQuestion: {input}`,\n inputVariables: [\"dialect\", \"table_info\", \"input\", \"top_k\"],\n});\n\nexport const SQL_ORACLE_PROMPT = /*#__PURE__*/ new PromptTemplate({\n template: `You are a ORACLE expert. Given an input question, first create a syntactically correct ORACLE query to run, then look at the results of the query and return the answer to the input question.\nUnless the user specifies in the question a specific number of examples to obtain, query for at most {top_k} results using the ROWNUM clause as per ORACLE. You can order the results to return the most informative data in the database.\nNever query for all columns from a table. You must query only the columns that are needed to answer the question.\nPay attention to use only the column names you can see in the tables below. Be careful to not query for columns that do not exist. Also, pay attention to which column is in which table.\n\nUse the following format:\n\nQuestion: \"Question here\"\nSQLQuery: \"SQL Query to run\"\nSQLResult: \"Result of the SQLQuery\"\nAnswer: \"Final answer here\"\n\nOnly use the following tables:\n{table_info}\n\nQuestion: {input}`,\n inputVariables: [\"dialect\", \"table_info\", \"input\", \"top_k\"],\n});\n\nexport type SqlDialect =\n | \"oracle\"\n | \"postgres\"\n | \"sqlite\"\n | \"mysql\"\n | \"mssql\"\n | \"sap hana\";\n\nexport const SQL_PROMPTS_MAP: Record<SqlDialect, BasePromptTemplate> = {\n oracle: SQL_ORACLE_PROMPT,\n postgres: SQL_POSTGRES_PROMPT,\n sqlite: SQL_SQLITE_PROMPT,\n mysql: SQL_MYSQL_PROMPT,\n mssql: SQL_MSSQL_PROMPT,\n \"sap hana\": SQL_SAP_HANA_PROMPT,\n};\n"],"mappings":";;AAEA,MAAa,
|
|
1
|
+
{"version":3,"file":"sql_db_prompt.js","names":[],"sources":["../../../src/chains/sql_db/sql_db_prompt.ts"],"sourcesContent":["import { BasePromptTemplate, PromptTemplate } from \"@langchain/core/prompts\";\n\nexport const DEFAULT_SQL_DATABASE_PROMPT = /*#__PURE__*/ new PromptTemplate({\n template: `Given an input question, first create a syntactically correct {dialect} query to run, then look at the results of the query and return the answer. Unless the user specifies in his question a specific number of examples he wishes to obtain, always limit your query to at most {top_k} results. You can order the results by a relevant column to return the most interesting examples in the database.\n\nNever query for all the columns from a specific table, only ask for a the few relevant columns given the question.\n\nPay attention to use only the column names that you can see in the schema description. Be careful to not query for columns that do not exist. Also, pay attention to which column is in which table.\n\nUse the following format:\n\nQuestion: \"Question here\"\nSQLQuery: \"SQL Query to run\"\nSQLResult: \"Result of the SQLQuery\"\nAnswer: \"Final answer here\"\n\nOnly use the tables listed below.\n\n{table_info}\n\nQuestion: {input}`,\n inputVariables: [\"dialect\", \"table_info\", \"input\", \"top_k\"],\n});\n\nexport const SQL_POSTGRES_PROMPT = /*#__PURE__*/ new PromptTemplate({\n template: `You are a PostgreSQL expert. Given an input question, first create a syntactically correct PostgreSQL query to run, then look at the results of the query and return the answer to the input question.\nUnless the user specifies in the question a specific number of examples to obtain, query for at most {top_k} results using the LIMIT clause as per PostgreSQL. You can order the results to return the most informative data in the database.\nNever query for all columns from a table. You must query only the columns that are needed to answer the question. Wrap each column name in double quotes (\") to denote them as delimited identifiers.\nPay attention to use only the column names you can see in the tables below. Be careful to not query for columns that do not exist. Also, pay attention to which column is in which table.\n\nUse the following format:\n\nQuestion: \"Question here\"\nSQLQuery: \"SQL Query to run\"\nSQLResult: \"Result of the SQLQuery\"\nAnswer: \"Final answer here\"\n\nOnly use the following tables:\n{table_info}\n\nQuestion: {input}`,\n inputVariables: [\"dialect\", \"table_info\", \"input\", \"top_k\"],\n});\n\nexport const SQL_SQLITE_PROMPT = /*#__PURE__*/ new PromptTemplate({\n template: `You are a SQLite expert. Given an input question, first create a syntactically correct SQLite query to run, then look at the results of the query and return the answer to the input question.\nUnless the user specifies in the question a specific number of examples to obtain, query for at most {top_k} results using the LIMIT clause as per SQLite. You can order the results to return the most informative data in the database.\nNever query for all columns from a table. You must query only the columns that are needed to answer the question. Wrap each column name in double quotes (\") to denote them as delimited identifiers.\nPay attention to use only the column names you can see in the tables below. Be careful to not query for columns that do not exist. Also, pay attention to which column is in which table.\n\nUse the following format:\n\nQuestion: \"Question here\"\nSQLQuery: \"SQL Query to run\"\nSQLResult: \"Result of the SQLQuery\"\nAnswer: \"Final answer here\"\n\nOnly use the following tables:\n{table_info}\n\nQuestion: {input}`,\n inputVariables: [\"dialect\", \"table_info\", \"input\", \"top_k\"],\n});\n\nexport const SQL_MYSQL_PROMPT = /*#__PURE__*/ new PromptTemplate({\n template: `You are a MySQL expert. Given an input question, first create a syntactically correct MySQL query to run, then look at the results of the query and return the answer to the input question.\nUnless the user specifies in the question a specific number of examples to obtain, query for at most {top_k} results using the LIMIT clause as per MySQL. You can order the results to return the most informative data in the database.\nNever query for all columns from a table. You must query only the columns that are needed to answer the question. Wrap each column name in backticks (\\`) to denote them as delimited identifiers.\nPay attention to use only the column names you can see in the tables below. Be careful to not query for columns that do not exist. Also, pay attention to which column is in which table.\n\nUse the following format:\n\nQuestion: \"Question here\"\nSQLQuery: \"SQL Query to run\"\nSQLResult: \"Result of the SQLQuery\"\nAnswer: \"Final answer here\"\n\nOnly use the following tables:\n{table_info}\n\nQuestion: {input}`,\n inputVariables: [\"dialect\", \"table_info\", \"input\", \"top_k\"],\n});\n\nexport const SQL_MSSQL_PROMPT = /*#__PURE__*/ new PromptTemplate({\n template: `You are an MS SQL expert. Given an input question, first create a syntactically correct MS SQL query to run, then look at the results of the query and return the answer to the input question.\nUnless the user specifies in the question a specific number of examples to obtain, query for at most {top_k} results using the TOP clause as per MS SQL. You can order the results to return the most informative data in the database.\nNever query for all columns from a table. You must query only the columns that are needed to answer the question. Wrap each column name in square brackets ([]) to denote them as delimited identifiers.\nPay attention to use only the column names you can see in the tables below. Be careful to not query for columns that do not exist. Also, pay attention to which column is in which table.\n\nUse the following format:\n\nQuestion: \"Question here\"\nSQLQuery: \"SQL Query to run\"\nSQLResult: \"Result of the SQLQuery\"\nAnswer: \"Final answer here\"\n\nOnly use the following tables:\n{table_info}\n\nQuestion: {input}`,\n inputVariables: [\"dialect\", \"table_info\", \"input\", \"top_k\"],\n});\n\nexport const SQL_SAP_HANA_PROMPT = /*#__PURE__*/ new PromptTemplate({\n template: `You are a SAP HANA expert. Given an input question, first create a syntactically correct SAP HANA query to run, then look at the results of the query and return the answer to the input question.\nUnless the user specifies in the question a specific number of examples to obtain, query for at most {top_k} results using the LIMIT clause as per SAP HANA. You can order the results to return the most informative data in the database.\nNever query for all columns from a table. You must query only the columns that are needed to answer the question. Wrap each column name in double quotes (\") to denote them as delimited identifiers.\nPay attention to use only the column names you can see in the tables below. Be careful to not query for columns that do not exist. Also, pay attention to which column is in which table.\nAlways use a schema name when executing a query.\n\nUse the following format:\n\nQuestion: \"Question here\"\nSQLQuery: \"SQL Query to run\"\nSQLResult: \"Result of the SQLQuery\"\nAnswer: \"Final answer here\"\n\nOnly use the following tables:\n{table_info}\n\nQuestion: {input}`,\n inputVariables: [\"dialect\", \"table_info\", \"input\", \"top_k\"],\n});\n\nexport const SQL_ORACLE_PROMPT = /*#__PURE__*/ new PromptTemplate({\n template: `You are a ORACLE expert. Given an input question, first create a syntactically correct ORACLE query to run, then look at the results of the query and return the answer to the input question.\nUnless the user specifies in the question a specific number of examples to obtain, query for at most {top_k} results using the ROWNUM clause as per ORACLE. You can order the results to return the most informative data in the database.\nNever query for all columns from a table. You must query only the columns that are needed to answer the question.\nPay attention to use only the column names you can see in the tables below. Be careful to not query for columns that do not exist. Also, pay attention to which column is in which table.\n\nUse the following format:\n\nQuestion: \"Question here\"\nSQLQuery: \"SQL Query to run\"\nSQLResult: \"Result of the SQLQuery\"\nAnswer: \"Final answer here\"\n\nOnly use the following tables:\n{table_info}\n\nQuestion: {input}`,\n inputVariables: [\"dialect\", \"table_info\", \"input\", \"top_k\"],\n});\n\nexport type SqlDialect =\n | \"oracle\"\n | \"postgres\"\n | \"sqlite\"\n | \"mysql\"\n | \"mssql\"\n | \"sap hana\";\n\nexport const SQL_PROMPTS_MAP: Record<SqlDialect, BasePromptTemplate> = {\n oracle: SQL_ORACLE_PROMPT,\n postgres: SQL_POSTGRES_PROMPT,\n sqlite: SQL_SQLITE_PROMPT,\n mysql: SQL_MYSQL_PROMPT,\n mssql: SQL_MSSQL_PROMPT,\n \"sap hana\": SQL_SAP_HANA_PROMPT,\n};\n"],"mappings":";;AAEA,MAAa,4CAA4C,IAAI,eAAe;CAC1E,UAAU;;;;;;;;;;;;;;;;;;CAkBV,gBAAgB;EAAC;EAAW;EAAc;EAAS;CAAO;AAC5D,CAAC;AAED,MAAa,oCAAoC,IAAI,eAAe;CAClE,UAAU;;;;;;;;;;;;;;;;CAgBV,gBAAgB;EAAC;EAAW;EAAc;EAAS;CAAO;AAC5D,CAAC;AAED,MAAa,kCAAkC,IAAI,eAAe;CAChE,UAAU;;;;;;;;;;;;;;;;CAgBV,gBAAgB;EAAC;EAAW;EAAc;EAAS;CAAO;AAC5D,CAAC;AAED,MAAa,iCAAiC,IAAI,eAAe;CAC/D,UAAU;;;;;;;;;;;;;;;;CAgBV,gBAAgB;EAAC;EAAW;EAAc;EAAS;CAAO;AAC5D,CAAC;AAED,MAAa,iCAAiC,IAAI,eAAe;CAC/D,UAAU;;;;;;;;;;;;;;;;CAgBV,gBAAgB;EAAC;EAAW;EAAc;EAAS;CAAO;AAC5D,CAAC;AAED,MAAa,oCAAoC,IAAI,eAAe;CAClE,UAAU;;;;;;;;;;;;;;;;;CAiBV,gBAAgB;EAAC;EAAW;EAAc;EAAS;CAAO;AAC5D,CAAC;AAED,MAAa,kCAAkC,IAAI,eAAe;CAChE,UAAU;;;;;;;;;;;;;;;;CAgBV,gBAAgB;EAAC;EAAW;EAAc;EAAS;CAAO;AAC5D,CAAC;AAUD,MAAa,kBAA0D;CACrE,QAAQ;CACR,UAAU;CACV,QAAQ;CACR,OAAO;CACP,OAAO;CACP,YAAY;AACd"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load.cjs","names":["DEFAULT_PROMPT","StuffDocumentsChain","LLMChain","MapReduceDocumentsChain","REFINE_PROMPT","RefineDocumentsChain"],"sources":["../../../src/chains/summarization/load.ts"],"sourcesContent":["import type { BaseLanguageModelInterface } from \"@langchain/core/language_models/base\";\nimport { BasePromptTemplate } from \"@langchain/core/prompts\";\nimport { LLMChain } from \"../llm_chain.js\";\nimport {\n StuffDocumentsChain,\n MapReduceDocumentsChain,\n RefineDocumentsChain,\n MapReduceDocumentsChainInput,\n} from \"../combine_docs_chain.js\";\nimport { DEFAULT_PROMPT } from \"./stuff_prompts.js\";\nimport { REFINE_PROMPT } from \"./refine_prompts.js\";\n\n/**\n * Type for the base parameters that can be used to configure a\n * summarization chain.\n */\ntype BaseParams = {\n verbose?: boolean;\n};\n\n/** @interface */\nexport type SummarizationChainParams = BaseParams &\n (\n | {\n type?: \"stuff\";\n prompt?: BasePromptTemplate;\n }\n | ({\n type?: \"map_reduce\";\n combineMapPrompt?: BasePromptTemplate;\n combinePrompt?: BasePromptTemplate;\n combineLLM?: BaseLanguageModelInterface;\n } & Pick<MapReduceDocumentsChainInput, \"returnIntermediateSteps\">)\n | {\n type?: \"refine\";\n refinePrompt?: BasePromptTemplate;\n refineLLM?: BaseLanguageModelInterface;\n questionPrompt?: BasePromptTemplate;\n }\n );\n\nexport const loadSummarizationChain = (\n llm: BaseLanguageModelInterface,\n params: SummarizationChainParams = { type: \"map_reduce\" }\n) => {\n const { verbose } = params;\n if (params.type === \"stuff\") {\n const { prompt = DEFAULT_PROMPT } = params;\n const llmChain = new LLMChain({ prompt, llm, verbose });\n const chain = new StuffDocumentsChain({\n llmChain,\n documentVariableName: \"text\",\n verbose,\n });\n return chain;\n }\n if (params.type === \"map_reduce\") {\n const {\n combineMapPrompt = DEFAULT_PROMPT,\n combinePrompt = DEFAULT_PROMPT,\n combineLLM,\n returnIntermediateSteps,\n } = params;\n const llmChain = new LLMChain({ prompt: combineMapPrompt, llm, verbose });\n const combineLLMChain = new LLMChain({\n prompt: combinePrompt,\n llm: combineLLM ?? llm,\n verbose,\n });\n const combineDocumentChain = new StuffDocumentsChain({\n llmChain: combineLLMChain,\n documentVariableName: \"text\",\n verbose,\n });\n const chain = new MapReduceDocumentsChain({\n llmChain,\n combineDocumentChain,\n documentVariableName: \"text\",\n returnIntermediateSteps,\n verbose,\n });\n return chain;\n }\n if (params.type === \"refine\") {\n const {\n refinePrompt = REFINE_PROMPT,\n refineLLM,\n questionPrompt = DEFAULT_PROMPT,\n } = params;\n const llmChain = new LLMChain({ prompt: questionPrompt, llm, verbose });\n const refineLLMChain = new LLMChain({\n prompt: refinePrompt,\n llm: refineLLM ?? llm,\n verbose,\n });\n const chain = new RefineDocumentsChain({\n llmChain,\n refineLLMChain,\n documentVariableName: \"text\",\n verbose,\n });\n return chain;\n }\n throw new Error(`Invalid _type: ${params.type}`);\n};\n"],"mappings":";;;;;AAyCA,MAAa,0BACX,KACA,SAAmC,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"load.cjs","names":["DEFAULT_PROMPT","StuffDocumentsChain","LLMChain","MapReduceDocumentsChain","REFINE_PROMPT","RefineDocumentsChain"],"sources":["../../../src/chains/summarization/load.ts"],"sourcesContent":["import type { BaseLanguageModelInterface } from \"@langchain/core/language_models/base\";\nimport { BasePromptTemplate } from \"@langchain/core/prompts\";\nimport { LLMChain } from \"../llm_chain.js\";\nimport {\n StuffDocumentsChain,\n MapReduceDocumentsChain,\n RefineDocumentsChain,\n MapReduceDocumentsChainInput,\n} from \"../combine_docs_chain.js\";\nimport { DEFAULT_PROMPT } from \"./stuff_prompts.js\";\nimport { REFINE_PROMPT } from \"./refine_prompts.js\";\n\n/**\n * Type for the base parameters that can be used to configure a\n * summarization chain.\n */\ntype BaseParams = {\n verbose?: boolean;\n};\n\n/** @interface */\nexport type SummarizationChainParams = BaseParams &\n (\n | {\n type?: \"stuff\";\n prompt?: BasePromptTemplate;\n }\n | ({\n type?: \"map_reduce\";\n combineMapPrompt?: BasePromptTemplate;\n combinePrompt?: BasePromptTemplate;\n combineLLM?: BaseLanguageModelInterface;\n } & Pick<MapReduceDocumentsChainInput, \"returnIntermediateSteps\">)\n | {\n type?: \"refine\";\n refinePrompt?: BasePromptTemplate;\n refineLLM?: BaseLanguageModelInterface;\n questionPrompt?: BasePromptTemplate;\n }\n );\n\nexport const loadSummarizationChain = (\n llm: BaseLanguageModelInterface,\n params: SummarizationChainParams = { type: \"map_reduce\" }\n) => {\n const { verbose } = params;\n if (params.type === \"stuff\") {\n const { prompt = DEFAULT_PROMPT } = params;\n const llmChain = new LLMChain({ prompt, llm, verbose });\n const chain = new StuffDocumentsChain({\n llmChain,\n documentVariableName: \"text\",\n verbose,\n });\n return chain;\n }\n if (params.type === \"map_reduce\") {\n const {\n combineMapPrompt = DEFAULT_PROMPT,\n combinePrompt = DEFAULT_PROMPT,\n combineLLM,\n returnIntermediateSteps,\n } = params;\n const llmChain = new LLMChain({ prompt: combineMapPrompt, llm, verbose });\n const combineLLMChain = new LLMChain({\n prompt: combinePrompt,\n llm: combineLLM ?? llm,\n verbose,\n });\n const combineDocumentChain = new StuffDocumentsChain({\n llmChain: combineLLMChain,\n documentVariableName: \"text\",\n verbose,\n });\n const chain = new MapReduceDocumentsChain({\n llmChain,\n combineDocumentChain,\n documentVariableName: \"text\",\n returnIntermediateSteps,\n verbose,\n });\n return chain;\n }\n if (params.type === \"refine\") {\n const {\n refinePrompt = REFINE_PROMPT,\n refineLLM,\n questionPrompt = DEFAULT_PROMPT,\n } = params;\n const llmChain = new LLMChain({ prompt: questionPrompt, llm, verbose });\n const refineLLMChain = new LLMChain({\n prompt: refinePrompt,\n llm: refineLLM ?? llm,\n verbose,\n });\n const chain = new RefineDocumentsChain({\n llmChain,\n refineLLMChain,\n documentVariableName: \"text\",\n verbose,\n });\n return chain;\n }\n throw new Error(`Invalid _type: ${params.type}`);\n};\n"],"mappings":";;;;;AAyCA,MAAa,0BACX,KACA,SAAmC,EAAE,MAAM,aAAa,MACrD;CACH,MAAM,EAAE,YAAY;CACpB,IAAI,OAAO,SAAS,SAAS;EAC3B,MAAM,EAAE,SAASA,sBAAAA,mBAAmB;EAOpC,OAAO,IALWC,2BAAAA,oBAAoB;GACpC,UAAA,IAFmBC,kBAAAA,SAAS;IAAE;IAAQ;IAAK;GAAQ,CAE5C;GACP,sBAAsB;GACtB;EACF,CACW;CACb;CACA,IAAI,OAAO,SAAS,cAAc;EAChC,MAAM,EACJ,mBAAmBF,sBAAAA,gBACnB,gBAAgBA,sBAAAA,gBAChB,YACA,4BACE;EAmBJ,OAAO,IAPWG,2BAAAA,wBAAwB;GACxC,UAAA,IAZmBD,kBAAAA,SAAS;IAAE,QAAQ;IAAkB;IAAK;GAAQ,CAY9D;GACP,sBAAA,IAP+BD,2BAAAA,oBAAoB;IACnD,UAAU,IANgBC,kBAAAA,SAAS;KACnC,QAAQ;KACR,KAAK,cAAc;KACnB;IACF,CAE0B;IACxB,sBAAsB;IACtB;GACF,CAGqB;GACnB,sBAAsB;GACtB;GACA;EACF,CACW;CACb;CACA,IAAI,OAAO,SAAS,UAAU;EAC5B,MAAM,EACJ,eAAeE,uBAAAA,eACf,WACA,iBAAiBJ,sBAAAA,mBACf;EAaJ,OAAO,IANWK,2BAAAA,qBAAqB;GACrC,UAAA,IAPmBH,kBAAAA,SAAS;IAAE,QAAQ;IAAgB;IAAK;GAAQ,CAO5D;GACP,gBAAA,IAPyBA,kBAAAA,SAAS;IAClC,QAAQ;IACR,KAAK,aAAa;IAClB;GACF,CAGe;GACb,sBAAsB;GACtB;EACF,CACW;CACb;CACA,MAAM,IAAI,MAAM,kBAAkB,OAAO,MAAM;AACjD"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { MapReduceDocumentsChain, MapReduceDocumentsChainInput, RefineDocumentsChain, StuffDocumentsChain } from "../combine_docs_chain.cjs";
|
|
2
2
|
import { BasePromptTemplate } from "@langchain/core/prompts";
|
|
3
3
|
import { BaseLanguageModelInterface } from "@langchain/core/language_models/base";
|
|
4
|
-
|
|
5
4
|
//#region src/chains/summarization/load.d.ts
|
|
6
5
|
/**
|
|
7
6
|
* Type for the base parameters that can be used to configure a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load.d.cts","names":[],"sources":["../../../src/chains/summarization/load.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"load.d.cts","names":[],"sources":["../../../src/chains/summarization/load.ts"],"mappings":";;;;;;;;KAgBK;EACH;;;KAIU,2BAA2B;EAG/B;EACA,SAAS;;EAGT;EACA,mBAAmB;EACnB,gBAAgB;EAChB,aAAa;IACX,KAAK;EAEP;EACA,eAAe;EACf,YAAY;EACZ,iBAAiB;;cAIZ,yBAAsB,KAC5B,4BAA0B,SACvB,6BAAwB,0BAAA,uBAAA"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { MapReduceDocumentsChain, MapReduceDocumentsChainInput, RefineDocumentsChain, StuffDocumentsChain } from "../combine_docs_chain.js";
|
|
2
2
|
import { BasePromptTemplate } from "@langchain/core/prompts";
|
|
3
3
|
import { BaseLanguageModelInterface } from "@langchain/core/language_models/base";
|
|
4
|
-
|
|
5
4
|
//#region src/chains/summarization/load.d.ts
|
|
6
5
|
/**
|
|
7
6
|
* Type for the base parameters that can be used to configure a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load.d.ts","names":[],"sources":["../../../src/chains/summarization/load.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"load.d.ts","names":[],"sources":["../../../src/chains/summarization/load.ts"],"mappings":";;;;;;;;KAgBK;EACH;;;KAIU,2BAA2B;EAG/B;EACA,SAAS;;EAGT;EACA,mBAAmB;EACnB,gBAAgB;EAChB,aAAa;IACX,KAAK;EAEP;EACA,eAAe;EACf,YAAY;EACZ,iBAAiB;;cAIZ,yBAAsB,KAC5B,4BAA0B,SACvB,6BAAwB,0BAAA,uBAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"load.js","names":[],"sources":["../../../src/chains/summarization/load.ts"],"sourcesContent":["import type { BaseLanguageModelInterface } from \"@langchain/core/language_models/base\";\nimport { BasePromptTemplate } from \"@langchain/core/prompts\";\nimport { LLMChain } from \"../llm_chain.js\";\nimport {\n StuffDocumentsChain,\n MapReduceDocumentsChain,\n RefineDocumentsChain,\n MapReduceDocumentsChainInput,\n} from \"../combine_docs_chain.js\";\nimport { DEFAULT_PROMPT } from \"./stuff_prompts.js\";\nimport { REFINE_PROMPT } from \"./refine_prompts.js\";\n\n/**\n * Type for the base parameters that can be used to configure a\n * summarization chain.\n */\ntype BaseParams = {\n verbose?: boolean;\n};\n\n/** @interface */\nexport type SummarizationChainParams = BaseParams &\n (\n | {\n type?: \"stuff\";\n prompt?: BasePromptTemplate;\n }\n | ({\n type?: \"map_reduce\";\n combineMapPrompt?: BasePromptTemplate;\n combinePrompt?: BasePromptTemplate;\n combineLLM?: BaseLanguageModelInterface;\n } & Pick<MapReduceDocumentsChainInput, \"returnIntermediateSteps\">)\n | {\n type?: \"refine\";\n refinePrompt?: BasePromptTemplate;\n refineLLM?: BaseLanguageModelInterface;\n questionPrompt?: BasePromptTemplate;\n }\n );\n\nexport const loadSummarizationChain = (\n llm: BaseLanguageModelInterface,\n params: SummarizationChainParams = { type: \"map_reduce\" }\n) => {\n const { verbose } = params;\n if (params.type === \"stuff\") {\n const { prompt = DEFAULT_PROMPT } = params;\n const llmChain = new LLMChain({ prompt, llm, verbose });\n const chain = new StuffDocumentsChain({\n llmChain,\n documentVariableName: \"text\",\n verbose,\n });\n return chain;\n }\n if (params.type === \"map_reduce\") {\n const {\n combineMapPrompt = DEFAULT_PROMPT,\n combinePrompt = DEFAULT_PROMPT,\n combineLLM,\n returnIntermediateSteps,\n } = params;\n const llmChain = new LLMChain({ prompt: combineMapPrompt, llm, verbose });\n const combineLLMChain = new LLMChain({\n prompt: combinePrompt,\n llm: combineLLM ?? llm,\n verbose,\n });\n const combineDocumentChain = new StuffDocumentsChain({\n llmChain: combineLLMChain,\n documentVariableName: \"text\",\n verbose,\n });\n const chain = new MapReduceDocumentsChain({\n llmChain,\n combineDocumentChain,\n documentVariableName: \"text\",\n returnIntermediateSteps,\n verbose,\n });\n return chain;\n }\n if (params.type === \"refine\") {\n const {\n refinePrompt = REFINE_PROMPT,\n refineLLM,\n questionPrompt = DEFAULT_PROMPT,\n } = params;\n const llmChain = new LLMChain({ prompt: questionPrompt, llm, verbose });\n const refineLLMChain = new LLMChain({\n prompt: refinePrompt,\n llm: refineLLM ?? llm,\n verbose,\n });\n const chain = new RefineDocumentsChain({\n llmChain,\n refineLLMChain,\n documentVariableName: \"text\",\n verbose,\n });\n return chain;\n }\n throw new Error(`Invalid _type: ${params.type}`);\n};\n"],"mappings":";;;;;AAyCA,MAAa,0BACX,KACA,SAAmC,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"load.js","names":[],"sources":["../../../src/chains/summarization/load.ts"],"sourcesContent":["import type { BaseLanguageModelInterface } from \"@langchain/core/language_models/base\";\nimport { BasePromptTemplate } from \"@langchain/core/prompts\";\nimport { LLMChain } from \"../llm_chain.js\";\nimport {\n StuffDocumentsChain,\n MapReduceDocumentsChain,\n RefineDocumentsChain,\n MapReduceDocumentsChainInput,\n} from \"../combine_docs_chain.js\";\nimport { DEFAULT_PROMPT } from \"./stuff_prompts.js\";\nimport { REFINE_PROMPT } from \"./refine_prompts.js\";\n\n/**\n * Type for the base parameters that can be used to configure a\n * summarization chain.\n */\ntype BaseParams = {\n verbose?: boolean;\n};\n\n/** @interface */\nexport type SummarizationChainParams = BaseParams &\n (\n | {\n type?: \"stuff\";\n prompt?: BasePromptTemplate;\n }\n | ({\n type?: \"map_reduce\";\n combineMapPrompt?: BasePromptTemplate;\n combinePrompt?: BasePromptTemplate;\n combineLLM?: BaseLanguageModelInterface;\n } & Pick<MapReduceDocumentsChainInput, \"returnIntermediateSteps\">)\n | {\n type?: \"refine\";\n refinePrompt?: BasePromptTemplate;\n refineLLM?: BaseLanguageModelInterface;\n questionPrompt?: BasePromptTemplate;\n }\n );\n\nexport const loadSummarizationChain = (\n llm: BaseLanguageModelInterface,\n params: SummarizationChainParams = { type: \"map_reduce\" }\n) => {\n const { verbose } = params;\n if (params.type === \"stuff\") {\n const { prompt = DEFAULT_PROMPT } = params;\n const llmChain = new LLMChain({ prompt, llm, verbose });\n const chain = new StuffDocumentsChain({\n llmChain,\n documentVariableName: \"text\",\n verbose,\n });\n return chain;\n }\n if (params.type === \"map_reduce\") {\n const {\n combineMapPrompt = DEFAULT_PROMPT,\n combinePrompt = DEFAULT_PROMPT,\n combineLLM,\n returnIntermediateSteps,\n } = params;\n const llmChain = new LLMChain({ prompt: combineMapPrompt, llm, verbose });\n const combineLLMChain = new LLMChain({\n prompt: combinePrompt,\n llm: combineLLM ?? llm,\n verbose,\n });\n const combineDocumentChain = new StuffDocumentsChain({\n llmChain: combineLLMChain,\n documentVariableName: \"text\",\n verbose,\n });\n const chain = new MapReduceDocumentsChain({\n llmChain,\n combineDocumentChain,\n documentVariableName: \"text\",\n returnIntermediateSteps,\n verbose,\n });\n return chain;\n }\n if (params.type === \"refine\") {\n const {\n refinePrompt = REFINE_PROMPT,\n refineLLM,\n questionPrompt = DEFAULT_PROMPT,\n } = params;\n const llmChain = new LLMChain({ prompt: questionPrompt, llm, verbose });\n const refineLLMChain = new LLMChain({\n prompt: refinePrompt,\n llm: refineLLM ?? llm,\n verbose,\n });\n const chain = new RefineDocumentsChain({\n llmChain,\n refineLLMChain,\n documentVariableName: \"text\",\n verbose,\n });\n return chain;\n }\n throw new Error(`Invalid _type: ${params.type}`);\n};\n"],"mappings":";;;;;AAyCA,MAAa,0BACX,KACA,SAAmC,EAAE,MAAM,aAAa,MACrD;CACH,MAAM,EAAE,YAAY;CACpB,IAAI,OAAO,SAAS,SAAS;EAC3B,MAAM,EAAE,SAAS,mBAAmB;EAOpC,OAAO,IALW,oBAAoB;GACpC,UAAA,IAFmB,SAAS;IAAE;IAAQ;IAAK;GAAQ,CAE5C;GACP,sBAAsB;GACtB;EACF,CACW;CACb;CACA,IAAI,OAAO,SAAS,cAAc;EAChC,MAAM,EACJ,mBAAmB,gBACnB,gBAAgB,gBAChB,YACA,4BACE;EAmBJ,OAAO,IAPW,wBAAwB;GACxC,UAAA,IAZmB,SAAS;IAAE,QAAQ;IAAkB;IAAK;GAAQ,CAY9D;GACP,sBAAA,IAP+B,oBAAoB;IACnD,UAAU,IANgB,SAAS;KACnC,QAAQ;KACR,KAAK,cAAc;KACnB;IACF,CAE0B;IACxB,sBAAsB;IACtB;GACF,CAGqB;GACnB,sBAAsB;GACtB;GACA;EACF,CACW;CACb;CACA,IAAI,OAAO,SAAS,UAAU;EAC5B,MAAM,EACJ,eAAe,eACf,WACA,iBAAiB,mBACf;EAaJ,OAAO,IANW,qBAAqB;GACrC,UAAA,IAPmB,SAAS;IAAE,QAAQ;IAAgB;IAAK;GAAQ,CAO5D;GACP,gBAAA,IAPyB,SAAS;IAClC,QAAQ;IACR,KAAK,aAAa;IAClB;GACF,CAGe;GACb,sBAAsB;GACtB;EACF,CACW;CACb;CACA,MAAM,IAAI,MAAM,kBAAkB,OAAO,MAAM;AACjD"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
require("
|
|
2
|
-
const REFINE_PROMPT = /* @__PURE__ */ new (require("@langchain/core/prompts")).PromptTemplate({
|
|
1
|
+
const REFINE_PROMPT = /* #__PURE__ */ new (require("@langchain/core/prompts")).PromptTemplate({
|
|
3
2
|
template: `Your job is to produce a final summary
|
|
4
3
|
We have provided an existing summary up to a certain point: "{existing_answer}"
|
|
5
4
|
We have the opportunity to refine the existing summary
|