langchain 0.0.192 → 0.0.194
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agents/agent.cjs +24 -0
- package/dist/agents/agent.d.ts +24 -0
- package/dist/agents/agent.js +24 -0
- package/dist/agents/chat/outputParser.cjs +32 -0
- package/dist/agents/chat/outputParser.d.ts +32 -0
- package/dist/agents/chat/outputParser.js +32 -0
- package/dist/agents/executor.cjs +14 -0
- package/dist/agents/executor.d.ts +14 -0
- package/dist/agents/executor.js +14 -0
- package/dist/agents/mrkl/index.cjs +21 -0
- package/dist/agents/mrkl/index.d.ts +21 -0
- package/dist/agents/mrkl/index.js +21 -0
- package/dist/agents/openai/output_parser.cjs +65 -0
- package/dist/agents/openai/output_parser.d.ts +65 -0
- package/dist/agents/openai/output_parser.js +65 -0
- package/dist/agents/react/output_parser.cjs +16 -0
- package/dist/agents/react/output_parser.d.ts +16 -0
- package/dist/agents/react/output_parser.js +16 -0
- package/dist/agents/structured_chat/outputParser.cjs +12 -0
- package/dist/agents/structured_chat/outputParser.d.ts +12 -0
- package/dist/agents/structured_chat/outputParser.js +12 -0
- package/dist/agents/toolkits/aws_sfn.cjs +20 -0
- package/dist/agents/toolkits/aws_sfn.d.ts +20 -0
- package/dist/agents/toolkits/aws_sfn.js +20 -0
- package/dist/agents/toolkits/json/json.cjs +8 -0
- package/dist/agents/toolkits/json/json.d.ts +8 -0
- package/dist/agents/toolkits/json/json.js +8 -0
- package/dist/agents/toolkits/openapi/openapi.cjs +18 -0
- package/dist/agents/toolkits/openapi/openapi.d.ts +18 -0
- package/dist/agents/toolkits/openapi/openapi.js +18 -0
- package/dist/agents/toolkits/sql/sql.cjs +8 -0
- package/dist/agents/toolkits/sql/sql.d.ts +8 -0
- package/dist/agents/toolkits/sql/sql.js +8 -0
- package/dist/agents/toolkits/vectorstore/vectorstore.cjs +16 -0
- package/dist/agents/toolkits/vectorstore/vectorstore.d.ts +16 -0
- package/dist/agents/toolkits/vectorstore/vectorstore.js +16 -0
- package/dist/agents/toolkits/zapier/zapier.cjs +10 -0
- package/dist/agents/toolkits/zapier/zapier.d.ts +10 -0
- package/dist/agents/toolkits/zapier/zapier.js +10 -0
- package/dist/agents/xml/output_parser.cjs +21 -0
- package/dist/agents/xml/output_parser.d.ts +21 -0
- package/dist/agents/xml/output_parser.js +21 -0
- package/dist/cache/cloudflare_kv.cjs +13 -0
- package/dist/cache/cloudflare_kv.d.ts +13 -0
- package/dist/cache/cloudflare_kv.js +13 -0
- package/dist/cache/ioredis.cjs +13 -0
- package/dist/cache/ioredis.d.ts +13 -0
- package/dist/cache/ioredis.js +13 -0
- package/dist/cache/momento.cjs +19 -0
- package/dist/cache/momento.d.ts +19 -0
- package/dist/cache/momento.js +19 -0
- package/dist/cache/redis.cjs +10 -0
- package/dist/cache/redis.d.ts +10 -0
- package/dist/cache/redis.js +10 -0
- package/dist/cache/upstash_redis.cjs +15 -0
- package/dist/cache/upstash_redis.d.ts +15 -0
- package/dist/cache/upstash_redis.js +15 -0
- package/dist/callbacks/handlers/console.cjs +10 -0
- package/dist/callbacks/handlers/console.d.ts +10 -0
- package/dist/callbacks/handlers/console.js +10 -0
- package/dist/callbacks/manager.cjs +49 -0
- package/dist/callbacks/manager.d.ts +49 -0
- package/dist/callbacks/manager.js +49 -0
- package/dist/chains/analyze_documents_chain.cjs +18 -0
- package/dist/chains/analyze_documents_chain.d.ts +18 -0
- package/dist/chains/analyze_documents_chain.js +18 -0
- package/dist/chains/constitutional_ai/constitutional_chain.cjs +21 -0
- package/dist/chains/constitutional_ai/constitutional_chain.d.ts +21 -0
- package/dist/chains/constitutional_ai/constitutional_chain.js +21 -0
- package/dist/chains/constitutional_ai/constitutional_principle.cjs +21 -0
- package/dist/chains/constitutional_ai/constitutional_principle.d.ts +21 -0
- package/dist/chains/constitutional_ai/constitutional_principle.js +21 -0
- package/dist/chains/conversation.cjs +13 -0
- package/dist/chains/conversation.d.ts +13 -0
- package/dist/chains/conversation.js +13 -0
- package/dist/chains/conversational_retrieval_chain.cjs +29 -0
- package/dist/chains/conversational_retrieval_chain.d.ts +29 -0
- package/dist/chains/conversational_retrieval_chain.js +29 -0
- package/dist/chains/graph_qa/cypher.cjs +10 -0
- package/dist/chains/graph_qa/cypher.d.ts +10 -0
- package/dist/chains/graph_qa/cypher.js +10 -0
- package/dist/chains/openai_moderation.cjs +28 -0
- package/dist/chains/openai_moderation.d.ts +28 -0
- package/dist/chains/openai_moderation.js +28 -0
- package/dist/chains/retrieval_qa.cjs +21 -0
- package/dist/chains/retrieval_qa.d.ts +21 -0
- package/dist/chains/retrieval_qa.js +21 -0
- package/dist/chains/router/multi_prompt.cjs +19 -0
- package/dist/chains/router/multi_prompt.d.ts +19 -0
- package/dist/chains/router/multi_prompt.js +19 -0
- package/dist/chains/router/multi_retrieval_qa.cjs +29 -0
- package/dist/chains/router/multi_retrieval_qa.d.ts +29 -0
- package/dist/chains/router/multi_retrieval_qa.js +29 -0
- package/dist/chains/sequential_chain.cjs +43 -0
- package/dist/chains/sequential_chain.d.ts +43 -0
- package/dist/chains/sequential_chain.js +43 -0
- package/dist/chains/sql_db/sql_db_chain.cjs +9 -0
- package/dist/chains/sql_db/sql_db_chain.d.ts +9 -0
- package/dist/chains/sql_db/sql_db_chain.js +9 -0
- package/dist/chat_models/anthropic.cjs +9 -1
- package/dist/chat_models/anthropic.d.ts +9 -1
- package/dist/chat_models/anthropic.js +9 -1
- package/dist/chat_models/baiduwenxin.cjs +20 -0
- package/dist/chat_models/baiduwenxin.d.ts +20 -0
- package/dist/chat_models/baiduwenxin.js +20 -0
- package/dist/chat_models/base.cjs +2 -0
- package/dist/chat_models/base.d.ts +1 -1
- package/dist/chat_models/base.js +2 -0
- package/dist/chat_models/bedrock/index.cjs +11 -0
- package/dist/chat_models/bedrock/index.d.ts +11 -0
- package/dist/chat_models/bedrock/index.js +11 -0
- package/dist/chat_models/bedrock/web.cjs +9 -0
- package/dist/chat_models/bedrock/web.d.ts +9 -0
- package/dist/chat_models/bedrock/web.js +9 -0
- package/dist/chat_models/cloudflare_workersai.cjs +15 -0
- package/dist/chat_models/cloudflare_workersai.d.ts +15 -0
- package/dist/chat_models/cloudflare_workersai.js +15 -0
- package/dist/chat_models/fake.cjs +16 -0
- package/dist/chat_models/fake.d.ts +16 -0
- package/dist/chat_models/fake.js +16 -0
- package/dist/chat_models/fireworks.cjs +10 -0
- package/dist/chat_models/fireworks.d.ts +10 -0
- package/dist/chat_models/fireworks.js +10 -0
- package/dist/chat_models/googlepalm.cjs +24 -0
- package/dist/chat_models/googlepalm.d.ts +24 -0
- package/dist/chat_models/googlepalm.js +24 -0
- package/dist/chat_models/googlevertexai/index.cjs +7 -0
- package/dist/chat_models/googlevertexai/index.d.ts +7 -0
- package/dist/chat_models/googlevertexai/index.js +7 -0
- package/dist/chat_models/googlevertexai/web.cjs +9 -0
- package/dist/chat_models/googlevertexai/web.d.ts +9 -0
- package/dist/chat_models/googlevertexai/web.js +9 -0
- package/dist/chat_models/iflytek_xinghuo/index.cjs +8 -0
- package/dist/chat_models/iflytek_xinghuo/index.d.ts +8 -0
- package/dist/chat_models/iflytek_xinghuo/index.js +8 -0
- package/dist/chat_models/iflytek_xinghuo/web.cjs +8 -0
- package/dist/chat_models/iflytek_xinghuo/web.d.ts +8 -0
- package/dist/chat_models/iflytek_xinghuo/web.js +8 -0
- package/dist/chat_models/llama_cpp.cjs +17 -0
- package/dist/chat_models/llama_cpp.d.ts +17 -0
- package/dist/chat_models/llama_cpp.js +17 -0
- package/dist/chat_models/minimax.cjs +27 -0
- package/dist/chat_models/minimax.d.ts +27 -0
- package/dist/chat_models/minimax.js +27 -0
- package/dist/chat_models/ollama.cjs +24 -0
- package/dist/chat_models/ollama.d.ts +24 -0
- package/dist/chat_models/ollama.js +24 -0
- package/dist/chat_models/openai.cjs +15 -0
- package/dist/chat_models/openai.d.ts +15 -0
- package/dist/chat_models/openai.js +15 -0
- package/dist/chat_models/yandex.cjs +14 -0
- package/dist/chat_models/yandex.d.ts +14 -0
- package/dist/chat_models/yandex.js +14 -0
- package/dist/document_loaders/fs/directory.cjs +14 -0
- package/dist/document_loaders/fs/directory.d.ts +14 -0
- package/dist/document_loaders/fs/directory.js +14 -0
- package/dist/document_loaders/fs/openai_whisper_audio.cjs +10 -0
- package/dist/document_loaders/fs/openai_whisper_audio.d.ts +10 -0
- package/dist/document_loaders/fs/openai_whisper_audio.js +10 -0
- package/dist/document_loaders/fs/pdf.cjs +6 -0
- package/dist/document_loaders/fs/pdf.d.ts +6 -0
- package/dist/document_loaders/fs/pdf.js +6 -0
- package/dist/document_loaders/fs/srt.cjs +6 -0
- package/dist/document_loaders/fs/srt.d.ts +6 -0
- package/dist/document_loaders/fs/srt.js +6 -0
- package/dist/document_loaders/fs/text.cjs +5 -0
- package/dist/document_loaders/fs/text.d.ts +5 -0
- package/dist/document_loaders/fs/text.js +5 -0
- package/dist/document_loaders/fs/unstructured.cjs +7 -0
- package/dist/document_loaders/fs/unstructured.d.ts +7 -0
- package/dist/document_loaders/fs/unstructured.js +7 -0
- package/dist/document_loaders/web/apify_dataset.cjs +21 -0
- package/dist/document_loaders/web/apify_dataset.d.ts +21 -0
- package/dist/document_loaders/web/apify_dataset.js +21 -0
- package/dist/document_loaders/web/assemblyai.cjs +24 -0
- package/dist/document_loaders/web/assemblyai.d.ts +24 -0
- package/dist/document_loaders/web/assemblyai.js +24 -0
- package/dist/document_loaders/web/azure_blob_storage_file.cjs +11 -0
- package/dist/document_loaders/web/azure_blob_storage_file.d.ts +11 -0
- package/dist/document_loaders/web/azure_blob_storage_file.js +11 -0
- package/dist/document_loaders/web/cheerio.cjs +6 -0
- package/dist/document_loaders/web/cheerio.d.ts +6 -0
- package/dist/document_loaders/web/cheerio.js +6 -0
- package/dist/document_loaders/web/college_confidential.cjs +6 -0
- package/dist/document_loaders/web/college_confidential.d.ts +6 -0
- package/dist/document_loaders/web/college_confidential.js +6 -0
- package/dist/document_loaders/web/confluence.cjs +11 -0
- package/dist/document_loaders/web/confluence.d.ts +11 -0
- package/dist/document_loaders/web/confluence.js +11 -0
- package/dist/document_loaders/web/figma.cjs +9 -0
- package/dist/document_loaders/web/figma.d.ts +9 -0
- package/dist/document_loaders/web/figma.js +9 -0
- package/dist/document_loaders/web/notionapi.cjs +16 -0
- package/dist/document_loaders/web/notionapi.d.ts +16 -0
- package/dist/document_loaders/web/notionapi.js +16 -0
- package/dist/document_loaders/web/notiondb.cjs +11 -1
- package/dist/document_loaders/web/notiondb.d.ts +11 -1
- package/dist/document_loaders/web/notiondb.js +11 -1
- package/dist/document_loaders/web/pdf.cjs +6 -0
- package/dist/document_loaders/web/pdf.d.ts +6 -0
- package/dist/document_loaders/web/pdf.js +6 -0
- package/dist/document_loaders/web/puppeteer.cjs +12 -0
- package/dist/document_loaders/web/puppeteer.d.ts +12 -0
- package/dist/document_loaders/web/puppeteer.js +12 -0
- package/dist/document_loaders/web/s3.cjs +17 -0
- package/dist/document_loaders/web/s3.d.ts +17 -0
- package/dist/document_loaders/web/s3.js +17 -0
- package/dist/document_loaders/web/searchapi.cjs +9 -0
- package/dist/document_loaders/web/searchapi.d.ts +9 -0
- package/dist/document_loaders/web/searchapi.js +9 -0
- package/dist/document_loaders/web/serpapi.cjs +5 -0
- package/dist/document_loaders/web/serpapi.d.ts +5 -0
- package/dist/document_loaders/web/serpapi.js +5 -0
- package/dist/document_loaders/web/sonix_audio.cjs +12 -0
- package/dist/document_loaders/web/sonix_audio.d.ts +12 -0
- package/dist/document_loaders/web/sonix_audio.js +12 -0
- package/dist/document_loaders/web/sort_xyz_blockchain.cjs +22 -0
- package/dist/document_loaders/web/sort_xyz_blockchain.d.ts +22 -0
- package/dist/document_loaders/web/sort_xyz_blockchain.js +22 -0
- package/dist/document_loaders/web/youtube.cjs +9 -0
- package/dist/document_loaders/web/youtube.d.ts +9 -0
- package/dist/document_loaders/web/youtube.js +9 -0
- package/dist/document_transformers/html_to_text.cjs +18 -0
- package/dist/document_transformers/html_to_text.d.ts +18 -0
- package/dist/document_transformers/html_to_text.js +18 -0
- package/dist/document_transformers/mozilla_readability.cjs +18 -0
- package/dist/document_transformers/mozilla_readability.d.ts +18 -0
- package/dist/document_transformers/mozilla_readability.js +18 -0
- package/dist/embeddings/bedrock.cjs +17 -0
- package/dist/embeddings/bedrock.d.ts +17 -0
- package/dist/embeddings/bedrock.js +17 -0
- package/dist/embeddings/cache_backed.cjs +37 -0
- package/dist/embeddings/cache_backed.d.ts +37 -0
- package/dist/embeddings/cache_backed.js +37 -0
- package/dist/embeddings/cohere.cjs +10 -0
- package/dist/embeddings/cohere.d.ts +10 -0
- package/dist/embeddings/cohere.js +10 -0
- package/dist/embeddings/googlepalm.cjs +17 -0
- package/dist/embeddings/googlepalm.d.ts +17 -0
- package/dist/embeddings/googlepalm.js +17 -0
- package/dist/embeddings/googlevertexai.cjs +8 -0
- package/dist/embeddings/googlevertexai.d.ts +8 -0
- package/dist/embeddings/googlevertexai.js +8 -0
- package/dist/embeddings/hf_transformers.cjs +18 -0
- package/dist/embeddings/hf_transformers.d.ts +18 -0
- package/dist/embeddings/hf_transformers.js +18 -0
- package/dist/embeddings/llama_cpp.cjs +16 -0
- package/dist/embeddings/llama_cpp.d.ts +16 -0
- package/dist/embeddings/llama_cpp.js +16 -0
- package/dist/embeddings/minimax.cjs +15 -0
- package/dist/embeddings/minimax.d.ts +15 -0
- package/dist/embeddings/minimax.js +15 -0
- package/dist/embeddings/openai.cjs +10 -0
- package/dist/embeddings/openai.d.ts +10 -0
- package/dist/embeddings/openai.js +10 -0
- package/dist/embeddings/tensorflow.cjs +16 -0
- package/dist/embeddings/tensorflow.d.ts +16 -0
- package/dist/embeddings/tensorflow.js +16 -0
- package/dist/experimental/autogpt/agent.cjs +21 -0
- package/dist/experimental/autogpt/agent.d.ts +21 -0
- package/dist/experimental/autogpt/agent.js +21 -0
- package/dist/experimental/babyagi/agent.cjs +12 -0
- package/dist/experimental/babyagi/agent.d.ts +12 -0
- package/dist/experimental/babyagi/agent.js +12 -0
- package/dist/experimental/chat_models/ollama_functions.cjs +12 -15
- package/dist/experimental/chat_models/ollama_functions.d.ts +3 -4
- package/dist/experimental/chat_models/ollama_functions.js +13 -16
- package/dist/experimental/generative_agents/generative_agent.cjs +30 -0
- package/dist/experimental/generative_agents/generative_agent.d.ts +30 -0
- package/dist/experimental/generative_agents/generative_agent.js +30 -0
- package/dist/experimental/generative_agents/generative_agent_memory.cjs +18 -0
- package/dist/experimental/generative_agents/generative_agent_memory.d.ts +18 -0
- package/dist/experimental/generative_agents/generative_agent_memory.js +18 -0
- package/dist/llms/base.cjs +3 -1
- package/dist/llms/base.d.ts +1 -1
- package/dist/llms/base.js +3 -1
- package/dist/llms/cohere.cjs +13 -0
- package/dist/llms/cohere.d.ts +13 -0
- package/dist/llms/cohere.js +13 -0
- package/dist/llms/googlevertexai/index.cjs +12 -0
- package/dist/llms/googlevertexai/index.d.ts +12 -0
- package/dist/llms/googlevertexai/index.js +12 -0
- package/dist/llms/googlevertexai/web.cjs +12 -0
- package/dist/llms/googlevertexai/web.d.ts +12 -0
- package/dist/llms/googlevertexai/web.js +12 -0
- package/dist/llms/hf.cjs +13 -0
- package/dist/llms/hf.d.ts +13 -0
- package/dist/llms/hf.js +13 -0
- package/dist/llms/ollama.cjs +19 -0
- package/dist/llms/ollama.d.ts +19 -0
- package/dist/llms/ollama.js +19 -0
- package/dist/llms/openai-chat.cjs +17 -0
- package/dist/llms/openai-chat.d.ts +17 -0
- package/dist/llms/openai-chat.js +17 -0
- package/dist/llms/openai.cjs +14 -0
- package/dist/llms/openai.d.ts +14 -0
- package/dist/llms/openai.js +14 -0
- package/dist/llms/portkey.cjs +24 -0
- package/dist/llms/portkey.d.ts +24 -0
- package/dist/llms/portkey.js +24 -0
- package/dist/llms/replicate.cjs +11 -0
- package/dist/llms/replicate.d.ts +11 -0
- package/dist/llms/replicate.js +11 -0
- package/dist/memory/buffer_memory.cjs +24 -0
- package/dist/memory/buffer_memory.d.ts +24 -0
- package/dist/memory/buffer_memory.js +24 -0
- package/dist/memory/buffer_token_memory.cjs +15 -0
- package/dist/memory/buffer_token_memory.d.ts +15 -0
- package/dist/memory/buffer_token_memory.js +15 -0
- package/dist/memory/buffer_window_memory.cjs +23 -0
- package/dist/memory/buffer_window_memory.d.ts +23 -0
- package/dist/memory/buffer_window_memory.js +23 -0
- package/dist/memory/entity_memory.cjs +29 -0
- package/dist/memory/entity_memory.d.ts +29 -0
- package/dist/memory/entity_memory.js +29 -0
- package/dist/memory/summary.cjs +24 -0
- package/dist/memory/summary.d.ts +24 -0
- package/dist/memory/summary.js +24 -0
- package/dist/memory/summary_buffer.cjs +32 -0
- package/dist/memory/summary_buffer.d.ts +32 -0
- package/dist/memory/summary_buffer.js +32 -0
- package/dist/memory/vector_store.cjs +24 -0
- package/dist/memory/vector_store.d.ts +24 -0
- package/dist/memory/vector_store.js +24 -0
- package/dist/memory/zep.cjs +34 -0
- package/dist/memory/zep.d.ts +34 -0
- package/dist/memory/zep.js +34 -0
- package/dist/prompts/chat.cjs +31 -0
- package/dist/prompts/chat.d.ts +31 -0
- package/dist/prompts/chat.js +31 -0
- package/dist/prompts/few_shot.cjs +31 -0
- package/dist/prompts/few_shot.d.ts +31 -0
- package/dist/prompts/few_shot.js +31 -0
- package/dist/prompts/pipeline.cjs +39 -0
- package/dist/prompts/pipeline.d.ts +39 -0
- package/dist/prompts/pipeline.js +39 -0
- package/dist/prompts/selectors/LengthBasedExampleSelector.cjs +36 -0
- package/dist/prompts/selectors/LengthBasedExampleSelector.d.ts +36 -0
- package/dist/prompts/selectors/LengthBasedExampleSelector.js +36 -0
- package/dist/prompts/selectors/SemanticSimilarityExampleSelector.cjs +25 -0
- package/dist/prompts/selectors/SemanticSimilarityExampleSelector.d.ts +25 -0
- package/dist/prompts/selectors/SemanticSimilarityExampleSelector.js +25 -0
- package/dist/retrievers/amazon_kendra.cjs +16 -0
- package/dist/retrievers/amazon_kendra.d.ts +16 -0
- package/dist/retrievers/amazon_kendra.js +16 -0
- package/dist/retrievers/chaindesk.cjs +11 -0
- package/dist/retrievers/chaindesk.d.ts +11 -0
- package/dist/retrievers/chaindesk.js +11 -0
- package/dist/retrievers/contextual_compression.cjs +10 -0
- package/dist/retrievers/contextual_compression.d.ts +10 -0
- package/dist/retrievers/contextual_compression.js +10 -0
- package/dist/retrievers/document_compressors/embeddings_filter.cjs +13 -0
- package/dist/retrievers/document_compressors/embeddings_filter.d.ts +13 -0
- package/dist/retrievers/document_compressors/embeddings_filter.js +13 -0
- package/dist/retrievers/document_compressors/index.cjs +26 -0
- package/dist/retrievers/document_compressors/index.d.ts +26 -0
- package/dist/retrievers/document_compressors/index.js +26 -0
- package/dist/retrievers/hyde.cjs +19 -0
- package/dist/retrievers/hyde.d.ts +19 -0
- package/dist/retrievers/hyde.js +19 -0
- package/dist/retrievers/metal.cjs +11 -0
- package/dist/retrievers/metal.d.ts +11 -0
- package/dist/retrievers/metal.js +11 -0
- package/dist/retrievers/multi_query.cjs +13 -1
- package/dist/retrievers/multi_query.d.ts +13 -0
- package/dist/retrievers/multi_query.js +13 -1
- package/dist/retrievers/multi_vector.cjs +13 -0
- package/dist/retrievers/multi_vector.d.ts +13 -0
- package/dist/retrievers/multi_vector.js +13 -0
- package/dist/retrievers/parent_document.cjs +21 -0
- package/dist/retrievers/parent_document.d.ts +21 -0
- package/dist/retrievers/parent_document.js +21 -0
- package/dist/retrievers/remote/chatgpt-plugin.cjs +10 -0
- package/dist/retrievers/remote/chatgpt-plugin.d.ts +10 -0
- package/dist/retrievers/remote/chatgpt-plugin.js +10 -0
- package/dist/retrievers/self_query/chroma.cjs +15 -0
- package/dist/retrievers/self_query/chroma.d.ts +15 -0
- package/dist/retrievers/self_query/chroma.js +15 -0
- package/dist/retrievers/self_query/functional.cjs +7 -0
- package/dist/retrievers/self_query/functional.d.ts +7 -0
- package/dist/retrievers/self_query/functional.js +7 -0
- package/dist/retrievers/self_query/index.cjs +13 -0
- package/dist/retrievers/self_query/index.d.ts +13 -0
- package/dist/retrievers/self_query/index.js +13 -0
- package/dist/retrievers/self_query/pinecone.cjs +14 -0
- package/dist/retrievers/self_query/pinecone.d.ts +14 -0
- package/dist/retrievers/self_query/pinecone.js +14 -0
- package/dist/retrievers/self_query/supabase.cjs +14 -0
- package/dist/retrievers/self_query/supabase.d.ts +14 -0
- package/dist/retrievers/self_query/supabase.js +14 -0
- package/dist/retrievers/self_query/weaviate.cjs +14 -0
- package/dist/retrievers/self_query/weaviate.d.ts +14 -0
- package/dist/retrievers/self_query/weaviate.js +14 -0
- package/dist/retrievers/time_weighted.cjs +16 -0
- package/dist/retrievers/time_weighted.d.ts +16 -0
- package/dist/retrievers/time_weighted.js +16 -0
- package/dist/retrievers/vespa.cjs +15 -0
- package/dist/retrievers/vespa.d.ts +15 -0
- package/dist/retrievers/vespa.js +15 -0
- package/dist/retrievers/zep.cjs +10 -0
- package/dist/retrievers/zep.d.ts +10 -0
- package/dist/retrievers/zep.js +10 -0
- package/dist/schema/index.d.ts +8 -6
- package/dist/schema/output_parser.cjs +15 -0
- package/dist/schema/output_parser.d.ts +15 -0
- package/dist/schema/output_parser.js +15 -0
- package/dist/schema/runnable/base.cjs +20 -0
- package/dist/schema/runnable/base.d.ts +20 -0
- package/dist/schema/runnable/base.js +20 -0
- package/dist/schema/runnable/branch.cjs +28 -0
- package/dist/schema/runnable/branch.d.ts +28 -0
- package/dist/schema/runnable/branch.js +28 -0
- package/dist/storage/file_system.cjs +21 -0
- package/dist/storage/file_system.d.ts +21 -0
- package/dist/storage/file_system.js +21 -0
- package/dist/storage/in_memory.cjs +15 -0
- package/dist/storage/in_memory.d.ts +15 -0
- package/dist/storage/in_memory.js +15 -0
- package/dist/storage/ioredis.cjs +24 -0
- package/dist/storage/ioredis.d.ts +24 -0
- package/dist/storage/ioredis.js +24 -0
- package/dist/storage/upstash_redis.cjs +19 -0
- package/dist/storage/upstash_redis.d.ts +19 -0
- package/dist/storage/upstash_redis.js +19 -0
- package/dist/storage/vercel_kv.cjs +16 -0
- package/dist/storage/vercel_kv.d.ts +16 -0
- package/dist/storage/vercel_kv.js +16 -0
- package/dist/stores/message/cassandra.cjs +25 -0
- package/dist/stores/message/cassandra.d.ts +25 -0
- package/dist/stores/message/cassandra.js +25 -0
- package/dist/stores/message/cloudflare_d1.cjs +18 -0
- package/dist/stores/message/cloudflare_d1.d.ts +18 -0
- package/dist/stores/message/cloudflare_d1.js +18 -0
- package/dist/stores/message/firestore.cjs +19 -0
- package/dist/stores/message/firestore.d.ts +19 -0
- package/dist/stores/message/firestore.js +19 -0
- package/dist/stores/message/ioredis.cjs +18 -0
- package/dist/stores/message/ioredis.d.ts +18 -0
- package/dist/stores/message/ioredis.js +18 -0
- package/dist/stores/message/momento.cjs +18 -0
- package/dist/stores/message/momento.d.ts +18 -0
- package/dist/stores/message/momento.js +18 -0
- package/dist/stores/message/mongodb.cjs +11 -0
- package/dist/stores/message/mongodb.d.ts +11 -0
- package/dist/stores/message/mongodb.js +11 -0
- package/dist/stores/message/planetscale.cjs +18 -0
- package/dist/stores/message/planetscale.d.ts +18 -0
- package/dist/stores/message/planetscale.js +18 -0
- package/dist/stores/message/redis.cjs +18 -0
- package/dist/stores/message/redis.d.ts +18 -0
- package/dist/stores/message/redis.js +18 -0
- package/dist/stores/message/xata.cjs +23 -0
- package/dist/stores/message/xata.d.ts +23 -0
- package/dist/stores/message/xata.js +23 -0
- package/dist/tools/calculator.cjs +6 -0
- package/dist/tools/calculator.d.ts +6 -0
- package/dist/tools/calculator.js +6 -0
- package/dist/tools/google_calendar/create.cjs +22 -0
- package/dist/tools/google_calendar/create.d.ts +22 -0
- package/dist/tools/google_calendar/create.js +22 -0
- package/dist/tools/google_calendar/view.cjs +20 -0
- package/dist/tools/google_calendar/view.d.ts +20 -0
- package/dist/tools/google_calendar/view.js +20 -0
- package/dist/tools/searchapi.cjs +27 -0
- package/dist/tools/searchapi.d.ts +27 -0
- package/dist/tools/searchapi.js +27 -0
- package/dist/tools/searxng_search.cjs +20 -1
- package/dist/tools/searxng_search.d.ts +20 -1
- package/dist/tools/searxng_search.js +20 -1
- package/dist/tools/webbrowser.cjs +8 -0
- package/dist/tools/webbrowser.d.ts +8 -0
- package/dist/tools/webbrowser.js +8 -0
- package/dist/tools/wikipedia_query_run.cjs +8 -0
- package/dist/tools/wikipedia_query_run.d.ts +8 -0
- package/dist/tools/wikipedia_query_run.js +8 -0
- package/dist/tools/wolframalpha.cjs +9 -0
- package/dist/tools/wolframalpha.d.ts +9 -0
- package/dist/tools/wolframalpha.js +9 -0
- package/dist/util/googlevertexai-connection.cjs +3 -9
- package/dist/util/googlevertexai-connection.js +3 -9
- package/dist/vectorstores/opensearch.cjs +2 -1
- package/dist/vectorstores/opensearch.js +2 -1
- package/dist/vectorstores/prisma.cjs +6 -0
- package/dist/vectorstores/prisma.d.ts +3 -0
- package/dist/vectorstores/prisma.js +6 -0
- package/package.json +2 -2
|
@@ -13,6 +13,19 @@ AI:`;
|
|
|
13
13
|
/**
|
|
14
14
|
* A class for conducting conversations between a human and an AI. It
|
|
15
15
|
* extends the {@link LLMChain} class.
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const model = new ChatOpenAI({});
|
|
19
|
+
* const chain = new ConversationChain({ llm: model });
|
|
20
|
+
*
|
|
21
|
+
* // Sending a greeting to the conversation chain
|
|
22
|
+
* const res1 = await chain.call({ input: "Hi! I'm Jim." });
|
|
23
|
+
* console.log({ res1 });
|
|
24
|
+
*
|
|
25
|
+
* // Following up with a question in the conversation
|
|
26
|
+
* const res2 = await chain.call({ input: "What's my name?" });
|
|
27
|
+
* console.log({ res2 });
|
|
28
|
+
* ```
|
|
16
29
|
*/
|
|
17
30
|
class ConversationChain extends llm_chain_js_1.LLMChain {
|
|
18
31
|
static lc_name() {
|
|
@@ -4,6 +4,19 @@ export declare const DEFAULT_TEMPLATE = "The following is a friendly conversatio
|
|
|
4
4
|
/**
|
|
5
5
|
* A class for conducting conversations between a human and an AI. It
|
|
6
6
|
* extends the {@link LLMChain} class.
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* const model = new ChatOpenAI({});
|
|
10
|
+
* const chain = new ConversationChain({ llm: model });
|
|
11
|
+
*
|
|
12
|
+
* // Sending a greeting to the conversation chain
|
|
13
|
+
* const res1 = await chain.call({ input: "Hi! I'm Jim." });
|
|
14
|
+
* console.log({ res1 });
|
|
15
|
+
*
|
|
16
|
+
* // Following up with a question in the conversation
|
|
17
|
+
* const res2 = await chain.call({ input: "What's my name?" });
|
|
18
|
+
* console.log({ res2 });
|
|
19
|
+
* ```
|
|
7
20
|
*/
|
|
8
21
|
export declare class ConversationChain extends LLMChain {
|
|
9
22
|
static lc_name(): string;
|
|
@@ -10,6 +10,19 @@ AI:`;
|
|
|
10
10
|
/**
|
|
11
11
|
* A class for conducting conversations between a human and an AI. It
|
|
12
12
|
* extends the {@link LLMChain} class.
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const model = new ChatOpenAI({});
|
|
16
|
+
* const chain = new ConversationChain({ llm: model });
|
|
17
|
+
*
|
|
18
|
+
* // Sending a greeting to the conversation chain
|
|
19
|
+
* const res1 = await chain.call({ input: "Hi! I'm Jim." });
|
|
20
|
+
* console.log({ res1 });
|
|
21
|
+
*
|
|
22
|
+
* // Following up with a question in the conversation
|
|
23
|
+
* const res2 = await chain.call({ input: "What's my name?" });
|
|
24
|
+
* console.log({ res2 });
|
|
25
|
+
* ```
|
|
13
26
|
*/
|
|
14
27
|
export class ConversationChain extends LLMChain {
|
|
15
28
|
static lc_name() {
|
|
@@ -16,6 +16,35 @@ Standalone question:`;
|
|
|
16
16
|
* Class for conducting conversational question-answering tasks with a
|
|
17
17
|
* retrieval component. Extends the BaseChain class and implements the
|
|
18
18
|
* ConversationalRetrievalQAChainInput interface.
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* const model = new ChatAnthropic({});
|
|
22
|
+
*
|
|
23
|
+
* const text = fs.readFileSync("state_of_the_union.txt", "utf8");
|
|
24
|
+
*
|
|
25
|
+
* const textSplitter = new RecursiveCharacterTextSplitter({ chunkSize: 1000 });
|
|
26
|
+
* const docs = await textSplitter.createDocuments([text]);
|
|
27
|
+
*
|
|
28
|
+
* const vectorStore = await HNSWLib.fromDocuments(docs, new OpenAIEmbeddings());
|
|
29
|
+
*
|
|
30
|
+
* const chain = ConversationalRetrievalQAChain.fromLLM(
|
|
31
|
+
* model,
|
|
32
|
+
* vectorStore.asRetriever(),
|
|
33
|
+
* );
|
|
34
|
+
*
|
|
35
|
+
* const question = "What did the president say about Justice Breyer?";
|
|
36
|
+
*
|
|
37
|
+
* const res = await chain.call({ question, chat_history: "" });
|
|
38
|
+
* console.log(res);
|
|
39
|
+
*
|
|
40
|
+
* const chatHistory = `${question}\n${res.text}`;
|
|
41
|
+
* const followUpRes = await chain.call({
|
|
42
|
+
* question: "Was that nice?",
|
|
43
|
+
* chat_history: chatHistory,
|
|
44
|
+
* });
|
|
45
|
+
* console.log(followUpRes);
|
|
46
|
+
*
|
|
47
|
+
* ```
|
|
19
48
|
*/
|
|
20
49
|
class ConversationalRetrievalQAChain extends base_js_1.BaseChain {
|
|
21
50
|
static lc_name() {
|
|
@@ -22,6 +22,35 @@ export interface ConversationalRetrievalQAChainInput extends ChainInputs {
|
|
|
22
22
|
* Class for conducting conversational question-answering tasks with a
|
|
23
23
|
* retrieval component. Extends the BaseChain class and implements the
|
|
24
24
|
* ConversationalRetrievalQAChainInput interface.
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* const model = new ChatAnthropic({});
|
|
28
|
+
*
|
|
29
|
+
* const text = fs.readFileSync("state_of_the_union.txt", "utf8");
|
|
30
|
+
*
|
|
31
|
+
* const textSplitter = new RecursiveCharacterTextSplitter({ chunkSize: 1000 });
|
|
32
|
+
* const docs = await textSplitter.createDocuments([text]);
|
|
33
|
+
*
|
|
34
|
+
* const vectorStore = await HNSWLib.fromDocuments(docs, new OpenAIEmbeddings());
|
|
35
|
+
*
|
|
36
|
+
* const chain = ConversationalRetrievalQAChain.fromLLM(
|
|
37
|
+
* model,
|
|
38
|
+
* vectorStore.asRetriever(),
|
|
39
|
+
* );
|
|
40
|
+
*
|
|
41
|
+
* const question = "What did the president say about Justice Breyer?";
|
|
42
|
+
*
|
|
43
|
+
* const res = await chain.call({ question, chat_history: "" });
|
|
44
|
+
* console.log(res);
|
|
45
|
+
*
|
|
46
|
+
* const chatHistory = `${question}\n${res.text}`;
|
|
47
|
+
* const followUpRes = await chain.call({
|
|
48
|
+
* question: "Was that nice?",
|
|
49
|
+
* chat_history: chatHistory,
|
|
50
|
+
* });
|
|
51
|
+
* console.log(followUpRes);
|
|
52
|
+
*
|
|
53
|
+
* ```
|
|
25
54
|
*/
|
|
26
55
|
export declare class ConversationalRetrievalQAChain extends BaseChain implements ConversationalRetrievalQAChainInput {
|
|
27
56
|
static lc_name(): string;
|
|
@@ -13,6 +13,35 @@ Standalone question:`;
|
|
|
13
13
|
* Class for conducting conversational question-answering tasks with a
|
|
14
14
|
* retrieval component. Extends the BaseChain class and implements the
|
|
15
15
|
* ConversationalRetrievalQAChainInput interface.
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const model = new ChatAnthropic({});
|
|
19
|
+
*
|
|
20
|
+
* const text = fs.readFileSync("state_of_the_union.txt", "utf8");
|
|
21
|
+
*
|
|
22
|
+
* const textSplitter = new RecursiveCharacterTextSplitter({ chunkSize: 1000 });
|
|
23
|
+
* const docs = await textSplitter.createDocuments([text]);
|
|
24
|
+
*
|
|
25
|
+
* const vectorStore = await HNSWLib.fromDocuments(docs, new OpenAIEmbeddings());
|
|
26
|
+
*
|
|
27
|
+
* const chain = ConversationalRetrievalQAChain.fromLLM(
|
|
28
|
+
* model,
|
|
29
|
+
* vectorStore.asRetriever(),
|
|
30
|
+
* );
|
|
31
|
+
*
|
|
32
|
+
* const question = "What did the president say about Justice Breyer?";
|
|
33
|
+
*
|
|
34
|
+
* const res = await chain.call({ question, chat_history: "" });
|
|
35
|
+
* console.log(res);
|
|
36
|
+
*
|
|
37
|
+
* const chatHistory = `${question}\n${res.text}`;
|
|
38
|
+
* const followUpRes = await chain.call({
|
|
39
|
+
* question: "Was that nice?",
|
|
40
|
+
* chat_history: chatHistory,
|
|
41
|
+
* });
|
|
42
|
+
* console.log(followUpRes);
|
|
43
|
+
*
|
|
44
|
+
* ```
|
|
16
45
|
*/
|
|
17
46
|
export class ConversationalRetrievalQAChain extends BaseChain {
|
|
18
47
|
static lc_name() {
|
|
@@ -5,6 +5,16 @@ const llm_chain_js_1 = require("../../chains/llm_chain.cjs");
|
|
|
5
5
|
const base_js_1 = require("../base.cjs");
|
|
6
6
|
const prompts_js_1 = require("./prompts.cjs");
|
|
7
7
|
exports.INTERMEDIATE_STEPS_KEY = "intermediateSteps";
|
|
8
|
+
/**
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const chain = new GraphCypherQAChain({
|
|
12
|
+
* llm: new ChatOpenAI({ temperature: 0 }),
|
|
13
|
+
* graph: new Neo4jGraph(),
|
|
14
|
+
* });
|
|
15
|
+
* const res = await chain.run("Who played in Pulp Fiction?");
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
8
18
|
class GraphCypherQAChain extends base_js_1.BaseChain {
|
|
9
19
|
constructor(props) {
|
|
10
20
|
super(props);
|
|
@@ -26,6 +26,16 @@ export interface FromLLMInput {
|
|
|
26
26
|
returnIntermediateSteps?: boolean;
|
|
27
27
|
returnDirect?: boolean;
|
|
28
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* const chain = new GraphCypherQAChain({
|
|
33
|
+
* llm: new ChatOpenAI({ temperature: 0 }),
|
|
34
|
+
* graph: new Neo4jGraph(),
|
|
35
|
+
* });
|
|
36
|
+
* const res = await chain.run("Who played in Pulp Fiction?");
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
29
39
|
export declare class GraphCypherQAChain extends BaseChain {
|
|
30
40
|
private graph;
|
|
31
41
|
private cypherGenerationChain;
|
|
@@ -2,6 +2,16 @@ import { LLMChain } from "../../chains/llm_chain.js";
|
|
|
2
2
|
import { BaseChain } from "../base.js";
|
|
3
3
|
import { CYPHER_GENERATION_PROMPT, CYPHER_QA_PROMPT } from "./prompts.js";
|
|
4
4
|
export const INTERMEDIATE_STEPS_KEY = "intermediateSteps";
|
|
5
|
+
/**
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* const chain = new GraphCypherQAChain({
|
|
9
|
+
* llm: new ChatOpenAI({ temperature: 0 }),
|
|
10
|
+
* graph: new Neo4jGraph(),
|
|
11
|
+
* });
|
|
12
|
+
* const res = await chain.run("Who played in Pulp Fiction?");
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
5
15
|
export class GraphCypherQAChain extends BaseChain {
|
|
6
16
|
constructor(props) {
|
|
7
17
|
super(props);
|
|
@@ -9,6 +9,34 @@ const env_js_1 = require("../util/env.cjs");
|
|
|
9
9
|
* Class representing a chain for moderating text using the OpenAI
|
|
10
10
|
* Moderation API. It extends the BaseChain class and implements the
|
|
11
11
|
* OpenAIModerationChainInput interface.
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const moderation = new ChatOpenAIModerationChain({ throwError: true });
|
|
15
|
+
*
|
|
16
|
+
* const badString = "Bad naughty words from user";
|
|
17
|
+
*
|
|
18
|
+
* try {
|
|
19
|
+
* const { output: moderatedContent, results } = await moderation.call({
|
|
20
|
+
* input: badString,
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* if (results[0].category_scores["harassment/threatening"] > 0.01) {
|
|
24
|
+
* throw new Error("Harassment detected!");
|
|
25
|
+
* }
|
|
26
|
+
*
|
|
27
|
+
* const model = new OpenAI({ temperature: 0 });
|
|
28
|
+
* const promptTemplate = "Hello, how are you today {person}?";
|
|
29
|
+
* const prompt = new PromptTemplate({
|
|
30
|
+
* template: promptTemplate,
|
|
31
|
+
* inputVariables: ["person"],
|
|
32
|
+
* });
|
|
33
|
+
* const chain = new LLMChain({ llm: model, prompt });
|
|
34
|
+
* const response = await chain.call({ person: moderatedContent });
|
|
35
|
+
* console.log({ response });
|
|
36
|
+
* } catch (error) {
|
|
37
|
+
* console.error("Naughty words detected!");
|
|
38
|
+
* }
|
|
39
|
+
* ```
|
|
12
40
|
*/
|
|
13
41
|
class OpenAIModerationChain extends base_js_1.BaseChain {
|
|
14
42
|
static lc_name() {
|
|
@@ -15,6 +15,34 @@ export interface OpenAIModerationChainInput extends ChainInputs, AsyncCallerPara
|
|
|
15
15
|
* Class representing a chain for moderating text using the OpenAI
|
|
16
16
|
* Moderation API. It extends the BaseChain class and implements the
|
|
17
17
|
* OpenAIModerationChainInput interface.
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const moderation = new ChatOpenAIModerationChain({ throwError: true });
|
|
21
|
+
*
|
|
22
|
+
* const badString = "Bad naughty words from user";
|
|
23
|
+
*
|
|
24
|
+
* try {
|
|
25
|
+
* const { output: moderatedContent, results } = await moderation.call({
|
|
26
|
+
* input: badString,
|
|
27
|
+
* });
|
|
28
|
+
*
|
|
29
|
+
* if (results[0].category_scores["harassment/threatening"] > 0.01) {
|
|
30
|
+
* throw new Error("Harassment detected!");
|
|
31
|
+
* }
|
|
32
|
+
*
|
|
33
|
+
* const model = new OpenAI({ temperature: 0 });
|
|
34
|
+
* const promptTemplate = "Hello, how are you today {person}?";
|
|
35
|
+
* const prompt = new PromptTemplate({
|
|
36
|
+
* template: promptTemplate,
|
|
37
|
+
* inputVariables: ["person"],
|
|
38
|
+
* });
|
|
39
|
+
* const chain = new LLMChain({ llm: model, prompt });
|
|
40
|
+
* const response = await chain.call({ person: moderatedContent });
|
|
41
|
+
* console.log({ response });
|
|
42
|
+
* } catch (error) {
|
|
43
|
+
* console.error("Naughty words detected!");
|
|
44
|
+
* }
|
|
45
|
+
* ```
|
|
18
46
|
*/
|
|
19
47
|
export declare class OpenAIModerationChain extends BaseChain implements OpenAIModerationChainInput {
|
|
20
48
|
static lc_name(): string;
|
|
@@ -6,6 +6,34 @@ import { getEnvironmentVariable } from "../util/env.js";
|
|
|
6
6
|
* Class representing a chain for moderating text using the OpenAI
|
|
7
7
|
* Moderation API. It extends the BaseChain class and implements the
|
|
8
8
|
* OpenAIModerationChainInput interface.
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const moderation = new ChatOpenAIModerationChain({ throwError: true });
|
|
12
|
+
*
|
|
13
|
+
* const badString = "Bad naughty words from user";
|
|
14
|
+
*
|
|
15
|
+
* try {
|
|
16
|
+
* const { output: moderatedContent, results } = await moderation.call({
|
|
17
|
+
* input: badString,
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* if (results[0].category_scores["harassment/threatening"] > 0.01) {
|
|
21
|
+
* throw new Error("Harassment detected!");
|
|
22
|
+
* }
|
|
23
|
+
*
|
|
24
|
+
* const model = new OpenAI({ temperature: 0 });
|
|
25
|
+
* const promptTemplate = "Hello, how are you today {person}?";
|
|
26
|
+
* const prompt = new PromptTemplate({
|
|
27
|
+
* template: promptTemplate,
|
|
28
|
+
* inputVariables: ["person"],
|
|
29
|
+
* });
|
|
30
|
+
* const chain = new LLMChain({ llm: model, prompt });
|
|
31
|
+
* const response = await chain.call({ person: moderatedContent });
|
|
32
|
+
* console.log({ response });
|
|
33
|
+
* } catch (error) {
|
|
34
|
+
* console.error("Naughty words detected!");
|
|
35
|
+
* }
|
|
36
|
+
* ```
|
|
9
37
|
*/
|
|
10
38
|
export class OpenAIModerationChain extends BaseChain {
|
|
11
39
|
static lc_name() {
|
|
@@ -6,6 +6,27 @@ const load_js_1 = require("./question_answering/load.cjs");
|
|
|
6
6
|
/**
|
|
7
7
|
* Class representing a chain for performing question-answering tasks with
|
|
8
8
|
* a retrieval component.
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* // Initialize the OpenAI model and the remote retriever with the specified configuration
|
|
12
|
+
* const model = new ChatOpenAI({});
|
|
13
|
+
* const retriever = new RemoteLangChainRetriever({
|
|
14
|
+
* url: "http://example.com/api",
|
|
15
|
+
* auth: { bearer: "foo" },
|
|
16
|
+
* inputKey: "message",
|
|
17
|
+
* responseKey: "response",
|
|
18
|
+
* });
|
|
19
|
+
*
|
|
20
|
+
* // Create a RetrievalQAChain using the model and retriever
|
|
21
|
+
* const chain = RetrievalQAChain.fromLLM(model, retriever);
|
|
22
|
+
*
|
|
23
|
+
* // Execute the chain with a query and log the result
|
|
24
|
+
* const res = await chain.call({
|
|
25
|
+
* query: "What did the president say about Justice Breyer?",
|
|
26
|
+
* });
|
|
27
|
+
* console.log({ res });
|
|
28
|
+
*
|
|
29
|
+
* ```
|
|
9
30
|
*/
|
|
10
31
|
class RetrievalQAChain extends base_js_1.BaseChain {
|
|
11
32
|
static lc_name() {
|
|
@@ -18,6 +18,27 @@ export interface RetrievalQAChainInput extends Omit<ChainInputs, "memory"> {
|
|
|
18
18
|
/**
|
|
19
19
|
* Class representing a chain for performing question-answering tasks with
|
|
20
20
|
* a retrieval component.
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* // Initialize the OpenAI model and the remote retriever with the specified configuration
|
|
24
|
+
* const model = new ChatOpenAI({});
|
|
25
|
+
* const retriever = new RemoteLangChainRetriever({
|
|
26
|
+
* url: "http://example.com/api",
|
|
27
|
+
* auth: { bearer: "foo" },
|
|
28
|
+
* inputKey: "message",
|
|
29
|
+
* responseKey: "response",
|
|
30
|
+
* });
|
|
31
|
+
*
|
|
32
|
+
* // Create a RetrievalQAChain using the model and retriever
|
|
33
|
+
* const chain = RetrievalQAChain.fromLLM(model, retriever);
|
|
34
|
+
*
|
|
35
|
+
* // Execute the chain with a query and log the result
|
|
36
|
+
* const res = await chain.call({
|
|
37
|
+
* query: "What did the president say about Justice Breyer?",
|
|
38
|
+
* });
|
|
39
|
+
* console.log({ res });
|
|
40
|
+
*
|
|
41
|
+
* ```
|
|
21
42
|
*/
|
|
22
43
|
export declare class RetrievalQAChain extends BaseChain implements RetrievalQAChainInput {
|
|
23
44
|
static lc_name(): string;
|
|
@@ -3,6 +3,27 @@ import { loadQAStuffChain, } from "./question_answering/load.js";
|
|
|
3
3
|
/**
|
|
4
4
|
* Class representing a chain for performing question-answering tasks with
|
|
5
5
|
* a retrieval component.
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* // Initialize the OpenAI model and the remote retriever with the specified configuration
|
|
9
|
+
* const model = new ChatOpenAI({});
|
|
10
|
+
* const retriever = new RemoteLangChainRetriever({
|
|
11
|
+
* url: "http://example.com/api",
|
|
12
|
+
* auth: { bearer: "foo" },
|
|
13
|
+
* inputKey: "message",
|
|
14
|
+
* responseKey: "response",
|
|
15
|
+
* });
|
|
16
|
+
*
|
|
17
|
+
* // Create a RetrievalQAChain using the model and retriever
|
|
18
|
+
* const chain = RetrievalQAChain.fromLLM(model, retriever);
|
|
19
|
+
*
|
|
20
|
+
* // Execute the chain with a query and log the result
|
|
21
|
+
* const res = await chain.call({
|
|
22
|
+
* query: "What did the president say about Justice Breyer?",
|
|
23
|
+
* });
|
|
24
|
+
* console.log({ res });
|
|
25
|
+
*
|
|
26
|
+
* ```
|
|
6
27
|
*/
|
|
7
28
|
export class RetrievalQAChain extends BaseChain {
|
|
8
29
|
static lc_name() {
|
|
@@ -15,6 +15,25 @@ const router_js_1 = require("../../output_parsers/router.cjs");
|
|
|
15
15
|
* A class that represents a multi-prompt chain in the LangChain
|
|
16
16
|
* framework. It extends the MultiRouteChain class and provides additional
|
|
17
17
|
* functionality specific to multi-prompt chains.
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const multiPromptChain = MultiPromptChain.fromLLMAndPrompts(new ChatOpenAI(), {
|
|
21
|
+
* promptNames: ["physics", "math", "history"],
|
|
22
|
+
* promptDescriptions: [
|
|
23
|
+
* "Good for answering questions about physics",
|
|
24
|
+
* "Good for answering math questions",
|
|
25
|
+
* "Good for answering questions about history",
|
|
26
|
+
* ],
|
|
27
|
+
* promptTemplates: [
|
|
28
|
+
* `You are a very smart physics professor. Here is a question:\n{input}\n`,
|
|
29
|
+
* `You are a very good mathematician. Here is a question:\n{input}\n`,
|
|
30
|
+
* `You are a very smart history professor. Here is a question:\n{input}\n`,
|
|
31
|
+
* ],
|
|
32
|
+
* });
|
|
33
|
+
* const result = await multiPromptChain.call({
|
|
34
|
+
* input: "What is the speed of light?",
|
|
35
|
+
* });
|
|
36
|
+
* ```
|
|
18
37
|
*/
|
|
19
38
|
class MultiPromptChain extends multi_route_js_1.MultiRouteChain {
|
|
20
39
|
/**
|
|
@@ -7,6 +7,25 @@ import { PromptTemplate } from "../../prompts/prompt.js";
|
|
|
7
7
|
* A class that represents a multi-prompt chain in the LangChain
|
|
8
8
|
* framework. It extends the MultiRouteChain class and provides additional
|
|
9
9
|
* functionality specific to multi-prompt chains.
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* const multiPromptChain = MultiPromptChain.fromLLMAndPrompts(new ChatOpenAI(), {
|
|
13
|
+
* promptNames: ["physics", "math", "history"],
|
|
14
|
+
* promptDescriptions: [
|
|
15
|
+
* "Good for answering questions about physics",
|
|
16
|
+
* "Good for answering math questions",
|
|
17
|
+
* "Good for answering questions about history",
|
|
18
|
+
* ],
|
|
19
|
+
* promptTemplates: [
|
|
20
|
+
* `You are a very smart physics professor. Here is a question:\n{input}\n`,
|
|
21
|
+
* `You are a very good mathematician. Here is a question:\n{input}\n`,
|
|
22
|
+
* `You are a very smart history professor. Here is a question:\n{input}\n`,
|
|
23
|
+
* ],
|
|
24
|
+
* });
|
|
25
|
+
* const result = await multiPromptChain.call({
|
|
26
|
+
* input: "What is the speed of light?",
|
|
27
|
+
* });
|
|
28
|
+
* ```
|
|
10
29
|
*/
|
|
11
30
|
export declare class MultiPromptChain extends MultiRouteChain {
|
|
12
31
|
/**
|
|
@@ -12,6 +12,25 @@ import { RouterOutputParser } from "../../output_parsers/router.js";
|
|
|
12
12
|
* A class that represents a multi-prompt chain in the LangChain
|
|
13
13
|
* framework. It extends the MultiRouteChain class and provides additional
|
|
14
14
|
* functionality specific to multi-prompt chains.
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* const multiPromptChain = MultiPromptChain.fromLLMAndPrompts(new ChatOpenAI(), {
|
|
18
|
+
* promptNames: ["physics", "math", "history"],
|
|
19
|
+
* promptDescriptions: [
|
|
20
|
+
* "Good for answering questions about physics",
|
|
21
|
+
* "Good for answering math questions",
|
|
22
|
+
* "Good for answering questions about history",
|
|
23
|
+
* ],
|
|
24
|
+
* promptTemplates: [
|
|
25
|
+
* `You are a very smart physics professor. Here is a question:\n{input}\n`,
|
|
26
|
+
* `You are a very good mathematician. Here is a question:\n{input}\n`,
|
|
27
|
+
* `You are a very smart history professor. Here is a question:\n{input}\n`,
|
|
28
|
+
* ],
|
|
29
|
+
* });
|
|
30
|
+
* const result = await multiPromptChain.call({
|
|
31
|
+
* input: "What is the speed of light?",
|
|
32
|
+
* });
|
|
33
|
+
* ```
|
|
15
34
|
*/
|
|
16
35
|
export class MultiPromptChain extends MultiRouteChain {
|
|
17
36
|
/**
|
|
@@ -16,6 +16,35 @@ const router_js_1 = require("../../output_parsers/router.cjs");
|
|
|
16
16
|
* the LangChain framework. It extends the MultiRouteChain class and
|
|
17
17
|
* provides additional functionality specific to multi-retrieval QA
|
|
18
18
|
* chains.
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* const multiRetrievalQAChain = MultiRetrievalQAChain.fromLLMAndRetrievers(
|
|
22
|
+
* new ChatOpenAI(),
|
|
23
|
+
* {
|
|
24
|
+
* retrieverNames: ["aqua teen", "mst3k", "animaniacs"],
|
|
25
|
+
* retrieverDescriptions: [
|
|
26
|
+
* "Good for answering questions about Aqua Teen Hunger Force theme song",
|
|
27
|
+
* "Good for answering questions about Mystery Science Theater 3000 theme song",
|
|
28
|
+
* "Good for answering questions about Animaniacs theme song",
|
|
29
|
+
* ],
|
|
30
|
+
* retrievers: [
|
|
31
|
+
* new MemoryVectorStore().asRetriever(3),
|
|
32
|
+
* new MemoryVectorStore().asRetriever(3),
|
|
33
|
+
* new MemoryVectorStore().asRetriever(3),
|
|
34
|
+
* ],
|
|
35
|
+
* retrievalQAChainOpts: {
|
|
36
|
+
* returnSourceDocuments: true,
|
|
37
|
+
* },
|
|
38
|
+
* },
|
|
39
|
+
* );
|
|
40
|
+
*
|
|
41
|
+
* const result = await multiRetrievalQAChain.call({
|
|
42
|
+
* input:
|
|
43
|
+
* "In the Aqua Teen Hunger Force theme song, who calls himself the mike rula?",
|
|
44
|
+
* });
|
|
45
|
+
*
|
|
46
|
+
* console.log(result.sourceDocuments, result.text);
|
|
47
|
+
* ```
|
|
19
48
|
*/
|
|
20
49
|
class MultiRetrievalQAChain extends multi_route_js_1.MultiRouteChain {
|
|
21
50
|
get outputKeys() {
|
|
@@ -19,6 +19,35 @@ export type MultiRetrievalDefaults = {
|
|
|
19
19
|
* the LangChain framework. It extends the MultiRouteChain class and
|
|
20
20
|
* provides additional functionality specific to multi-retrieval QA
|
|
21
21
|
* chains.
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* const multiRetrievalQAChain = MultiRetrievalQAChain.fromLLMAndRetrievers(
|
|
25
|
+
* new ChatOpenAI(),
|
|
26
|
+
* {
|
|
27
|
+
* retrieverNames: ["aqua teen", "mst3k", "animaniacs"],
|
|
28
|
+
* retrieverDescriptions: [
|
|
29
|
+
* "Good for answering questions about Aqua Teen Hunger Force theme song",
|
|
30
|
+
* "Good for answering questions about Mystery Science Theater 3000 theme song",
|
|
31
|
+
* "Good for answering questions about Animaniacs theme song",
|
|
32
|
+
* ],
|
|
33
|
+
* retrievers: [
|
|
34
|
+
* new MemoryVectorStore().asRetriever(3),
|
|
35
|
+
* new MemoryVectorStore().asRetriever(3),
|
|
36
|
+
* new MemoryVectorStore().asRetriever(3),
|
|
37
|
+
* ],
|
|
38
|
+
* retrievalQAChainOpts: {
|
|
39
|
+
* returnSourceDocuments: true,
|
|
40
|
+
* },
|
|
41
|
+
* },
|
|
42
|
+
* );
|
|
43
|
+
*
|
|
44
|
+
* const result = await multiRetrievalQAChain.call({
|
|
45
|
+
* input:
|
|
46
|
+
* "In the Aqua Teen Hunger Force theme song, who calls himself the mike rula?",
|
|
47
|
+
* });
|
|
48
|
+
*
|
|
49
|
+
* console.log(result.sourceDocuments, result.text);
|
|
50
|
+
* ```
|
|
22
51
|
*/
|
|
23
52
|
export declare class MultiRetrievalQAChain extends MultiRouteChain {
|
|
24
53
|
get outputKeys(): string[];
|
|
@@ -13,6 +13,35 @@ import { RouterOutputParser } from "../../output_parsers/router.js";
|
|
|
13
13
|
* the LangChain framework. It extends the MultiRouteChain class and
|
|
14
14
|
* provides additional functionality specific to multi-retrieval QA
|
|
15
15
|
* chains.
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const multiRetrievalQAChain = MultiRetrievalQAChain.fromLLMAndRetrievers(
|
|
19
|
+
* new ChatOpenAI(),
|
|
20
|
+
* {
|
|
21
|
+
* retrieverNames: ["aqua teen", "mst3k", "animaniacs"],
|
|
22
|
+
* retrieverDescriptions: [
|
|
23
|
+
* "Good for answering questions about Aqua Teen Hunger Force theme song",
|
|
24
|
+
* "Good for answering questions about Mystery Science Theater 3000 theme song",
|
|
25
|
+
* "Good for answering questions about Animaniacs theme song",
|
|
26
|
+
* ],
|
|
27
|
+
* retrievers: [
|
|
28
|
+
* new MemoryVectorStore().asRetriever(3),
|
|
29
|
+
* new MemoryVectorStore().asRetriever(3),
|
|
30
|
+
* new MemoryVectorStore().asRetriever(3),
|
|
31
|
+
* ],
|
|
32
|
+
* retrievalQAChainOpts: {
|
|
33
|
+
* returnSourceDocuments: true,
|
|
34
|
+
* },
|
|
35
|
+
* },
|
|
36
|
+
* );
|
|
37
|
+
*
|
|
38
|
+
* const result = await multiRetrievalQAChain.call({
|
|
39
|
+
* input:
|
|
40
|
+
* "In the Aqua Teen Hunger Force theme song, who calls himself the mike rula?",
|
|
41
|
+
* });
|
|
42
|
+
*
|
|
43
|
+
* console.log(result.sourceDocuments, result.text);
|
|
44
|
+
* ```
|
|
16
45
|
*/
|
|
17
46
|
export class MultiRetrievalQAChain extends MultiRouteChain {
|
|
18
47
|
get outputKeys() {
|
|
@@ -10,6 +10,49 @@ function formatSet(input) {
|
|
|
10
10
|
}
|
|
11
11
|
/**
|
|
12
12
|
* Chain where the outputs of one chain feed directly into next.
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const promptTemplate = new PromptTemplate({
|
|
16
|
+
* template: `You are a playwright. Given the title of play and the era it is set in, it is your job to write a synopsis for that title.
|
|
17
|
+
* Title: {title}
|
|
18
|
+
* Era: {era}
|
|
19
|
+
* Playwright: This is a synopsis for the above play:`,
|
|
20
|
+
* inputVariables: ["title", "era"],
|
|
21
|
+
* });
|
|
22
|
+
|
|
23
|
+
* const reviewPromptTemplate = new PromptTemplate({
|
|
24
|
+
* template: `You are a play critic from the New York Times. Given the synopsis of play, it is your job to write a review for that play.
|
|
25
|
+
*
|
|
26
|
+
* Play Synopsis:
|
|
27
|
+
* {synopsis}
|
|
28
|
+
* Review from a New York Times play critic of the above play:`,
|
|
29
|
+
* inputVariables: ["synopsis"],
|
|
30
|
+
* });
|
|
31
|
+
|
|
32
|
+
* const overallChain = new SequentialChain({
|
|
33
|
+
* chains: [
|
|
34
|
+
* new LLMChain({
|
|
35
|
+
* llm: new ChatOpenAI({ temperature: 0 }),
|
|
36
|
+
* prompt: promptTemplate,
|
|
37
|
+
* outputKey: "synopsis",
|
|
38
|
+
* }),
|
|
39
|
+
* new LLMChain({
|
|
40
|
+
* llm: new OpenAI({ temperature: 0 }),
|
|
41
|
+
* prompt: reviewPromptTemplate,
|
|
42
|
+
* outputKey: "review",
|
|
43
|
+
* }),
|
|
44
|
+
* ],
|
|
45
|
+
* inputVariables: ["era", "title"],
|
|
46
|
+
* outputVariables: ["synopsis", "review"],
|
|
47
|
+
* verbose: true,
|
|
48
|
+
* });
|
|
49
|
+
|
|
50
|
+
* const chainExecutionResult = await overallChain.call({
|
|
51
|
+
* title: "Tragedy at sunset on the beach",
|
|
52
|
+
* era: "Victorian England",
|
|
53
|
+
* });
|
|
54
|
+
* console.log(chainExecutionResult);
|
|
55
|
+
* ```
|
|
13
56
|
*/
|
|
14
57
|
class SequentialChain extends base_js_1.BaseChain {
|
|
15
58
|
static lc_name() {
|