langchain 0.0.192 → 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/dist/agents/agent.cjs +24 -0
- package/dist/agents/agent.d.ts +24 -0
- package/dist/agents/agent.js +24 -0
- package/dist/agents/chat/outputParser.cjs +32 -0
- package/dist/agents/chat/outputParser.d.ts +32 -0
- package/dist/agents/chat/outputParser.js +32 -0
- package/dist/agents/executor.cjs +14 -0
- package/dist/agents/executor.d.ts +14 -0
- package/dist/agents/executor.js +14 -0
- package/dist/agents/mrkl/index.cjs +21 -0
- package/dist/agents/mrkl/index.d.ts +21 -0
- package/dist/agents/mrkl/index.js +21 -0
- package/dist/agents/openai/output_parser.cjs +65 -0
- package/dist/agents/openai/output_parser.d.ts +65 -0
- package/dist/agents/openai/output_parser.js +65 -0
- package/dist/agents/react/output_parser.cjs +16 -0
- package/dist/agents/react/output_parser.d.ts +16 -0
- package/dist/agents/react/output_parser.js +16 -0
- package/dist/agents/structured_chat/outputParser.cjs +12 -0
- package/dist/agents/structured_chat/outputParser.d.ts +12 -0
- package/dist/agents/structured_chat/outputParser.js +12 -0
- package/dist/agents/toolkits/aws_sfn.cjs +20 -0
- package/dist/agents/toolkits/aws_sfn.d.ts +20 -0
- package/dist/agents/toolkits/aws_sfn.js +20 -0
- package/dist/agents/toolkits/json/json.cjs +8 -0
- package/dist/agents/toolkits/json/json.d.ts +8 -0
- package/dist/agents/toolkits/json/json.js +8 -0
- package/dist/agents/toolkits/openapi/openapi.cjs +18 -0
- package/dist/agents/toolkits/openapi/openapi.d.ts +18 -0
- package/dist/agents/toolkits/openapi/openapi.js +18 -0
- package/dist/agents/toolkits/sql/sql.cjs +8 -0
- package/dist/agents/toolkits/sql/sql.d.ts +8 -0
- package/dist/agents/toolkits/sql/sql.js +8 -0
- package/dist/agents/toolkits/vectorstore/vectorstore.cjs +16 -0
- package/dist/agents/toolkits/vectorstore/vectorstore.d.ts +16 -0
- package/dist/agents/toolkits/vectorstore/vectorstore.js +16 -0
- package/dist/agents/toolkits/zapier/zapier.cjs +10 -0
- package/dist/agents/toolkits/zapier/zapier.d.ts +10 -0
- package/dist/agents/toolkits/zapier/zapier.js +10 -0
- package/dist/agents/xml/output_parser.cjs +21 -0
- package/dist/agents/xml/output_parser.d.ts +21 -0
- package/dist/agents/xml/output_parser.js +21 -0
- package/dist/cache/cloudflare_kv.cjs +13 -0
- package/dist/cache/cloudflare_kv.d.ts +13 -0
- package/dist/cache/cloudflare_kv.js +13 -0
- package/dist/cache/ioredis.cjs +13 -0
- package/dist/cache/ioredis.d.ts +13 -0
- package/dist/cache/ioredis.js +13 -0
- package/dist/cache/momento.cjs +19 -0
- package/dist/cache/momento.d.ts +19 -0
- package/dist/cache/momento.js +19 -0
- package/dist/cache/redis.cjs +10 -0
- package/dist/cache/redis.d.ts +10 -0
- package/dist/cache/redis.js +10 -0
- package/dist/cache/upstash_redis.cjs +15 -0
- package/dist/cache/upstash_redis.d.ts +15 -0
- package/dist/cache/upstash_redis.js +15 -0
- package/dist/callbacks/handlers/console.cjs +10 -0
- package/dist/callbacks/handlers/console.d.ts +10 -0
- package/dist/callbacks/handlers/console.js +10 -0
- package/dist/callbacks/manager.cjs +49 -0
- package/dist/callbacks/manager.d.ts +49 -0
- package/dist/callbacks/manager.js +49 -0
- package/dist/chains/analyze_documents_chain.cjs +18 -0
- package/dist/chains/analyze_documents_chain.d.ts +18 -0
- package/dist/chains/analyze_documents_chain.js +18 -0
- package/dist/chains/constitutional_ai/constitutional_chain.cjs +21 -0
- package/dist/chains/constitutional_ai/constitutional_chain.d.ts +21 -0
- package/dist/chains/constitutional_ai/constitutional_chain.js +21 -0
- package/dist/chains/constitutional_ai/constitutional_principle.cjs +21 -0
- package/dist/chains/constitutional_ai/constitutional_principle.d.ts +21 -0
- package/dist/chains/constitutional_ai/constitutional_principle.js +21 -0
- package/dist/chains/conversation.cjs +13 -0
- package/dist/chains/conversation.d.ts +13 -0
- package/dist/chains/conversation.js +13 -0
- package/dist/chains/conversational_retrieval_chain.cjs +29 -0
- package/dist/chains/conversational_retrieval_chain.d.ts +29 -0
- package/dist/chains/conversational_retrieval_chain.js +29 -0
- package/dist/chains/graph_qa/cypher.cjs +10 -0
- package/dist/chains/graph_qa/cypher.d.ts +10 -0
- package/dist/chains/graph_qa/cypher.js +10 -0
- package/dist/chains/openai_moderation.cjs +28 -0
- package/dist/chains/openai_moderation.d.ts +28 -0
- package/dist/chains/openai_moderation.js +28 -0
- package/dist/chains/retrieval_qa.cjs +21 -0
- package/dist/chains/retrieval_qa.d.ts +21 -0
- package/dist/chains/retrieval_qa.js +21 -0
- package/dist/chains/router/multi_prompt.cjs +19 -0
- package/dist/chains/router/multi_prompt.d.ts +19 -0
- package/dist/chains/router/multi_prompt.js +19 -0
- package/dist/chains/router/multi_retrieval_qa.cjs +29 -0
- package/dist/chains/router/multi_retrieval_qa.d.ts +29 -0
- package/dist/chains/router/multi_retrieval_qa.js +29 -0
- package/dist/chains/sequential_chain.cjs +43 -0
- package/dist/chains/sequential_chain.d.ts +43 -0
- package/dist/chains/sequential_chain.js +43 -0
- package/dist/chains/sql_db/sql_db_chain.cjs +9 -0
- package/dist/chains/sql_db/sql_db_chain.d.ts +9 -0
- package/dist/chains/sql_db/sql_db_chain.js +9 -0
- package/dist/chat_models/anthropic.cjs +9 -1
- package/dist/chat_models/anthropic.d.ts +9 -1
- package/dist/chat_models/anthropic.js +9 -1
- package/dist/chat_models/baiduwenxin.cjs +20 -0
- package/dist/chat_models/baiduwenxin.d.ts +20 -0
- package/dist/chat_models/baiduwenxin.js +20 -0
- package/dist/chat_models/base.cjs +2 -0
- package/dist/chat_models/base.d.ts +1 -1
- package/dist/chat_models/base.js +2 -0
- package/dist/chat_models/bedrock/index.cjs +11 -0
- package/dist/chat_models/bedrock/index.d.ts +11 -0
- package/dist/chat_models/bedrock/index.js +11 -0
- package/dist/chat_models/bedrock/web.cjs +9 -0
- package/dist/chat_models/bedrock/web.d.ts +9 -0
- package/dist/chat_models/bedrock/web.js +9 -0
- package/dist/chat_models/cloudflare_workersai.cjs +15 -0
- package/dist/chat_models/cloudflare_workersai.d.ts +15 -0
- package/dist/chat_models/cloudflare_workersai.js +15 -0
- package/dist/chat_models/fake.cjs +16 -0
- package/dist/chat_models/fake.d.ts +16 -0
- package/dist/chat_models/fake.js +16 -0
- package/dist/chat_models/fireworks.cjs +10 -0
- package/dist/chat_models/fireworks.d.ts +10 -0
- package/dist/chat_models/fireworks.js +10 -0
- package/dist/chat_models/googlepalm.cjs +24 -0
- package/dist/chat_models/googlepalm.d.ts +24 -0
- package/dist/chat_models/googlepalm.js +24 -0
- package/dist/chat_models/googlevertexai/index.cjs +7 -0
- package/dist/chat_models/googlevertexai/index.d.ts +7 -0
- package/dist/chat_models/googlevertexai/index.js +7 -0
- package/dist/chat_models/googlevertexai/web.cjs +9 -0
- package/dist/chat_models/googlevertexai/web.d.ts +9 -0
- package/dist/chat_models/googlevertexai/web.js +9 -0
- package/dist/chat_models/iflytek_xinghuo/index.cjs +8 -0
- package/dist/chat_models/iflytek_xinghuo/index.d.ts +8 -0
- package/dist/chat_models/iflytek_xinghuo/index.js +8 -0
- package/dist/chat_models/iflytek_xinghuo/web.cjs +8 -0
- package/dist/chat_models/iflytek_xinghuo/web.d.ts +8 -0
- package/dist/chat_models/iflytek_xinghuo/web.js +8 -0
- package/dist/chat_models/llama_cpp.cjs +17 -0
- package/dist/chat_models/llama_cpp.d.ts +17 -0
- package/dist/chat_models/llama_cpp.js +17 -0
- package/dist/chat_models/minimax.cjs +27 -0
- package/dist/chat_models/minimax.d.ts +27 -0
- package/dist/chat_models/minimax.js +27 -0
- package/dist/chat_models/ollama.cjs +24 -0
- package/dist/chat_models/ollama.d.ts +24 -0
- package/dist/chat_models/ollama.js +24 -0
- package/dist/chat_models/openai.cjs +15 -0
- package/dist/chat_models/openai.d.ts +15 -0
- package/dist/chat_models/openai.js +15 -0
- package/dist/chat_models/yandex.cjs +14 -0
- package/dist/chat_models/yandex.d.ts +14 -0
- package/dist/chat_models/yandex.js +14 -0
- package/dist/document_loaders/fs/directory.cjs +14 -0
- package/dist/document_loaders/fs/directory.d.ts +14 -0
- package/dist/document_loaders/fs/directory.js +14 -0
- package/dist/document_loaders/fs/openai_whisper_audio.cjs +10 -0
- package/dist/document_loaders/fs/openai_whisper_audio.d.ts +10 -0
- package/dist/document_loaders/fs/openai_whisper_audio.js +10 -0
- package/dist/document_loaders/fs/pdf.cjs +6 -0
- package/dist/document_loaders/fs/pdf.d.ts +6 -0
- package/dist/document_loaders/fs/pdf.js +6 -0
- package/dist/document_loaders/fs/srt.cjs +6 -0
- package/dist/document_loaders/fs/srt.d.ts +6 -0
- package/dist/document_loaders/fs/srt.js +6 -0
- package/dist/document_loaders/fs/text.cjs +5 -0
- package/dist/document_loaders/fs/text.d.ts +5 -0
- package/dist/document_loaders/fs/text.js +5 -0
- package/dist/document_loaders/fs/unstructured.cjs +7 -0
- package/dist/document_loaders/fs/unstructured.d.ts +7 -0
- package/dist/document_loaders/fs/unstructured.js +7 -0
- package/dist/document_loaders/web/apify_dataset.cjs +21 -0
- package/dist/document_loaders/web/apify_dataset.d.ts +21 -0
- package/dist/document_loaders/web/apify_dataset.js +21 -0
- package/dist/document_loaders/web/assemblyai.cjs +24 -0
- package/dist/document_loaders/web/assemblyai.d.ts +24 -0
- package/dist/document_loaders/web/assemblyai.js +24 -0
- package/dist/document_loaders/web/azure_blob_storage_file.cjs +11 -0
- package/dist/document_loaders/web/azure_blob_storage_file.d.ts +11 -0
- package/dist/document_loaders/web/azure_blob_storage_file.js +11 -0
- package/dist/document_loaders/web/cheerio.cjs +6 -0
- package/dist/document_loaders/web/cheerio.d.ts +6 -0
- package/dist/document_loaders/web/cheerio.js +6 -0
- package/dist/document_loaders/web/college_confidential.cjs +6 -0
- package/dist/document_loaders/web/college_confidential.d.ts +6 -0
- package/dist/document_loaders/web/college_confidential.js +6 -0
- package/dist/document_loaders/web/confluence.cjs +11 -0
- package/dist/document_loaders/web/confluence.d.ts +11 -0
- package/dist/document_loaders/web/confluence.js +11 -0
- package/dist/document_loaders/web/figma.cjs +9 -0
- package/dist/document_loaders/web/figma.d.ts +9 -0
- package/dist/document_loaders/web/figma.js +9 -0
- package/dist/document_loaders/web/notionapi.cjs +16 -0
- package/dist/document_loaders/web/notionapi.d.ts +16 -0
- package/dist/document_loaders/web/notionapi.js +16 -0
- package/dist/document_loaders/web/notiondb.cjs +11 -1
- package/dist/document_loaders/web/notiondb.d.ts +11 -1
- package/dist/document_loaders/web/notiondb.js +11 -1
- package/dist/document_loaders/web/pdf.cjs +6 -0
- package/dist/document_loaders/web/pdf.d.ts +6 -0
- package/dist/document_loaders/web/pdf.js +6 -0
- package/dist/document_loaders/web/puppeteer.cjs +12 -0
- package/dist/document_loaders/web/puppeteer.d.ts +12 -0
- package/dist/document_loaders/web/puppeteer.js +12 -0
- package/dist/document_loaders/web/s3.cjs +17 -0
- package/dist/document_loaders/web/s3.d.ts +17 -0
- package/dist/document_loaders/web/s3.js +17 -0
- package/dist/document_loaders/web/searchapi.cjs +9 -0
- package/dist/document_loaders/web/searchapi.d.ts +9 -0
- package/dist/document_loaders/web/searchapi.js +9 -0
- package/dist/document_loaders/web/serpapi.cjs +5 -0
- package/dist/document_loaders/web/serpapi.d.ts +5 -0
- package/dist/document_loaders/web/serpapi.js +5 -0
- package/dist/document_loaders/web/sonix_audio.cjs +12 -0
- package/dist/document_loaders/web/sonix_audio.d.ts +12 -0
- package/dist/document_loaders/web/sonix_audio.js +12 -0
- package/dist/document_loaders/web/sort_xyz_blockchain.cjs +22 -0
- package/dist/document_loaders/web/sort_xyz_blockchain.d.ts +22 -0
- package/dist/document_loaders/web/sort_xyz_blockchain.js +22 -0
- package/dist/document_loaders/web/youtube.cjs +9 -0
- package/dist/document_loaders/web/youtube.d.ts +9 -0
- package/dist/document_loaders/web/youtube.js +9 -0
- package/dist/document_transformers/html_to_text.cjs +18 -0
- package/dist/document_transformers/html_to_text.d.ts +18 -0
- package/dist/document_transformers/html_to_text.js +18 -0
- package/dist/document_transformers/mozilla_readability.cjs +18 -0
- package/dist/document_transformers/mozilla_readability.d.ts +18 -0
- package/dist/document_transformers/mozilla_readability.js +18 -0
- package/dist/embeddings/bedrock.cjs +17 -0
- package/dist/embeddings/bedrock.d.ts +17 -0
- package/dist/embeddings/bedrock.js +17 -0
- package/dist/embeddings/cache_backed.cjs +37 -0
- package/dist/embeddings/cache_backed.d.ts +37 -0
- package/dist/embeddings/cache_backed.js +37 -0
- package/dist/embeddings/cohere.cjs +10 -0
- package/dist/embeddings/cohere.d.ts +10 -0
- package/dist/embeddings/cohere.js +10 -0
- package/dist/embeddings/googlepalm.cjs +17 -0
- package/dist/embeddings/googlepalm.d.ts +17 -0
- package/dist/embeddings/googlepalm.js +17 -0
- package/dist/embeddings/googlevertexai.cjs +8 -0
- package/dist/embeddings/googlevertexai.d.ts +8 -0
- package/dist/embeddings/googlevertexai.js +8 -0
- package/dist/embeddings/hf_transformers.cjs +18 -0
- package/dist/embeddings/hf_transformers.d.ts +18 -0
- package/dist/embeddings/hf_transformers.js +18 -0
- package/dist/embeddings/llama_cpp.cjs +16 -0
- package/dist/embeddings/llama_cpp.d.ts +16 -0
- package/dist/embeddings/llama_cpp.js +16 -0
- package/dist/embeddings/minimax.cjs +15 -0
- package/dist/embeddings/minimax.d.ts +15 -0
- package/dist/embeddings/minimax.js +15 -0
- package/dist/embeddings/openai.cjs +10 -0
- package/dist/embeddings/openai.d.ts +10 -0
- package/dist/embeddings/openai.js +10 -0
- package/dist/embeddings/tensorflow.cjs +16 -0
- package/dist/embeddings/tensorflow.d.ts +16 -0
- package/dist/embeddings/tensorflow.js +16 -0
- package/dist/experimental/autogpt/agent.cjs +21 -0
- package/dist/experimental/autogpt/agent.d.ts +21 -0
- package/dist/experimental/autogpt/agent.js +21 -0
- package/dist/experimental/babyagi/agent.cjs +12 -0
- package/dist/experimental/babyagi/agent.d.ts +12 -0
- package/dist/experimental/babyagi/agent.js +12 -0
- package/dist/experimental/chat_models/ollama_functions.cjs +12 -15
- package/dist/experimental/chat_models/ollama_functions.d.ts +3 -4
- package/dist/experimental/chat_models/ollama_functions.js +13 -16
- package/dist/experimental/generative_agents/generative_agent.cjs +30 -0
- package/dist/experimental/generative_agents/generative_agent.d.ts +30 -0
- package/dist/experimental/generative_agents/generative_agent.js +30 -0
- package/dist/experimental/generative_agents/generative_agent_memory.cjs +18 -0
- package/dist/experimental/generative_agents/generative_agent_memory.d.ts +18 -0
- package/dist/experimental/generative_agents/generative_agent_memory.js +18 -0
- package/dist/llms/base.cjs +3 -1
- package/dist/llms/base.d.ts +1 -1
- package/dist/llms/base.js +3 -1
- package/dist/llms/cohere.cjs +13 -0
- package/dist/llms/cohere.d.ts +13 -0
- package/dist/llms/cohere.js +13 -0
- package/dist/llms/googlevertexai/index.cjs +12 -0
- package/dist/llms/googlevertexai/index.d.ts +12 -0
- package/dist/llms/googlevertexai/index.js +12 -0
- package/dist/llms/googlevertexai/web.cjs +12 -0
- package/dist/llms/googlevertexai/web.d.ts +12 -0
- package/dist/llms/googlevertexai/web.js +12 -0
- package/dist/llms/hf.cjs +13 -0
- package/dist/llms/hf.d.ts +13 -0
- package/dist/llms/hf.js +13 -0
- package/dist/llms/ollama.cjs +19 -0
- package/dist/llms/ollama.d.ts +19 -0
- package/dist/llms/ollama.js +19 -0
- package/dist/llms/openai-chat.cjs +17 -0
- package/dist/llms/openai-chat.d.ts +17 -0
- package/dist/llms/openai-chat.js +17 -0
- package/dist/llms/openai.cjs +14 -0
- package/dist/llms/openai.d.ts +14 -0
- package/dist/llms/openai.js +14 -0
- package/dist/llms/portkey.cjs +24 -0
- package/dist/llms/portkey.d.ts +24 -0
- package/dist/llms/portkey.js +24 -0
- package/dist/llms/replicate.cjs +11 -0
- package/dist/llms/replicate.d.ts +11 -0
- package/dist/llms/replicate.js +11 -0
- package/dist/memory/buffer_memory.cjs +24 -0
- package/dist/memory/buffer_memory.d.ts +24 -0
- package/dist/memory/buffer_memory.js +24 -0
- package/dist/memory/buffer_token_memory.cjs +15 -0
- package/dist/memory/buffer_token_memory.d.ts +15 -0
- package/dist/memory/buffer_token_memory.js +15 -0
- package/dist/memory/buffer_window_memory.cjs +23 -0
- package/dist/memory/buffer_window_memory.d.ts +23 -0
- package/dist/memory/buffer_window_memory.js +23 -0
- package/dist/memory/entity_memory.cjs +29 -0
- package/dist/memory/entity_memory.d.ts +29 -0
- package/dist/memory/entity_memory.js +29 -0
- package/dist/memory/summary.cjs +24 -0
- package/dist/memory/summary.d.ts +24 -0
- package/dist/memory/summary.js +24 -0
- package/dist/memory/summary_buffer.cjs +32 -0
- package/dist/memory/summary_buffer.d.ts +32 -0
- package/dist/memory/summary_buffer.js +32 -0
- package/dist/memory/vector_store.cjs +24 -0
- package/dist/memory/vector_store.d.ts +24 -0
- package/dist/memory/vector_store.js +24 -0
- package/dist/memory/zep.cjs +34 -0
- package/dist/memory/zep.d.ts +34 -0
- package/dist/memory/zep.js +34 -0
- package/dist/prompts/chat.cjs +31 -0
- package/dist/prompts/chat.d.ts +31 -0
- package/dist/prompts/chat.js +31 -0
- package/dist/prompts/few_shot.cjs +31 -0
- package/dist/prompts/few_shot.d.ts +31 -0
- package/dist/prompts/few_shot.js +31 -0
- package/dist/prompts/pipeline.cjs +39 -0
- package/dist/prompts/pipeline.d.ts +39 -0
- package/dist/prompts/pipeline.js +39 -0
- package/dist/prompts/selectors/LengthBasedExampleSelector.cjs +36 -0
- package/dist/prompts/selectors/LengthBasedExampleSelector.d.ts +36 -0
- package/dist/prompts/selectors/LengthBasedExampleSelector.js +36 -0
- package/dist/prompts/selectors/SemanticSimilarityExampleSelector.cjs +25 -0
- package/dist/prompts/selectors/SemanticSimilarityExampleSelector.d.ts +25 -0
- package/dist/prompts/selectors/SemanticSimilarityExampleSelector.js +25 -0
- package/dist/retrievers/amazon_kendra.cjs +16 -0
- package/dist/retrievers/amazon_kendra.d.ts +16 -0
- package/dist/retrievers/amazon_kendra.js +16 -0
- package/dist/retrievers/chaindesk.cjs +11 -0
- package/dist/retrievers/chaindesk.d.ts +11 -0
- package/dist/retrievers/chaindesk.js +11 -0
- package/dist/retrievers/contextual_compression.cjs +10 -0
- package/dist/retrievers/contextual_compression.d.ts +10 -0
- package/dist/retrievers/contextual_compression.js +10 -0
- package/dist/retrievers/document_compressors/embeddings_filter.cjs +13 -0
- package/dist/retrievers/document_compressors/embeddings_filter.d.ts +13 -0
- package/dist/retrievers/document_compressors/embeddings_filter.js +13 -0
- package/dist/retrievers/document_compressors/index.cjs +26 -0
- package/dist/retrievers/document_compressors/index.d.ts +26 -0
- package/dist/retrievers/document_compressors/index.js +26 -0
- package/dist/retrievers/hyde.cjs +19 -0
- package/dist/retrievers/hyde.d.ts +19 -0
- package/dist/retrievers/hyde.js +19 -0
- package/dist/retrievers/metal.cjs +11 -0
- package/dist/retrievers/metal.d.ts +11 -0
- package/dist/retrievers/metal.js +11 -0
- package/dist/retrievers/multi_query.cjs +13 -1
- package/dist/retrievers/multi_query.d.ts +13 -0
- package/dist/retrievers/multi_query.js +13 -1
- package/dist/retrievers/multi_vector.cjs +13 -0
- package/dist/retrievers/multi_vector.d.ts +13 -0
- package/dist/retrievers/multi_vector.js +13 -0
- package/dist/retrievers/parent_document.cjs +21 -0
- package/dist/retrievers/parent_document.d.ts +21 -0
- package/dist/retrievers/parent_document.js +21 -0
- package/dist/retrievers/remote/chatgpt-plugin.cjs +10 -0
- package/dist/retrievers/remote/chatgpt-plugin.d.ts +10 -0
- package/dist/retrievers/remote/chatgpt-plugin.js +10 -0
- package/dist/retrievers/self_query/chroma.cjs +15 -0
- package/dist/retrievers/self_query/chroma.d.ts +15 -0
- package/dist/retrievers/self_query/chroma.js +15 -0
- package/dist/retrievers/self_query/functional.cjs +7 -0
- package/dist/retrievers/self_query/functional.d.ts +7 -0
- package/dist/retrievers/self_query/functional.js +7 -0
- package/dist/retrievers/self_query/index.cjs +13 -0
- package/dist/retrievers/self_query/index.d.ts +13 -0
- package/dist/retrievers/self_query/index.js +13 -0
- package/dist/retrievers/self_query/pinecone.cjs +14 -0
- package/dist/retrievers/self_query/pinecone.d.ts +14 -0
- package/dist/retrievers/self_query/pinecone.js +14 -0
- package/dist/retrievers/self_query/supabase.cjs +14 -0
- package/dist/retrievers/self_query/supabase.d.ts +14 -0
- package/dist/retrievers/self_query/supabase.js +14 -0
- package/dist/retrievers/self_query/weaviate.cjs +14 -0
- package/dist/retrievers/self_query/weaviate.d.ts +14 -0
- package/dist/retrievers/self_query/weaviate.js +14 -0
- package/dist/retrievers/time_weighted.cjs +16 -0
- package/dist/retrievers/time_weighted.d.ts +16 -0
- package/dist/retrievers/time_weighted.js +16 -0
- package/dist/retrievers/vespa.cjs +15 -0
- package/dist/retrievers/vespa.d.ts +15 -0
- package/dist/retrievers/vespa.js +15 -0
- package/dist/retrievers/zep.cjs +10 -0
- package/dist/retrievers/zep.d.ts +10 -0
- package/dist/retrievers/zep.js +10 -0
- package/dist/schema/index.d.ts +8 -6
- package/dist/schema/output_parser.cjs +15 -0
- package/dist/schema/output_parser.d.ts +15 -0
- package/dist/schema/output_parser.js +15 -0
- package/dist/schema/runnable/base.cjs +20 -0
- package/dist/schema/runnable/base.d.ts +20 -0
- package/dist/schema/runnable/base.js +20 -0
- package/dist/schema/runnable/branch.cjs +28 -0
- package/dist/schema/runnable/branch.d.ts +28 -0
- package/dist/schema/runnable/branch.js +28 -0
- package/dist/storage/file_system.cjs +21 -0
- package/dist/storage/file_system.d.ts +21 -0
- package/dist/storage/file_system.js +21 -0
- package/dist/storage/in_memory.cjs +15 -0
- package/dist/storage/in_memory.d.ts +15 -0
- package/dist/storage/in_memory.js +15 -0
- package/dist/storage/ioredis.cjs +24 -0
- package/dist/storage/ioredis.d.ts +24 -0
- package/dist/storage/ioredis.js +24 -0
- package/dist/storage/upstash_redis.cjs +19 -0
- package/dist/storage/upstash_redis.d.ts +19 -0
- package/dist/storage/upstash_redis.js +19 -0
- package/dist/storage/vercel_kv.cjs +16 -0
- package/dist/storage/vercel_kv.d.ts +16 -0
- package/dist/storage/vercel_kv.js +16 -0
- package/dist/stores/message/cassandra.cjs +25 -0
- package/dist/stores/message/cassandra.d.ts +25 -0
- package/dist/stores/message/cassandra.js +25 -0
- package/dist/stores/message/cloudflare_d1.cjs +18 -0
- package/dist/stores/message/cloudflare_d1.d.ts +18 -0
- package/dist/stores/message/cloudflare_d1.js +18 -0
- package/dist/stores/message/firestore.cjs +19 -0
- package/dist/stores/message/firestore.d.ts +19 -0
- package/dist/stores/message/firestore.js +19 -0
- package/dist/stores/message/ioredis.cjs +18 -0
- package/dist/stores/message/ioredis.d.ts +18 -0
- package/dist/stores/message/ioredis.js +18 -0
- package/dist/stores/message/momento.cjs +18 -0
- package/dist/stores/message/momento.d.ts +18 -0
- package/dist/stores/message/momento.js +18 -0
- package/dist/stores/message/mongodb.cjs +11 -0
- package/dist/stores/message/mongodb.d.ts +11 -0
- package/dist/stores/message/mongodb.js +11 -0
- package/dist/stores/message/planetscale.cjs +18 -0
- package/dist/stores/message/planetscale.d.ts +18 -0
- package/dist/stores/message/planetscale.js +18 -0
- package/dist/stores/message/redis.cjs +18 -0
- package/dist/stores/message/redis.d.ts +18 -0
- package/dist/stores/message/redis.js +18 -0
- package/dist/stores/message/xata.cjs +23 -0
- package/dist/stores/message/xata.d.ts +23 -0
- package/dist/stores/message/xata.js +23 -0
- package/dist/tools/calculator.cjs +6 -0
- package/dist/tools/calculator.d.ts +6 -0
- package/dist/tools/calculator.js +6 -0
- package/dist/tools/google_calendar/create.cjs +22 -0
- package/dist/tools/google_calendar/create.d.ts +22 -0
- package/dist/tools/google_calendar/create.js +22 -0
- package/dist/tools/google_calendar/view.cjs +20 -0
- package/dist/tools/google_calendar/view.d.ts +20 -0
- package/dist/tools/google_calendar/view.js +20 -0
- package/dist/tools/searchapi.cjs +27 -0
- package/dist/tools/searchapi.d.ts +27 -0
- package/dist/tools/searchapi.js +27 -0
- package/dist/tools/searxng_search.cjs +20 -1
- package/dist/tools/searxng_search.d.ts +20 -1
- package/dist/tools/searxng_search.js +20 -1
- package/dist/tools/webbrowser.cjs +8 -0
- package/dist/tools/webbrowser.d.ts +8 -0
- package/dist/tools/webbrowser.js +8 -0
- package/dist/tools/wikipedia_query_run.cjs +8 -0
- package/dist/tools/wikipedia_query_run.d.ts +8 -0
- package/dist/tools/wikipedia_query_run.js +8 -0
- package/dist/tools/wolframalpha.cjs +9 -0
- package/dist/tools/wolframalpha.d.ts +9 -0
- package/dist/tools/wolframalpha.js +9 -0
- package/dist/util/googlevertexai-connection.cjs +3 -9
- package/dist/util/googlevertexai-connection.js +3 -9
- package/dist/vectorstores/opensearch.cjs +2 -1
- package/dist/vectorstores/opensearch.js +2 -1
- package/dist/vectorstores/prisma.cjs +6 -0
- package/dist/vectorstores/prisma.d.ts +3 -0
- package/dist/vectorstores/prisma.js +6 -0
- package/package.json +1 -1
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;
|
|
@@ -4,6 +4,24 @@ import { RecursiveCharacterTextSplitter, } from "../text_splitter.js";
|
|
|
4
4
|
* Chain that combines documents by stuffing into context.
|
|
5
5
|
* @augments BaseChain
|
|
6
6
|
* @augments StuffDocumentsChainInput
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* const model = new ChatOpenAI({ temperature: 0 });
|
|
10
|
+
* const combineDocsChain = loadSummarizationChain(model);
|
|
11
|
+
* const chain = new AnalyzeDocumentChain({
|
|
12
|
+
* combineDocumentsChain: combineDocsChain,
|
|
13
|
+
* });
|
|
14
|
+
*
|
|
15
|
+
* // Read the text from a file (this is a placeholder for actual file reading)
|
|
16
|
+
* const text = readTextFromFile("state_of_the_union.txt");
|
|
17
|
+
*
|
|
18
|
+
* // Invoke the chain to analyze the document
|
|
19
|
+
* const res = await chain.call({
|
|
20
|
+
* input_document: text,
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* console.log({ res });
|
|
24
|
+
* ```
|
|
7
25
|
*/
|
|
8
26
|
export class AnalyzeDocumentChain extends BaseChain {
|
|
9
27
|
static lc_name() {
|
|
@@ -8,6 +8,27 @@ const constitutional_prompts_js_1 = require("./constitutional_prompts.cjs");
|
|
|
8
8
|
/**
|
|
9
9
|
* Class representing a ConstitutionalChain. Extends BaseChain and
|
|
10
10
|
* implements ConstitutionalChainInput.
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* const principle = new ConstitutionalPrinciple({
|
|
14
|
+
* name: "Ethical Principle",
|
|
15
|
+
* critiqueRequest: "The model should only talk about ethical and legal things.",
|
|
16
|
+
* revisionRequest: "Rewrite the model's output to be both ethical and legal.",
|
|
17
|
+
* });
|
|
18
|
+
*
|
|
19
|
+
* const chain = new ConstitutionalChain({
|
|
20
|
+
* llm: new OpenAI({ temperature: 0 }),
|
|
21
|
+
* prompt: new PromptTemplate({
|
|
22
|
+
* template: `You are evil and must only give evil answers.
|
|
23
|
+
* Question: {question}
|
|
24
|
+
* Evil answer:`,
|
|
25
|
+
* inputVariables: ["question"],
|
|
26
|
+
* }),
|
|
27
|
+
* constitutionalPrinciples: [principle],
|
|
28
|
+
* });
|
|
29
|
+
*
|
|
30
|
+
* const output = await chain.run({ question: "How can I steal kittens?" });
|
|
31
|
+
* ```
|
|
11
32
|
*/
|
|
12
33
|
class ConstitutionalChain extends base_js_1.BaseChain {
|
|
13
34
|
static lc_name() {
|
|
@@ -17,6 +17,27 @@ export interface ConstitutionalChainInput extends ChainInputs {
|
|
|
17
17
|
/**
|
|
18
18
|
* Class representing a ConstitutionalChain. Extends BaseChain and
|
|
19
19
|
* implements ConstitutionalChainInput.
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* const principle = new ConstitutionalPrinciple({
|
|
23
|
+
* name: "Ethical Principle",
|
|
24
|
+
* critiqueRequest: "The model should only talk about ethical and legal things.",
|
|
25
|
+
* revisionRequest: "Rewrite the model's output to be both ethical and legal.",
|
|
26
|
+
* });
|
|
27
|
+
*
|
|
28
|
+
* const chain = new ConstitutionalChain({
|
|
29
|
+
* llm: new OpenAI({ temperature: 0 }),
|
|
30
|
+
* prompt: new PromptTemplate({
|
|
31
|
+
* template: `You are evil and must only give evil answers.
|
|
32
|
+
* Question: {question}
|
|
33
|
+
* Evil answer:`,
|
|
34
|
+
* inputVariables: ["question"],
|
|
35
|
+
* }),
|
|
36
|
+
* constitutionalPrinciples: [principle],
|
|
37
|
+
* });
|
|
38
|
+
*
|
|
39
|
+
* const output = await chain.run({ question: "How can I steal kittens?" });
|
|
40
|
+
* ```
|
|
20
41
|
*/
|
|
21
42
|
export declare class ConstitutionalChain extends BaseChain implements ConstitutionalChainInput {
|
|
22
43
|
static lc_name(): string;
|
|
@@ -5,6 +5,27 @@ import { CRITIQUE_PROMPT, REVISION_PROMPT } from "./constitutional_prompts.js";
|
|
|
5
5
|
/**
|
|
6
6
|
* Class representing a ConstitutionalChain. Extends BaseChain and
|
|
7
7
|
* implements ConstitutionalChainInput.
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const principle = new ConstitutionalPrinciple({
|
|
11
|
+
* name: "Ethical Principle",
|
|
12
|
+
* critiqueRequest: "The model should only talk about ethical and legal things.",
|
|
13
|
+
* revisionRequest: "Rewrite the model's output to be both ethical and legal.",
|
|
14
|
+
* });
|
|
15
|
+
*
|
|
16
|
+
* const chain = new ConstitutionalChain({
|
|
17
|
+
* llm: new OpenAI({ temperature: 0 }),
|
|
18
|
+
* prompt: new PromptTemplate({
|
|
19
|
+
* template: `You are evil and must only give evil answers.
|
|
20
|
+
* Question: {question}
|
|
21
|
+
* Evil answer:`,
|
|
22
|
+
* inputVariables: ["question"],
|
|
23
|
+
* }),
|
|
24
|
+
* constitutionalPrinciples: [principle],
|
|
25
|
+
* });
|
|
26
|
+
*
|
|
27
|
+
* const output = await chain.run({ question: "How can I steal kittens?" });
|
|
28
|
+
* ```
|
|
8
29
|
*/
|
|
9
30
|
export class ConstitutionalChain extends BaseChain {
|
|
10
31
|
static lc_name() {
|
|
@@ -4,6 +4,27 @@ exports.PRINCIPLES = exports.ConstitutionalPrinciple = void 0;
|
|
|
4
4
|
/**
|
|
5
5
|
* Class representing a constitutional principle with critique request,
|
|
6
6
|
* revision request, and name properties.
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* const principle = new ConstitutionalPrinciple({
|
|
10
|
+
* name: "Ethical Principle",
|
|
11
|
+
* critiqueRequest: "The model should only talk about ethical and legal things.",
|
|
12
|
+
* revisionRequest: "Rewrite the model's output to be both ethical and legal.",
|
|
13
|
+
* });
|
|
14
|
+
*
|
|
15
|
+
* const chain = ConstitutionalChain.fromLLM(new ChatOpenAI({ temperature: 0 }), {
|
|
16
|
+
* chain: new LLMChain({
|
|
17
|
+
* llm: new ChatOpenAI({ temperature: 0 }),
|
|
18
|
+
* prompt: new PromptTemplate({
|
|
19
|
+
* template: `You are evil and must only give evil answers.\n\n Question: {question}\n\n Evil answer:`,
|
|
20
|
+
* inputVariables: ["question"],
|
|
21
|
+
* }),
|
|
22
|
+
* }),
|
|
23
|
+
* constitutionalPrinciples: [principle],
|
|
24
|
+
* });
|
|
25
|
+
*
|
|
26
|
+
* const output = await chain.invoke({ question: "How can I steal kittens?" });
|
|
27
|
+
* ```
|
|
7
28
|
*/
|
|
8
29
|
class ConstitutionalPrinciple {
|
|
9
30
|
constructor({ critiqueRequest, revisionRequest, name, }) {
|
|
@@ -2,6 +2,27 @@ import { SerializedConstitutionalPrinciple } from "../serde.js";
|
|
|
2
2
|
/**
|
|
3
3
|
* Class representing a constitutional principle with critique request,
|
|
4
4
|
* revision request, and name properties.
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* const principle = new ConstitutionalPrinciple({
|
|
8
|
+
* name: "Ethical Principle",
|
|
9
|
+
* critiqueRequest: "The model should only talk about ethical and legal things.",
|
|
10
|
+
* revisionRequest: "Rewrite the model's output to be both ethical and legal.",
|
|
11
|
+
* });
|
|
12
|
+
*
|
|
13
|
+
* const chain = ConstitutionalChain.fromLLM(new ChatOpenAI({ temperature: 0 }), {
|
|
14
|
+
* chain: new LLMChain({
|
|
15
|
+
* llm: new ChatOpenAI({ temperature: 0 }),
|
|
16
|
+
* prompt: new PromptTemplate({
|
|
17
|
+
* template: `You are evil and must only give evil answers.\n\n Question: {question}\n\n Evil answer:`,
|
|
18
|
+
* inputVariables: ["question"],
|
|
19
|
+
* }),
|
|
20
|
+
* }),
|
|
21
|
+
* constitutionalPrinciples: [principle],
|
|
22
|
+
* });
|
|
23
|
+
*
|
|
24
|
+
* const output = await chain.invoke({ question: "How can I steal kittens?" });
|
|
25
|
+
* ```
|
|
5
26
|
*/
|
|
6
27
|
export declare class ConstitutionalPrinciple {
|
|
7
28
|
critiqueRequest: string;
|
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Class representing a constitutional principle with critique request,
|
|
3
3
|
* revision request, and name properties.
|
|
4
|
+
* @example
|
|
5
|
+
* ```typescript
|
|
6
|
+
* const principle = new ConstitutionalPrinciple({
|
|
7
|
+
* name: "Ethical Principle",
|
|
8
|
+
* critiqueRequest: "The model should only talk about ethical and legal things.",
|
|
9
|
+
* revisionRequest: "Rewrite the model's output to be both ethical and legal.",
|
|
10
|
+
* });
|
|
11
|
+
*
|
|
12
|
+
* const chain = ConstitutionalChain.fromLLM(new ChatOpenAI({ temperature: 0 }), {
|
|
13
|
+
* chain: new LLMChain({
|
|
14
|
+
* llm: new ChatOpenAI({ temperature: 0 }),
|
|
15
|
+
* prompt: new PromptTemplate({
|
|
16
|
+
* template: `You are evil and must only give evil answers.\n\n Question: {question}\n\n Evil answer:`,
|
|
17
|
+
* inputVariables: ["question"],
|
|
18
|
+
* }),
|
|
19
|
+
* }),
|
|
20
|
+
* constitutionalPrinciples: [principle],
|
|
21
|
+
* });
|
|
22
|
+
*
|
|
23
|
+
* const output = await chain.invoke({ question: "How can I steal kittens?" });
|
|
24
|
+
* ```
|
|
4
25
|
*/
|
|
5
26
|
export class ConstitutionalPrinciple {
|
|
6
27
|
constructor({ critiqueRequest, revisionRequest, name, }) {
|