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
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { BaseCache, Generation } from "../schema/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* A cache that uses the local filesystem as the backing store.
|
|
4
|
+
* This is useful for local development and testing. But it is not recommended for production use.
|
|
5
|
+
*/
|
|
6
|
+
export declare class LocalFileCache extends BaseCache {
|
|
7
|
+
private cacheDir;
|
|
8
|
+
private constructor();
|
|
9
|
+
/**
|
|
10
|
+
* Create a new cache backed by the local filesystem.
|
|
11
|
+
* It ensures that the cache directory exists before returning.
|
|
12
|
+
* @param cacheDir
|
|
13
|
+
*/
|
|
14
|
+
static create(cacheDir?: string): Promise<LocalFileCache>;
|
|
15
|
+
/**
|
|
16
|
+
* Retrieves data from the cache. It constructs a cache key from the given
|
|
17
|
+
* `prompt` and `llmKey`, and retrieves the corresponding value from the
|
|
18
|
+
* cache files.
|
|
19
|
+
* @param prompt The prompt used to construct the cache key.
|
|
20
|
+
* @param llmKey The LLM key used to construct the cache key.
|
|
21
|
+
* @returns An array of Generations if found, null otherwise.
|
|
22
|
+
*/
|
|
23
|
+
lookup(prompt: string, llmKey: string): Promise<any>;
|
|
24
|
+
/**
|
|
25
|
+
* Updates the cache with new data. It constructs a cache key from the
|
|
26
|
+
* given `prompt` and `llmKey`, and stores the `value` in a specific
|
|
27
|
+
* file in the cache directory.
|
|
28
|
+
* @param prompt The prompt used to construct the cache key.
|
|
29
|
+
* @param llmKey The LLM key used to construct the cache key.
|
|
30
|
+
* @param generations The value to be stored in the cache.
|
|
31
|
+
*/
|
|
32
|
+
update(prompt: string, llmKey: string, generations: Generation[]): Promise<void>;
|
|
33
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import fs from "node:fs/promises";
|
|
3
|
+
import { BaseCache } from "../schema/index.js";
|
|
4
|
+
import { getCacheKey, serializeGeneration, deserializeStoredGeneration, } from "./base.js";
|
|
5
|
+
/**
|
|
6
|
+
* A cache that uses the local filesystem as the backing store.
|
|
7
|
+
* This is useful for local development and testing. But it is not recommended for production use.
|
|
8
|
+
*/
|
|
9
|
+
export class LocalFileCache extends BaseCache {
|
|
10
|
+
constructor(cacheDir) {
|
|
11
|
+
super();
|
|
12
|
+
Object.defineProperty(this, "cacheDir", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
configurable: true,
|
|
15
|
+
writable: true,
|
|
16
|
+
value: void 0
|
|
17
|
+
});
|
|
18
|
+
this.cacheDir = cacheDir;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Create a new cache backed by the local filesystem.
|
|
22
|
+
* It ensures that the cache directory exists before returning.
|
|
23
|
+
* @param cacheDir
|
|
24
|
+
*/
|
|
25
|
+
static async create(cacheDir) {
|
|
26
|
+
if (!cacheDir) {
|
|
27
|
+
// eslint-disable-next-line no-param-reassign
|
|
28
|
+
cacheDir = await fs.mkdtemp("langchain-cache-");
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
// ensure the cache directory exists
|
|
32
|
+
await fs.mkdir(cacheDir, { recursive: true });
|
|
33
|
+
}
|
|
34
|
+
return new LocalFileCache(cacheDir);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Retrieves data from the cache. It constructs a cache key from the given
|
|
38
|
+
* `prompt` and `llmKey`, and retrieves the corresponding value from the
|
|
39
|
+
* cache files.
|
|
40
|
+
* @param prompt The prompt used to construct the cache key.
|
|
41
|
+
* @param llmKey The LLM key used to construct the cache key.
|
|
42
|
+
* @returns An array of Generations if found, null otherwise.
|
|
43
|
+
*/
|
|
44
|
+
async lookup(prompt, llmKey) {
|
|
45
|
+
const key = `${getCacheKey(prompt, llmKey)}.json`;
|
|
46
|
+
try {
|
|
47
|
+
const content = await fs.readFile(path.join(this.cacheDir, key));
|
|
48
|
+
return JSON.parse(content.toString()).map(deserializeStoredGeneration);
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Updates the cache with new data. It constructs a cache key from the
|
|
56
|
+
* given `prompt` and `llmKey`, and stores the `value` in a specific
|
|
57
|
+
* file in the cache directory.
|
|
58
|
+
* @param prompt The prompt used to construct the cache key.
|
|
59
|
+
* @param llmKey The LLM key used to construct the cache key.
|
|
60
|
+
* @param generations The value to be stored in the cache.
|
|
61
|
+
*/
|
|
62
|
+
async update(prompt, llmKey, generations) {
|
|
63
|
+
const key = `${getCacheKey(prompt, llmKey)}.json`;
|
|
64
|
+
await fs.writeFile(path.join(this.cacheDir, key), JSON.stringify(generations.map(serializeGeneration)));
|
|
65
|
+
}
|
|
66
|
+
}
|
package/dist/cache/ioredis.cjs
CHANGED
|
@@ -5,6 +5,19 @@ const index_js_1 = require("../schema/index.cjs");
|
|
|
5
5
|
const base_js_1 = require("./base.cjs");
|
|
6
6
|
/**
|
|
7
7
|
* Cache LLM results using Redis.
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const model = new ChatOpenAI({
|
|
11
|
+
* cache: new RedisCache(new Redis(), { ttl: 60 }),
|
|
12
|
+
* });
|
|
13
|
+
*
|
|
14
|
+
* // Invoke the model with a prompt
|
|
15
|
+
* const response = await model.invoke("Do something random!");
|
|
16
|
+
* console.log(response);
|
|
17
|
+
*
|
|
18
|
+
* // Remember to disconnect the Redis client when done
|
|
19
|
+
* await redisClient.disconnect();
|
|
20
|
+
* ```
|
|
8
21
|
*/
|
|
9
22
|
class RedisCache extends index_js_1.BaseCache {
|
|
10
23
|
constructor(redisClient, config) {
|
package/dist/cache/ioredis.d.ts
CHANGED
|
@@ -2,6 +2,19 @@ import { Redis } from "ioredis";
|
|
|
2
2
|
import { BaseCache, Generation } from "../schema/index.js";
|
|
3
3
|
/**
|
|
4
4
|
* Cache LLM results using Redis.
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* const model = new ChatOpenAI({
|
|
8
|
+
* cache: new RedisCache(new Redis(), { ttl: 60 }),
|
|
9
|
+
* });
|
|
10
|
+
*
|
|
11
|
+
* // Invoke the model with a prompt
|
|
12
|
+
* const response = await model.invoke("Do something random!");
|
|
13
|
+
* console.log(response);
|
|
14
|
+
*
|
|
15
|
+
* // Remember to disconnect the Redis client when done
|
|
16
|
+
* await redisClient.disconnect();
|
|
17
|
+
* ```
|
|
5
18
|
*/
|
|
6
19
|
export declare class RedisCache extends BaseCache {
|
|
7
20
|
protected redisClient: Redis;
|
package/dist/cache/ioredis.js
CHANGED
|
@@ -2,6 +2,19 @@ import { BaseCache } from "../schema/index.js";
|
|
|
2
2
|
import { serializeGeneration, deserializeStoredGeneration, getCacheKey, } from "./base.js";
|
|
3
3
|
/**
|
|
4
4
|
* Cache LLM results using Redis.
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* const model = new ChatOpenAI({
|
|
8
|
+
* cache: new RedisCache(new Redis(), { ttl: 60 }),
|
|
9
|
+
* });
|
|
10
|
+
*
|
|
11
|
+
* // Invoke the model with a prompt
|
|
12
|
+
* const response = await model.invoke("Do something random!");
|
|
13
|
+
* console.log(response);
|
|
14
|
+
*
|
|
15
|
+
* // Remember to disconnect the Redis client when done
|
|
16
|
+
* await redisClient.disconnect();
|
|
17
|
+
* ```
|
|
5
18
|
*/
|
|
6
19
|
export class RedisCache extends BaseCache {
|
|
7
20
|
constructor(redisClient, config) {
|
package/dist/cache/momento.cjs
CHANGED
|
@@ -9,6 +9,25 @@ const momento_js_1 = require("../util/momento.cjs");
|
|
|
9
9
|
/**
|
|
10
10
|
* A cache that uses Momento as the backing store.
|
|
11
11
|
* See https://gomomento.com.
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const cache = new MomentoCache({
|
|
15
|
+
* client: new CacheClient({
|
|
16
|
+
* configuration: Configurations.Laptop.v1(),
|
|
17
|
+
* credentialProvider: CredentialProvider.fromEnvironmentVariable({
|
|
18
|
+
* environmentVariableName: "MOMENTO_API_KEY",
|
|
19
|
+
* }),
|
|
20
|
+
* defaultTtlSeconds: 60 * 60 * 24, // Cache TTL set to 24 hours.
|
|
21
|
+
* }),
|
|
22
|
+
* cacheName: "langchain",
|
|
23
|
+
* });
|
|
24
|
+
* // Initialize the OpenAI model with Momento cache for caching responses
|
|
25
|
+
* const model = new ChatOpenAI({
|
|
26
|
+
* cache,
|
|
27
|
+
* });
|
|
28
|
+
* await model.invoke("How are you today?");
|
|
29
|
+
* const cachedValues = await cache.lookup("How are you today?", "llmKey");
|
|
30
|
+
* ```
|
|
12
31
|
*/
|
|
13
32
|
class MomentoCache extends index_js_1.BaseCache {
|
|
14
33
|
constructor(props) {
|
package/dist/cache/momento.d.ts
CHANGED
|
@@ -27,6 +27,25 @@ export interface MomentoCacheProps {
|
|
|
27
27
|
/**
|
|
28
28
|
* A cache that uses Momento as the backing store.
|
|
29
29
|
* See https://gomomento.com.
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* const cache = new MomentoCache({
|
|
33
|
+
* client: new CacheClient({
|
|
34
|
+
* configuration: Configurations.Laptop.v1(),
|
|
35
|
+
* credentialProvider: CredentialProvider.fromEnvironmentVariable({
|
|
36
|
+
* environmentVariableName: "MOMENTO_API_KEY",
|
|
37
|
+
* }),
|
|
38
|
+
* defaultTtlSeconds: 60 * 60 * 24, // Cache TTL set to 24 hours.
|
|
39
|
+
* }),
|
|
40
|
+
* cacheName: "langchain",
|
|
41
|
+
* });
|
|
42
|
+
* // Initialize the OpenAI model with Momento cache for caching responses
|
|
43
|
+
* const model = new ChatOpenAI({
|
|
44
|
+
* cache,
|
|
45
|
+
* });
|
|
46
|
+
* await model.invoke("How are you today?");
|
|
47
|
+
* const cachedValues = await cache.lookup("How are you today?", "llmKey");
|
|
48
|
+
* ```
|
|
30
49
|
*/
|
|
31
50
|
export declare class MomentoCache extends BaseCache {
|
|
32
51
|
private client;
|
package/dist/cache/momento.js
CHANGED
|
@@ -6,6 +6,25 @@ import { ensureCacheExists } from "../util/momento.js";
|
|
|
6
6
|
/**
|
|
7
7
|
* A cache that uses Momento as the backing store.
|
|
8
8
|
* See https://gomomento.com.
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const cache = new MomentoCache({
|
|
12
|
+
* client: new CacheClient({
|
|
13
|
+
* configuration: Configurations.Laptop.v1(),
|
|
14
|
+
* credentialProvider: CredentialProvider.fromEnvironmentVariable({
|
|
15
|
+
* environmentVariableName: "MOMENTO_API_KEY",
|
|
16
|
+
* }),
|
|
17
|
+
* defaultTtlSeconds: 60 * 60 * 24, // Cache TTL set to 24 hours.
|
|
18
|
+
* }),
|
|
19
|
+
* cacheName: "langchain",
|
|
20
|
+
* });
|
|
21
|
+
* // Initialize the OpenAI model with Momento cache for caching responses
|
|
22
|
+
* const model = new ChatOpenAI({
|
|
23
|
+
* cache,
|
|
24
|
+
* });
|
|
25
|
+
* await model.invoke("How are you today?");
|
|
26
|
+
* const cachedValues = await cache.lookup("How are you today?", "llmKey");
|
|
27
|
+
* ```
|
|
9
28
|
*/
|
|
10
29
|
export class MomentoCache extends BaseCache {
|
|
11
30
|
constructor(props) {
|
package/dist/cache/redis.cjs
CHANGED
|
@@ -7,6 +7,16 @@ const base_js_1 = require("./base.cjs");
|
|
|
7
7
|
* Represents a specific implementation of a caching mechanism using Redis
|
|
8
8
|
* as the underlying storage system. It extends the `BaseCache` class and
|
|
9
9
|
* overrides its methods to provide the Redis-specific logic.
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* const model = new ChatOpenAI({
|
|
13
|
+
* cache: new RedisCache(new Redis(), { ttl: 60 }),
|
|
14
|
+
* });
|
|
15
|
+
*
|
|
16
|
+
* // Invoke the model to perform an action
|
|
17
|
+
* const response = await model.invoke("Do something random!");
|
|
18
|
+
* console.log(response);
|
|
19
|
+
* ```
|
|
10
20
|
*/
|
|
11
21
|
class RedisCache extends index_js_1.BaseCache {
|
|
12
22
|
constructor(redisClient) {
|
package/dist/cache/redis.d.ts
CHANGED
|
@@ -9,6 +9,16 @@ type RedisClientType = ReturnType<typeof createClient> | ReturnType<typeof creat
|
|
|
9
9
|
* Represents a specific implementation of a caching mechanism using Redis
|
|
10
10
|
* as the underlying storage system. It extends the `BaseCache` class and
|
|
11
11
|
* overrides its methods to provide the Redis-specific logic.
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* const model = new ChatOpenAI({
|
|
15
|
+
* cache: new RedisCache(new Redis(), { ttl: 60 }),
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* // Invoke the model to perform an action
|
|
19
|
+
* const response = await model.invoke("Do something random!");
|
|
20
|
+
* console.log(response);
|
|
21
|
+
* ```
|
|
12
22
|
*/
|
|
13
23
|
export declare class RedisCache extends BaseCache {
|
|
14
24
|
private redisClient;
|
package/dist/cache/redis.js
CHANGED
|
@@ -4,6 +4,16 @@ import { deserializeStoredGeneration, getCacheKey, serializeGeneration, } from "
|
|
|
4
4
|
* Represents a specific implementation of a caching mechanism using Redis
|
|
5
5
|
* as the underlying storage system. It extends the `BaseCache` class and
|
|
6
6
|
* overrides its methods to provide the Redis-specific logic.
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* const model = new ChatOpenAI({
|
|
10
|
+
* cache: new RedisCache(new Redis(), { ttl: 60 }),
|
|
11
|
+
* });
|
|
12
|
+
*
|
|
13
|
+
* // Invoke the model to perform an action
|
|
14
|
+
* const response = await model.invoke("Do something random!");
|
|
15
|
+
* console.log(response);
|
|
16
|
+
* ```
|
|
7
17
|
*/
|
|
8
18
|
export class RedisCache extends BaseCache {
|
|
9
19
|
constructor(redisClient) {
|
|
@@ -7,6 +7,21 @@ const base_js_1 = require("./base.cjs");
|
|
|
7
7
|
/**
|
|
8
8
|
* A cache that uses Upstash as the backing store.
|
|
9
9
|
* See https://docs.upstash.com/redis.
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* const cache = new UpstashRedisCache({
|
|
13
|
+
* config: {
|
|
14
|
+
* url: "UPSTASH_REDIS_REST_URL",
|
|
15
|
+
* token: "UPSTASH_REDIS_REST_TOKEN",
|
|
16
|
+
* },
|
|
17
|
+
* });
|
|
18
|
+
* // Initialize the OpenAI model with Upstash Redis cache for caching responses
|
|
19
|
+
* const model = new ChatOpenAI({
|
|
20
|
+
* cache,
|
|
21
|
+
* });
|
|
22
|
+
* await model.invoke("How are you today?");
|
|
23
|
+
* const cachedValues = await cache.lookup("How are you today?", "llmKey");
|
|
24
|
+
* ```
|
|
10
25
|
*/
|
|
11
26
|
class UpstashRedisCache extends index_js_1.BaseCache {
|
|
12
27
|
constructor(props) {
|
|
@@ -13,6 +13,21 @@ export type UpstashRedisCacheProps = {
|
|
|
13
13
|
/**
|
|
14
14
|
* A cache that uses Upstash as the backing store.
|
|
15
15
|
* See https://docs.upstash.com/redis.
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const cache = new UpstashRedisCache({
|
|
19
|
+
* config: {
|
|
20
|
+
* url: "UPSTASH_REDIS_REST_URL",
|
|
21
|
+
* token: "UPSTASH_REDIS_REST_TOKEN",
|
|
22
|
+
* },
|
|
23
|
+
* });
|
|
24
|
+
* // Initialize the OpenAI model with Upstash Redis cache for caching responses
|
|
25
|
+
* const model = new ChatOpenAI({
|
|
26
|
+
* cache,
|
|
27
|
+
* });
|
|
28
|
+
* await model.invoke("How are you today?");
|
|
29
|
+
* const cachedValues = await cache.lookup("How are you today?", "llmKey");
|
|
30
|
+
* ```
|
|
16
31
|
*/
|
|
17
32
|
export declare class UpstashRedisCache extends BaseCache {
|
|
18
33
|
private redisClient;
|
|
@@ -4,6 +4,21 @@ import { deserializeStoredGeneration, getCacheKey, serializeGeneration, } from "
|
|
|
4
4
|
/**
|
|
5
5
|
* A cache that uses Upstash as the backing store.
|
|
6
6
|
* See https://docs.upstash.com/redis.
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* const cache = new UpstashRedisCache({
|
|
10
|
+
* config: {
|
|
11
|
+
* url: "UPSTASH_REDIS_REST_URL",
|
|
12
|
+
* token: "UPSTASH_REDIS_REST_TOKEN",
|
|
13
|
+
* },
|
|
14
|
+
* });
|
|
15
|
+
* // Initialize the OpenAI model with Upstash Redis cache for caching responses
|
|
16
|
+
* const model = new ChatOpenAI({
|
|
17
|
+
* cache,
|
|
18
|
+
* });
|
|
19
|
+
* await model.invoke("How are you today?");
|
|
20
|
+
* const cachedValues = await cache.lookup("How are you today?", "llmKey");
|
|
21
|
+
* ```
|
|
7
22
|
*/
|
|
8
23
|
export class UpstashRedisCache extends BaseCache {
|
|
9
24
|
constructor(props) {
|
|
@@ -31,6 +31,16 @@ const { color } = ansi_styles_1.default;
|
|
|
31
31
|
* A tracer that logs all events to the console. It extends from the
|
|
32
32
|
* `BaseTracer` class and overrides its methods to provide custom logging
|
|
33
33
|
* functionality.
|
|
34
|
+
* @example
|
|
35
|
+
* ```typescript
|
|
36
|
+
*
|
|
37
|
+
* const llm = new ChatAnthropic({
|
|
38
|
+
* temperature: 0,
|
|
39
|
+
* tags: ["example", "callbacks", "constructor"],
|
|
40
|
+
* callbacks: [new ConsoleCallbackHandler()],
|
|
41
|
+
* });
|
|
42
|
+
*
|
|
43
|
+
* ```
|
|
34
44
|
*/
|
|
35
45
|
class ConsoleCallbackHandler extends tracer_js_1.BaseTracer {
|
|
36
46
|
constructor() {
|
|
@@ -3,6 +3,16 @@ import { BaseTracer, Run } from "./tracer.js";
|
|
|
3
3
|
* A tracer that logs all events to the console. It extends from the
|
|
4
4
|
* `BaseTracer` class and overrides its methods to provide custom logging
|
|
5
5
|
* functionality.
|
|
6
|
+
* @example
|
|
7
|
+
* ```typescript
|
|
8
|
+
*
|
|
9
|
+
* const llm = new ChatAnthropic({
|
|
10
|
+
* temperature: 0,
|
|
11
|
+
* tags: ["example", "callbacks", "constructor"],
|
|
12
|
+
* callbacks: [new ConsoleCallbackHandler()],
|
|
13
|
+
* });
|
|
14
|
+
*
|
|
15
|
+
* ```
|
|
6
16
|
*/
|
|
7
17
|
export declare class ConsoleCallbackHandler extends BaseTracer {
|
|
8
18
|
name: "console_callback_handler";
|
|
@@ -25,6 +25,16 @@ const { color } = styles;
|
|
|
25
25
|
* A tracer that logs all events to the console. It extends from the
|
|
26
26
|
* `BaseTracer` class and overrides its methods to provide custom logging
|
|
27
27
|
* functionality.
|
|
28
|
+
* @example
|
|
29
|
+
* ```typescript
|
|
30
|
+
*
|
|
31
|
+
* const llm = new ChatAnthropic({
|
|
32
|
+
* temperature: 0,
|
|
33
|
+
* tags: ["example", "callbacks", "constructor"],
|
|
34
|
+
* callbacks: [new ConsoleCallbackHandler()],
|
|
35
|
+
* });
|
|
36
|
+
*
|
|
37
|
+
* ```
|
|
28
38
|
*/
|
|
29
39
|
export class ConsoleCallbackHandler extends BaseTracer {
|
|
30
40
|
constructor() {
|
|
@@ -275,6 +275,24 @@ class CallbackManagerForToolRun extends BaseRunManager {
|
|
|
275
275
|
}
|
|
276
276
|
}
|
|
277
277
|
exports.CallbackManagerForToolRun = CallbackManagerForToolRun;
|
|
278
|
+
/**
|
|
279
|
+
* @example
|
|
280
|
+
* ```typescript
|
|
281
|
+
* const prompt = PromptTemplate.fromTemplate("What is the answer to {question}?");
|
|
282
|
+
*
|
|
283
|
+
* // Example of using LLMChain with OpenAI and a simple prompt
|
|
284
|
+
* const chain = new LLMChain({
|
|
285
|
+
* llm: new ChatOpenAI({ temperature: 0.9 }),
|
|
286
|
+
* prompt,
|
|
287
|
+
* });
|
|
288
|
+
*
|
|
289
|
+
* // Running the chain with a single question
|
|
290
|
+
* const result = await chain.call({
|
|
291
|
+
* question: "What is the airspeed velocity of an unladen swallow?",
|
|
292
|
+
* });
|
|
293
|
+
* console.log("The answer is:", result);
|
|
294
|
+
* ```
|
|
295
|
+
*/
|
|
278
296
|
class CallbackManager extends BaseCallbackManager {
|
|
279
297
|
constructor(parentRunId) {
|
|
280
298
|
super();
|
|
@@ -552,6 +570,37 @@ function ensureHandler(handler) {
|
|
|
552
570
|
}
|
|
553
571
|
return base_js_1.BaseCallbackHandler.fromMethods(handler);
|
|
554
572
|
}
|
|
573
|
+
/**
|
|
574
|
+
* @example
|
|
575
|
+
* ```typescript
|
|
576
|
+
* const prompt = PromptTemplate.fromTemplate(`What is the answer to {question}?`);
|
|
577
|
+
*
|
|
578
|
+
* // Example of using LLMChain to process a series of questions
|
|
579
|
+
* const chain = new LLMChain({
|
|
580
|
+
* llm: new ChatOpenAI({ temperature: 0.9 }),
|
|
581
|
+
* prompt,
|
|
582
|
+
* });
|
|
583
|
+
*
|
|
584
|
+
* // Process questions using the chain
|
|
585
|
+
* const processQuestions = async (questions) => {
|
|
586
|
+
* for (const question of questions) {
|
|
587
|
+
* const result = await chain.call({ question });
|
|
588
|
+
* console.log(result);
|
|
589
|
+
* }
|
|
590
|
+
* };
|
|
591
|
+
*
|
|
592
|
+
* // Example questions
|
|
593
|
+
* const questions = [
|
|
594
|
+
* "What is your name?",
|
|
595
|
+
* "What is your quest?",
|
|
596
|
+
* "What is your favorite color?",
|
|
597
|
+
* ];
|
|
598
|
+
*
|
|
599
|
+
* // Run the example
|
|
600
|
+
* processQuestions(questions).catch(console.error);
|
|
601
|
+
*
|
|
602
|
+
* ```
|
|
603
|
+
*/
|
|
555
604
|
class TraceGroup {
|
|
556
605
|
constructor(groupName, options) {
|
|
557
606
|
Object.defineProperty(this, "groupName", {
|
|
@@ -86,6 +86,24 @@ export declare class CallbackManagerForToolRun extends BaseRunManager implements
|
|
|
86
86
|
handleToolError(err: Error | unknown): Promise<void>;
|
|
87
87
|
handleToolEnd(output: string): Promise<void>;
|
|
88
88
|
}
|
|
89
|
+
/**
|
|
90
|
+
* @example
|
|
91
|
+
* ```typescript
|
|
92
|
+
* const prompt = PromptTemplate.fromTemplate("What is the answer to {question}?");
|
|
93
|
+
*
|
|
94
|
+
* // Example of using LLMChain with OpenAI and a simple prompt
|
|
95
|
+
* const chain = new LLMChain({
|
|
96
|
+
* llm: new ChatOpenAI({ temperature: 0.9 }),
|
|
97
|
+
* prompt,
|
|
98
|
+
* });
|
|
99
|
+
*
|
|
100
|
+
* // Running the chain with a single question
|
|
101
|
+
* const result = await chain.call({
|
|
102
|
+
* question: "What is the airspeed velocity of an unladen swallow?",
|
|
103
|
+
* });
|
|
104
|
+
* console.log("The answer is:", result);
|
|
105
|
+
* ```
|
|
106
|
+
*/
|
|
89
107
|
export declare class CallbackManager extends BaseCallbackManager implements BaseCallbackManagerMethods {
|
|
90
108
|
handlers: BaseCallbackHandler[];
|
|
91
109
|
inheritableHandlers: BaseCallbackHandler[];
|
|
@@ -112,6 +130,37 @@ export declare class CallbackManager extends BaseCallbackManager implements Base
|
|
|
112
130
|
static fromHandlers(handlers: CallbackHandlerMethods): CallbackManager;
|
|
113
131
|
static configure(inheritableHandlers?: Callbacks, localHandlers?: Callbacks, inheritableTags?: string[], localTags?: string[], inheritableMetadata?: Record<string, unknown>, localMetadata?: Record<string, unknown>, options?: CallbackManagerOptions): Promise<CallbackManager | undefined>;
|
|
114
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* @example
|
|
135
|
+
* ```typescript
|
|
136
|
+
* const prompt = PromptTemplate.fromTemplate(`What is the answer to {question}?`);
|
|
137
|
+
*
|
|
138
|
+
* // Example of using LLMChain to process a series of questions
|
|
139
|
+
* const chain = new LLMChain({
|
|
140
|
+
* llm: new ChatOpenAI({ temperature: 0.9 }),
|
|
141
|
+
* prompt,
|
|
142
|
+
* });
|
|
143
|
+
*
|
|
144
|
+
* // Process questions using the chain
|
|
145
|
+
* const processQuestions = async (questions) => {
|
|
146
|
+
* for (const question of questions) {
|
|
147
|
+
* const result = await chain.call({ question });
|
|
148
|
+
* console.log(result);
|
|
149
|
+
* }
|
|
150
|
+
* };
|
|
151
|
+
*
|
|
152
|
+
* // Example questions
|
|
153
|
+
* const questions = [
|
|
154
|
+
* "What is your name?",
|
|
155
|
+
* "What is your quest?",
|
|
156
|
+
* "What is your favorite color?",
|
|
157
|
+
* ];
|
|
158
|
+
*
|
|
159
|
+
* // Run the example
|
|
160
|
+
* processQuestions(questions).catch(console.error);
|
|
161
|
+
*
|
|
162
|
+
* ```
|
|
163
|
+
*/
|
|
115
164
|
export declare class TraceGroup {
|
|
116
165
|
private groupName;
|
|
117
166
|
private options?;
|
|
@@ -266,6 +266,24 @@ export class CallbackManagerForToolRun extends BaseRunManager {
|
|
|
266
266
|
}, handler.awaitHandlers)));
|
|
267
267
|
}
|
|
268
268
|
}
|
|
269
|
+
/**
|
|
270
|
+
* @example
|
|
271
|
+
* ```typescript
|
|
272
|
+
* const prompt = PromptTemplate.fromTemplate("What is the answer to {question}?");
|
|
273
|
+
*
|
|
274
|
+
* // Example of using LLMChain with OpenAI and a simple prompt
|
|
275
|
+
* const chain = new LLMChain({
|
|
276
|
+
* llm: new ChatOpenAI({ temperature: 0.9 }),
|
|
277
|
+
* prompt,
|
|
278
|
+
* });
|
|
279
|
+
*
|
|
280
|
+
* // Running the chain with a single question
|
|
281
|
+
* const result = await chain.call({
|
|
282
|
+
* question: "What is the airspeed velocity of an unladen swallow?",
|
|
283
|
+
* });
|
|
284
|
+
* console.log("The answer is:", result);
|
|
285
|
+
* ```
|
|
286
|
+
*/
|
|
269
287
|
export class CallbackManager extends BaseCallbackManager {
|
|
270
288
|
constructor(parentRunId) {
|
|
271
289
|
super();
|
|
@@ -542,6 +560,37 @@ function ensureHandler(handler) {
|
|
|
542
560
|
}
|
|
543
561
|
return BaseCallbackHandler.fromMethods(handler);
|
|
544
562
|
}
|
|
563
|
+
/**
|
|
564
|
+
* @example
|
|
565
|
+
* ```typescript
|
|
566
|
+
* const prompt = PromptTemplate.fromTemplate(`What is the answer to {question}?`);
|
|
567
|
+
*
|
|
568
|
+
* // Example of using LLMChain to process a series of questions
|
|
569
|
+
* const chain = new LLMChain({
|
|
570
|
+
* llm: new ChatOpenAI({ temperature: 0.9 }),
|
|
571
|
+
* prompt,
|
|
572
|
+
* });
|
|
573
|
+
*
|
|
574
|
+
* // Process questions using the chain
|
|
575
|
+
* const processQuestions = async (questions) => {
|
|
576
|
+
* for (const question of questions) {
|
|
577
|
+
* const result = await chain.call({ question });
|
|
578
|
+
* console.log(result);
|
|
579
|
+
* }
|
|
580
|
+
* };
|
|
581
|
+
*
|
|
582
|
+
* // Example questions
|
|
583
|
+
* const questions = [
|
|
584
|
+
* "What is your name?",
|
|
585
|
+
* "What is your quest?",
|
|
586
|
+
* "What is your favorite color?",
|
|
587
|
+
* ];
|
|
588
|
+
*
|
|
589
|
+
* // Run the example
|
|
590
|
+
* processQuestions(questions).catch(console.error);
|
|
591
|
+
*
|
|
592
|
+
* ```
|
|
593
|
+
*/
|
|
545
594
|
export class TraceGroup {
|
|
546
595
|
constructor(groupName, options) {
|
|
547
596
|
Object.defineProperty(this, "groupName", {
|
|
@@ -7,6 +7,24 @@ const text_splitter_js_1 = require("../text_splitter.cjs");
|
|
|
7
7
|
* Chain that combines documents by stuffing into context.
|
|
8
8
|
* @augments BaseChain
|
|
9
9
|
* @augments StuffDocumentsChainInput
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* const model = new ChatOpenAI({ temperature: 0 });
|
|
13
|
+
* const combineDocsChain = loadSummarizationChain(model);
|
|
14
|
+
* const chain = new AnalyzeDocumentChain({
|
|
15
|
+
* combineDocumentsChain: combineDocsChain,
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* // Read the text from a file (this is a placeholder for actual file reading)
|
|
19
|
+
* const text = readTextFromFile("state_of_the_union.txt");
|
|
20
|
+
*
|
|
21
|
+
* // Invoke the chain to analyze the document
|
|
22
|
+
* const res = await chain.call({
|
|
23
|
+
* input_document: text,
|
|
24
|
+
* });
|
|
25
|
+
*
|
|
26
|
+
* console.log({ res });
|
|
27
|
+
* ```
|
|
10
28
|
*/
|
|
11
29
|
class AnalyzeDocumentChain extends base_js_1.BaseChain {
|
|
12
30
|
static lc_name() {
|
|
@@ -17,6 +17,24 @@ export interface AnalyzeDocumentChainInput extends Omit<ChainInputs, "memory"> {
|
|
|
17
17
|
* Chain that combines documents by stuffing into context.
|
|
18
18
|
* @augments BaseChain
|
|
19
19
|
* @augments StuffDocumentsChainInput
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* const model = new ChatOpenAI({ temperature: 0 });
|
|
23
|
+
* const combineDocsChain = loadSummarizationChain(model);
|
|
24
|
+
* const chain = new AnalyzeDocumentChain({
|
|
25
|
+
* combineDocumentsChain: combineDocsChain,
|
|
26
|
+
* });
|
|
27
|
+
*
|
|
28
|
+
* // Read the text from a file (this is a placeholder for actual file reading)
|
|
29
|
+
* const text = readTextFromFile("state_of_the_union.txt");
|
|
30
|
+
*
|
|
31
|
+
* // Invoke the chain to analyze the document
|
|
32
|
+
* const res = await chain.call({
|
|
33
|
+
* input_document: text,
|
|
34
|
+
* });
|
|
35
|
+
*
|
|
36
|
+
* console.log({ res });
|
|
37
|
+
* ```
|
|
20
38
|
*/
|
|
21
39
|
export declare class AnalyzeDocumentChain extends BaseChain implements AnalyzeDocumentChainInput {
|
|
22
40
|
static lc_name(): string;
|