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
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
import { test } from "@jest/globals";
|
|
2
|
-
import { ChatOpenAI } from "@langchain/openai";
|
|
3
|
-
import { Client } from "langsmith";
|
|
4
|
-
import { BaseChatModel } from "@langchain/core/language_models/chat_models";
|
|
5
|
-
import { LLM } from "@langchain/core/language_models/llms";
|
|
6
|
-
import { AIMessage, isBaseMessage, } from "@langchain/core/messages";
|
|
7
|
-
import { RunnableLambda } from "@langchain/core/runnables";
|
|
8
|
-
import { randomName } from "../name_generation.js";
|
|
9
|
-
import { runOnDataset } from "../runner_utils.js";
|
|
10
|
-
const answers = {
|
|
11
|
-
"What's the capital of California?": "Sacramento",
|
|
12
|
-
"What's the capital of Nevada?": "Carson City",
|
|
13
|
-
"What's the capital of Oregon?": "Salem",
|
|
14
|
-
"What's the capital of Washington?": "Olympia",
|
|
15
|
-
};
|
|
16
|
-
class FakeLLM extends LLM {
|
|
17
|
-
_llmType() {
|
|
18
|
-
return "fake";
|
|
19
|
-
}
|
|
20
|
-
async _call(prompt) {
|
|
21
|
-
return answers[prompt] || prompt;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
export class FakeChatModel extends BaseChatModel {
|
|
25
|
-
_combineLLMOutput() {
|
|
26
|
-
return [];
|
|
27
|
-
}
|
|
28
|
-
_llmType() {
|
|
29
|
-
return "fake";
|
|
30
|
-
}
|
|
31
|
-
async _generate(messages, _, runManager) {
|
|
32
|
-
const text = messages[messages.length - 1].content;
|
|
33
|
-
const answer = (answers[text] || text);
|
|
34
|
-
await runManager?.handleLLMNewToken(answer);
|
|
35
|
-
const result = new AIMessage({ content: answer });
|
|
36
|
-
return {
|
|
37
|
-
generations: [
|
|
38
|
-
{
|
|
39
|
-
message: result,
|
|
40
|
-
text: answer,
|
|
41
|
-
},
|
|
42
|
-
],
|
|
43
|
-
llmOutput: {},
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
const getScore = ({ outputs }) => outputs && Object.values(outputs).length > 0;
|
|
48
|
-
const outputNotEmpty = async ({ run }, options) => {
|
|
49
|
-
const lambda = new RunnableLambda({ func: getScore });
|
|
50
|
-
const score = await lambda.invoke(run, options?.config);
|
|
51
|
-
return {
|
|
52
|
-
key: "output_not_empty",
|
|
53
|
-
score,
|
|
54
|
-
comment: "We have thoroughly checked the output and it is possibly not not empty.",
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
|
-
const alwaysPass = (_) => ({
|
|
58
|
-
key: "always_pass",
|
|
59
|
-
score: true,
|
|
60
|
-
});
|
|
61
|
-
const checkFeedbackPassed = (evalResults) => {
|
|
62
|
-
expect(evalResults.projectName).toBeDefined();
|
|
63
|
-
expect(evalResults.results).toBeDefined();
|
|
64
|
-
expect(Object.keys(evalResults.results).length).toBeGreaterThan(0);
|
|
65
|
-
for (const [, result] of Object.entries(evalResults.results)) {
|
|
66
|
-
expect(result.execution_time).toBeGreaterThan(0);
|
|
67
|
-
expect(result.run_id).toBeDefined();
|
|
68
|
-
expect(result.feedback).toBeDefined();
|
|
69
|
-
expect(result.feedback.length).toBeGreaterThan(0);
|
|
70
|
-
// eslint-disable-next-line no-loop-func
|
|
71
|
-
result.feedback.forEach((feedback) => {
|
|
72
|
-
expect(feedback.score).toBeDefined();
|
|
73
|
-
expect(feedback.score).toBeTruthy();
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
const kvDataset = Object.entries(answers).map(([question, answer]) => ({
|
|
78
|
-
inputs: { input: question },
|
|
79
|
-
outputs: { output: answer },
|
|
80
|
-
}));
|
|
81
|
-
const chatDataset = kvDataset.map((message) => ({
|
|
82
|
-
inputs: {
|
|
83
|
-
input: [
|
|
84
|
-
{ type: "system", data: { content: "Hello, how are you?" } },
|
|
85
|
-
{ type: "human", data: { content: message.inputs.input } },
|
|
86
|
-
],
|
|
87
|
-
},
|
|
88
|
-
outputs: {
|
|
89
|
-
output: { type: "ai", data: { content: message.outputs.output } },
|
|
90
|
-
},
|
|
91
|
-
}));
|
|
92
|
-
const datasetTypes = ["kv", "llm"]; // TODO: add chat
|
|
93
|
-
describe.skip.each(datasetTypes)("runner_utils %s dataset", (datasetType) => {
|
|
94
|
-
let client;
|
|
95
|
-
const datasetName = `lcjs ${datasetType} integration tests`;
|
|
96
|
-
const evalConfig = {
|
|
97
|
-
customEvaluators: [outputNotEmpty, alwaysPass],
|
|
98
|
-
evaluators: [
|
|
99
|
-
{
|
|
100
|
-
evaluatorType: "labeled_criteria",
|
|
101
|
-
criteria: "correctness",
|
|
102
|
-
feedbackKey: "labeledCorrect",
|
|
103
|
-
formatEvaluatorInputs: ({ rawInput, rawPrediction, rawReferenceOutput, }) => {
|
|
104
|
-
let prediction;
|
|
105
|
-
if (isBaseMessage(rawPrediction)) {
|
|
106
|
-
if (typeof rawPrediction.content !== "string") {
|
|
107
|
-
throw new Error("Multimodal mesages not supported.");
|
|
108
|
-
}
|
|
109
|
-
prediction = rawPrediction.content;
|
|
110
|
-
}
|
|
111
|
-
else if (typeof rawPrediction === "string") {
|
|
112
|
-
prediction = rawPrediction;
|
|
113
|
-
}
|
|
114
|
-
else if (rawPrediction &&
|
|
115
|
-
typeof rawPrediction === "object" &&
|
|
116
|
-
"output" in rawPrediction) {
|
|
117
|
-
prediction = rawPrediction.output;
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
throw new Error("Unsupported prediction type.");
|
|
121
|
-
}
|
|
122
|
-
return {
|
|
123
|
-
input: rawInput.input,
|
|
124
|
-
prediction,
|
|
125
|
-
reference: rawReferenceOutput.output,
|
|
126
|
-
};
|
|
127
|
-
},
|
|
128
|
-
llm: new ChatOpenAI({
|
|
129
|
-
modelName: "gpt-3.5-turbo",
|
|
130
|
-
temperature: 0,
|
|
131
|
-
modelKwargs: { seed: 42 },
|
|
132
|
-
}),
|
|
133
|
-
},
|
|
134
|
-
],
|
|
135
|
-
};
|
|
136
|
-
beforeAll(async () => {
|
|
137
|
-
client = new Client();
|
|
138
|
-
try {
|
|
139
|
-
await client.readDataset({ datasetName });
|
|
140
|
-
}
|
|
141
|
-
catch (e) {
|
|
142
|
-
const dataset = await client.createDataset(datasetName, {
|
|
143
|
-
dataType: datasetType,
|
|
144
|
-
});
|
|
145
|
-
const examples = datasetType === "chat" ? chatDataset : kvDataset;
|
|
146
|
-
await Promise.all(examples.map(async (example) => {
|
|
147
|
-
void client.createExample(example.inputs, example.outputs, {
|
|
148
|
-
datasetId: dataset.id,
|
|
149
|
-
});
|
|
150
|
-
}));
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
test(`Chat model on ${datasetType} singleio dataset`, async () => {
|
|
154
|
-
const llm = new FakeChatModel({});
|
|
155
|
-
const evalResults = await runOnDataset(llm, datasetName, {
|
|
156
|
-
client,
|
|
157
|
-
evaluationConfig: evalConfig,
|
|
158
|
-
projectName: `fake-chat-model-${randomName()}`,
|
|
159
|
-
projectMetadata: { env: "integration-tests", model: "fake-chat-model" },
|
|
160
|
-
});
|
|
161
|
-
checkFeedbackPassed(evalResults);
|
|
162
|
-
});
|
|
163
|
-
test(`FakeLLM on ${datasetType} singleio dataset`, async () => {
|
|
164
|
-
const llm = new FakeLLM({});
|
|
165
|
-
const evalResults = await runOnDataset(llm, datasetName, {
|
|
166
|
-
client,
|
|
167
|
-
evaluationConfig: evalConfig,
|
|
168
|
-
projectName: `fake-llm-${randomName()}`,
|
|
169
|
-
projectMetadata: { env: "integration-tests", model: "fake-llm" },
|
|
170
|
-
});
|
|
171
|
-
checkFeedbackPassed(evalResults);
|
|
172
|
-
});
|
|
173
|
-
test(`Runnable on ${datasetType} singleio dataset`, async () => {
|
|
174
|
-
const runnable = new RunnableLambda({
|
|
175
|
-
func: (input) => ({ output: answers[input.input] }),
|
|
176
|
-
});
|
|
177
|
-
const evalResults = await runOnDataset(runnable, datasetName, {
|
|
178
|
-
client,
|
|
179
|
-
evaluationConfig: evalConfig,
|
|
180
|
-
projectName: `runnable-${randomName()}`,
|
|
181
|
-
projectMetadata: { env: "integration-tests" },
|
|
182
|
-
maxConcurrency: 5,
|
|
183
|
-
});
|
|
184
|
-
checkFeedbackPassed(evalResults);
|
|
185
|
-
});
|
|
186
|
-
test(`Runnable constructor on ${datasetType} singleio dataset`, async () => {
|
|
187
|
-
const runnable = new RunnableLambda({
|
|
188
|
-
func: (input) => ({ output: answers[input.input] }),
|
|
189
|
-
});
|
|
190
|
-
function construct() {
|
|
191
|
-
return runnable;
|
|
192
|
-
}
|
|
193
|
-
const evalResults = await runOnDataset(construct, datasetName, {
|
|
194
|
-
client,
|
|
195
|
-
evaluationConfig: evalConfig,
|
|
196
|
-
projectName: `runnable-constructor-${randomName()}`,
|
|
197
|
-
projectMetadata: { env: "integration-tests" },
|
|
198
|
-
maxConcurrency: 5,
|
|
199
|
-
});
|
|
200
|
-
checkFeedbackPassed(evalResults);
|
|
201
|
-
});
|
|
202
|
-
test(`Arb func on ${datasetType} singleio dataset`, async () => {
|
|
203
|
-
async function my_func({ input }) {
|
|
204
|
-
return { output: answers[input] };
|
|
205
|
-
}
|
|
206
|
-
const evalResults = await runOnDataset(my_func, datasetName, {
|
|
207
|
-
evaluationConfig: evalConfig,
|
|
208
|
-
client,
|
|
209
|
-
maxConcurrency: 5,
|
|
210
|
-
projectName: `arb-function-${randomName()}`,
|
|
211
|
-
projectMetadata: {
|
|
212
|
-
env: "integration-tests",
|
|
213
|
-
model: "fake-chat-in-runnable",
|
|
214
|
-
},
|
|
215
|
-
});
|
|
216
|
-
checkFeedbackPassed(evalResults);
|
|
217
|
-
});
|
|
218
|
-
test(`Arb constructor on ${datasetType} singleio dataset`, async () => {
|
|
219
|
-
async function my_func({ input }) {
|
|
220
|
-
return { output: answers[input] };
|
|
221
|
-
}
|
|
222
|
-
const evalResults = await runOnDataset(() => my_func, datasetName, {
|
|
223
|
-
evaluationConfig: evalConfig,
|
|
224
|
-
client,
|
|
225
|
-
maxConcurrency: 5,
|
|
226
|
-
projectName: `arb-constructor-function-${randomName()}`,
|
|
227
|
-
projectMetadata: {
|
|
228
|
-
env: "integration-tests",
|
|
229
|
-
model: "fake-chat-in-runnable",
|
|
230
|
-
},
|
|
231
|
-
});
|
|
232
|
-
checkFeedbackPassed(evalResults);
|
|
233
|
-
});
|
|
234
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-process-env */
|
|
2
|
-
import { test } from "@jest/globals";
|
|
3
|
-
import * as fs from "node:fs";
|
|
4
|
-
import * as path from "node:path";
|
|
5
|
-
import * as os from "node:os";
|
|
6
|
-
import { LocalFileStore } from "../file_system.js";
|
|
7
|
-
describe("LocalFileStore", () => {
|
|
8
|
-
const keys = ["key1", "key2"];
|
|
9
|
-
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "file_system_store_test"));
|
|
10
|
-
const secondaryRootPath = "./file_system_store_test_secondary";
|
|
11
|
-
test("LocalFileStore can write & read values", async () => {
|
|
12
|
-
const encoder = new TextEncoder();
|
|
13
|
-
const decoder = new TextDecoder();
|
|
14
|
-
const store = await LocalFileStore.fromPath(tempDir);
|
|
15
|
-
const value1 = new Date().toISOString();
|
|
16
|
-
const value2 = new Date().toISOString() + new Date().toISOString();
|
|
17
|
-
await store.mset([
|
|
18
|
-
[keys[0], encoder.encode(value1)],
|
|
19
|
-
[keys[1], encoder.encode(value2)],
|
|
20
|
-
]);
|
|
21
|
-
const retrievedValues = await store.mget([keys[0], keys[1]]);
|
|
22
|
-
const everyValueDefined = retrievedValues.every((v) => v !== undefined);
|
|
23
|
-
expect(everyValueDefined).toBe(true);
|
|
24
|
-
expect(retrievedValues.map((v) => decoder.decode(v))).toEqual([
|
|
25
|
-
value1,
|
|
26
|
-
value2,
|
|
27
|
-
]);
|
|
28
|
-
});
|
|
29
|
-
test("LocalFileStore can delete values", async () => {
|
|
30
|
-
const encoder = new TextEncoder();
|
|
31
|
-
const store = await LocalFileStore.fromPath(tempDir);
|
|
32
|
-
const value1 = new Date().toISOString();
|
|
33
|
-
const value2 = new Date().toISOString() + new Date().toISOString();
|
|
34
|
-
await store.mset([
|
|
35
|
-
[keys[0], encoder.encode(value1)],
|
|
36
|
-
[keys[1], encoder.encode(value2)],
|
|
37
|
-
]);
|
|
38
|
-
await store.mdelete(keys);
|
|
39
|
-
const retrievedValues = await store.mget([keys[0], keys[1]]);
|
|
40
|
-
const everyValueUndefined = retrievedValues.every((v) => v === undefined);
|
|
41
|
-
expect(everyValueUndefined).toBe(true);
|
|
42
|
-
});
|
|
43
|
-
test("LocalFileStore can yield keys with prefix", async () => {
|
|
44
|
-
const encoder = new TextEncoder();
|
|
45
|
-
const prefix = "prefix_";
|
|
46
|
-
const keysWithPrefix = keys.map((key) => `${prefix}${key}`);
|
|
47
|
-
const store = await LocalFileStore.fromPath(tempDir);
|
|
48
|
-
const value = new Date().toISOString();
|
|
49
|
-
await store.mset(keysWithPrefix.map((key) => [key, encoder.encode(value)]));
|
|
50
|
-
const yieldedKeys = [];
|
|
51
|
-
for await (const key of store.yieldKeys(prefix)) {
|
|
52
|
-
yieldedKeys.push(key);
|
|
53
|
-
}
|
|
54
|
-
console.log("Yielded keys:", yieldedKeys);
|
|
55
|
-
expect(yieldedKeys.sort()).toEqual(keysWithPrefix.sort());
|
|
56
|
-
// afterEach won't automatically delete these since we're applying a prefix.
|
|
57
|
-
await store.mdelete(keysWithPrefix);
|
|
58
|
-
});
|
|
59
|
-
test("LocalFileStore works with a file which does not exist", async () => {
|
|
60
|
-
const encoder = new TextEncoder();
|
|
61
|
-
const decoder = new TextDecoder();
|
|
62
|
-
const store = await LocalFileStore.fromPath(secondaryRootPath);
|
|
63
|
-
const value1 = new Date().toISOString();
|
|
64
|
-
const value2 = new Date().toISOString() + new Date().toISOString();
|
|
65
|
-
await store.mset([
|
|
66
|
-
[keys[0], encoder.encode(value1)],
|
|
67
|
-
[keys[1], encoder.encode(value2)],
|
|
68
|
-
]);
|
|
69
|
-
const retrievedValues = await store.mget([keys[0], keys[1]]);
|
|
70
|
-
const everyValueDefined = retrievedValues.every((v) => v !== undefined);
|
|
71
|
-
expect(everyValueDefined).toBe(true);
|
|
72
|
-
console.log("retrievedValues", retrievedValues);
|
|
73
|
-
expect(retrievedValues.map((v) => {
|
|
74
|
-
if (!v) {
|
|
75
|
-
throw new Error("Value is undefined");
|
|
76
|
-
}
|
|
77
|
-
return decoder.decode(v);
|
|
78
|
-
})).toEqual([value1, value2]);
|
|
79
|
-
await fs.promises.rm(secondaryRootPath, { recursive: true, force: true });
|
|
80
|
-
});
|
|
81
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import { test, expect, jest } from "@jest/globals";
|
|
2
|
-
import { LLM } from "@langchain/core/language_models/llms";
|
|
3
|
-
import { PromptTemplate } from "@langchain/core/prompts";
|
|
4
|
-
import { FakeEmbeddings } from "@langchain/core/utils/testing";
|
|
5
|
-
import { ChainTool } from "../chain.js";
|
|
6
|
-
import { LLMChain } from "../../chains/llm_chain.js";
|
|
7
|
-
import { VectorDBQAChain } from "../../chains/vector_db_qa.js";
|
|
8
|
-
import { MemoryVectorStore } from "../../vectorstores/memory.js";
|
|
9
|
-
class FakeLLM extends LLM {
|
|
10
|
-
_llmType() {
|
|
11
|
-
return "fake";
|
|
12
|
-
}
|
|
13
|
-
async _call(prompt) {
|
|
14
|
-
return prompt;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
test("chain tool with llm chain and local callback", async () => {
|
|
18
|
-
const calls = [];
|
|
19
|
-
const handleToolStart = jest.fn(() => {
|
|
20
|
-
calls.push("tool start");
|
|
21
|
-
});
|
|
22
|
-
const handleToolEnd = jest.fn(() => {
|
|
23
|
-
calls.push("tool end");
|
|
24
|
-
});
|
|
25
|
-
const handleLLMStart = jest.fn(() => {
|
|
26
|
-
calls.push("llm start");
|
|
27
|
-
});
|
|
28
|
-
const handleLLMEnd = jest.fn(() => {
|
|
29
|
-
calls.push("llm end");
|
|
30
|
-
});
|
|
31
|
-
const handleChainStart = jest.fn(() => {
|
|
32
|
-
calls.push("chain start");
|
|
33
|
-
});
|
|
34
|
-
const handleChainEnd = jest.fn(() => {
|
|
35
|
-
calls.push("chain end");
|
|
36
|
-
});
|
|
37
|
-
const chain = new LLMChain({
|
|
38
|
-
llm: new FakeLLM({}),
|
|
39
|
-
prompt: PromptTemplate.fromTemplate("hello world"),
|
|
40
|
-
});
|
|
41
|
-
const tool = new ChainTool({ chain, name: "fake", description: "fake" });
|
|
42
|
-
const result = await tool.invoke("hi", {
|
|
43
|
-
callbacks: [
|
|
44
|
-
{
|
|
45
|
-
awaitHandlers: true,
|
|
46
|
-
handleToolStart,
|
|
47
|
-
handleToolEnd,
|
|
48
|
-
handleLLMStart,
|
|
49
|
-
handleLLMEnd,
|
|
50
|
-
handleChainStart,
|
|
51
|
-
handleChainEnd,
|
|
52
|
-
},
|
|
53
|
-
],
|
|
54
|
-
});
|
|
55
|
-
expect(result).toMatchInlineSnapshot(`"hello world"`);
|
|
56
|
-
expect(handleToolStart).toBeCalledTimes(1);
|
|
57
|
-
expect(handleToolEnd).toBeCalledTimes(1);
|
|
58
|
-
expect(handleLLMStart).toBeCalledTimes(1);
|
|
59
|
-
expect(handleLLMEnd).toBeCalledTimes(1);
|
|
60
|
-
expect(handleChainStart).toBeCalledTimes(1);
|
|
61
|
-
expect(handleChainEnd).toBeCalledTimes(1);
|
|
62
|
-
expect(calls).toMatchInlineSnapshot(`
|
|
63
|
-
[
|
|
64
|
-
"tool start",
|
|
65
|
-
"chain start",
|
|
66
|
-
"llm start",
|
|
67
|
-
"llm end",
|
|
68
|
-
"chain end",
|
|
69
|
-
"tool end",
|
|
70
|
-
]
|
|
71
|
-
`);
|
|
72
|
-
});
|
|
73
|
-
test("chain tool with vectordbqa chain", async () => {
|
|
74
|
-
const calls = [];
|
|
75
|
-
const handleToolStart = jest.fn(() => {
|
|
76
|
-
calls.push("tool start");
|
|
77
|
-
});
|
|
78
|
-
const handleToolEnd = jest.fn(() => {
|
|
79
|
-
calls.push("tool end");
|
|
80
|
-
});
|
|
81
|
-
const handleLLMStart = jest.fn(() => {
|
|
82
|
-
calls.push("llm start");
|
|
83
|
-
});
|
|
84
|
-
const handleLLMEnd = jest.fn(() => {
|
|
85
|
-
calls.push("llm end");
|
|
86
|
-
});
|
|
87
|
-
const handleChainStart = jest.fn(() => {
|
|
88
|
-
calls.push("chain start");
|
|
89
|
-
});
|
|
90
|
-
const handleChainEnd = jest.fn(() => {
|
|
91
|
-
calls.push("chain end");
|
|
92
|
-
});
|
|
93
|
-
const chain = VectorDBQAChain.fromLLM(new FakeLLM({}), await MemoryVectorStore.fromExistingIndex(new FakeEmbeddings()));
|
|
94
|
-
const tool = new ChainTool({ chain, name: "fake", description: "fake" });
|
|
95
|
-
const result = await tool.invoke("hi", {
|
|
96
|
-
callbacks: [
|
|
97
|
-
{
|
|
98
|
-
awaitHandlers: true,
|
|
99
|
-
handleToolStart,
|
|
100
|
-
handleToolEnd,
|
|
101
|
-
handleLLMStart,
|
|
102
|
-
handleLLMEnd,
|
|
103
|
-
handleChainStart,
|
|
104
|
-
handleChainEnd,
|
|
105
|
-
},
|
|
106
|
-
],
|
|
107
|
-
});
|
|
108
|
-
expect(result).toMatchInlineSnapshot(`
|
|
109
|
-
"Use the following pieces of context to answer the question at the end. If you don't know the answer, just say that you don't know, don't try to make up an answer.
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
Question: hi
|
|
114
|
-
Helpful Answer:"
|
|
115
|
-
`);
|
|
116
|
-
expect(handleToolStart).toBeCalledTimes(1);
|
|
117
|
-
expect(handleToolEnd).toBeCalledTimes(1);
|
|
118
|
-
expect(handleLLMStart).toBeCalledTimes(1);
|
|
119
|
-
expect(handleLLMEnd).toBeCalledTimes(1);
|
|
120
|
-
expect(handleChainStart).toBeCalledTimes(3);
|
|
121
|
-
expect(handleChainEnd).toBeCalledTimes(3);
|
|
122
|
-
expect(calls).toMatchInlineSnapshot(`
|
|
123
|
-
[
|
|
124
|
-
"tool start",
|
|
125
|
-
"chain start",
|
|
126
|
-
"chain start",
|
|
127
|
-
"chain start",
|
|
128
|
-
"llm start",
|
|
129
|
-
"llm end",
|
|
130
|
-
"chain end",
|
|
131
|
-
"chain end",
|
|
132
|
-
"chain end",
|
|
133
|
-
"tool end",
|
|
134
|
-
]
|
|
135
|
-
`);
|
|
136
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { test, expect, describe } from "@jest/globals";
|
|
2
|
-
import { ChatOpenAI, OpenAIEmbeddings } from "@langchain/openai";
|
|
3
|
-
import { WebBrowser } from "../webbrowser.js";
|
|
4
|
-
import fetchAdapter from "../../util/axios-fetch-adapter.js";
|
|
5
|
-
describe("webbrowser Test suite", () => {
|
|
6
|
-
test("get word of the day", async () => {
|
|
7
|
-
const model = new ChatOpenAI({ temperature: 0 });
|
|
8
|
-
const embeddings = new OpenAIEmbeddings();
|
|
9
|
-
const browser = new WebBrowser({ model, embeddings });
|
|
10
|
-
const result = await browser.call(`"https://www.merriam-webster.com/word-of-the-day","word of the day"`);
|
|
11
|
-
expect(result).toContain("Word of the Day:");
|
|
12
|
-
});
|
|
13
|
-
test("get a summary of the page when empty request with fetch adapter", async () => {
|
|
14
|
-
const model = new ChatOpenAI({ temperature: 0 });
|
|
15
|
-
const embeddings = new OpenAIEmbeddings();
|
|
16
|
-
const browser = new WebBrowser({
|
|
17
|
-
model,
|
|
18
|
-
embeddings,
|
|
19
|
-
axiosConfig: {
|
|
20
|
-
adapter: fetchAdapter,
|
|
21
|
-
},
|
|
22
|
-
});
|
|
23
|
-
const result = await browser.call(`"https://www.merriam-webster.com/word-of-the-day",""`);
|
|
24
|
-
// fuzzy, sometimes its capped and others not
|
|
25
|
-
expect(result).toMatch(/word of the day/i);
|
|
26
|
-
});
|
|
27
|
-
test("error no url", async () => {
|
|
28
|
-
const model = new ChatOpenAI({ temperature: 0 });
|
|
29
|
-
const embeddings = new OpenAIEmbeddings();
|
|
30
|
-
const browser = new WebBrowser({ model, embeddings });
|
|
31
|
-
const result = await browser.call(`"",""`);
|
|
32
|
-
expect(result).toContain("Invalid URL");
|
|
33
|
-
});
|
|
34
|
-
test("error no protocol or malformed", async () => {
|
|
35
|
-
const model = new ChatOpenAI({ temperature: 0 });
|
|
36
|
-
const embeddings = new OpenAIEmbeddings();
|
|
37
|
-
const browser = new WebBrowser({ model, embeddings });
|
|
38
|
-
const result = await browser.call(`"www.merriam-webster.com/word-of-the-day","word of the day"`);
|
|
39
|
-
expect(result).toContain("Invalid URL");
|
|
40
|
-
});
|
|
41
|
-
test("error bad site", async () => {
|
|
42
|
-
const model = new ChatOpenAI({ temperature: 0 });
|
|
43
|
-
const embeddings = new OpenAIEmbeddings();
|
|
44
|
-
const browser = new WebBrowser({ model, embeddings });
|
|
45
|
-
const result = await browser.call(`"https://www.hDjRBKoAD0EIbF29TWM4rbXDGGM5Nhy4uzNEAdDS.com","word of the day"`);
|
|
46
|
-
expect(result).toEqual("Error: getaddrinfo ENOTFOUND www.hdjrbkoad0eibf29twm4rbxdggm5nhy4uzneadds.com");
|
|
47
|
-
});
|
|
48
|
-
test.skip("get a summary of a page that detects scraping", async () => {
|
|
49
|
-
const model = new ChatOpenAI({ temperature: 0 });
|
|
50
|
-
const embeddings = new OpenAIEmbeddings();
|
|
51
|
-
const browser = new WebBrowser({ model, embeddings });
|
|
52
|
-
const result = await browser.call(`"https://www.musicgateway.com/spotify-pre-save",""`);
|
|
53
|
-
expect(result).not.toEqual("Error: http response 403");
|
|
54
|
-
});
|
|
55
|
-
// cant we figure the headers to fix this?
|
|
56
|
-
test.skip("get a summary of a page that detects scraping 2", async () => {
|
|
57
|
-
const model = new ChatOpenAI({ temperature: 0 });
|
|
58
|
-
const embeddings = new OpenAIEmbeddings();
|
|
59
|
-
const browser = new WebBrowser({ model, embeddings });
|
|
60
|
-
const result = await browser.call(`"https://parade.com/991228/marynliles/couples-goals",""`);
|
|
61
|
-
expect(result).not.toEqual("Error: http response 403");
|
|
62
|
-
});
|
|
63
|
-
test("get a summary of a page that rejects unauthorized", async () => {
|
|
64
|
-
const model = new ChatOpenAI({ temperature: 0 });
|
|
65
|
-
const embeddings = new OpenAIEmbeddings();
|
|
66
|
-
const browser = new WebBrowser({ model, embeddings });
|
|
67
|
-
const result = await browser.call(`"https://firstround.com/review/how-to-fix-the-co-founder-fights-youre-sick-of-having-lessons-from-couples-therapist-esther-perel",""`);
|
|
68
|
-
expect(result).toContain("Esther Perel");
|
|
69
|
-
});
|
|
70
|
-
// other urls that have done this too
|
|
71
|
-
// "https://wsimag.com/economy-and-politics/15473-power-and-money",
|
|
72
|
-
// "https://thriveglobal.com/stories/sleep-what-to-do-what-not-to-do",
|
|
73
|
-
test.skip("get a summary of a page that redirects too many times", async () => {
|
|
74
|
-
const model = new ChatOpenAI({ temperature: 0 });
|
|
75
|
-
const embeddings = new OpenAIEmbeddings();
|
|
76
|
-
const browser = new WebBrowser({ model, embeddings });
|
|
77
|
-
const result = await browser.call(`"https://www.healtheuropa.eu/why-mdma-must-be-reclassified-as-a-schedule-2-drug/95780",""`);
|
|
78
|
-
expect(result).toContain("Beckley Foundation");
|
|
79
|
-
});
|
|
80
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { test, expect, describe } from "@jest/globals";
|
|
2
|
-
import { readFileSync } from "fs";
|
|
3
|
-
import { getText, parseInputs } from "../webbrowser.js";
|
|
4
|
-
describe("webbrowser Test suite", () => {
|
|
5
|
-
const html = readFileSync("./src/tools/fixtures/wordoftheday.html", "utf8");
|
|
6
|
-
test("parse html to text and links", async () => {
|
|
7
|
-
const baseUrl = "https://www.merriam-webster.com/word-of-the-day";
|
|
8
|
-
const text = getText(html, baseUrl, false);
|
|
9
|
-
expect(text).toContain("Word of the Day: Foible");
|
|
10
|
-
});
|
|
11
|
-
test("parseInputs", () => {
|
|
12
|
-
expect(parseInputs(`"https://www.merriam-webster.com/word-of-the-day",""`)).toEqual(["https://www.merriam-webster.com/word-of-the-day", ""]);
|
|
13
|
-
expect(parseInputs(`"https://www.merriam-webster.com/word-of-the-day","word of the day"`)).toEqual([
|
|
14
|
-
"https://www.merriam-webster.com/word-of-the-day",
|
|
15
|
-
"word of the day",
|
|
16
|
-
]);
|
|
17
|
-
expect(parseInputs(`"https://www.merriam-webster.com/word-of-the-day","`)).toEqual(["https://www.merriam-webster.com/word-of-the-day", ""]);
|
|
18
|
-
expect(parseInputs(`"https://www.merriam-webster.com/word-of-the-day",`)).toEqual(["https://www.merriam-webster.com/word-of-the-day", ""]);
|
|
19
|
-
expect(parseInputs(`"https://www.merriam-webster.com/word-of-the-day"`)).toEqual(["https://www.merriam-webster.com/word-of-the-day", undefined]);
|
|
20
|
-
});
|
|
21
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { test, expect } from "@jest/globals";
|
|
2
|
-
import { OpenAI } from "@langchain/openai";
|
|
3
|
-
import { AsyncCaller } from "@langchain/core/utils/async_caller";
|
|
4
|
-
test("AsyncCaller.call passes on arguments and returns return value", async () => {
|
|
5
|
-
const caller = new AsyncCaller({});
|
|
6
|
-
const callable = () => fetch("https://langchain.com/");
|
|
7
|
-
const resultDirect = await callable();
|
|
8
|
-
const resultWrapped = await caller.call(callable);
|
|
9
|
-
expect(resultDirect.status).toEqual(200);
|
|
10
|
-
expect(resultWrapped.status).toEqual(200);
|
|
11
|
-
});
|
|
12
|
-
test("AsyncCaller doesn't retry on axios error 401", async () => {
|
|
13
|
-
const llm = new OpenAI({ openAIApiKey: "invalid" });
|
|
14
|
-
await expect(() => llm.call("test")).rejects.toThrowError();
|
|
15
|
-
}, 5000);
|
|
16
|
-
test("AsyncCaller doesn't retry on timeout", async () => {
|
|
17
|
-
const caller = new AsyncCaller({});
|
|
18
|
-
const callable = () => fetch("https://langchain.com/?sleep=1000", {
|
|
19
|
-
signal: AbortSignal.timeout(10),
|
|
20
|
-
});
|
|
21
|
-
await expect(() => caller.call(callable)).rejects.toThrowError("TimeoutError: The operation was aborted due to timeout");
|
|
22
|
-
}, 5000);
|
|
23
|
-
test("AsyncCaller doesn't retry on signal abort", async () => {
|
|
24
|
-
const controller = new AbortController();
|
|
25
|
-
const caller = new AsyncCaller({});
|
|
26
|
-
const callable = () => {
|
|
27
|
-
const ret = fetch("https://langchain.com/?sleep=1000", {
|
|
28
|
-
signal: controller.signal,
|
|
29
|
-
});
|
|
30
|
-
controller.abort();
|
|
31
|
-
return ret;
|
|
32
|
-
};
|
|
33
|
-
await expect(() => caller.call(callable)).rejects.toThrowError("AbortError: This operation was aborted");
|
|
34
|
-
}, 5000);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { getEndpoint } from "@langchain/openai";
|
|
2
|
-
describe("getEndpoint", () => {
|
|
3
|
-
it("should return the correct endpoint with azureOpenAIBasePath and azureOpenAIApiDeploymentName", () => {
|
|
4
|
-
const config = {
|
|
5
|
-
azureOpenAIApiKey: "API-KEY",
|
|
6
|
-
azureOpenAIApiDeploymentName: "deploymentName",
|
|
7
|
-
azureOpenAIBasePath: "https://westeurope.api.cognitive.microsoft.com/openai/deployments",
|
|
8
|
-
};
|
|
9
|
-
const result = getEndpoint(config);
|
|
10
|
-
expect(result).toBe("https://westeurope.api.cognitive.microsoft.com/openai/deployments/deploymentName");
|
|
11
|
-
});
|
|
12
|
-
it("should return the correct endpoint with azureOpenAIApiKey, azureOpenAIApiInstanceName, and azureOpenAIApiDeploymentName", () => {
|
|
13
|
-
const config = {
|
|
14
|
-
azureOpenAIApiKey: "key",
|
|
15
|
-
azureOpenAIApiInstanceName: "instanceName",
|
|
16
|
-
azureOpenAIApiDeploymentName: "deploymentName",
|
|
17
|
-
};
|
|
18
|
-
const result = getEndpoint(config);
|
|
19
|
-
expect(result).toBe("https://instanceName.openai.azure.com/openai/deployments/deploymentName");
|
|
20
|
-
});
|
|
21
|
-
it("should throw error when azureOpenAIApiInstanceName is missing with azureOpenAIApiKey", () => {
|
|
22
|
-
const config = {
|
|
23
|
-
azureOpenAIApiKey: "key",
|
|
24
|
-
azureOpenAIApiDeploymentName: "deploymentName",
|
|
25
|
-
};
|
|
26
|
-
expect(() => getEndpoint(config)).toThrowError("azureOpenAIApiInstanceName is required when using azureOpenAIApiKey");
|
|
27
|
-
});
|
|
28
|
-
it("should throw error when azureOpenAIApiDeploymentName is missing with azureOpenAIApiKey", () => {
|
|
29
|
-
const config = {
|
|
30
|
-
azureOpenAIApiKey: "key",
|
|
31
|
-
azureOpenAIApiInstanceName: "instanceName",
|
|
32
|
-
};
|
|
33
|
-
expect(() => getEndpoint(config)).toThrowError("azureOpenAIApiDeploymentName is a required parameter when using azureOpenAIApiKey");
|
|
34
|
-
});
|
|
35
|
-
it("should return the custom basePath when neither azureOpenAIBasePath nor azureOpenAIApiKey is provided", () => {
|
|
36
|
-
const config = {
|
|
37
|
-
baseURL: "https://basepath.com",
|
|
38
|
-
};
|
|
39
|
-
const result = getEndpoint(config);
|
|
40
|
-
expect(result).toBe("https://basepath.com");
|
|
41
|
-
});
|
|
42
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|