langchain 0.0.191 → 0.0.193
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/cache/file_system.cjs +1 -0
- package/cache/file_system.d.ts +1 -0
- package/cache/file_system.js +1 -0
- 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/file_system.cjs +73 -0
- package/dist/cache/file_system.d.ts +33 -0
- package/dist/cache/file_system.js +66 -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 +10 -1
- package/dist/chat_models/bedrock/web.d.ts +9 -0
- package/dist/chat_models/bedrock/web.js +10 -1
- 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 +15 -2
- package/dist/document_loaders/fs/pdf.d.ts +9 -1
- package/dist/document_loaders/fs/pdf.js +15 -2
- 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 +26 -2
- package/dist/document_loaders/web/apify_dataset.d.ts +25 -1
- package/dist/document_loaders/web/apify_dataset.js +26 -2
- 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 +15 -2
- package/dist/document_loaders/web/pdf.d.ts +9 -1
- package/dist/document_loaders/web/pdf.js +15 -2
- 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/bedrock/web.cjs +1 -1
- package/dist/llms/bedrock/web.js +1 -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/load/import_constants.cjs +2 -0
- package/dist/load/import_constants.js +2 -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 +20 -2
- package/dist/vectorstores/prisma.d.ts +4 -0
- package/dist/vectorstores/prisma.js +20 -2
- package/dist/vectorstores/rockset.cjs +353 -0
- package/dist/vectorstores/rockset.d.ts +202 -0
- package/dist/vectorstores/rockset.js +347 -0
- package/package.json +24 -5
- package/vectorstores/rockset.cjs +1 -0
- package/vectorstores/rockset.d.ts +1 -0
- package/vectorstores/rockset.js +1 -0
|
@@ -14,6 +14,30 @@ export interface OllamaCallOptions extends BaseLanguageModelCallOptions {
|
|
|
14
14
|
* A class that enables calls to the Ollama API to access large language
|
|
15
15
|
* models in a chat-like fashion. It extends the SimpleChatModel class and
|
|
16
16
|
* implements the OllamaInput interface.
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const prompt = ChatPromptTemplate.fromMessages([
|
|
20
|
+
* [
|
|
21
|
+
* "system",
|
|
22
|
+
* `You are an expert translator. Format all responses as JSON objects with two keys: "original" and "translated".`,
|
|
23
|
+
* ],
|
|
24
|
+
* ["human", `Translate "{input}" into {language}.`],
|
|
25
|
+
* ]);
|
|
26
|
+
*
|
|
27
|
+
* const model = new ChatOllama({
|
|
28
|
+
* baseUrl: "http://api.example.com",
|
|
29
|
+
* model: "llama2",
|
|
30
|
+
* format: "json",
|
|
31
|
+
* });
|
|
32
|
+
*
|
|
33
|
+
* const chain = prompt.pipe(model);
|
|
34
|
+
*
|
|
35
|
+
* const result = await chain.invoke({
|
|
36
|
+
* input: "I love programming",
|
|
37
|
+
* language: "German",
|
|
38
|
+
* });
|
|
39
|
+
*
|
|
40
|
+
* ```
|
|
17
41
|
*/
|
|
18
42
|
export declare class ChatOllama extends SimpleChatModel<OllamaCallOptions> implements OllamaInput {
|
|
19
43
|
static lc_name(): string;
|
|
@@ -5,6 +5,30 @@ import { AIMessageChunk, ChatGenerationChunk, ChatMessage, } from "../schema/ind
|
|
|
5
5
|
* A class that enables calls to the Ollama API to access large language
|
|
6
6
|
* models in a chat-like fashion. It extends the SimpleChatModel class and
|
|
7
7
|
* implements the OllamaInput interface.
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const prompt = ChatPromptTemplate.fromMessages([
|
|
11
|
+
* [
|
|
12
|
+
* "system",
|
|
13
|
+
* `You are an expert translator. Format all responses as JSON objects with two keys: "original" and "translated".`,
|
|
14
|
+
* ],
|
|
15
|
+
* ["human", `Translate "{input}" into {language}.`],
|
|
16
|
+
* ]);
|
|
17
|
+
*
|
|
18
|
+
* const model = new ChatOllama({
|
|
19
|
+
* baseUrl: "http://api.example.com",
|
|
20
|
+
* model: "llama2",
|
|
21
|
+
* format: "json",
|
|
22
|
+
* });
|
|
23
|
+
*
|
|
24
|
+
* const chain = prompt.pipe(model);
|
|
25
|
+
*
|
|
26
|
+
* const result = await chain.invoke({
|
|
27
|
+
* input: "I love programming",
|
|
28
|
+
* language: "German",
|
|
29
|
+
* });
|
|
30
|
+
*
|
|
31
|
+
* ```
|
|
8
32
|
*/
|
|
9
33
|
export class ChatOllama extends SimpleChatModel {
|
|
10
34
|
static lc_name() {
|
|
@@ -128,6 +128,21 @@ function convertMessagesToOpenAIParams(messages) {
|
|
|
128
128
|
* https://platform.openai.com/docs/api-reference/chat/create |
|
|
129
129
|
* `openai.createChatCompletion`} can be passed through {@link modelKwargs}, even
|
|
130
130
|
* if not explicitly available on this class.
|
|
131
|
+
* @example
|
|
132
|
+
* ```typescript
|
|
133
|
+
* // Create a new instance of ChatOpenAI with specific temperature and model name settings
|
|
134
|
+
* const model = new ChatOpenAI({
|
|
135
|
+
* temperature: 0.9,
|
|
136
|
+
* modelName: "ft:gpt-3.5-turbo-0613:{ORG_NAME}::{MODEL_ID}",
|
|
137
|
+
* });
|
|
138
|
+
*
|
|
139
|
+
* // Invoke the model with a message and await the response
|
|
140
|
+
* const message = await model.invoke("Hi there!");
|
|
141
|
+
*
|
|
142
|
+
* // Log the response to the console
|
|
143
|
+
* console.log(message);
|
|
144
|
+
*
|
|
145
|
+
* ```
|
|
131
146
|
*/
|
|
132
147
|
class ChatOpenAI extends base_js_1.BaseChatModel {
|
|
133
148
|
static lc_name() {
|
|
@@ -41,6 +41,21 @@ export interface ChatOpenAICallOptions extends OpenAICallOptions, BaseFunctionCa
|
|
|
41
41
|
* https://platform.openai.com/docs/api-reference/chat/create |
|
|
42
42
|
* `openai.createChatCompletion`} can be passed through {@link modelKwargs}, even
|
|
43
43
|
* if not explicitly available on this class.
|
|
44
|
+
* @example
|
|
45
|
+
* ```typescript
|
|
46
|
+
* // Create a new instance of ChatOpenAI with specific temperature and model name settings
|
|
47
|
+
* const model = new ChatOpenAI({
|
|
48
|
+
* temperature: 0.9,
|
|
49
|
+
* modelName: "ft:gpt-3.5-turbo-0613:{ORG_NAME}::{MODEL_ID}",
|
|
50
|
+
* });
|
|
51
|
+
*
|
|
52
|
+
* // Invoke the model with a message and await the response
|
|
53
|
+
* const message = await model.invoke("Hi there!");
|
|
54
|
+
*
|
|
55
|
+
* // Log the response to the console
|
|
56
|
+
* console.log(message);
|
|
57
|
+
*
|
|
58
|
+
* ```
|
|
44
59
|
*/
|
|
45
60
|
export declare class ChatOpenAI<CallOptions extends ChatOpenAICallOptions = ChatOpenAICallOptions> extends BaseChatModel<CallOptions> implements OpenAIChatInput, AzureOpenAIInput {
|
|
46
61
|
static lc_name(): string;
|
|
@@ -125,6 +125,21 @@ function convertMessagesToOpenAIParams(messages) {
|
|
|
125
125
|
* https://platform.openai.com/docs/api-reference/chat/create |
|
|
126
126
|
* `openai.createChatCompletion`} can be passed through {@link modelKwargs}, even
|
|
127
127
|
* if not explicitly available on this class.
|
|
128
|
+
* @example
|
|
129
|
+
* ```typescript
|
|
130
|
+
* // Create a new instance of ChatOpenAI with specific temperature and model name settings
|
|
131
|
+
* const model = new ChatOpenAI({
|
|
132
|
+
* temperature: 0.9,
|
|
133
|
+
* modelName: "ft:gpt-3.5-turbo-0613:{ORG_NAME}::{MODEL_ID}",
|
|
134
|
+
* });
|
|
135
|
+
*
|
|
136
|
+
* // Invoke the model with a message and await the response
|
|
137
|
+
* const message = await model.invoke("Hi there!");
|
|
138
|
+
*
|
|
139
|
+
* // Log the response to the console
|
|
140
|
+
* console.log(message);
|
|
141
|
+
*
|
|
142
|
+
* ```
|
|
128
143
|
*/
|
|
129
144
|
export class ChatOpenAI extends BaseChatModel {
|
|
130
145
|
static lc_name() {
|
|
@@ -26,6 +26,20 @@ function _parseChatHistory(history) {
|
|
|
26
26
|
}
|
|
27
27
|
return [chatHistory, instruction];
|
|
28
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* const chat = new ChatYandexGPT({});
|
|
33
|
+
* // The assistant is set to translate English to French.
|
|
34
|
+
* const res = await chat.call([
|
|
35
|
+
* new SystemMessage(
|
|
36
|
+
* "You are a helpful assistant that translates English to French."
|
|
37
|
+
* ),
|
|
38
|
+
* new HumanMessage("I love programming."),
|
|
39
|
+
* ]);
|
|
40
|
+
* console.log(res);
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
29
43
|
class ChatYandexGPT extends base_js_1.BaseChatModel {
|
|
30
44
|
constructor(fields) {
|
|
31
45
|
super(fields ?? {});
|
|
@@ -2,6 +2,20 @@ import { CallbackManagerForLLMRun } from "../callbacks/manager.js";
|
|
|
2
2
|
import { YandexGPTInputs } from "../llms/yandex.js";
|
|
3
3
|
import { BaseMessage, ChatResult } from "../schema/index.js";
|
|
4
4
|
import { BaseChatModel } from "./base.js";
|
|
5
|
+
/**
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* const chat = new ChatYandexGPT({});
|
|
9
|
+
* // The assistant is set to translate English to French.
|
|
10
|
+
* const res = await chat.call([
|
|
11
|
+
* new SystemMessage(
|
|
12
|
+
* "You are a helpful assistant that translates English to French."
|
|
13
|
+
* ),
|
|
14
|
+
* new HumanMessage("I love programming."),
|
|
15
|
+
* ]);
|
|
16
|
+
* console.log(res);
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
5
19
|
export declare class ChatYandexGPT extends BaseChatModel {
|
|
6
20
|
apiKey?: string;
|
|
7
21
|
iamToken?: string;
|
|
@@ -23,6 +23,20 @@ function _parseChatHistory(history) {
|
|
|
23
23
|
}
|
|
24
24
|
return [chatHistory, instruction];
|
|
25
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* const chat = new ChatYandexGPT({});
|
|
30
|
+
* // The assistant is set to translate English to French.
|
|
31
|
+
* const res = await chat.call([
|
|
32
|
+
* new SystemMessage(
|
|
33
|
+
* "You are a helpful assistant that translates English to French."
|
|
34
|
+
* ),
|
|
35
|
+
* new HumanMessage("I love programming."),
|
|
36
|
+
* ]);
|
|
37
|
+
* console.log(res);
|
|
38
|
+
* ```
|
|
39
|
+
*/
|
|
26
40
|
export class ChatYandexGPT extends BaseChatModel {
|
|
27
41
|
constructor(fields) {
|
|
28
42
|
super(fields ?? {});
|
|
@@ -13,6 +13,20 @@ exports.UnknownHandling = {
|
|
|
13
13
|
/**
|
|
14
14
|
* A document loader that loads documents from a directory. It extends the
|
|
15
15
|
* `BaseDocumentLoader` class and implements the `load()` method.
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
*
|
|
19
|
+
* const directoryLoader = new DirectoryLoader(
|
|
20
|
+
* "src/document_loaders/example_data/",
|
|
21
|
+
* {
|
|
22
|
+
* ".pdf": (path: string) => new PDFLoader(path),
|
|
23
|
+
* },
|
|
24
|
+
* );
|
|
25
|
+
*
|
|
26
|
+
* const docs = await directoryLoader.load();
|
|
27
|
+
* console.log({ docs });
|
|
28
|
+
*
|
|
29
|
+
* ```
|
|
16
30
|
*/
|
|
17
31
|
class DirectoryLoader extends base_js_1.BaseDocumentLoader {
|
|
18
32
|
constructor(directoryPath, loaders, recursive = true, unknown = exports.UnknownHandling.Warn) {
|
|
@@ -24,6 +24,20 @@ export interface LoadersMapping {
|
|
|
24
24
|
/**
|
|
25
25
|
* A document loader that loads documents from a directory. It extends the
|
|
26
26
|
* `BaseDocumentLoader` class and implements the `load()` method.
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
*
|
|
30
|
+
* const directoryLoader = new DirectoryLoader(
|
|
31
|
+
* "src/document_loaders/example_data/",
|
|
32
|
+
* {
|
|
33
|
+
* ".pdf": (path: string) => new PDFLoader(path),
|
|
34
|
+
* },
|
|
35
|
+
* );
|
|
36
|
+
*
|
|
37
|
+
* const docs = await directoryLoader.load();
|
|
38
|
+
* console.log({ docs });
|
|
39
|
+
*
|
|
40
|
+
* ```
|
|
27
41
|
*/
|
|
28
42
|
export declare class DirectoryLoader extends BaseDocumentLoader {
|
|
29
43
|
directoryPath: string;
|
|
@@ -10,6 +10,20 @@ export const UnknownHandling = {
|
|
|
10
10
|
/**
|
|
11
11
|
* A document loader that loads documents from a directory. It extends the
|
|
12
12
|
* `BaseDocumentLoader` class and implements the `load()` method.
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
*
|
|
16
|
+
* const directoryLoader = new DirectoryLoader(
|
|
17
|
+
* "src/document_loaders/example_data/",
|
|
18
|
+
* {
|
|
19
|
+
* ".pdf": (path: string) => new PDFLoader(path),
|
|
20
|
+
* },
|
|
21
|
+
* );
|
|
22
|
+
*
|
|
23
|
+
* const docs = await directoryLoader.load();
|
|
24
|
+
* console.log({ docs });
|
|
25
|
+
*
|
|
26
|
+
* ```
|
|
13
27
|
*/
|
|
14
28
|
export class DirectoryLoader extends BaseDocumentLoader {
|
|
15
29
|
constructor(directoryPath, loaders, recursive = true, unknown = UnknownHandling.Warn) {
|
|
@@ -5,6 +5,16 @@ const openai_1 = require("openai");
|
|
|
5
5
|
const document_js_1 = require("../../document.cjs");
|
|
6
6
|
const buffer_js_1 = require("./buffer.cjs");
|
|
7
7
|
const MODEL_NAME = "whisper-1";
|
|
8
|
+
/**
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const loader = new OpenAIWhisperAudio(
|
|
12
|
+
* "./src/document_loaders/example_data/test.mp3",
|
|
13
|
+
* );
|
|
14
|
+
* const docs = await loader.load();
|
|
15
|
+
* console.log(docs);
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
8
18
|
class OpenAIWhisperAudio extends buffer_js_1.BufferLoader {
|
|
9
19
|
constructor(filePathOrBlob, fields) {
|
|
10
20
|
super(filePathOrBlob);
|
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
import { type ClientOptions } from "openai";
|
|
3
3
|
import { Document } from "../../document.js";
|
|
4
4
|
import { BufferLoader } from "./buffer.js";
|
|
5
|
+
/**
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* const loader = new OpenAIWhisperAudio(
|
|
9
|
+
* "./src/document_loaders/example_data/test.mp3",
|
|
10
|
+
* );
|
|
11
|
+
* const docs = await loader.load();
|
|
12
|
+
* console.log(docs);
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
5
15
|
export declare class OpenAIWhisperAudio extends BufferLoader {
|
|
6
16
|
private readonly openAIClient;
|
|
7
17
|
constructor(filePathOrBlob: string | Blob, fields?: {
|
|
@@ -2,6 +2,16 @@ import { OpenAI as OpenAIClient, toFile } from "openai";
|
|
|
2
2
|
import { Document } from "../../document.js";
|
|
3
3
|
import { BufferLoader } from "./buffer.js";
|
|
4
4
|
const MODEL_NAME = "whisper-1";
|
|
5
|
+
/**
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
* const loader = new OpenAIWhisperAudio(
|
|
9
|
+
* "./src/document_loaders/example_data/test.mp3",
|
|
10
|
+
* );
|
|
11
|
+
* const docs = await loader.load();
|
|
12
|
+
* console.log(docs);
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
5
15
|
export class OpenAIWhisperAudio extends BufferLoader {
|
|
6
16
|
constructor(filePathOrBlob, fields) {
|
|
7
17
|
super(filePathOrBlob);
|
|
@@ -7,9 +7,15 @@ const document_js_2 = require("../../util/document.cjs");
|
|
|
7
7
|
/**
|
|
8
8
|
* A class that extends the `BufferLoader` class. It represents a document
|
|
9
9
|
* loader that loads documents from PDF files.
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* const loader = new PDFLoader("path/to/bitcoin.pdf");
|
|
13
|
+
* const docs = await loader.load();
|
|
14
|
+
* console.log({ docs });
|
|
15
|
+
* ```
|
|
10
16
|
*/
|
|
11
17
|
class PDFLoader extends buffer_js_1.BufferLoader {
|
|
12
|
-
constructor(filePathOrBlob, { splitPages = true, pdfjs = PDFLoaderImports } = {}) {
|
|
18
|
+
constructor(filePathOrBlob, { splitPages = true, pdfjs = PDFLoaderImports, parsedItemSeparator = " ", } = {}) {
|
|
13
19
|
super(filePathOrBlob);
|
|
14
20
|
Object.defineProperty(this, "splitPages", {
|
|
15
21
|
enumerable: true,
|
|
@@ -23,8 +29,15 @@ class PDFLoader extends buffer_js_1.BufferLoader {
|
|
|
23
29
|
writable: true,
|
|
24
30
|
value: void 0
|
|
25
31
|
});
|
|
32
|
+
Object.defineProperty(this, "parsedItemSeparator", {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
configurable: true,
|
|
35
|
+
writable: true,
|
|
36
|
+
value: void 0
|
|
37
|
+
});
|
|
26
38
|
this.splitPages = splitPages;
|
|
27
39
|
this.pdfjs = pdfjs;
|
|
40
|
+
this.parsedItemSeparator = parsedItemSeparator;
|
|
28
41
|
}
|
|
29
42
|
/**
|
|
30
43
|
* A method that takes a `raw` buffer and `metadata` as parameters and
|
|
@@ -75,7 +88,7 @@ class PDFLoader extends buffer_js_1.BufferLoader {
|
|
|
75
88
|
lastY = item.transform[5];
|
|
76
89
|
}
|
|
77
90
|
}
|
|
78
|
-
const text = textItems.join(
|
|
91
|
+
const text = textItems.join(this.parsedItemSeparator);
|
|
79
92
|
documents.push(new document_js_1.Document({
|
|
80
93
|
pageContent: text,
|
|
81
94
|
metadata: {
|
|
@@ -5,13 +5,21 @@ import { BufferLoader } from "./buffer.js";
|
|
|
5
5
|
/**
|
|
6
6
|
* A class that extends the `BufferLoader` class. It represents a document
|
|
7
7
|
* loader that loads documents from PDF files.
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const loader = new PDFLoader("path/to/bitcoin.pdf");
|
|
11
|
+
* const docs = await loader.load();
|
|
12
|
+
* console.log({ docs });
|
|
13
|
+
* ```
|
|
8
14
|
*/
|
|
9
15
|
export declare class PDFLoader extends BufferLoader {
|
|
10
16
|
private splitPages;
|
|
11
17
|
private pdfjs;
|
|
12
|
-
|
|
18
|
+
protected parsedItemSeparator: string;
|
|
19
|
+
constructor(filePathOrBlob: string | Blob, { splitPages, pdfjs, parsedItemSeparator, }?: {
|
|
13
20
|
splitPages?: boolean | undefined;
|
|
14
21
|
pdfjs?: typeof PDFLoaderImports | undefined;
|
|
22
|
+
parsedItemSeparator?: string | undefined;
|
|
15
23
|
});
|
|
16
24
|
/**
|
|
17
25
|
* A method that takes a `raw` buffer and `metadata` as parameters and
|
|
@@ -4,9 +4,15 @@ import { formatDocumentsAsString } from "../../util/document.js";
|
|
|
4
4
|
/**
|
|
5
5
|
* A class that extends the `BufferLoader` class. It represents a document
|
|
6
6
|
* loader that loads documents from PDF files.
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* const loader = new PDFLoader("path/to/bitcoin.pdf");
|
|
10
|
+
* const docs = await loader.load();
|
|
11
|
+
* console.log({ docs });
|
|
12
|
+
* ```
|
|
7
13
|
*/
|
|
8
14
|
export class PDFLoader extends BufferLoader {
|
|
9
|
-
constructor(filePathOrBlob, { splitPages = true, pdfjs = PDFLoaderImports } = {}) {
|
|
15
|
+
constructor(filePathOrBlob, { splitPages = true, pdfjs = PDFLoaderImports, parsedItemSeparator = " ", } = {}) {
|
|
10
16
|
super(filePathOrBlob);
|
|
11
17
|
Object.defineProperty(this, "splitPages", {
|
|
12
18
|
enumerable: true,
|
|
@@ -20,8 +26,15 @@ export class PDFLoader extends BufferLoader {
|
|
|
20
26
|
writable: true,
|
|
21
27
|
value: void 0
|
|
22
28
|
});
|
|
29
|
+
Object.defineProperty(this, "parsedItemSeparator", {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
configurable: true,
|
|
32
|
+
writable: true,
|
|
33
|
+
value: void 0
|
|
34
|
+
});
|
|
23
35
|
this.splitPages = splitPages;
|
|
24
36
|
this.pdfjs = pdfjs;
|
|
37
|
+
this.parsedItemSeparator = parsedItemSeparator;
|
|
25
38
|
}
|
|
26
39
|
/**
|
|
27
40
|
* A method that takes a `raw` buffer and `metadata` as parameters and
|
|
@@ -72,7 +85,7 @@ export class PDFLoader extends BufferLoader {
|
|
|
72
85
|
lastY = item.transform[5];
|
|
73
86
|
}
|
|
74
87
|
}
|
|
75
|
-
const text = textItems.join(
|
|
88
|
+
const text = textItems.join(this.parsedItemSeparator);
|
|
76
89
|
documents.push(new Document({
|
|
77
90
|
pageContent: text,
|
|
78
91
|
metadata: {
|
|
@@ -9,6 +9,12 @@ const text_js_1 = require("./text.cjs");
|
|
|
9
9
|
* path to the SRT file or a `Blob` object. The `parse()` method is
|
|
10
10
|
* implemented to parse the SRT file and extract the text content of each
|
|
11
11
|
* subtitle.
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const loader = new SRTLoader("path/to/file.srt");
|
|
15
|
+
* const docs = await loader.load();
|
|
16
|
+
* console.log({ docs });
|
|
17
|
+
* ```
|
|
12
18
|
*/
|
|
13
19
|
class SRTLoader extends text_js_1.TextLoader {
|
|
14
20
|
constructor(filePathOrBlob) {
|
|
@@ -6,6 +6,12 @@ import { TextLoader } from "./text.js";
|
|
|
6
6
|
* path to the SRT file or a `Blob` object. The `parse()` method is
|
|
7
7
|
* implemented to parse the SRT file and extract the text content of each
|
|
8
8
|
* subtitle.
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const loader = new SRTLoader("path/to/file.srt");
|
|
12
|
+
* const docs = await loader.load();
|
|
13
|
+
* console.log({ docs });
|
|
14
|
+
* ```
|
|
9
15
|
*/
|
|
10
16
|
export declare class SRTLoader extends TextLoader {
|
|
11
17
|
constructor(filePathOrBlob: string | Blob);
|
|
@@ -6,6 +6,12 @@ import { TextLoader } from "./text.js";
|
|
|
6
6
|
* path to the SRT file or a `Blob` object. The `parse()` method is
|
|
7
7
|
* implemented to parse the SRT file and extract the text content of each
|
|
8
8
|
* subtitle.
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const loader = new SRTLoader("path/to/file.srt");
|
|
12
|
+
* const docs = await loader.load();
|
|
13
|
+
* console.log({ docs });
|
|
14
|
+
* ```
|
|
9
15
|
*/
|
|
10
16
|
export class SRTLoader extends TextLoader {
|
|
11
17
|
constructor(filePathOrBlob) {
|
|
@@ -11,6 +11,11 @@ const base_js_1 = require("../base.cjs");
|
|
|
11
11
|
* using the `parse()` method, and create a `Document` instance for each
|
|
12
12
|
* parsed page. The metadata includes the source of the text (file path or
|
|
13
13
|
* blob) and, if there are multiple pages, the line number of each page.
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* const loader = new TextLoader("src/document_loaders/example_data/example.txt");
|
|
17
|
+
* const docs = await loader.load();
|
|
18
|
+
* ```
|
|
14
19
|
*/
|
|
15
20
|
class TextLoader extends base_js_1.BaseDocumentLoader {
|
|
16
21
|
constructor(filePathOrBlob) {
|
|
@@ -9,6 +9,11 @@ import { BaseDocumentLoader } from "../base.js";
|
|
|
9
9
|
* using the `parse()` method, and create a `Document` instance for each
|
|
10
10
|
* parsed page. The metadata includes the source of the text (file path or
|
|
11
11
|
* blob) and, if there are multiple pages, the line number of each page.
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const loader = new TextLoader("src/document_loaders/example_data/example.txt");
|
|
15
|
+
* const docs = await loader.load();
|
|
16
|
+
* ```
|
|
12
17
|
*/
|
|
13
18
|
export declare class TextLoader extends BaseDocumentLoader {
|
|
14
19
|
filePathOrBlob: string | Blob;
|
|
@@ -8,6 +8,11 @@ import { BaseDocumentLoader } from "../base.js";
|
|
|
8
8
|
* using the `parse()` method, and create a `Document` instance for each
|
|
9
9
|
* parsed page. The metadata includes the source of the text (file path or
|
|
10
10
|
* blob) and, if there are multiple pages, the line number of each page.
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const loader = new TextLoader("src/document_loaders/example_data/example.txt");
|
|
14
|
+
* const docs = await loader.load();
|
|
15
|
+
* ```
|
|
11
16
|
*/
|
|
12
17
|
export class TextLoader extends BaseDocumentLoader {
|
|
13
18
|
constructor(filePathOrBlob) {
|
|
@@ -229,6 +229,13 @@ exports.UnstructuredLoader = UnstructuredLoader;
|
|
|
229
229
|
* using the UnstructuredLoader. It creates a UnstructuredLoader instance
|
|
230
230
|
* for each supported file type and passes it to the DirectoryLoader
|
|
231
231
|
* constructor.
|
|
232
|
+
* @example
|
|
233
|
+
* ```typescript
|
|
234
|
+
* const loader = new UnstructuredDirectoryLoader("path/to/directory", {
|
|
235
|
+
* apiKey: "MY_API_KEY",
|
|
236
|
+
* });
|
|
237
|
+
* const docs = await loader.load();
|
|
238
|
+
* ```
|
|
232
239
|
*/
|
|
233
240
|
class UnstructuredDirectoryLoader extends directory_js_1.DirectoryLoader {
|
|
234
241
|
constructor(directoryPathOrLegacyApiUrl, optionsOrLegacyDirectoryPath, legacyOptionRecursive = true, legacyOptionUnknown = directory_js_1.UnknownHandling.Warn) {
|
|
@@ -94,6 +94,13 @@ export declare class UnstructuredLoader extends BaseDocumentLoader {
|
|
|
94
94
|
* using the UnstructuredLoader. It creates a UnstructuredLoader instance
|
|
95
95
|
* for each supported file type and passes it to the DirectoryLoader
|
|
96
96
|
* constructor.
|
|
97
|
+
* @example
|
|
98
|
+
* ```typescript
|
|
99
|
+
* const loader = new UnstructuredDirectoryLoader("path/to/directory", {
|
|
100
|
+
* apiKey: "MY_API_KEY",
|
|
101
|
+
* });
|
|
102
|
+
* const docs = await loader.load();
|
|
103
|
+
* ```
|
|
97
104
|
*/
|
|
98
105
|
export declare class UnstructuredDirectoryLoader extends DirectoryLoader {
|
|
99
106
|
constructor(directoryPathOrLegacyApiUrl: string, optionsOrLegacyDirectoryPath: UnstructuredDirectoryLoaderOptions | string, legacyOptionRecursive?: boolean, legacyOptionUnknown?: UnknownHandling);
|
|
@@ -224,6 +224,13 @@ export class UnstructuredLoader extends BaseDocumentLoader {
|
|
|
224
224
|
* using the UnstructuredLoader. It creates a UnstructuredLoader instance
|
|
225
225
|
* for each supported file type and passes it to the DirectoryLoader
|
|
226
226
|
* constructor.
|
|
227
|
+
* @example
|
|
228
|
+
* ```typescript
|
|
229
|
+
* const loader = new UnstructuredDirectoryLoader("path/to/directory", {
|
|
230
|
+
* apiKey: "MY_API_KEY",
|
|
231
|
+
* });
|
|
232
|
+
* const docs = await loader.load();
|
|
233
|
+
* ```
|
|
227
234
|
*/
|
|
228
235
|
export class UnstructuredDirectoryLoader extends DirectoryLoader {
|
|
229
236
|
constructor(directoryPathOrLegacyApiUrl, optionsOrLegacyDirectoryPath, legacyOptionRecursive = true, legacyOptionUnknown = UnknownHandling.Warn) {
|
|
@@ -10,6 +10,27 @@ const env_js_1 = require("../../util/env.cjs");
|
|
|
10
10
|
* A class that extends the BaseDocumentLoader and implements the
|
|
11
11
|
* DocumentLoader interface. It represents a document loader that loads
|
|
12
12
|
* documents from an Apify dataset.
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const loader = new ApifyDatasetLoader("your-dataset-id", {
|
|
16
|
+
* datasetMappingFunction: (item) =>
|
|
17
|
+
* new Document({
|
|
18
|
+
* pageContent: item.text || "",
|
|
19
|
+
* metadata: { source: item.url },
|
|
20
|
+
* }),
|
|
21
|
+
* clientOptions: {
|
|
22
|
+
* token: "your-apify-token",
|
|
23
|
+
* },
|
|
24
|
+
* });
|
|
25
|
+
*
|
|
26
|
+
* const docs = await loader.load();
|
|
27
|
+
*
|
|
28
|
+
* const chain = new RetrievalQAChain();
|
|
29
|
+
* const res = await chain.invoke({ query: "What is LangChain?" });
|
|
30
|
+
*
|
|
31
|
+
* console.log(res.text);
|
|
32
|
+
* console.log(res.sourceDocuments.map((d) => d.metadata.source));
|
|
33
|
+
* ```
|
|
13
34
|
*/
|
|
14
35
|
class ApifyDatasetLoader extends base_js_1.BaseDocumentLoader {
|
|
15
36
|
constructor(datasetId, config) {
|
|
@@ -55,8 +76,11 @@ class ApifyDatasetLoader extends base_js_1.BaseDocumentLoader {
|
|
|
55
76
|
* @returns An array of Document instances.
|
|
56
77
|
*/
|
|
57
78
|
async load() {
|
|
58
|
-
const
|
|
59
|
-
|
|
79
|
+
const dataset = await this.apifyClient
|
|
80
|
+
.dataset(this.datasetId)
|
|
81
|
+
.listItems({ clean: true });
|
|
82
|
+
const documentList = await Promise.all(dataset.items.map((item) => this.caller.call(async () => this.datasetMappingFunction(item))));
|
|
83
|
+
return documentList.flat();
|
|
60
84
|
}
|
|
61
85
|
/**
|
|
62
86
|
* Create an ApifyDatasetLoader by calling an Actor on the Apify platform and waiting for its results to be ready.
|
|
@@ -5,8 +5,11 @@ import { Document } from "../../document.js";
|
|
|
5
5
|
/**
|
|
6
6
|
* A type that represents a function that takes a single object (an Apify
|
|
7
7
|
* dataset item) and converts it to an instance of the Document class.
|
|
8
|
+
*
|
|
9
|
+
* Change function signature to only be asynchronous for simplicity in v0.1.0
|
|
10
|
+
* https://github.com/langchain-ai/langchainjs/pull/3262
|
|
8
11
|
*/
|
|
9
|
-
export type ApifyDatasetMappingFunction<Metadata extends Record<string, any>> = (item: Record<string | number, unknown>) => Document<Metadata> | Promise<Document<Metadata
|
|
12
|
+
export type ApifyDatasetMappingFunction<Metadata extends Record<string, any>> = (item: Record<string | number, unknown>) => Document<Metadata> | Array<Document<Metadata>> | Promise<Document<Metadata> | Array<Document<Metadata>>>;
|
|
10
13
|
export interface ApifyDatasetLoaderConfig<Metadata extends Record<string, any>> extends AsyncCallerParams {
|
|
11
14
|
datasetMappingFunction: ApifyDatasetMappingFunction<Metadata>;
|
|
12
15
|
clientOptions?: ApifyClientOptions;
|
|
@@ -15,6 +18,27 @@ export interface ApifyDatasetLoaderConfig<Metadata extends Record<string, any>>
|
|
|
15
18
|
* A class that extends the BaseDocumentLoader and implements the
|
|
16
19
|
* DocumentLoader interface. It represents a document loader that loads
|
|
17
20
|
* documents from an Apify dataset.
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* const loader = new ApifyDatasetLoader("your-dataset-id", {
|
|
24
|
+
* datasetMappingFunction: (item) =>
|
|
25
|
+
* new Document({
|
|
26
|
+
* pageContent: item.text || "",
|
|
27
|
+
* metadata: { source: item.url },
|
|
28
|
+
* }),
|
|
29
|
+
* clientOptions: {
|
|
30
|
+
* token: "your-apify-token",
|
|
31
|
+
* },
|
|
32
|
+
* });
|
|
33
|
+
*
|
|
34
|
+
* const docs = await loader.load();
|
|
35
|
+
*
|
|
36
|
+
* const chain = new RetrievalQAChain();
|
|
37
|
+
* const res = await chain.invoke({ query: "What is LangChain?" });
|
|
38
|
+
*
|
|
39
|
+
* console.log(res.text);
|
|
40
|
+
* console.log(res.sourceDocuments.map((d) => d.metadata.source));
|
|
41
|
+
* ```
|
|
18
42
|
*/
|
|
19
43
|
export declare class ApifyDatasetLoader<Metadata extends Record<string, any>> extends BaseDocumentLoader implements DocumentLoader {
|
|
20
44
|
protected apifyClient: ApifyClient;
|