langchain 0.2.10 → 0.2.11
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/chat_models/universal.cjs +1 -0
- package/chat_models/universal.d.cts +1 -0
- package/chat_models/universal.d.ts +1 -0
- package/chat_models/universal.js +1 -0
- package/dist/chat_models/universal.cjs +600 -0
- package/dist/chat_models/universal.d.ts +115 -0
- package/dist/chat_models/universal.js +595 -0
- package/dist/document_loaders/web/assemblyai.cjs +9 -1
- package/dist/document_loaders/web/assemblyai.js +9 -1
- package/dist/experimental/chrome_ai/app/dist/bundle.cjs +1250 -0
- package/dist/experimental/chrome_ai/app/dist/bundle.d.ts +1 -0
- package/dist/experimental/chrome_ai/app/dist/bundle.js +1249 -0
- package/dist/load/import_constants.cjs +1 -0
- package/dist/load/import_constants.js +1 -0
- package/package.json +65 -6
- package/dist/agents/tests/agent.int.test.d.ts +0 -1
- package/dist/agents/tests/agent.int.test.js +0 -309
- package/dist/agents/tests/chat_convo_output_parser.test.d.ts +0 -1
- package/dist/agents/tests/chat_convo_output_parser.test.js +0 -91
- package/dist/agents/tests/create_openai_functions_agent.int.test.d.ts +0 -2
- package/dist/agents/tests/create_openai_functions_agent.int.test.js +0 -71
- package/dist/agents/tests/create_openai_tools_agent.int.test.d.ts +0 -1
- package/dist/agents/tests/create_openai_tools_agent.int.test.js +0 -75
- package/dist/agents/tests/create_react_agent.int.test.d.ts +0 -1
- package/dist/agents/tests/create_react_agent.int.test.js +0 -32
- package/dist/agents/tests/create_structured_chat_agent.int.test.d.ts +0 -1
- package/dist/agents/tests/create_structured_chat_agent.int.test.js +0 -32
- package/dist/agents/tests/create_tool_calling_agent.int.test.d.ts +0 -1
- package/dist/agents/tests/create_tool_calling_agent.int.test.js +0 -122
- package/dist/agents/tests/create_xml_agent.int.test.d.ts +0 -1
- package/dist/agents/tests/create_xml_agent.int.test.js +0 -32
- package/dist/agents/tests/json.test.d.ts +0 -1
- package/dist/agents/tests/json.test.js +0 -74
- package/dist/agents/tests/react.test.d.ts +0 -1
- package/dist/agents/tests/react.test.js +0 -44
- package/dist/agents/tests/runnable.int.test.d.ts +0 -1
- package/dist/agents/tests/runnable.int.test.js +0 -104
- package/dist/agents/tests/sql.test.d.ts +0 -1
- package/dist/agents/tests/sql.test.js +0 -133
- package/dist/agents/tests/structured_chat_output_parser.test.d.ts +0 -1
- package/dist/agents/tests/structured_chat_output_parser.test.js +0 -35
- package/dist/agents/tests/structured_chat_output_parser_with_retries.int.test.d.ts +0 -1
- package/dist/agents/tests/structured_chat_output_parser_with_retries.int.test.js +0 -44
- package/dist/agents/tests/structured_output_runnables.int.test.d.ts +0 -1
- package/dist/agents/tests/structured_output_runnables.int.test.js +0 -112
- package/dist/agents/toolkits/tests/conversational_retrieval.int.test.d.ts +0 -1
- package/dist/agents/toolkits/tests/conversational_retrieval.int.test.js +0 -41
- package/dist/cache/tests/file_system.int.test.d.ts +0 -1
- package/dist/cache/tests/file_system.int.test.js +0 -32
- package/dist/chains/openai_functions/tests/create_runnable_chains.int.test.d.ts +0 -1
- package/dist/chains/openai_functions/tests/create_runnable_chains.int.test.js +0 -139
- package/dist/chains/openai_functions/tests/extraction.int.test.d.ts +0 -1
- package/dist/chains/openai_functions/tests/extraction.int.test.js +0 -33
- package/dist/chains/openai_functions/tests/openapi.int.test.d.ts +0 -1
- package/dist/chains/openai_functions/tests/openapi.int.test.js +0 -130
- package/dist/chains/openai_functions/tests/openapi.test.d.ts +0 -1
- package/dist/chains/openai_functions/tests/openapi.test.js +0 -172
- package/dist/chains/openai_functions/tests/structured_output.int.test.d.ts +0 -1
- package/dist/chains/openai_functions/tests/structured_output.int.test.js +0 -40
- package/dist/chains/openai_functions/tests/structured_output.test.d.ts +0 -1
- package/dist/chains/openai_functions/tests/structured_output.test.js +0 -102
- package/dist/chains/openai_functions/tests/tagging.int.test.d.ts +0 -1
- package/dist/chains/openai_functions/tests/tagging.int.test.js +0 -21
- package/dist/chains/query_constructor/tests/query_chain.int.test.d.ts +0 -1
- package/dist/chains/query_constructor/tests/query_chain.int.test.js +0 -93
- package/dist/chains/query_constructor/tests/query_parser.test.d.ts +0 -1
- package/dist/chains/query_constructor/tests/query_parser.test.js +0 -28
- package/dist/chains/question_answering/tests/load.int.test.d.ts +0 -1
- package/dist/chains/question_answering/tests/load.int.test.js +0 -39
- package/dist/chains/router/tests/multi_prompt.int.test.d.ts +0 -1
- package/dist/chains/router/tests/multi_prompt.int.test.js +0 -45
- package/dist/chains/router/tests/multi_prompt.test.d.ts +0 -1
- package/dist/chains/router/tests/multi_prompt.test.js +0 -62
- package/dist/chains/router/tests/multi_retrieval_qa.int.test.d.ts +0 -1
- package/dist/chains/router/tests/multi_retrieval_qa.int.test.js +0 -67
- package/dist/chains/router/tests/multi_retrieval_qa.test.d.ts +0 -1
- package/dist/chains/router/tests/multi_retrieval_qa.test.js +0 -125
- package/dist/chains/summarization/tests/load.int.test.d.ts +0 -1
- package/dist/chains/summarization/tests/load.int.test.js +0 -37
- package/dist/chains/tests/api_chain.int.test.d.ts +0 -1
- package/dist/chains/tests/api_chain.int.test.js +0 -55
- package/dist/chains/tests/combine_docs_chain.int.test.d.ts +0 -1
- package/dist/chains/tests/combine_docs_chain.int.test.js +0 -50
- package/dist/chains/tests/combine_docs_chain.test.d.ts +0 -1
- package/dist/chains/tests/combine_docs_chain.test.js +0 -98
- package/dist/chains/tests/constitutional_chain.int.test.d.ts +0 -1
- package/dist/chains/tests/constitutional_chain.int.test.js +0 -30
- package/dist/chains/tests/constitutional_chain.test.d.ts +0 -1
- package/dist/chains/tests/constitutional_chain.test.js +0 -63
- package/dist/chains/tests/conversation_chain.int.test.d.ts +0 -1
- package/dist/chains/tests/conversation_chain.int.test.js +0 -9
- package/dist/chains/tests/conversational_retrieval_chain.int.test.d.ts +0 -1
- package/dist/chains/tests/conversational_retrieval_chain.int.test.js +0 -243
- package/dist/chains/tests/example_data/open_meteo_docs.d.ts +0 -1
- package/dist/chains/tests/example_data/open_meteo_docs.js +0 -29
- package/dist/chains/tests/history_aware_retriever.int.test.d.ts +0 -1
- package/dist/chains/tests/history_aware_retriever.int.test.js +0 -41
- package/dist/chains/tests/history_aware_retriever.test.d.ts +0 -1
- package/dist/chains/tests/history_aware_retriever.test.js +0 -27
- package/dist/chains/tests/llm_chain.int.test.d.ts +0 -1
- package/dist/chains/tests/llm_chain.int.test.js +0 -119
- package/dist/chains/tests/openai_moderation.int.test.d.ts +0 -1
- package/dist/chains/tests/openai_moderation.int.test.js +0 -30
- package/dist/chains/tests/retrieval_chain.int.test.d.ts +0 -1
- package/dist/chains/tests/retrieval_chain.int.test.js +0 -69
- package/dist/chains/tests/retrieval_chain.test.d.ts +0 -1
- package/dist/chains/tests/retrieval_chain.test.js +0 -36
- package/dist/chains/tests/sequential_chain.int.test.d.ts +0 -1
- package/dist/chains/tests/sequential_chain.int.test.js +0 -88
- package/dist/chains/tests/sequential_chain.test.d.ts +0 -1
- package/dist/chains/tests/sequential_chain.test.js +0 -295
- package/dist/chains/tests/simple_sequential_chain.int.test.d.ts +0 -1
- package/dist/chains/tests/simple_sequential_chain.int.test.js +0 -81
- package/dist/chains/tests/simple_sequential_chain.test.d.ts +0 -1
- package/dist/chains/tests/simple_sequential_chain.test.js +0 -128
- package/dist/chains/tests/sql_db_chain.int.test.d.ts +0 -1
- package/dist/chains/tests/sql_db_chain.int.test.js +0 -125
- package/dist/chains/tests/transform.test.d.ts +0 -1
- package/dist/chains/tests/transform.test.js +0 -12
- package/dist/chains/tests/vector_db_qa_chain.int.test.d.ts +0 -1
- package/dist/chains/tests/vector_db_qa_chain.int.test.js +0 -45
- package/dist/document_loaders/tests/assemblyai.int.test.d.ts +0 -1
- package/dist/document_loaders/tests/assemblyai.int.test.js +0 -111
- package/dist/document_loaders/tests/chatgpt-blob.test.d.ts +0 -1
- package/dist/document_loaders/tests/chatgpt-blob.test.js +0 -30
- package/dist/document_loaders/tests/chatgpt.test.d.ts +0 -1
- package/dist/document_loaders/tests/chatgpt.test.js +0 -29
- package/dist/document_loaders/tests/cheerio.int.test.d.ts +0 -1
- package/dist/document_loaders/tests/cheerio.int.test.js +0 -21
- package/dist/document_loaders/tests/college_confidential.int.test.d.ts +0 -1
- package/dist/document_loaders/tests/college_confidential.int.test.js +0 -6
- package/dist/document_loaders/tests/confluence.test.d.ts +0 -1
- package/dist/document_loaders/tests/confluence.test.js +0 -52
- package/dist/document_loaders/tests/couchbase.int.test.d.ts +0 -1
- package/dist/document_loaders/tests/couchbase.int.test.js +0 -28
- package/dist/document_loaders/tests/csv-blob.test.d.ts +0 -1
- package/dist/document_loaders/tests/csv-blob.test.js +0 -53
- package/dist/document_loaders/tests/csv.test.d.ts +0 -1
- package/dist/document_loaders/tests/csv.test.js +0 -41
- package/dist/document_loaders/tests/directory.test.d.ts +0 -1
- package/dist/document_loaders/tests/directory.test.js +0 -38
- package/dist/document_loaders/tests/docx.test.d.ts +0 -1
- package/dist/document_loaders/tests/docx.test.js +0 -11
- package/dist/document_loaders/tests/epub.test.d.ts +0 -1
- package/dist/document_loaders/tests/epub.test.js +0 -18
- package/dist/document_loaders/tests/example_data/github_api_responses.d.ts +0 -5
- package/dist/document_loaders/tests/example_data/github_api_responses.js +0 -91
- package/dist/document_loaders/tests/figma.int.test.d.ts +0 -1
- package/dist/document_loaders/tests/figma.int.test.js +0 -13
- package/dist/document_loaders/tests/firecrawl.int.test.d.ts +0 -1
- package/dist/document_loaders/tests/firecrawl.int.test.js +0 -30
- package/dist/document_loaders/tests/gitbook.int.test.d.ts +0 -1
- package/dist/document_loaders/tests/gitbook.int.test.js +0 -14
- package/dist/document_loaders/tests/github.int.test.d.ts +0 -1
- package/dist/document_loaders/tests/github.int.test.js +0 -86
- package/dist/document_loaders/tests/github.test.d.ts +0 -1
- package/dist/document_loaders/tests/github.test.js +0 -51
- package/dist/document_loaders/tests/hn.int.test.d.ts +0 -1
- package/dist/document_loaders/tests/hn.int.test.js +0 -6
- package/dist/document_loaders/tests/imsdb.test.d.ts +0 -1
- package/dist/document_loaders/tests/imsdb.test.js +0 -6
- package/dist/document_loaders/tests/json-blob.test.d.ts +0 -1
- package/dist/document_loaders/tests/json-blob.test.js +0 -91
- package/dist/document_loaders/tests/json.test.d.ts +0 -1
- package/dist/document_loaders/tests/json.test.js +0 -69
- package/dist/document_loaders/tests/jsonl-blob.test.d.ts +0 -1
- package/dist/document_loaders/tests/jsonl-blob.test.js +0 -46
- package/dist/document_loaders/tests/jsonl.test.d.ts +0 -1
- package/dist/document_loaders/tests/jsonl.test.js +0 -15
- package/dist/document_loaders/tests/multi_file.test.d.ts +0 -1
- package/dist/document_loaders/tests/multi_file.test.js +0 -49
- package/dist/document_loaders/tests/notion.test.d.ts +0 -1
- package/dist/document_loaders/tests/notion.test.js +0 -11
- package/dist/document_loaders/tests/notionapi.int.test.d.ts +0 -1
- package/dist/document_loaders/tests/notionapi.int.test.js +0 -80
- package/dist/document_loaders/tests/notionapi.test.d.ts +0 -1
- package/dist/document_loaders/tests/notionapi.test.js +0 -84
- package/dist/document_loaders/tests/notiondb.int.test.d.ts +0 -1
- package/dist/document_loaders/tests/notiondb.int.test.js +0 -13
- package/dist/document_loaders/tests/obsidian.test.d.ts +0 -1
- package/dist/document_loaders/tests/obsidian.test.js +0 -119
- package/dist/document_loaders/tests/pdf-blob.test.d.ts +0 -1
- package/dist/document_loaders/tests/pdf-blob.test.js +0 -44
- package/dist/document_loaders/tests/pdf.test.d.ts +0 -1
- package/dist/document_loaders/tests/pdf.test.js +0 -25
- package/dist/document_loaders/tests/playwright_web.int.test.d.ts +0 -1
- package/dist/document_loaders/tests/playwright_web.int.test.js +0 -27
- package/dist/document_loaders/tests/pptx.test.d.ts +0 -1
- package/dist/document_loaders/tests/pptx.test.js +0 -17
- package/dist/document_loaders/tests/puppeteer.int.test.d.ts +0 -1
- package/dist/document_loaders/tests/puppeteer.int.test.js +0 -47
- package/dist/document_loaders/tests/recursive_url.int.test.d.ts +0 -1
- package/dist/document_loaders/tests/recursive_url.int.test.js +0 -64
- package/dist/document_loaders/tests/s3.int.test.d.ts +0 -1
- package/dist/document_loaders/tests/s3.int.test.js +0 -48
- package/dist/document_loaders/tests/searchapi.test.d.ts +0 -1
- package/dist/document_loaders/tests/searchapi.test.js +0 -29
- package/dist/document_loaders/tests/serpapi.test.d.ts +0 -1
- package/dist/document_loaders/tests/serpapi.test.js +0 -21
- package/dist/document_loaders/tests/sitemap.int.test.d.ts +0 -1
- package/dist/document_loaders/tests/sitemap.int.test.js +0 -28
- package/dist/document_loaders/tests/sonix_audio.int.test.d.ts +0 -1
- package/dist/document_loaders/tests/sonix_audio.int.test.js +0 -55
- package/dist/document_loaders/tests/sort_xyz_blockchain.int.test.d.ts +0 -1
- package/dist/document_loaders/tests/sort_xyz_blockchain.int.test.js +0 -38
- package/dist/document_loaders/tests/srt-blob.test.d.ts +0 -1
- package/dist/document_loaders/tests/srt-blob.test.js +0 -18
- package/dist/document_loaders/tests/srt.test.d.ts +0 -1
- package/dist/document_loaders/tests/srt.test.js +0 -16
- package/dist/document_loaders/tests/text-blob.test.d.ts +0 -1
- package/dist/document_loaders/tests/text-blob.test.js +0 -14
- package/dist/document_loaders/tests/text.test.d.ts +0 -1
- package/dist/document_loaders/tests/text.test.js +0 -22
- package/dist/document_loaders/tests/unstructured.int.test.d.ts +0 -1
- package/dist/document_loaders/tests/unstructured.int.test.js +0 -58
- package/dist/document_loaders/tests/webpdf.int.test.d.ts +0 -1
- package/dist/document_loaders/tests/webpdf.int.test.js +0 -90
- package/dist/document_transformers/tests/openai_functions.int.test.d.ts +0 -1
- package/dist/document_transformers/tests/openai_functions.int.test.js +0 -40
- package/dist/embeddings/tests/cache.test.d.ts +0 -1
- package/dist/embeddings/tests/cache.test.js +0 -24
- package/dist/embeddings/tests/fake.test.d.ts +0 -1
- package/dist/embeddings/tests/fake.test.js +0 -34
- package/dist/evaluation/agents/tests/trajectory_eval_chain.int.test.d.ts +0 -1
- package/dist/evaluation/agents/tests/trajectory_eval_chain.int.test.js +0 -33
- package/dist/evaluation/comparison/tests/pairwise_eval_chain.int.test.d.ts +0 -1
- package/dist/evaluation/comparison/tests/pairwise_eval_chain.int.test.js +0 -46
- package/dist/evaluation/criteria/tests/criteria_eval_chain.int.test.d.ts +0 -1
- package/dist/evaluation/criteria/tests/criteria_eval_chain.int.test.js +0 -108
- package/dist/evaluation/embedding_distance/tests/embedding_distance_eval_chain.int.test.d.ts +0 -1
- package/dist/evaluation/embedding_distance/tests/embedding_distance_eval_chain.int.test.js +0 -26
- package/dist/evaluation/qa/tests/eval_chain.int.test.d.ts +0 -1
- package/dist/evaluation/qa/tests/eval_chain.int.test.js +0 -27
- package/dist/experimental/autogpt/tests/output_parser.test.d.ts +0 -1
- package/dist/experimental/autogpt/tests/output_parser.test.js +0 -8
- package/dist/experimental/autogpt/tests/prompt.test.d.ts +0 -1
- package/dist/experimental/autogpt/tests/prompt.test.js +0 -69
- package/dist/experimental/autogpt/tests/prompt_generator.test.d.ts +0 -1
- package/dist/experimental/autogpt/tests/prompt_generator.test.js +0 -91
- package/dist/experimental/chains/tests/violation_of_expectations_chain.int.test.d.ts +0 -1
- package/dist/experimental/chains/tests/violation_of_expectations_chain.int.test.js +0 -26
- package/dist/experimental/generative_agents/tests/generative_agent.int.test.d.ts +0 -1
- package/dist/experimental/generative_agents/tests/generative_agent.int.test.js +0 -304
- package/dist/experimental/masking/tests/masking-extended.test.d.ts +0 -1
- package/dist/experimental/masking/tests/masking-extended.test.js +0 -58
- package/dist/experimental/masking/tests/masking.test.d.ts +0 -1
- package/dist/experimental/masking/tests/masking.test.js +0 -388
- package/dist/experimental/openai_assistant/tests/openai_assistant.int.test.d.ts +0 -1
- package/dist/experimental/openai_assistant/tests/openai_assistant.int.test.js +0 -203
- package/dist/experimental/openai_files/tests/openai_file.int.test.d.ts +0 -1
- package/dist/experimental/openai_files/tests/openai_file.int.test.js +0 -87
- package/dist/experimental/plan_and_execute/tests/plan_and_execute.int.test.d.ts +0 -1
- package/dist/experimental/plan_and_execute/tests/plan_and_execute.int.test.js +0 -54
- package/dist/experimental/prompts/tests/handlebars.test.d.ts +0 -1
- package/dist/experimental/prompts/tests/handlebars.test.js +0 -24
- package/dist/experimental/tools/tests/pyinterpreter.int.test.d.ts +0 -1
- package/dist/experimental/tools/tests/pyinterpreter.int.test.js +0 -22
- package/dist/load/tests/cross_language.test.d.ts +0 -1
- package/dist/load/tests/cross_language.test.js +0 -83
- package/dist/load/tests/load.int.test.d.ts +0 -1
- package/dist/load/tests/load.int.test.js +0 -9
- package/dist/load/tests/load.test.d.ts +0 -1
- package/dist/load/tests/load.test.js +0 -412
- package/dist/memory/tests/buffer_memory.test.d.ts +0 -1
- package/dist/memory/tests/buffer_memory.test.js +0 -34
- package/dist/memory/tests/buffer_token_memory.int.test.d.ts +0 -1
- package/dist/memory/tests/buffer_token_memory.int.test.js +0 -47
- package/dist/memory/tests/buffer_window_memory.test.d.ts +0 -1
- package/dist/memory/tests/buffer_window_memory.test.js +0 -42
- package/dist/memory/tests/combined_memory.int.test.d.ts +0 -1
- package/dist/memory/tests/combined_memory.int.test.js +0 -74
- package/dist/memory/tests/entity_memory.int.test.d.ts +0 -1
- package/dist/memory/tests/entity_memory.int.test.js +0 -79
- package/dist/memory/tests/entity_memory.test.d.ts +0 -1
- package/dist/memory/tests/entity_memory.test.js +0 -48
- package/dist/memory/tests/summary.int.test.d.ts +0 -1
- package/dist/memory/tests/summary.int.test.js +0 -50
- package/dist/memory/tests/summary_buffer.int.test.d.ts +0 -1
- package/dist/memory/tests/summary_buffer.int.test.js +0 -55
- package/dist/memory/tests/vector_store_memory.int.test.d.ts +0 -1
- package/dist/memory/tests/vector_store_memory.int.test.js +0 -55
- package/dist/output_parsers/tests/combining.int.test.d.ts +0 -1
- package/dist/output_parsers/tests/combining.int.test.js +0 -26
- package/dist/output_parsers/tests/combining.test.d.ts +0 -1
- package/dist/output_parsers/tests/combining.test.js +0 -54
- package/dist/output_parsers/tests/datetime.test.d.ts +0 -1
- package/dist/output_parsers/tests/datetime.test.js +0 -14
- package/dist/output_parsers/tests/expression.test.d.ts +0 -1
- package/dist/output_parsers/tests/expression.test.js +0 -339
- package/dist/output_parsers/tests/http_response.test.d.ts +0 -1
- package/dist/output_parsers/tests/http_response.test.js +0 -39
- package/dist/output_parsers/tests/list.test.d.ts +0 -1
- package/dist/output_parsers/tests/list.test.js +0 -27
- package/dist/output_parsers/tests/openai_functions.int.test.d.ts +0 -1
- package/dist/output_parsers/tests/openai_functions.int.test.js +0 -89
- package/dist/output_parsers/tests/openai_tools.int.test.d.ts +0 -1
- package/dist/output_parsers/tests/openai_tools.int.test.js +0 -36
- package/dist/output_parsers/tests/structured.int.test.d.ts +0 -1
- package/dist/output_parsers/tests/structured.int.test.js +0 -150
- package/dist/prompts/tests/selectors.test.d.ts +0 -1
- package/dist/prompts/tests/selectors.test.js +0 -59
- package/dist/retrievers/self_query/tests/memory_self_query.int.test.d.ts +0 -1
- package/dist/retrievers/self_query/tests/memory_self_query.int.test.js +0 -330
- package/dist/retrievers/tests/chain_extract.int.test.d.ts +0 -1
- package/dist/retrievers/tests/chain_extract.int.test.js +0 -32
- package/dist/retrievers/tests/ensemble_retriever.int.test.d.ts +0 -1
- package/dist/retrievers/tests/ensemble_retriever.int.test.js +0 -74
- package/dist/retrievers/tests/hyde.int.test.d.ts +0 -1
- package/dist/retrievers/tests/hyde.int.test.js +0 -44
- package/dist/retrievers/tests/matryoshka_retriever.int.test.d.ts +0 -1
- package/dist/retrievers/tests/matryoshka_retriever.int.test.js +0 -113
- package/dist/retrievers/tests/multi_query.int.test.d.ts +0 -1
- package/dist/retrievers/tests/multi_query.int.test.js +0 -45
- package/dist/retrievers/tests/parent_document.int.test.d.ts +0 -1
- package/dist/retrievers/tests/parent_document.int.test.js +0 -122
- package/dist/retrievers/tests/score_threshold.int.test.d.ts +0 -1
- package/dist/retrievers/tests/score_threshold.int.test.js +0 -83
- package/dist/retrievers/tests/time_weighted.test.d.ts +0 -1
- package/dist/retrievers/tests/time_weighted.test.js +0 -320
- package/dist/retrievers/tests/vectorstores.test.d.ts +0 -1
- package/dist/retrievers/tests/vectorstores.test.js +0 -50
- package/dist/smith/tests/run_on_dataset.int.test.d.ts +0 -1
- package/dist/smith/tests/run_on_dataset.int.test.js +0 -257
- package/dist/smith/tests/runner_utils.int.test.d.ts +0 -9
- package/dist/smith/tests/runner_utils.int.test.js +0 -234
- package/dist/storage/tests/file_system.test.d.ts +0 -1
- package/dist/storage/tests/file_system.test.js +0 -81
- package/dist/tools/tests/chain.test.d.ts +0 -1
- package/dist/tools/tests/chain.test.js +0 -136
- package/dist/tools/tests/webbrowser.int.test.d.ts +0 -1
- package/dist/tools/tests/webbrowser.int.test.js +0 -80
- package/dist/tools/tests/webbrowser.test.d.ts +0 -1
- package/dist/tools/tests/webbrowser.test.js +0 -21
- package/dist/util/tests/async_caller.int.test.d.ts +0 -1
- package/dist/util/tests/async_caller.int.test.js +0 -34
- package/dist/util/tests/azure.test.d.ts +0 -1
- package/dist/util/tests/azure.test.js +0 -42
- package/dist/util/tests/openai-stream.test.d.ts +0 -1
- package/dist/util/tests/openai-stream.test.js +0 -135
- package/dist/util/tests/set.test.d.ts +0 -1
- package/dist/util/tests/set.test.js +0 -36
- package/dist/util/tests/sql_utils.test.d.ts +0 -1
- package/dist/util/tests/sql_utils.test.js +0 -50
- package/dist/vectorstores/tests/memory.test.d.ts +0 -1
- package/dist/vectorstores/tests/memory.test.js +0 -78
|
@@ -12,6 +12,7 @@ exports.optionalImportEntrypoints = [
|
|
|
12
12
|
"langchain/chains/query_constructor/ir",
|
|
13
13
|
"langchain/chains/sql_db",
|
|
14
14
|
"langchain/chains/graph_qa/cypher",
|
|
15
|
+
"langchain/chat_models/universal",
|
|
15
16
|
"langchain/document_loaders/web/apify_dataset",
|
|
16
17
|
"langchain/document_loaders/web/assemblyai",
|
|
17
18
|
"langchain/document_loaders/web/azure_blob_storage_container",
|
|
@@ -9,6 +9,7 @@ export const optionalImportEntrypoints = [
|
|
|
9
9
|
"langchain/chains/query_constructor/ir",
|
|
10
10
|
"langchain/chains/sql_db",
|
|
11
11
|
"langchain/chains/graph_qa/cypher",
|
|
12
|
+
"langchain/chat_models/universal",
|
|
12
13
|
"langchain/document_loaders/web/apify_dataset",
|
|
13
14
|
"langchain/document_loaders/web/assemblyai",
|
|
14
15
|
"langchain/document_loaders/web/azure_blob_storage_container",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "langchain",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.11",
|
|
4
4
|
"description": "Typescript bindings for langchain",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -134,6 +134,10 @@
|
|
|
134
134
|
"chains/graph_qa/cypher.js",
|
|
135
135
|
"chains/graph_qa/cypher.d.ts",
|
|
136
136
|
"chains/graph_qa/cypher.d.cts",
|
|
137
|
+
"chat_models/universal.cjs",
|
|
138
|
+
"chat_models/universal.js",
|
|
139
|
+
"chat_models/universal.d.ts",
|
|
140
|
+
"chat_models/universal.d.cts",
|
|
137
141
|
"embeddings/cache_backed.cjs",
|
|
138
142
|
"embeddings/cache_backed.js",
|
|
139
143
|
"embeddings/cache_backed.d.ts",
|
|
@@ -570,7 +574,7 @@
|
|
|
570
574
|
"homepage": "https://github.com/langchain-ai/langchainjs/tree/main/langchain/",
|
|
571
575
|
"scripts": {
|
|
572
576
|
"build": "yarn turbo:command build:internal --filter=langchain",
|
|
573
|
-
"build:internal": "yarn
|
|
577
|
+
"build:internal": "yarn lc_build_v2 --create-entrypoints --pre --tree-shaking --gen-maps",
|
|
574
578
|
"build:deps": "yarn run turbo:command build --filter=@langchain/openai --filter=@langchain/textsplitters --filter=@langchain/cohere --concurrency=1",
|
|
575
579
|
"build:esm": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist/ && rimraf dist/tests dist/**/tests",
|
|
576
580
|
"build:cjs": "NODE_OPTIONS=--max-old-space-size=4096 tsc --outDir dist-cjs/ -p tsconfig.cjs.json && yarn move-cjs-to-dist && rimraf dist-cjs",
|
|
@@ -609,8 +613,15 @@
|
|
|
609
613
|
"@gomomento/sdk": "^1.51.1",
|
|
610
614
|
"@gomomento/sdk-core": "^1.51.1",
|
|
611
615
|
"@jest/globals": "^29.5.0",
|
|
612
|
-
"@langchain/
|
|
613
|
-
"@langchain/
|
|
616
|
+
"@langchain/anthropic": "^0.2.8",
|
|
617
|
+
"@langchain/aws": "^0.0.5",
|
|
618
|
+
"@langchain/cohere": "^0.2.1",
|
|
619
|
+
"@langchain/google-genai": "^0.0.23",
|
|
620
|
+
"@langchain/google-vertexai": "^0.0.20",
|
|
621
|
+
"@langchain/groq": "^0.0.15",
|
|
622
|
+
"@langchain/mistralai": "^0.0.26",
|
|
623
|
+
"@langchain/ollama": "^0.0.2",
|
|
624
|
+
"@langchain/scripts": "~0.0.20",
|
|
614
625
|
"@mendable/firecrawl-js": "^0.0.13",
|
|
615
626
|
"@notionhq/client": "^2.2.10",
|
|
616
627
|
"@pinecone-database/pinecone": "^1.1.0",
|
|
@@ -632,7 +643,7 @@
|
|
|
632
643
|
"@vercel/kv": "^0.2.3",
|
|
633
644
|
"@xata.io/client": "^0.28.0",
|
|
634
645
|
"apify-client": "^2.7.1",
|
|
635
|
-
"assemblyai": "^4.
|
|
646
|
+
"assemblyai": "^4.6.0",
|
|
636
647
|
"axios": "^0.26.0",
|
|
637
648
|
"cheerio": "^1.0.0-rc.12",
|
|
638
649
|
"chromadb": "^1.5.3",
|
|
@@ -694,6 +705,15 @@
|
|
|
694
705
|
"@gomomento/sdk": "^1.51.1",
|
|
695
706
|
"@gomomento/sdk-core": "^1.51.1",
|
|
696
707
|
"@gomomento/sdk-web": "^1.51.1",
|
|
708
|
+
"@langchain/anthropic": "*",
|
|
709
|
+
"@langchain/aws": "*",
|
|
710
|
+
"@langchain/cohere": "*",
|
|
711
|
+
"@langchain/community": "*",
|
|
712
|
+
"@langchain/google-genai": "*",
|
|
713
|
+
"@langchain/google-vertexai": "*",
|
|
714
|
+
"@langchain/groq": "*",
|
|
715
|
+
"@langchain/mistralai": "*",
|
|
716
|
+
"@langchain/ollama": "*",
|
|
697
717
|
"@mendable/firecrawl-js": "^0.0.13",
|
|
698
718
|
"@notionhq/client": "^2.2.10",
|
|
699
719
|
"@pinecone-database/pinecone": "*",
|
|
@@ -701,7 +721,7 @@
|
|
|
701
721
|
"@vercel/kv": "^0.2.3",
|
|
702
722
|
"@xata.io/client": "^0.28.0",
|
|
703
723
|
"apify-client": "^2.7.1",
|
|
704
|
-
"assemblyai": "^4.
|
|
724
|
+
"assemblyai": "^4.6.0",
|
|
705
725
|
"axios": "*",
|
|
706
726
|
"cheerio": "^1.0.0-rc.12",
|
|
707
727
|
"chromadb": "*",
|
|
@@ -763,6 +783,36 @@
|
|
|
763
783
|
"@gomomento/sdk-web": {
|
|
764
784
|
"optional": true
|
|
765
785
|
},
|
|
786
|
+
"@langchain/anthropic": {
|
|
787
|
+
"optional": true
|
|
788
|
+
},
|
|
789
|
+
"@langchain/aws": {
|
|
790
|
+
"optional": true
|
|
791
|
+
},
|
|
792
|
+
"@langchain/cohere": {
|
|
793
|
+
"optional": true
|
|
794
|
+
},
|
|
795
|
+
"@langchain/community": {
|
|
796
|
+
"optional": true
|
|
797
|
+
},
|
|
798
|
+
"@langchain/google-genai": {
|
|
799
|
+
"optional": true
|
|
800
|
+
},
|
|
801
|
+
"@langchain/google-vertexai": {
|
|
802
|
+
"optional": true
|
|
803
|
+
},
|
|
804
|
+
"@langchain/google-vertexai-web": {
|
|
805
|
+
"optional": true
|
|
806
|
+
},
|
|
807
|
+
"@langchain/groq": {
|
|
808
|
+
"optional": true
|
|
809
|
+
},
|
|
810
|
+
"@langchain/mistralai": {
|
|
811
|
+
"optional": true
|
|
812
|
+
},
|
|
813
|
+
"@langchain/ollama": {
|
|
814
|
+
"optional": true
|
|
815
|
+
},
|
|
766
816
|
"@mendable/firecrawl-js": {
|
|
767
817
|
"optional": true
|
|
768
818
|
},
|
|
@@ -1202,6 +1252,15 @@
|
|
|
1202
1252
|
"import": "./chains/graph_qa/cypher.js",
|
|
1203
1253
|
"require": "./chains/graph_qa/cypher.cjs"
|
|
1204
1254
|
},
|
|
1255
|
+
"./chat_models/universal": {
|
|
1256
|
+
"types": {
|
|
1257
|
+
"import": "./chat_models/universal.d.ts",
|
|
1258
|
+
"require": "./chat_models/universal.d.cts",
|
|
1259
|
+
"default": "./chat_models/universal.d.ts"
|
|
1260
|
+
},
|
|
1261
|
+
"import": "./chat_models/universal.js",
|
|
1262
|
+
"require": "./chat_models/universal.cjs"
|
|
1263
|
+
},
|
|
1205
1264
|
"./embeddings/cache_backed": {
|
|
1206
1265
|
"types": {
|
|
1207
1266
|
"import": "./embeddings/cache_backed.d.ts",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,309 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-process-env */
|
|
2
|
-
import { expect, test } from "@jest/globals";
|
|
3
|
-
import { OpenAI, OpenAIEmbeddings, ChatOpenAI } from "@langchain/openai";
|
|
4
|
-
import { RunnableSequence } from "@langchain/core/runnables";
|
|
5
|
-
import { OutputParserException } from "@langchain/core/output_parsers";
|
|
6
|
-
import { ChatMessageHistory } from "../../stores/message/in_memory.js";
|
|
7
|
-
import { AgentExecutor, ZeroShotAgent } from "../index.js";
|
|
8
|
-
import { SerpAPI } from "../../util/testing/tools/serpapi.js";
|
|
9
|
-
import { Calculator } from "../../util/testing/tools/calculator.js";
|
|
10
|
-
import { initializeAgentExecutorWithOptions } from "../initialize.js";
|
|
11
|
-
import { WebBrowser } from "../../tools/webbrowser.js";
|
|
12
|
-
import { BufferMemory } from "../../memory/buffer_memory.js";
|
|
13
|
-
test("Pass runnable to agent executor", async () => {
|
|
14
|
-
const model = new ChatOpenAI({ temperature: 0, modelName: "gpt-3.5-turbo" });
|
|
15
|
-
const tools = [
|
|
16
|
-
new SerpAPI(undefined, {
|
|
17
|
-
location: "Austin,Texas,United States",
|
|
18
|
-
hl: "en",
|
|
19
|
-
gl: "us",
|
|
20
|
-
}),
|
|
21
|
-
new Calculator(),
|
|
22
|
-
];
|
|
23
|
-
const prompt = ZeroShotAgent.createPrompt(tools);
|
|
24
|
-
const outputParser = ZeroShotAgent.getDefaultOutputParser();
|
|
25
|
-
const runnable = RunnableSequence.from([
|
|
26
|
-
{
|
|
27
|
-
input: (i) => i.input,
|
|
28
|
-
agent_scratchpad: (i) => i.input,
|
|
29
|
-
},
|
|
30
|
-
prompt,
|
|
31
|
-
model,
|
|
32
|
-
outputParser,
|
|
33
|
-
]);
|
|
34
|
-
const executor = AgentExecutor.fromAgentAndTools({
|
|
35
|
-
agent: runnable,
|
|
36
|
-
tools,
|
|
37
|
-
});
|
|
38
|
-
const res = await executor.invoke({
|
|
39
|
-
input: "Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power?",
|
|
40
|
-
});
|
|
41
|
-
console.log({
|
|
42
|
-
res,
|
|
43
|
-
}, "Pass runnable to agent executor");
|
|
44
|
-
expect(res.output).not.toEqual("");
|
|
45
|
-
expect(res.output).not.toEqual("Agent stopped due to max iterations.");
|
|
46
|
-
});
|
|
47
|
-
test("Custom output parser", async () => {
|
|
48
|
-
const model = new ChatOpenAI({ temperature: 0, modelName: "gpt-3.5-turbo" });
|
|
49
|
-
const tools = [
|
|
50
|
-
new SerpAPI(undefined, {
|
|
51
|
-
location: "Austin,Texas,United States",
|
|
52
|
-
hl: "en",
|
|
53
|
-
gl: "us",
|
|
54
|
-
}),
|
|
55
|
-
new Calculator(),
|
|
56
|
-
];
|
|
57
|
-
const parser = (output) => {
|
|
58
|
-
const text = output.content;
|
|
59
|
-
if (typeof text !== "string") {
|
|
60
|
-
throw new Error("Cannot parse non-string output.");
|
|
61
|
-
}
|
|
62
|
-
if (text.includes("Final Answer:")) {
|
|
63
|
-
return {
|
|
64
|
-
returnValues: {
|
|
65
|
-
output: "We did it!",
|
|
66
|
-
},
|
|
67
|
-
log: text,
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
const match = /Action:([\s\S]*?)(?:\nAction Input:([\s\S]*?))?$/.exec(text);
|
|
71
|
-
if (!match) {
|
|
72
|
-
throw new OutputParserException(`Could not parse LLM output: ${text}`);
|
|
73
|
-
}
|
|
74
|
-
return {
|
|
75
|
-
tool: match[1].trim(),
|
|
76
|
-
toolInput: match[2]
|
|
77
|
-
? match[2].trim().replace(/^("+)(.*?)(\1)$/, "$2")
|
|
78
|
-
: "",
|
|
79
|
-
log: text,
|
|
80
|
-
};
|
|
81
|
-
};
|
|
82
|
-
const prompt = ZeroShotAgent.createPrompt(tools);
|
|
83
|
-
const runnable = RunnableSequence.from([
|
|
84
|
-
{
|
|
85
|
-
input: (i) => i.input,
|
|
86
|
-
agent_scratchpad: (i) => i.input,
|
|
87
|
-
},
|
|
88
|
-
prompt,
|
|
89
|
-
model,
|
|
90
|
-
parser,
|
|
91
|
-
]);
|
|
92
|
-
const executor = AgentExecutor.fromAgentAndTools({
|
|
93
|
-
agent: runnable,
|
|
94
|
-
tools,
|
|
95
|
-
});
|
|
96
|
-
const res = await executor.invoke({
|
|
97
|
-
input: "Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power?",
|
|
98
|
-
});
|
|
99
|
-
console.log({
|
|
100
|
-
res,
|
|
101
|
-
}, "Custom output parser");
|
|
102
|
-
expect(res.output).toEqual("We did it!");
|
|
103
|
-
});
|
|
104
|
-
test("Add a fallback method", async () => {
|
|
105
|
-
// Model should always fail since the model name passed does not exist.
|
|
106
|
-
const modelBase = new ChatOpenAI({
|
|
107
|
-
modelName: "fake-model",
|
|
108
|
-
temperature: 10,
|
|
109
|
-
});
|
|
110
|
-
const modelLarge = new ChatOpenAI({
|
|
111
|
-
modelName: "gpt-3.5-turbo-16k",
|
|
112
|
-
temperature: 0.6,
|
|
113
|
-
});
|
|
114
|
-
const model = modelBase.withFallbacks({
|
|
115
|
-
fallbacks: [modelLarge],
|
|
116
|
-
});
|
|
117
|
-
const prompt = ZeroShotAgent.createPrompt([]);
|
|
118
|
-
const outputParser = ZeroShotAgent.getDefaultOutputParser();
|
|
119
|
-
const runnable = RunnableSequence.from([
|
|
120
|
-
{
|
|
121
|
-
input: (i) => i.input,
|
|
122
|
-
agent_scratchpad: (i) => i.input,
|
|
123
|
-
},
|
|
124
|
-
prompt,
|
|
125
|
-
model,
|
|
126
|
-
outputParser,
|
|
127
|
-
]);
|
|
128
|
-
const executor = AgentExecutor.fromAgentAndTools({
|
|
129
|
-
agent: runnable,
|
|
130
|
-
tools: [],
|
|
131
|
-
});
|
|
132
|
-
const res = await executor.invoke({
|
|
133
|
-
input: "Is the sky blue? Response with a concise answer",
|
|
134
|
-
});
|
|
135
|
-
console.log({
|
|
136
|
-
res,
|
|
137
|
-
}, "Pass runnable to agent executor");
|
|
138
|
-
expect(res.output).not.toEqual("");
|
|
139
|
-
expect(res.output).not.toEqual("Agent stopped due to max iterations.");
|
|
140
|
-
});
|
|
141
|
-
test("Run agent with an abort signal", async () => {
|
|
142
|
-
const model = new OpenAI({ temperature: 0, modelName: "text-babbage-001" });
|
|
143
|
-
const tools = [new Calculator()];
|
|
144
|
-
const executor = await initializeAgentExecutorWithOptions(tools, model, {
|
|
145
|
-
agentType: "zero-shot-react-description",
|
|
146
|
-
});
|
|
147
|
-
console.log("Loaded agent.");
|
|
148
|
-
const input = `What is 3 to the fourth power?`;
|
|
149
|
-
console.log(`Executing with input "${input}"...`);
|
|
150
|
-
const controller = new AbortController();
|
|
151
|
-
await expect(() => {
|
|
152
|
-
const result = executor.call({ input, signal: controller.signal });
|
|
153
|
-
controller.abort();
|
|
154
|
-
return result;
|
|
155
|
-
}).rejects.toThrow();
|
|
156
|
-
});
|
|
157
|
-
test("Run agent with incorrect api key should throw error", async () => {
|
|
158
|
-
const model = new OpenAI({
|
|
159
|
-
temperature: 0,
|
|
160
|
-
modelName: "text-babbage-001",
|
|
161
|
-
openAIApiKey: "invalid",
|
|
162
|
-
});
|
|
163
|
-
const tools = [
|
|
164
|
-
new SerpAPI(undefined, {
|
|
165
|
-
location: "Austin,Texas,United States",
|
|
166
|
-
hl: "en",
|
|
167
|
-
gl: "us",
|
|
168
|
-
}),
|
|
169
|
-
new Calculator(),
|
|
170
|
-
];
|
|
171
|
-
const executor = await initializeAgentExecutorWithOptions(tools, model, {
|
|
172
|
-
agentType: "zero-shot-react-description",
|
|
173
|
-
});
|
|
174
|
-
console.log("Loaded agent.");
|
|
175
|
-
const input = `Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power?`;
|
|
176
|
-
let error;
|
|
177
|
-
// Test that the model throws an error
|
|
178
|
-
await expect(async () => {
|
|
179
|
-
try {
|
|
180
|
-
await model.invoke(input);
|
|
181
|
-
}
|
|
182
|
-
catch (e) {
|
|
183
|
-
error = e;
|
|
184
|
-
throw e;
|
|
185
|
-
}
|
|
186
|
-
}).rejects.toThrowError();
|
|
187
|
-
// Test that the agent throws the same error
|
|
188
|
-
await expect(() => executor.call({ input })).rejects.toThrowError(
|
|
189
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
190
|
-
error.message);
|
|
191
|
-
}, 10000);
|
|
192
|
-
test("Run tool web-browser", async () => {
|
|
193
|
-
const model = new OpenAI({ temperature: 0 });
|
|
194
|
-
const tools = [
|
|
195
|
-
new SerpAPI(process.env.SERPAPI_API_KEY, {
|
|
196
|
-
location: "Austin,Texas,United States",
|
|
197
|
-
hl: "en",
|
|
198
|
-
gl: "us",
|
|
199
|
-
}),
|
|
200
|
-
new Calculator(),
|
|
201
|
-
new WebBrowser({ model, embeddings: new OpenAIEmbeddings() }),
|
|
202
|
-
];
|
|
203
|
-
const executor = await initializeAgentExecutorWithOptions(tools, model, {
|
|
204
|
-
agentType: "zero-shot-react-description",
|
|
205
|
-
returnIntermediateSteps: true,
|
|
206
|
-
});
|
|
207
|
-
console.log("Loaded agent.");
|
|
208
|
-
const input = `What is the word of the day on merriam webster`;
|
|
209
|
-
console.log(`Executing with input "${input}"...`);
|
|
210
|
-
const result = await executor.call({ input });
|
|
211
|
-
console.log({
|
|
212
|
-
result,
|
|
213
|
-
}, "Run tool web-browser");
|
|
214
|
-
expect(result.intermediateSteps.length).toBeGreaterThanOrEqual(1);
|
|
215
|
-
expect(result.intermediateSteps[0].action.tool).toEqual("search");
|
|
216
|
-
expect(result.intermediateSteps[1].action.tool).toEqual("web-browser");
|
|
217
|
-
expect(result.output).not.toEqual("");
|
|
218
|
-
expect(result.output).not.toEqual("Agent stopped due to max iterations.");
|
|
219
|
-
});
|
|
220
|
-
test("Agent can stream", async () => {
|
|
221
|
-
const model = new ChatOpenAI({
|
|
222
|
-
temperature: 0,
|
|
223
|
-
modelName: "gpt-4-1106-preview",
|
|
224
|
-
streaming: true,
|
|
225
|
-
});
|
|
226
|
-
const tools = [
|
|
227
|
-
new Calculator(),
|
|
228
|
-
new WebBrowser({ model, embeddings: new OpenAIEmbeddings() }),
|
|
229
|
-
];
|
|
230
|
-
const executor = await initializeAgentExecutorWithOptions(tools, model, {
|
|
231
|
-
agentType: "zero-shot-react-description",
|
|
232
|
-
returnIntermediateSteps: false,
|
|
233
|
-
});
|
|
234
|
-
console.log("Loaded agent.");
|
|
235
|
-
const input = `What is the word of the day on merriam webster`;
|
|
236
|
-
console.log(`Executing with input "${input}"...`);
|
|
237
|
-
const result = await executor.stream({ input });
|
|
238
|
-
let streamIters = 0;
|
|
239
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
240
|
-
const finalResponse = [];
|
|
241
|
-
for await (const item of result) {
|
|
242
|
-
streamIters += 1;
|
|
243
|
-
console.log("Stream item:", item);
|
|
244
|
-
// each stream does NOT contain the previous steps,
|
|
245
|
-
// because returnIntermediateSteps is false so we
|
|
246
|
-
// push each new stream item to the array.
|
|
247
|
-
finalResponse.push(item);
|
|
248
|
-
}
|
|
249
|
-
// The last item should contain "output"
|
|
250
|
-
expect("output" in finalResponse[finalResponse.length - 1]).toBeTruthy();
|
|
251
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
252
|
-
const intermediateSteps = finalResponse.flatMap((item) => {
|
|
253
|
-
if ("intermediateSteps" in item) {
|
|
254
|
-
return item.intermediateSteps;
|
|
255
|
-
}
|
|
256
|
-
return [];
|
|
257
|
-
});
|
|
258
|
-
expect(streamIters).toBeGreaterThan(1);
|
|
259
|
-
const toolsUsed = intermediateSteps.map((step) => step.action.tool);
|
|
260
|
-
// the last tool used should be the web-browser
|
|
261
|
-
expect(toolsUsed?.[toolsUsed.length - 1]).toEqual("web-browser");
|
|
262
|
-
});
|
|
263
|
-
test("Agent can stream with chat messages", async () => {
|
|
264
|
-
const model = new ChatOpenAI({
|
|
265
|
-
temperature: 0,
|
|
266
|
-
modelName: "gpt-4-1106-preview",
|
|
267
|
-
streaming: true,
|
|
268
|
-
});
|
|
269
|
-
const tools = [
|
|
270
|
-
new Calculator(),
|
|
271
|
-
new WebBrowser({ model, embeddings: new OpenAIEmbeddings() }),
|
|
272
|
-
];
|
|
273
|
-
const memory = new BufferMemory({
|
|
274
|
-
chatHistory: new ChatMessageHistory([]),
|
|
275
|
-
memoryKey: "chat_history",
|
|
276
|
-
inputKey: "input",
|
|
277
|
-
outputKey: "output",
|
|
278
|
-
returnMessages: true,
|
|
279
|
-
});
|
|
280
|
-
const executor = await initializeAgentExecutorWithOptions(tools, model, {
|
|
281
|
-
agentType: "chat-conversational-react-description",
|
|
282
|
-
returnIntermediateSteps: true,
|
|
283
|
-
memory,
|
|
284
|
-
});
|
|
285
|
-
console.log("Loaded agent.");
|
|
286
|
-
const input = `What is the word of the day on merriam webster, and what is the sum of all letter indices (relative to the english alphabet) in the word?`;
|
|
287
|
-
console.log(`Executing with input "${input}"...`);
|
|
288
|
-
const result = await executor.stream({ input, chat_history: [] });
|
|
289
|
-
let streamIters = 0;
|
|
290
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
291
|
-
let finalResponse;
|
|
292
|
-
for await (const item of result) {
|
|
293
|
-
streamIters += 1;
|
|
294
|
-
console.log("Stream item:", item);
|
|
295
|
-
// each stream contains the previous steps
|
|
296
|
-
// because returnIntermediateSteps is true),
|
|
297
|
-
// so we can overwrite on each stream.
|
|
298
|
-
finalResponse = item;
|
|
299
|
-
}
|
|
300
|
-
console.log("__finalResponse__", finalResponse);
|
|
301
|
-
expect("intermediateSteps" in finalResponse).toBeTruthy();
|
|
302
|
-
expect("output" in finalResponse).toBeTruthy();
|
|
303
|
-
expect(streamIters).toBeGreaterThan(1);
|
|
304
|
-
const toolsUsed = finalResponse.intermediateSteps.map((step) => step.action.tool);
|
|
305
|
-
// the first tool used should be web-browser, and last should be calculator.
|
|
306
|
-
// This can be flaky so if the test is failing, inspect these conditions first.
|
|
307
|
-
expect(toolsUsed?.[toolsUsed.length - 1]).toEqual("calculator");
|
|
308
|
-
expect(toolsUsed?.[0]).toEqual("web-browser");
|
|
309
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { test, expect } from "@jest/globals";
|
|
2
|
-
import { ChatConversationalAgentOutputParser } from "../chat_convo/outputParser.js";
|
|
3
|
-
test("Can parse JSON with text in front of it", async () => {
|
|
4
|
-
const testCases = [
|
|
5
|
-
{
|
|
6
|
-
input: `Based on the information from the search, I can provide you with a query to get all the orders for the email \`example@gmail.com\`. Here's the query:\n\n\`\`\`sql\nSELECT * FROM orders\nJOIN users ON users.id = orders.user_id\nWHERE users.email = 'example@gmail.com'\n\`\`\`\n\nPlease make any necessary modifications depending on your database schema and table structures. Run this query on your database to retrieve the orders made by the specified user.\n\n\`\`\`json\n{\n "action": "Final Answer",\n "action_input": "To get all the orders for a user with the email \`example@gmail.com\`, you can use the following query:\\n\\n\`\`\`\\nSELECT * FROM orders\\nJOIN users ON users.id = orders.user_id\\nWHERE users.email = 'example@gmail.com'\\n\`\`\`\\n\\nPlease make any necessary modifications depending on your database schema and table structures. Run this query on your database to retrieve the orders made by the specified user."\n}\n\`\`\``,
|
|
7
|
-
output: `{\n "action": "Final Answer",\n "action_input": "To get all the orders for a user with the email \`example@gmail.com\`, you can use the following query:\\n\\n\`\`\`\\nSELECT * FROM orders\\nJOIN users ON users.id = orders.user_id\\nWHERE users.email = 'example@gmail.com'\\n\`\`\`\\n\\nPlease make any necessary modifications depending on your database schema and table structures. Run this query on your database to retrieve the made by the specifsredroied user."\n}`,
|
|
8
|
-
tool: "Final Answer",
|
|
9
|
-
toolInput: "To get all the orders for a user with the email ",
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
input: 'Here is an example of a valid JSON object matching the provided spec:\n\n```json\n{\n "action": "metabase",\n "action_input": ["GET", "/api/table/1"]\n}\n```\n\nIn this example, the "action" key has a string value of "metabase", and the "action_input" key has an array value containing two elements: a string value of "GET" and a string value of "/api/table/1". This JSON object could be used to make a request to a Metabase API endpoint with the specified method and arguments.',
|
|
13
|
-
output: `{ "action": "metabase", "action_input": ["GET", "/api/table/1"] } `,
|
|
14
|
-
tool: "metabase",
|
|
15
|
-
toolInput: ["GET", "/api/table/1"],
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
input: '```\n{\n "action": "metabase",\n "action_input": ["GET", "/api/table/1"]\n}\n```',
|
|
19
|
-
output: `{ "action": "metabase", "action_input": ["GET", "/api/table/1"] } `,
|
|
20
|
-
tool: "metabase",
|
|
21
|
-
toolInput: ["GET", "/api/table/1"],
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
input: 'Here we have some boilerplate nonsense```\n{\n "action": "blogpost",\n "action_input": "```sql\\nSELECT * FROM orders\\nJOIN users ON users.id = orders.user_id\\nWHERE users.email = \'bud\'```"\n}\n``` and at the end there is more nonsense',
|
|
25
|
-
output: '{"action":"blogpost","action_input":"```sql\\nSELECT * FROM orders\\nJOIN users ON users.id = orders.user_id\\nWHERE users.email = \'bud\'```"}',
|
|
26
|
-
tool: "blogpost",
|
|
27
|
-
toolInput: "```sql\nSELECT * FROM orders\nJOIN users ON users.id = orders.user_id\nWHERE users.email = 'bud'```",
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
input: 'Here we have some boilerplate nonsense```json\n{\n \t\r\n"action": "blogpost",\n\t\r "action_input": "```sql\\nSELECT * FROM orders\\nJOIN users ON users.id = orders.user_id\\nWHERE users.email = \'bud\'```"\n\t\r}\n\n\n\t\r``` and at the end there is more nonsense',
|
|
31
|
-
output: '{"action":"blogpost","action_input":"```sql\\nSELECT * FROM orders\\nJOIN users ON users.id = orders.user_id\\nWHERE users.email = \'bud\'```"}',
|
|
32
|
-
tool: "blogpost",
|
|
33
|
-
toolInput: "```sql\nSELECT * FROM orders\nJOIN users ON users.id = orders.user_id\nWHERE users.email = 'bud'```",
|
|
34
|
-
},
|
|
35
|
-
{
|
|
36
|
-
input: '{\n \t\r\n"action":"Final Answer",\n\t\r "action_input":"The tool input ```json\\n{\\"yes\\":true}\\n```"\n\t\r}',
|
|
37
|
-
output: '{"action":"Final Answer","action_input":"The tool input ```json\\n{\\"yes\\":true}\\n```"}',
|
|
38
|
-
tool: "Final Answer",
|
|
39
|
-
toolInput: 'The tool input ```json\\n{\\"yes\\":true}\\n```',
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
input: '```json\n{\n \t\r\n"action":"Final Answer",\n\t\r "action_input":"The tool input ```json\\n{\\"yes\\":true}\\n```"\n\t\r}\n\n\n\t\r```',
|
|
43
|
-
output: '{"action":"Final Answer","action_input":"The tool input ```json\\n{\\"yes\\":true}\\n```"}',
|
|
44
|
-
tool: "Final Answer",
|
|
45
|
-
toolInput: 'The tool input ```json\\n{\\"yes\\":true}\\n```',
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
input: 'Here we have some boilerplate nonsense```json\n{\n \t\r\n"action":"Final Answer",\n\t\r "action_input":"The tool input ```json\\n{\\"yes\\":true}\\n```"\n\t\r}\n\n\n\t\r``` and at the end there is more nonsense',
|
|
49
|
-
output: '{"action":"Final Answer","action_input":"The tool input ```json\\n{\\"yes\\":true}\\n```"}',
|
|
50
|
-
tool: "Final Answer",
|
|
51
|
-
toolInput: 'The tool input ```json\\n{\\"yes\\":true}\\n```',
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
input: 'Here we have some boilerplate nonsense```\n{\n \t\r\n"action":"Final Answer",\n\t\r "action_input":"The tool input ```javascript\\n{\\"yes\\":true}\\n```"\n\t\r}\n\n\n\t\r``` and at the end there is more nonsense',
|
|
55
|
-
output: '{"action":"Final Answer","action_input":"The tool input ```javascript\\n{\\"yes\\":true}\\n```"}',
|
|
56
|
-
tool: "Final Answer",
|
|
57
|
-
toolInput: 'The tool input ```javascript\\n{\\"yes\\":true}\\n```',
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
input: '{\n \t\r\n"action":"Final Answer",\n\t\r "action_input":"The tool input ```javascript\\n{\\"yes\\":true}\\n```"\n\t\r}',
|
|
61
|
-
output: '{"action":"Final Answer","action_input":"The tool input ```javascript\\n{\\"yes\\":true}\\n```"}',
|
|
62
|
-
tool: "Final Answer",
|
|
63
|
-
toolInput: 'The tool input ```javascript\\n{\\"yes\\":true}\\n```',
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
input: '{\n \t\r\n"action":"Final Answer",\n\t\r "action_input":"this is a regular text response"\n\t\r}',
|
|
67
|
-
output: '{"action":"Final Answer","action_input":"this is a regular text response"}',
|
|
68
|
-
tool: "Final Answer",
|
|
69
|
-
toolInput: "this is a regular text response",
|
|
70
|
-
},
|
|
71
|
-
];
|
|
72
|
-
const p = new ChatConversationalAgentOutputParser({
|
|
73
|
-
toolNames: ["blogpost", "metabase", "ToolWithJson"],
|
|
74
|
-
});
|
|
75
|
-
for (const message of testCases) {
|
|
76
|
-
const parsed = await p.parse(message.input);
|
|
77
|
-
expect(parsed).toBeDefined();
|
|
78
|
-
if (message.tool === "Final Answer") {
|
|
79
|
-
expect(parsed.returnValues).toBeDefined();
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
expect(parsed.tool).toEqual(message.tool);
|
|
83
|
-
if (typeof message.toolInput === "object") {
|
|
84
|
-
expect(message.toolInput).toEqual(parsed.toolInput);
|
|
85
|
-
}
|
|
86
|
-
if (typeof message.toolInput === "string") {
|
|
87
|
-
expect(message.toolInput).toContain(parsed.toolInput);
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
});
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
/** eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
2
|
-
import { test, expect } from "@jest/globals";
|
|
3
|
-
import { ChatOpenAI } from "@langchain/openai";
|
|
4
|
-
import { TavilySearchResults } from "../../util/testing/tools/tavily_search.js";
|
|
5
|
-
import { pull } from "../../hub.js";
|
|
6
|
-
import { AgentExecutor, createOpenAIFunctionsAgent } from "../index.js";
|
|
7
|
-
const tools = [new TavilySearchResults({ maxResults: 1 })];
|
|
8
|
-
test("createOpenAIFunctionsAgent works", async () => {
|
|
9
|
-
const prompt = await pull("hwchase17/openai-functions-agent");
|
|
10
|
-
const llm = new ChatOpenAI({
|
|
11
|
-
modelName: "gpt-3.5-turbo-1106",
|
|
12
|
-
temperature: 0,
|
|
13
|
-
});
|
|
14
|
-
const agent = await createOpenAIFunctionsAgent({
|
|
15
|
-
llm,
|
|
16
|
-
tools,
|
|
17
|
-
prompt,
|
|
18
|
-
});
|
|
19
|
-
const agentExecutor = new AgentExecutor({
|
|
20
|
-
agent,
|
|
21
|
-
tools,
|
|
22
|
-
});
|
|
23
|
-
const input = "what is LangChain?";
|
|
24
|
-
const result = await agentExecutor.invoke({
|
|
25
|
-
input,
|
|
26
|
-
});
|
|
27
|
-
console.log(result);
|
|
28
|
-
expect(result.input).toBe(input);
|
|
29
|
-
expect(typeof result.output).toBe("string");
|
|
30
|
-
// Length greater than 10 because any less than that would warrant
|
|
31
|
-
// an investigation into why such a short generation was returned.
|
|
32
|
-
expect(result.output.length).toBeGreaterThan(10);
|
|
33
|
-
});
|
|
34
|
-
test("createOpenAIFunctionsAgent can stream log", async () => {
|
|
35
|
-
const prompt = await pull("hwchase17/openai-functions-agent");
|
|
36
|
-
const llm = new ChatOpenAI({
|
|
37
|
-
modelName: "gpt-3.5-turbo-1106",
|
|
38
|
-
temperature: 0,
|
|
39
|
-
streaming: true,
|
|
40
|
-
});
|
|
41
|
-
const agent = await createOpenAIFunctionsAgent({
|
|
42
|
-
llm,
|
|
43
|
-
tools,
|
|
44
|
-
prompt,
|
|
45
|
-
});
|
|
46
|
-
const agentExecutor = new AgentExecutor({
|
|
47
|
-
agent,
|
|
48
|
-
tools,
|
|
49
|
-
});
|
|
50
|
-
const input = "tell me a short story.";
|
|
51
|
-
const logStream = await agentExecutor.streamLog({
|
|
52
|
-
input,
|
|
53
|
-
});
|
|
54
|
-
const chunks = [];
|
|
55
|
-
let firstChunkTime;
|
|
56
|
-
for await (const chunk of logStream) {
|
|
57
|
-
if (!firstChunkTime) {
|
|
58
|
-
firstChunkTime = new Date().getTime();
|
|
59
|
-
}
|
|
60
|
-
console.log(chunk);
|
|
61
|
-
chunks.push(chunk);
|
|
62
|
-
}
|
|
63
|
-
if (!firstChunkTime) {
|
|
64
|
-
throw new Error("firstChunkTime was not set.");
|
|
65
|
-
}
|
|
66
|
-
console.log(chunks.length);
|
|
67
|
-
console.log();
|
|
68
|
-
console.log("Time to complete after first chunk:", new Date().getTime() - firstChunkTime);
|
|
69
|
-
console.log(chunks.length);
|
|
70
|
-
expect(chunks.length).toBeGreaterThan(1);
|
|
71
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|