langchain 0.2.10 → 0.2.12
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 +99 -43
- 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,48 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-process-env */
|
|
2
|
-
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
3
|
-
import { test, jest, expect } from "@jest/globals";
|
|
4
|
-
import S3Client from "@aws-sdk/client-s3";
|
|
5
|
-
import * as fs from "node:fs";
|
|
6
|
-
import * as path from "node:path";
|
|
7
|
-
import { S3Loader } from "../web/s3.js";
|
|
8
|
-
const fsMock = {
|
|
9
|
-
...fs,
|
|
10
|
-
mkdtempSync: jest.fn().mockReturnValue("tmp/s3fileloader-12345"),
|
|
11
|
-
mkdirSync: jest.fn().mockImplementation(() => { }),
|
|
12
|
-
writeFileSync: jest.fn().mockImplementation((path, data) => {
|
|
13
|
-
console.log(`Writing "${data.toString()}" to ${path}`);
|
|
14
|
-
}),
|
|
15
|
-
};
|
|
16
|
-
const UnstructuredLoaderMock = jest.fn().mockImplementation(() => ({
|
|
17
|
-
load: jest.fn().mockImplementation(() => ["fake document"]),
|
|
18
|
-
}));
|
|
19
|
-
test.skip("Test S3 loader", async () => {
|
|
20
|
-
if (!S3Client) {
|
|
21
|
-
// this is to avoid a linting error. S3Client is mocked above.
|
|
22
|
-
}
|
|
23
|
-
const loader = new S3Loader({
|
|
24
|
-
bucket: process.env.AWS_S3_BUCKET_NAME,
|
|
25
|
-
key: process.env.AWS_S3_KEY,
|
|
26
|
-
unstructuredAPIURL: "http://localhost:8000/general/v0/general",
|
|
27
|
-
unstructuredAPIKey: "",
|
|
28
|
-
fs: fsMock,
|
|
29
|
-
UnstructuredLoader: UnstructuredLoaderMock,
|
|
30
|
-
s3Config: {
|
|
31
|
-
credentials: {
|
|
32
|
-
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
|
|
33
|
-
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
|
|
34
|
-
},
|
|
35
|
-
region: process.env.AWS_REGION,
|
|
36
|
-
},
|
|
37
|
-
});
|
|
38
|
-
const result = await loader.load();
|
|
39
|
-
const unstructuredOptions = {
|
|
40
|
-
apiUrl: "http://localhost:8000/general/v0/general",
|
|
41
|
-
apiKey: "",
|
|
42
|
-
};
|
|
43
|
-
expect(fsMock.mkdtempSync).toHaveBeenCalled();
|
|
44
|
-
expect(fsMock.mkdirSync).toHaveBeenCalled();
|
|
45
|
-
expect(fsMock.writeFileSync).toHaveBeenCalled();
|
|
46
|
-
expect(UnstructuredLoaderMock).toHaveBeenCalledWith(path.join("tmp", "s3fileloader-12345", "test.txt"), unstructuredOptions);
|
|
47
|
-
expect(result).toEqual(["fake document"]);
|
|
48
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { Document } from "@langchain/core/documents";
|
|
2
|
-
import { SearchApiLoader } from "../web/searchapi.js";
|
|
3
|
-
test("Test buildUrl method without engine", () => {
|
|
4
|
-
const loader = new SearchApiLoader({ apiKey: "ApiKey", q: "Query" });
|
|
5
|
-
expect(loader.buildUrl()).toBe("https://www.searchapi.io/api/v1/search?engine=google&api_key=ApiKey&q=Query");
|
|
6
|
-
});
|
|
7
|
-
test("Test buildUrl method with engine override", () => {
|
|
8
|
-
const loader = new SearchApiLoader({
|
|
9
|
-
engine: "google_news",
|
|
10
|
-
apiKey: "ApiKey",
|
|
11
|
-
q: "Query",
|
|
12
|
-
});
|
|
13
|
-
expect(loader.buildUrl()).toBe("https://www.searchapi.io/api/v1/search?engine=google_news&api_key=ApiKey&q=Query");
|
|
14
|
-
});
|
|
15
|
-
test("Test processResponseData method", () => {
|
|
16
|
-
const loader = new SearchApiLoader({ apiKey: "ApiKey", q: "Query" });
|
|
17
|
-
const data = {
|
|
18
|
-
answer_box: { type: "organic_result", answer: "1918" },
|
|
19
|
-
};
|
|
20
|
-
const documents = loader.processResponseData(data);
|
|
21
|
-
expect(documents).toHaveLength(1);
|
|
22
|
-
const document = documents[0];
|
|
23
|
-
expect(document).toBeInstanceOf(Document);
|
|
24
|
-
expect(document.pageContent).toBe(JSON.stringify(data.answer_box));
|
|
25
|
-
expect(document.metadata).toEqual({
|
|
26
|
-
source: "SearchApi",
|
|
27
|
-
responseType: "answer_box",
|
|
28
|
-
});
|
|
29
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Document } from "@langchain/core/documents";
|
|
2
|
-
import { SerpAPILoader } from "../web/serpapi.js";
|
|
3
|
-
test("Test buildUrl method", () => {
|
|
4
|
-
const loader = new SerpAPILoader({ q: "testQuery", apiKey: "testApiKey" });
|
|
5
|
-
expect(loader.buildUrl()).toBe("https://serpapi.com/search?api_key=testApiKey&q=testQuery");
|
|
6
|
-
});
|
|
7
|
-
test("Test processResponseData method", () => {
|
|
8
|
-
const loader = new SerpAPILoader({ q: "testQuery", apiKey: "testApiKey" });
|
|
9
|
-
const data = {
|
|
10
|
-
answer_box: { type: "calculator_result", result: "3.141592653589793" },
|
|
11
|
-
};
|
|
12
|
-
const documents = loader.processResponseData(data);
|
|
13
|
-
expect(documents).toHaveLength(1);
|
|
14
|
-
const document = documents[0];
|
|
15
|
-
expect(document).toBeInstanceOf(Document);
|
|
16
|
-
expect(document.pageContent).toBe(JSON.stringify(data.answer_box));
|
|
17
|
-
expect(document.metadata).toEqual({
|
|
18
|
-
source: "SerpAPI",
|
|
19
|
-
responseType: "answer_box",
|
|
20
|
-
});
|
|
21
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { test } from "@jest/globals";
|
|
2
|
-
import { SitemapLoader } from "../web/sitemap.js";
|
|
3
|
-
test("SitemapLoader", async () => {
|
|
4
|
-
const regexFailIfNotJsLangChain = /^https:\/\/js\.langchain\.com\//;
|
|
5
|
-
const regexContainsToolsDynamic = /tools\/dynamic/;
|
|
6
|
-
// Filter our 1 bad url (has since been fixed in vercel, but keep the test!)
|
|
7
|
-
const loader = new SitemapLoader("https://js.langchain.com/", {
|
|
8
|
-
filterUrls: [regexFailIfNotJsLangChain, regexContainsToolsDynamic],
|
|
9
|
-
});
|
|
10
|
-
const docs = await loader.load();
|
|
11
|
-
expect(docs.length).toBeGreaterThan(0);
|
|
12
|
-
});
|
|
13
|
-
test("checkUrlPatterns can properly identify unwanted links", async () => {
|
|
14
|
-
const links = [
|
|
15
|
-
"https://js.langchain.com/docs/use_cases/agent_simulations/",
|
|
16
|
-
"https://js.langchain.com/docs/use_cases/agent_simulations/generative_agents",
|
|
17
|
-
"https://js.langchain.com/docs/integrations/platforms/google",
|
|
18
|
-
"https://js.langchain.com/docs/integrations/vectorstores/analyticdb",
|
|
19
|
-
"https://js.langchain.com/docs/expression_language/interface",
|
|
20
|
-
"https://js.langchain.com/docs/modules/data_connection/",
|
|
21
|
-
];
|
|
22
|
-
const linkRegex = /^(https:\/\/js\.langchain\.com\/docs\/use_cases)|.*interface$/;
|
|
23
|
-
const loader = new SitemapLoader("https://www.langchain.com/", {
|
|
24
|
-
filterUrls: [linkRegex.source],
|
|
25
|
-
});
|
|
26
|
-
const matches = links.map((link) => loader._checkUrlPatterns(link));
|
|
27
|
-
expect(matches).toEqual([true, true, false, false, true, false]);
|
|
28
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
import { test, jest, expect } from "@jest/globals";
|
|
3
|
-
import { SonixSpeechRecognitionService } from "sonix-speech-recognition";
|
|
4
|
-
import { SonixAudioTranscriptionLoader } from "../web/sonix_audio.js";
|
|
5
|
-
jest.mock("sonix-speech-recognition");
|
|
6
|
-
describe("SonixAudioTranscriptionLoader", () => {
|
|
7
|
-
let sonixSpeechRecognitionService;
|
|
8
|
-
let speechToTextRequest;
|
|
9
|
-
let sonixAudioTranscriptionLoader;
|
|
10
|
-
beforeEach(() => {
|
|
11
|
-
sonixSpeechRecognitionService = new SonixSpeechRecognitionService("auth-key");
|
|
12
|
-
speechToTextRequest = {
|
|
13
|
-
fileName: "test.mp3",
|
|
14
|
-
language: "en",
|
|
15
|
-
audioFilePath: "./test.mp3",
|
|
16
|
-
};
|
|
17
|
-
sonixAudioTranscriptionLoader = new SonixAudioTranscriptionLoader({
|
|
18
|
-
sonixAuthKey: "auth-key",
|
|
19
|
-
request: speechToTextRequest,
|
|
20
|
-
});
|
|
21
|
-
sonixAudioTranscriptionLoader.sonixSpeechRecognitionService =
|
|
22
|
-
sonixSpeechRecognitionService;
|
|
23
|
-
});
|
|
24
|
-
test("should initialize properly", () => {
|
|
25
|
-
expect(sonixAudioTranscriptionLoader).toBeDefined();
|
|
26
|
-
});
|
|
27
|
-
describe("load", () => {
|
|
28
|
-
test("should return a document when transcription is successful", async () => {
|
|
29
|
-
const response = {
|
|
30
|
-
jobId: "job-id",
|
|
31
|
-
text: "test transcription",
|
|
32
|
-
status: "completed",
|
|
33
|
-
};
|
|
34
|
-
sonixSpeechRecognitionService.speechToText = jest
|
|
35
|
-
.fn()
|
|
36
|
-
.mockResolvedValue(response);
|
|
37
|
-
const documents = await sonixAudioTranscriptionLoader.load();
|
|
38
|
-
expect(documents).toHaveLength(1);
|
|
39
|
-
expect(documents[0].pageContent).toBe(response.text);
|
|
40
|
-
expect(documents[0].metadata.fileName).toBe(speechToTextRequest.fileName);
|
|
41
|
-
});
|
|
42
|
-
test("should throw when transcription fails", async () => {
|
|
43
|
-
const response = {
|
|
44
|
-
jobId: "job-id",
|
|
45
|
-
text: "",
|
|
46
|
-
status: "failed",
|
|
47
|
-
error: "Error message",
|
|
48
|
-
};
|
|
49
|
-
sonixSpeechRecognitionService.speechToText = jest
|
|
50
|
-
.fn()
|
|
51
|
-
.mockResolvedValue(response);
|
|
52
|
-
await expect(sonixAudioTranscriptionLoader.load()).rejects.toThrow();
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { test } from "@jest/globals";
|
|
2
|
-
import { SortXYZBlockchainLoader } from "../web/sort_xyz_blockchain.js";
|
|
3
|
-
const SORT_XYZ_DEMO_API_KEY = "dd46a0ae-5a1a-4c6f-8328-46618c4a73d4";
|
|
4
|
-
const contractAddress = "0x887F3909C14DAbd9e9510128cA6cBb448E932d7f".toLowerCase();
|
|
5
|
-
test.skip("Test Blockchain NFT Metadata Loader", async () => {
|
|
6
|
-
const nftMetadataLoader = new SortXYZBlockchainLoader({
|
|
7
|
-
apiKey: SORT_XYZ_DEMO_API_KEY,
|
|
8
|
-
query: {
|
|
9
|
-
type: "NFTMetadata",
|
|
10
|
-
blockchain: "ethereum",
|
|
11
|
-
contractAddress,
|
|
12
|
-
limit: 3,
|
|
13
|
-
},
|
|
14
|
-
});
|
|
15
|
-
const response = await nftMetadataLoader.load();
|
|
16
|
-
console.log(response);
|
|
17
|
-
});
|
|
18
|
-
test.skip("Test Blockchain Latest Transactions Loader", async () => {
|
|
19
|
-
const latestTransactionsLoader = new SortXYZBlockchainLoader({
|
|
20
|
-
apiKey: SORT_XYZ_DEMO_API_KEY,
|
|
21
|
-
query: {
|
|
22
|
-
type: "latestTransactions",
|
|
23
|
-
blockchain: "ethereum",
|
|
24
|
-
contractAddress,
|
|
25
|
-
limit: 3,
|
|
26
|
-
},
|
|
27
|
-
});
|
|
28
|
-
const response = await latestTransactionsLoader.load();
|
|
29
|
-
console.log(response);
|
|
30
|
-
});
|
|
31
|
-
test.skip("Test Blockchain SQL Query Loader", async () => {
|
|
32
|
-
const sqlQueryLoader = new SortXYZBlockchainLoader({
|
|
33
|
-
apiKey: SORT_XYZ_DEMO_API_KEY,
|
|
34
|
-
query: `SELECT * FROM ethereum.nft_metadata WHERE contract_address = '${contractAddress}' AND token_id = 1 LIMIT 1`,
|
|
35
|
-
});
|
|
36
|
-
const response = await sqlQueryLoader.load();
|
|
37
|
-
console.log(response);
|
|
38
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import * as url from "node:url";
|
|
2
|
-
import * as path from "node:path";
|
|
3
|
-
import * as fs from "node:fs/promises";
|
|
4
|
-
import { test, expect } from "@jest/globals";
|
|
5
|
-
import { SRTLoader } from "../fs/srt.js";
|
|
6
|
-
test("Test SRT loader from blob", async () => {
|
|
7
|
-
const filePath = path.resolve(path.dirname(url.fileURLToPath(import.meta.url)), "./example_data/Star_Wars_The_Clone_Wars_S06E07_Crisis_at_the_Heart.srt");
|
|
8
|
-
const loader = new SRTLoader(new Blob([await fs.readFile(filePath)], { type: "application/x-subrip" }));
|
|
9
|
-
const docs = await loader.load();
|
|
10
|
-
expect(docs.length).toBe(1);
|
|
11
|
-
expect(docs[0].metadata).toMatchInlineSnapshot(`
|
|
12
|
-
{
|
|
13
|
-
"blobType": "application/x-subrip",
|
|
14
|
-
"source": "blob",
|
|
15
|
-
}
|
|
16
|
-
`);
|
|
17
|
-
expect(docs[0].pageContent).toContain("Corruption discovered");
|
|
18
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import * as url from "node:url";
|
|
2
|
-
import * as path from "node:path";
|
|
3
|
-
import { test, expect } from "@jest/globals";
|
|
4
|
-
import { SRTLoader } from "../fs/srt.js";
|
|
5
|
-
test("Test SRT loader from file", async () => {
|
|
6
|
-
const filePath = path.resolve(path.dirname(url.fileURLToPath(import.meta.url)), "./example_data/Star_Wars_The_Clone_Wars_S06E07_Crisis_at_the_Heart.srt");
|
|
7
|
-
const loader = new SRTLoader(filePath);
|
|
8
|
-
const docs = await loader.load();
|
|
9
|
-
expect(docs.length).toBe(1);
|
|
10
|
-
expect(docs[0].metadata).toMatchInlineSnapshot(`
|
|
11
|
-
{
|
|
12
|
-
"source": "${filePath}",
|
|
13
|
-
}
|
|
14
|
-
`);
|
|
15
|
-
expect(docs[0].pageContent).toContain("Corruption discovered");
|
|
16
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { test, expect } from "@jest/globals";
|
|
2
|
-
import { TextLoader } from "../fs/text.js";
|
|
3
|
-
test("Test Text loader from blob", async () => {
|
|
4
|
-
const loader = new TextLoader(new Blob(["Hello, world!"], { type: "text/plain" }));
|
|
5
|
-
const docs = await loader.load();
|
|
6
|
-
expect(docs.length).toBe(1);
|
|
7
|
-
expect(docs[0].pageContent).toBe("Hello, world!");
|
|
8
|
-
expect(docs[0].metadata).toMatchInlineSnapshot(`
|
|
9
|
-
{
|
|
10
|
-
"blobType": "text/plain",
|
|
11
|
-
"source": "blob",
|
|
12
|
-
}
|
|
13
|
-
`);
|
|
14
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { test, expect } from "@jest/globals";
|
|
2
|
-
import * as url from "node:url";
|
|
3
|
-
import * as path from "node:path";
|
|
4
|
-
import { TextLoader } from "../fs/text.js";
|
|
5
|
-
test("Test Text loader from file", async () => {
|
|
6
|
-
const filePath = path.resolve(path.dirname(url.fileURLToPath(import.meta.url)), "./example_data/example.txt");
|
|
7
|
-
const loader = new TextLoader(filePath);
|
|
8
|
-
const docs = await loader.load();
|
|
9
|
-
expect(docs.length).toBe(1);
|
|
10
|
-
expect(docs[0].pageContent).toMatchInlineSnapshot(`
|
|
11
|
-
"Foo
|
|
12
|
-
Bar
|
|
13
|
-
Baz
|
|
14
|
-
|
|
15
|
-
"
|
|
16
|
-
`);
|
|
17
|
-
expect(docs[0].metadata).toMatchInlineSnapshot(`
|
|
18
|
-
{
|
|
19
|
-
"source": "${filePath}",
|
|
20
|
-
}
|
|
21
|
-
`);
|
|
22
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-process-env */
|
|
2
|
-
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
3
|
-
import * as url from "node:url";
|
|
4
|
-
import * as path from "node:path";
|
|
5
|
-
import { readFile } from "node:fs/promises";
|
|
6
|
-
import { test, expect } from "@jest/globals";
|
|
7
|
-
import { UnstructuredDirectoryLoader, UnstructuredLoader, UnknownHandling, } from "../fs/unstructured.js";
|
|
8
|
-
test.skip("Test Unstructured base loader", async () => {
|
|
9
|
-
const filePath = path.resolve(path.dirname(url.fileURLToPath(import.meta.url)), "./example_data/example.txt");
|
|
10
|
-
const options = {
|
|
11
|
-
apiKey: process.env.UNSTRUCTURED_API_KEY,
|
|
12
|
-
};
|
|
13
|
-
const loader = new UnstructuredLoader(filePath, options);
|
|
14
|
-
const docs = await loader.load();
|
|
15
|
-
expect(docs.length).toBe(3);
|
|
16
|
-
for (const doc of docs) {
|
|
17
|
-
expect(typeof doc.pageContent).toBe("string");
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
test.skip("Test Unstructured base loader with buffer", async () => {
|
|
21
|
-
const filePath = path.resolve(path.dirname(url.fileURLToPath(import.meta.url)), "./example_data/example.txt");
|
|
22
|
-
const options = {
|
|
23
|
-
apiKey: process.env.UNSTRUCTURED_API_KEY,
|
|
24
|
-
};
|
|
25
|
-
const buffer = await readFile(filePath);
|
|
26
|
-
const fileName = "example.txt";
|
|
27
|
-
const loader = new UnstructuredLoader({
|
|
28
|
-
buffer,
|
|
29
|
-
fileName,
|
|
30
|
-
}, options);
|
|
31
|
-
const docs = await loader.load();
|
|
32
|
-
expect(docs.length).toBe(3);
|
|
33
|
-
for (const doc of docs) {
|
|
34
|
-
expect(typeof doc.pageContent).toBe("string");
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
test.skip("Test Unstructured base loader with fast strategy", async () => {
|
|
38
|
-
const filePath = path.resolve(path.dirname(url.fileURLToPath(import.meta.url)), "./example_data/1706.03762.pdf");
|
|
39
|
-
const options = {
|
|
40
|
-
apiKey: process.env.UNSTRUCTURED_API_KEY,
|
|
41
|
-
strategy: "fast",
|
|
42
|
-
};
|
|
43
|
-
const loader = new UnstructuredLoader(filePath, options);
|
|
44
|
-
const docs = await loader.load();
|
|
45
|
-
expect(docs.length).toBeGreaterThan(10);
|
|
46
|
-
expect(typeof docs[0].pageContent).toBe("string");
|
|
47
|
-
});
|
|
48
|
-
test.skip("Test Unstructured directory loader", async () => {
|
|
49
|
-
const directoryPath = path.resolve(path.dirname(url.fileURLToPath(import.meta.url)), "./example_data");
|
|
50
|
-
const options = {
|
|
51
|
-
apiKey: process.env.UNSTRUCTURED_API_KEY,
|
|
52
|
-
strategy: "fast",
|
|
53
|
-
};
|
|
54
|
-
const loader = new UnstructuredDirectoryLoader(directoryPath, options, true, UnknownHandling.Ignore);
|
|
55
|
-
const docs = await loader.load();
|
|
56
|
-
expect(docs.length).toBeGreaterThan(100);
|
|
57
|
-
expect(typeof docs[0].pageContent).toBe("string");
|
|
58
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { test, expect } from "@jest/globals";
|
|
2
|
-
import * as url from "node:url";
|
|
3
|
-
import * as path from "node:path";
|
|
4
|
-
import * as fs from "node:fs/promises";
|
|
5
|
-
import { WebPDFLoader } from "../web/pdf.js";
|
|
6
|
-
test("Test Web PDF loader from blob", async () => {
|
|
7
|
-
const filePath = path.resolve(path.dirname(url.fileURLToPath(import.meta.url)), "./example_data/1706.03762.pdf");
|
|
8
|
-
const loader = new WebPDFLoader(new Blob([await fs.readFile(filePath)], {
|
|
9
|
-
type: "application/pdf",
|
|
10
|
-
}));
|
|
11
|
-
const docs = await loader.load();
|
|
12
|
-
expect(docs.length).toBe(15);
|
|
13
|
-
expect(docs[0].pageContent).toContain("Attention Is All You Need");
|
|
14
|
-
expect(docs[0].metadata).toMatchInlineSnapshot(`
|
|
15
|
-
{
|
|
16
|
-
"loc": {
|
|
17
|
-
"pageNumber": 1,
|
|
18
|
-
},
|
|
19
|
-
"pdf": {
|
|
20
|
-
"info": {
|
|
21
|
-
"Author": "",
|
|
22
|
-
"CreationDate": "D:20171207010315Z",
|
|
23
|
-
"Creator": "LaTeX with hyperref package",
|
|
24
|
-
"IsAcroFormPresent": false,
|
|
25
|
-
"IsXFAPresent": false,
|
|
26
|
-
"Keywords": "",
|
|
27
|
-
"ModDate": "D:20171207010315Z",
|
|
28
|
-
"PDFFormatVersion": "1.5",
|
|
29
|
-
"Producer": "pdfTeX-1.40.17",
|
|
30
|
-
"Subject": "",
|
|
31
|
-
"Title": "",
|
|
32
|
-
"Trapped": {
|
|
33
|
-
"name": "False",
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
"metadata": null,
|
|
37
|
-
"totalPages": 15,
|
|
38
|
-
"version": "1.10.100",
|
|
39
|
-
},
|
|
40
|
-
}
|
|
41
|
-
`);
|
|
42
|
-
});
|
|
43
|
-
test("Test Web PDF loader with custom pdfjs", async () => {
|
|
44
|
-
const filePath = path.resolve(path.dirname(url.fileURLToPath(import.meta.url)), "./example_data/1706.03762.pdf");
|
|
45
|
-
const loader = new WebPDFLoader(new Blob([await fs.readFile(filePath)], {
|
|
46
|
-
type: "application/pdf",
|
|
47
|
-
}), {
|
|
48
|
-
pdfjs: () => import("pdf-parse/lib/pdf.js/v1.10.100/build/pdf.js"),
|
|
49
|
-
});
|
|
50
|
-
const docs = await loader.load();
|
|
51
|
-
expect(docs.length).toBe(15);
|
|
52
|
-
expect(docs[0].pageContent).toContain("Attention Is All You Need");
|
|
53
|
-
expect(docs[0].metadata).toMatchInlineSnapshot(`
|
|
54
|
-
{
|
|
55
|
-
"loc": {
|
|
56
|
-
"pageNumber": 1,
|
|
57
|
-
},
|
|
58
|
-
"pdf": {
|
|
59
|
-
"info": {
|
|
60
|
-
"Author": "",
|
|
61
|
-
"CreationDate": "D:20171207010315Z",
|
|
62
|
-
"Creator": "LaTeX with hyperref package",
|
|
63
|
-
"IsAcroFormPresent": false,
|
|
64
|
-
"IsXFAPresent": false,
|
|
65
|
-
"Keywords": "",
|
|
66
|
-
"ModDate": "D:20171207010315Z",
|
|
67
|
-
"PDFFormatVersion": "1.5",
|
|
68
|
-
"Producer": "pdfTeX-1.40.17",
|
|
69
|
-
"Subject": "",
|
|
70
|
-
"Title": "",
|
|
71
|
-
"Trapped": {
|
|
72
|
-
"name": "False",
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
"metadata": null,
|
|
76
|
-
"totalPages": 15,
|
|
77
|
-
"version": "1.10.100",
|
|
78
|
-
},
|
|
79
|
-
}
|
|
80
|
-
`);
|
|
81
|
-
});
|
|
82
|
-
test("Test Web PDF loader lines", async () => {
|
|
83
|
-
const filePath = path.resolve(path.dirname(url.fileURLToPath(import.meta.url)), "./example_data/Jacob_Lee_Resume_2023.pdf");
|
|
84
|
-
const loader = new WebPDFLoader(new Blob([await fs.readFile(filePath)], {
|
|
85
|
-
type: "application/pdf",
|
|
86
|
-
}), { splitPages: false });
|
|
87
|
-
const docs = await loader.load();
|
|
88
|
-
expect(docs.length).toBe(1);
|
|
89
|
-
expect(docs[0].pageContent.split("\n").length).toBeLessThan(100);
|
|
90
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { expect, test } from "@jest/globals";
|
|
3
|
-
import { Document } from "@langchain/core/documents";
|
|
4
|
-
import { ChatOpenAI } from "@langchain/openai";
|
|
5
|
-
import { PromptTemplate } from "@langchain/core/prompts";
|
|
6
|
-
import { createMetadataTaggerFromZod } from "../openai_functions.js";
|
|
7
|
-
const taggingChainTemplate = `Extract the desired information from the following passage.
|
|
8
|
-
Anonymous critics are actually Roger Ebert.
|
|
9
|
-
|
|
10
|
-
Passage:
|
|
11
|
-
{input}
|
|
12
|
-
`;
|
|
13
|
-
test("Test OpenAIFunctions MetadataTagger", async () => {
|
|
14
|
-
const zodSchema = z.object({
|
|
15
|
-
movie_title: z.string(),
|
|
16
|
-
critic: z.string(),
|
|
17
|
-
tone: z.enum(["positive", "negative"]),
|
|
18
|
-
rating: z
|
|
19
|
-
.optional(z.number())
|
|
20
|
-
.describe("The number of stars the critic rated the movie"),
|
|
21
|
-
});
|
|
22
|
-
const metadataTagger = createMetadataTaggerFromZod(zodSchema, {
|
|
23
|
-
llm: new ChatOpenAI({ modelName: "gpt-3.5-turbo" }),
|
|
24
|
-
prompt: PromptTemplate.fromTemplate(taggingChainTemplate),
|
|
25
|
-
});
|
|
26
|
-
const documents = [
|
|
27
|
-
new Document({
|
|
28
|
-
pageContent: "Review of The Bee Movie\nBy Roger Ebert\nThis is the greatest movie ever made. 4 out of 5 stars.",
|
|
29
|
-
}),
|
|
30
|
-
new Document({
|
|
31
|
-
pageContent: "Review of The Godfather\nBy Anonymous\n\nThis movie was super boring. 1 out of 5 stars.",
|
|
32
|
-
metadata: { reliable: false },
|
|
33
|
-
}),
|
|
34
|
-
];
|
|
35
|
-
const newDocuments = await metadataTagger.transformDocuments(documents);
|
|
36
|
-
console.log(newDocuments);
|
|
37
|
-
expect(newDocuments.length).toBe(2);
|
|
38
|
-
expect(newDocuments[0].metadata.movie_title).toBe("The Bee Movie");
|
|
39
|
-
expect(newDocuments[1].metadata.movie_title).toBe("The Godfather");
|
|
40
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { test, expect } from "@jest/globals";
|
|
2
|
-
import { Embeddings } from "@langchain/core/embeddings";
|
|
3
|
-
import { CacheBackedEmbeddings } from "../cache_backed.js";
|
|
4
|
-
import { InMemoryStore } from "../../storage/in_memory.js";
|
|
5
|
-
class RandomEmbeddings extends Embeddings {
|
|
6
|
-
async embedDocuments(documents) {
|
|
7
|
-
const quoteUnquoteEmbeddings = [];
|
|
8
|
-
for (const document of documents) {
|
|
9
|
-
quoteUnquoteEmbeddings.push(await this.embedQuery(document));
|
|
10
|
-
}
|
|
11
|
-
return quoteUnquoteEmbeddings;
|
|
12
|
-
}
|
|
13
|
-
async embedQuery(_document) {
|
|
14
|
-
return [Math.random(), Math.random()];
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
test("Basic embeddings cache", async () => {
|
|
18
|
-
const embeddingsCache = CacheBackedEmbeddings.fromBytesStore(new RandomEmbeddings({}), new InMemoryStore());
|
|
19
|
-
const documents = ["How are you?", "I am fine", "I am LangChain"];
|
|
20
|
-
const result = await embeddingsCache.embedDocuments(documents);
|
|
21
|
-
expect(result.findIndex((v) => v === undefined)).toEqual(-1);
|
|
22
|
-
const result2 = await embeddingsCache.embedDocuments(documents);
|
|
23
|
-
expect(result).toEqual(result2);
|
|
24
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { test, expect } from "@jest/globals";
|
|
2
|
-
import { SyntheticEmbeddings } from "@langchain/core/utils/testing";
|
|
3
|
-
test("Synthetic basic", async () => {
|
|
4
|
-
const embed = new SyntheticEmbeddings({ vectorSize: 5 });
|
|
5
|
-
const vector = await embed.embedQuery("aaaaaaaaaa");
|
|
6
|
-
expect(vector).toHaveLength(5);
|
|
7
|
-
expect(vector[0]).toEqual(0.46153846153846156);
|
|
8
|
-
expect(vector[4]).toEqual(0.46153846153846156);
|
|
9
|
-
});
|
|
10
|
-
test("Synthetic Padding", async () => {
|
|
11
|
-
const embed = new SyntheticEmbeddings({ vectorSize: 5 });
|
|
12
|
-
const vector = await embed.embedQuery("aaaaaaaaa");
|
|
13
|
-
expect(vector).toHaveLength(5);
|
|
14
|
-
expect(vector[0]).toEqual(0.46153846153846156);
|
|
15
|
-
expect(vector[4]).toEqual(0.9615384615384616);
|
|
16
|
-
});
|
|
17
|
-
test("Synthetic extreme padding", async () => {
|
|
18
|
-
const embed = new SyntheticEmbeddings({ vectorSize: 768 });
|
|
19
|
-
const vector = await embed.embedQuery("aa");
|
|
20
|
-
expect(vector).toHaveLength(768);
|
|
21
|
-
expect(vector[0]).toEqual(0.7307692307692307);
|
|
22
|
-
expect(vector[1]).toEqual(0.7307692307692307);
|
|
23
|
-
expect(vector[2]).toEqual(0);
|
|
24
|
-
});
|
|
25
|
-
test("Synthetic similarity", async () => {
|
|
26
|
-
const embed = new SyntheticEmbeddings({ vectorSize: 2 });
|
|
27
|
-
const v1 = await embed.embedQuery("this");
|
|
28
|
-
const v2 = await embed.embedQuery("that");
|
|
29
|
-
console.log(v1, v2);
|
|
30
|
-
expect(v1).toHaveLength(2);
|
|
31
|
-
expect(v2).toHaveLength(2);
|
|
32
|
-
expect(v1[0]).toEqual(v2[0]);
|
|
33
|
-
expect(v1[1]).not.toEqual(v2[1]);
|
|
34
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { expect, test } from "@jest/globals";
|
|
2
|
-
import process from "process";
|
|
3
|
-
import { OpenAI } from "@langchain/openai";
|
|
4
|
-
import { SerpAPI } from "../../../util/testing/tools/serpapi.js";
|
|
5
|
-
import { Calculator } from "../../../util/testing/tools/calculator.js";
|
|
6
|
-
import { initializeAgentExecutorWithOptions } from "../../../agents/index.js";
|
|
7
|
-
import { loadEvaluator } from "../../loader.js";
|
|
8
|
-
test("Test TrajectoryEvalChain", async () => {
|
|
9
|
-
const model = new OpenAI({ temperature: 0 });
|
|
10
|
-
const tools = [
|
|
11
|
-
// eslint-disable-next-line no-process-env
|
|
12
|
-
new SerpAPI(process.env.SERPAPI_API_KEY, {
|
|
13
|
-
location: "Austin,Texas,United States",
|
|
14
|
-
hl: "en",
|
|
15
|
-
gl: "us",
|
|
16
|
-
}),
|
|
17
|
-
new Calculator(),
|
|
18
|
-
];
|
|
19
|
-
const executor = await initializeAgentExecutorWithOptions(tools, model, {
|
|
20
|
-
agentType: "zero-shot-react-description",
|
|
21
|
-
returnIntermediateSteps: true,
|
|
22
|
-
});
|
|
23
|
-
const input = `Who is Olivia Wilde's boyfriend? What is his current age raised to the 0.23 power?`;
|
|
24
|
-
const result = await executor.call({ input });
|
|
25
|
-
const chain = await loadEvaluator("trajectory");
|
|
26
|
-
const res = await chain.evaluateAgentTrajectory({
|
|
27
|
-
prediction: result.output,
|
|
28
|
-
input,
|
|
29
|
-
agentTrajectory: result.intermediateSteps,
|
|
30
|
-
});
|
|
31
|
-
expect(res.score).toBeDefined();
|
|
32
|
-
console.log({ res });
|
|
33
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|