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,125 +0,0 @@
|
|
|
1
|
-
import { expect, test } from "@jest/globals";
|
|
2
|
-
import { DataSource } from "typeorm";
|
|
3
|
-
import { OpenAI } from "@langchain/openai";
|
|
4
|
-
import { SqlDatabaseChain } from "../sql_db/sql_db_chain.js";
|
|
5
|
-
import { SqlDatabase } from "../../sql_db.js";
|
|
6
|
-
import { SQL_SQLITE_PROMPT } from "../sql_db/sql_db_prompt.js";
|
|
7
|
-
test("Test SqlDatabaseChain", async () => {
|
|
8
|
-
const datasource = new DataSource({
|
|
9
|
-
type: "sqlite",
|
|
10
|
-
database: ":memory:",
|
|
11
|
-
synchronize: true,
|
|
12
|
-
});
|
|
13
|
-
await datasource.initialize();
|
|
14
|
-
await datasource.query(`
|
|
15
|
-
CREATE TABLE users (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER);
|
|
16
|
-
`);
|
|
17
|
-
await datasource.query(`
|
|
18
|
-
INSERT INTO users (name, age) VALUES ('Alice', 20);
|
|
19
|
-
`);
|
|
20
|
-
await datasource.query(`
|
|
21
|
-
INSERT INTO users (name, age) VALUES ('Bob', 21);
|
|
22
|
-
`);
|
|
23
|
-
await datasource.query(`
|
|
24
|
-
INSERT INTO users (name, age) VALUES ('Charlie', 22);
|
|
25
|
-
`);
|
|
26
|
-
const db = await SqlDatabase.fromDataSourceParams({
|
|
27
|
-
appDataSource: datasource,
|
|
28
|
-
});
|
|
29
|
-
const chain = new SqlDatabaseChain({
|
|
30
|
-
llm: new OpenAI({ temperature: 0 }),
|
|
31
|
-
database: db,
|
|
32
|
-
});
|
|
33
|
-
expect(chain.prompt).toBe(SQL_SQLITE_PROMPT);
|
|
34
|
-
const run = await chain.run("How many users are there?");
|
|
35
|
-
console.log(run);
|
|
36
|
-
await datasource.destroy();
|
|
37
|
-
});
|
|
38
|
-
test("Test SqlDatabaseChain with sqlOutputKey", async () => {
|
|
39
|
-
const datasource = new DataSource({
|
|
40
|
-
type: "sqlite",
|
|
41
|
-
database: ":memory:",
|
|
42
|
-
synchronize: true,
|
|
43
|
-
});
|
|
44
|
-
await datasource.initialize();
|
|
45
|
-
await datasource.query(`
|
|
46
|
-
CREATE TABLE users (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER);
|
|
47
|
-
`);
|
|
48
|
-
await datasource.query(`
|
|
49
|
-
INSERT INTO users (name, age) VALUES ('Alice', 20);
|
|
50
|
-
`);
|
|
51
|
-
await datasource.query(`
|
|
52
|
-
INSERT INTO users (name, age) VALUES ('Bob', 21);
|
|
53
|
-
`);
|
|
54
|
-
await datasource.query(`
|
|
55
|
-
INSERT INTO users (name, age) VALUES ('Charlie', 22);
|
|
56
|
-
`);
|
|
57
|
-
const db = await SqlDatabase.fromDataSourceParams({
|
|
58
|
-
appDataSource: datasource,
|
|
59
|
-
});
|
|
60
|
-
const chain = new SqlDatabaseChain({
|
|
61
|
-
llm: new OpenAI({ temperature: 0 }),
|
|
62
|
-
database: db,
|
|
63
|
-
inputKey: "query",
|
|
64
|
-
sqlOutputKey: "sql",
|
|
65
|
-
});
|
|
66
|
-
expect(chain.prompt).toBe(SQL_SQLITE_PROMPT);
|
|
67
|
-
const run = await chain.call({ query: "How many users are there?" });
|
|
68
|
-
console.log(run);
|
|
69
|
-
expect(run).toHaveProperty("sql");
|
|
70
|
-
await datasource.destroy();
|
|
71
|
-
});
|
|
72
|
-
// We create this string to reach the token limit of the query built to describe the database and get the SQL query.
|
|
73
|
-
const veryLongString = `Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam orci nisi, vulputate ac pulvinar eu, maximus a tortor. Duis suscipit, nibh vel fermentum vehicula, mauris ante convallis metus, et feugiat turpis mauris non felis. Interdum et malesuada fames ac ante ipsum primis in faucibus. Maecenas efficitur nibh in nisi sagittis ultrices. Donec id velit nunc. Nam a lacus risus. Vestibulum molestie massa eget convallis pellentesque.
|
|
74
|
-
Mauris a nisl eget velit finibus blandit ac a odio. Sed sagittis consequat urna a egestas. Curabitur pretium convallis nibh, in ullamcorper odio tempus nec. Curabitur laoreet nec nisl sed accumsan. Sed elementum eleifend molestie. Aenean ullamcorper interdum risus, eget pharetra est volutpat ut. Aenean maximus consequat justo rutrum finibus. Mauris consequat facilisis consectetur. Vivamus rutrum dignissim libero, non aliquam lectus tempus id. In hac habitasse platea dictumst. Sed at magna dignissim, tincidunt lectus in, malesuada risus. Phasellus placerat blandit ligula. Integer posuere id elit at commodo. Sed consequat sagittis odio eget congue.
|
|
75
|
-
Aliquam ultricies, sapien a porta luctus, dolor nibh dignissim erat, dictum luctus orci lorem non quam. Quisque dapibus tempus mattis. Suspendisse gravida consequat mi at viverra. Quisque sed est purus. Fusce tincidunt semper massa eu blandit. Donec in lacus a tortor facilisis facilisis. Interdum et malesuada fames ac ante ipsum primis in faucibus. In aliquam dignissim eros ac consectetur. Aliquam fringilla magna erat. Nullam tincidunt maximus nulla, quis gravida est varius vel. Aliquam cursus, diam non facilisis mollis, nunc diam convallis enim, ac tempus diam tortor in dui. Nunc feugiat ligula odio, eleifend fermentum quam tincidunt sed. Duis pellentesque quam eget volutpat commodo.
|
|
76
|
-
Aliquam ex velit, porta sit amet augue vulputate, rhoncus fermentum magna. Integer non elementum augue. Phasellus rhoncus nisl nec magna lacinia vulputate. Suspendisse diam nibh, egestas a porta a, pellentesque ut nisl. Donec tempus ligula at leo convallis consequat. Duis sapien lorem, lobortis ac nisl dapibus, bibendum mollis lorem. Sed congue porttitor ex, eget scelerisque ligula consectetur quis. Mauris felis mauris, sodales quis nunc non, condimentum eleifend quam. Ut vitae viverra lorem. Vivamus lacinia et dolor vitae cursus. Proin faucibus venenatis enim vitae tincidunt. Sed sed venenatis leo.
|
|
77
|
-
Donec eu erat ullamcorper, consectetur dui sed, cursus tellus. Phasellus consectetur felis augue, quis auctor odio semper ac. In scelerisque gravida ligula eget lobortis. Sed tristique ultricies fringilla. Nunc in ultrices purus. Curabitur dictum cursus ante, at tempus est interdum at. Donec gravida lectus ut purus vestibulum, eu accumsan nisl pharetra.
|
|
78
|
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam orci nisi, vulputate ac pulvinar eu, maximus a tortor. Duis suscipit, nibh vel fermentum vehicula, mauris ante convallis metus, et feugiat turpis mauris non felis. Interdum et malesuada fames ac ante ipsum primis in faucibus. Maecenas efficitur nibh in nisi sagittis ultrices. Donec id velit nunc. Nam a lacus risus. Vestibulum molestie massa eget convallis pellentesque.
|
|
79
|
-
Mauris a nisl eget velit finibus blandit ac a odio. Sed sagittis consequat urna a egestas. Curabitur pretium convallis nibh, in ullamcorper odio tempus nec. Curabitur laoreet nec nisl sed accumsan. Sed elementum eleifend molestie. Aenean ullamcorper interdum risus, eget pharetra est volutpat ut. Aenean maximus consequat justo rutrum finibus. Mauris consequat facilisis consectetur. Vivamus rutrum dignissim libero, non aliquam lectus tempus id. In hac habitasse platea dictumst. Sed at magna dignissim, tincidunt lectus in, malesuada risus. Phasellus placerat blandit ligula. Integer posuere id elit at commodo. Sed consequat sagittis odio eget congue.
|
|
80
|
-
Aliquam ultricies, sapien a porta luctus, dolor nibh dignissim erat, dictum luctus orci lorem non quam. Quisque dapibus tempus mattis. Suspendisse gravida consequat mi at viverra. Quisque sed est purus. Fusce tincidunt semper massa eu blandit. Donec in lacus a tortor facilisis facilisis. Interdum et malesuada fames ac ante ipsum primis in faucibus. In aliquam dignissim eros ac consectetur. Aliquam fringilla magna erat. Nullam tincidunt maximus nulla, quis gravida est varius vel. Aliquam cursus, diam non facilisis mollis, nunc diam convallis enim, ac tempus diam tortor in dui. Nunc feugiat ligula odio, eleifend fermentum quam tincidunt sed. Duis pellentesque quam eget volutpat commodo.
|
|
81
|
-
Aliquam ex velit, porta sit amet augue vulputate, rhoncus fermentum magna. Integer non elementum augue. Phasellus rhoncus nisl nec magna lacinia vulputate. Suspendisse diam nibh, egestas a porta a, pellentesque ut nisl. Donec tempus ligula at leo convallis consequat. Duis sapien lorem, lobortis ac nisl dapibus, bibendum mollis lorem. Sed congue porttitor ex, eget scelerisque ligula consectetur quis. Mauris felis mauris, sodales quis nunc non, condimentum eleifend quam. Ut vitae viverra lorem. Vivamus lacinia et dolor vitae cursus. Proin faucibus venenatis enim vitae tincidunt. Sed sed venenatis leo.
|
|
82
|
-
Donec eu erat ullamcorper, consectetur dui sed, cursus tellus. Phasellus consectetur felis augue, quis auctor odio semper ac. In scelerisque gravida ligula eget lobortis. Sed tristique ultricies fringilla. Nunc in ultrices purus. Curabitur dictum cursus ante, at tempus est interdum at. Donec gravida lectus ut purus vestibulum, eu accumsan nisl pharetra.
|
|
83
|
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam orci nisi, vulputate ac pulvinar eu, maximus a tortor. Duis suscipit, nibh vel fermentum vehicula, mauris ante convallis metus, et feugiat turpis mauris non felis. Interdum et malesuada fames ac ante ipsum primis in faucibus. Maecenas efficitur nibh in nisi sagittis ultrices. Donec id velit nunc. Nam a lacus risus. Vestibulum molestie massa eget convallis pellentesque.
|
|
84
|
-
Mauris a nisl eget velit finibus blandit ac a odio. Sed sagittis consequat urna a egestas. Curabitur pretium convallis nibh, in ullamcorper odio tempus nec. Curabitur laoreet nec nisl sed accumsan. Sed elementum eleifend molestie. Aenean ullamcorper interdum risus, eget pharetra est volutpat ut. Aenean maximus consequat justo rutrum finibus. Mauris consequat facilisis consectetur. Vivamus rutrum dignissim libero, non aliquam lectus tempus id. In hac habitasse platea dictumst. Sed at magna dignissim, tincidunt lectus in, malesuada risus. Phasellus placerat blandit ligula. Integer posuere id elit at commodo. Sed consequat sagittis odio eget congue.
|
|
85
|
-
Aliquam ultricies, sapien a porta luctus, dolor nibh dignissim erat, dictum luctus orci lorem non quam. Quisque dapibus tempus mattis. Suspendisse gravida consequat mi at viverra. Quisque sed est purus. Fusce tincidunt semper massa eu blandit. Donec in lacus a tortor facilisis facilisis. Interdum et malesuada fames ac ante ipsum primis in faucibus. In aliquam dignissim eros ac consectetur. Aliquam fringilla magna erat. Nullam tincidunt maximus nulla, quis gravida est varius vel. Aliquam cursus, diam non facilisis mollis, nunc diam convallis enim, ac tempus diam tortor in dui. Nunc feugiat ligula odio, eleifend fermentum quam tincidunt sed. Duis pellentesque quam eget volutpat commodo.
|
|
86
|
-
Aliquam ex velit, porta sit amet augue vulputate, rhoncus fermentum magna. Integer non elementum augue. Phasellus rhoncus nisl nec magna lacinia vulputate. Suspendisse diam nibh, egestas a porta a, pellentesque ut nisl. Donec tempus ligula at leo convallis consequat. Duis sapien lorem, lobortis ac nisl dapibus, bibendum mollis lorem. Sed congue porttitor ex, eget scelerisque ligula consectetur quis. Mauris felis mauris, sodales quis nunc non, condimentum eleifend quam. Ut vitae viverra lorem. Vivamus lacinia et dolor vitae cursus. Proin faucibus venenatis enim vitae tincidunt. Sed sed venenatis leo.
|
|
87
|
-
Donec eu erat ullamcorper, consectetur dui sed, cursus tellus. Phasellus consectetur felis augue, quis auctor odio semper ac. In scelerisque gravida ligula eget lobortis. Sed tristique ultricies fringilla. Nunc in ultrices purus. Curabitur dictum cursus ante, at tempus est interdum at. Donec gravida lectus ut purus vestibulum, eu accumsan nisl pharetra.
|
|
88
|
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aliquam orci nisi, vulputate ac pulvinar eu, maximus a tortor. Duis suscipit, nibh vel fermentum vehicula, mauris ante convallis metus, et feugiat turpis mauris non felis. Interdum et malesuada fames ac ante ipsum primis in faucibus. Maecenas efficitur nibh in nisi sagittis ultrices. Donec id velit nunc. Nam a lacus risus. Vestibulum molestie massa eget convallis pellentesque.
|
|
89
|
-
Mauris a nisl eget velit finibus blandit ac a odio. Sed sagittis consequat urna a egestas. Curabitur pretium convallis nibh, in ullamcorper odio tempus nec. Curabitur laoreet nec nisl sed accumsan. Sed elementum eleifend molestie. Aenean ullamcorper interdum risus, eget pharetra est volutpat ut. Aenean maximus consequat justo rutrum finibus. Mauris consequat facilisis consectetur. Vivamus rutrum dignissim libero, non aliquam lectus tempus id. In hac habitasse platea dictumst. Sed at magna dignissim, tincidunt lectus in, malesuada risus. Phasellus placerat blandit ligula. Integer posuere id elit at commodo. Sed consequat sagittis odio eget congue.
|
|
90
|
-
Aliquam ultricies, sapien a porta luctus, dolor nibh dignissim erat, dictum luctus orci lorem non quam. Quisque dapibus tempus mattis. Suspendisse gravida consequat mi at viverra. Quisque sed est purus. Fusce tincidunt semper massa eu blandit. Donec in lacus a tortor facilisis facilisis. Interdum et malesuada fames ac ante ipsum primis in faucibus. In aliquam dignissim eros ac consectetur. Aliquam fringilla magna erat. Nullam tincidunt maximus nulla, quis gravida est varius vel. Aliquam cursus, diam non facilisis mollis, nunc diam convallis enim, ac tempus diam tortor in dui. Nunc feugiat ligula odio, eleifend fermentum quam tincidunt sed. Duis pellentesque quam eget volutpat commodo.
|
|
91
|
-
Aliquam ex velit, porta sit amet augue vulputate, rhoncus fermentum magna. Integer non elementum augue. Phasellus rhoncus nisl nec magna lacinia vulputate. Suspendisse diam nibh, egestas a porta a, pellentesque ut nisl. Donec tempus ligula at leo convallis consequat. Duis sapien lorem, lobortis ac nisl dapibus, bibendum mollis lorem. Sed congue porttitor ex, eget scelerisque ligula consectetur quis. Mauris felis mauris, sodales quis nunc non, condimentum eleifend quam. Ut vitae viverra lorem. Vivamus lacinia et dolor vitae cursus. Proin faucibus venenatis enim vitae tincidunt. Sed sed venenatis leo.
|
|
92
|
-
`;
|
|
93
|
-
test.skip("Test token limit SqlDatabaseChain", async () => {
|
|
94
|
-
const datasource = new DataSource({
|
|
95
|
-
type: "sqlite",
|
|
96
|
-
database: ":memory:",
|
|
97
|
-
synchronize: true,
|
|
98
|
-
});
|
|
99
|
-
await datasource.initialize();
|
|
100
|
-
await datasource.query(`
|
|
101
|
-
CREATE TABLE users (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT, age INTEGER);
|
|
102
|
-
`);
|
|
103
|
-
await datasource.query(`
|
|
104
|
-
INSERT INTO users (name, age) VALUES ('Alice', 20);
|
|
105
|
-
`);
|
|
106
|
-
await datasource.query(`
|
|
107
|
-
INSERT INTO users (name, age) VALUES ('Bob', 21);
|
|
108
|
-
`);
|
|
109
|
-
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
110
|
-
await datasource.query(`
|
|
111
|
-
INSERT INTO users (name, age) VALUES ('${veryLongString}', 22);
|
|
112
|
-
`);
|
|
113
|
-
const db = await SqlDatabase.fromDataSourceParams({
|
|
114
|
-
appDataSource: datasource,
|
|
115
|
-
});
|
|
116
|
-
const chain = new SqlDatabaseChain({
|
|
117
|
-
llm: new OpenAI({ temperature: 0 }),
|
|
118
|
-
database: db,
|
|
119
|
-
});
|
|
120
|
-
const runChain = async () => {
|
|
121
|
-
await chain.run("How many users are there?");
|
|
122
|
-
};
|
|
123
|
-
await expect(runChain()).rejects.toThrow();
|
|
124
|
-
await datasource.destroy();
|
|
125
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { test, expect } from "@jest/globals";
|
|
2
|
-
import { TransformChain } from "../transform.js";
|
|
3
|
-
test("TransformChain", async () => {
|
|
4
|
-
const chain = new TransformChain({
|
|
5
|
-
transform: async (values) => ({
|
|
6
|
-
c: values.a + values.b,
|
|
7
|
-
}),
|
|
8
|
-
inputVariables: ["a", "b"],
|
|
9
|
-
outputVariables: ["c"],
|
|
10
|
-
});
|
|
11
|
-
await expect(chain.invoke({ a: 1, b: 2 })).resolves.toEqual({ c: 3 });
|
|
12
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { test } from "@jest/globals";
|
|
2
|
-
import { OpenAI, OpenAIEmbeddings } from "@langchain/openai";
|
|
3
|
-
import { PromptTemplate } from "@langchain/core/prompts";
|
|
4
|
-
import { LLMChain } from "../llm_chain.js";
|
|
5
|
-
import { StuffDocumentsChain } from "../combine_docs_chain.js";
|
|
6
|
-
import { VectorDBQAChain } from "../vector_db_qa.js";
|
|
7
|
-
import { MemoryVectorStore } from "../../vectorstores/memory.js";
|
|
8
|
-
test("Test VectorDBQAChain", async () => {
|
|
9
|
-
const model = new OpenAI({ modelName: "gpt-3.5-turbo-instruct" });
|
|
10
|
-
const prompt = new PromptTemplate({
|
|
11
|
-
template: "Print {foo}",
|
|
12
|
-
inputVariables: ["foo"],
|
|
13
|
-
});
|
|
14
|
-
const vectorStore = await MemoryVectorStore.fromTexts(["Hello world", "Bye bye", "hello nice world", "bye", "hi"], [{ id: 2 }, { id: 1 }, { id: 3 }, { id: 4 }, { id: 5 }], new OpenAIEmbeddings());
|
|
15
|
-
const llmChain = new LLMChain({ prompt, llm: model });
|
|
16
|
-
const combineDocsChain = new StuffDocumentsChain({
|
|
17
|
-
llmChain,
|
|
18
|
-
documentVariableName: "foo",
|
|
19
|
-
});
|
|
20
|
-
const chain = new VectorDBQAChain({
|
|
21
|
-
combineDocumentsChain: combineDocsChain,
|
|
22
|
-
vectorstore: vectorStore,
|
|
23
|
-
});
|
|
24
|
-
const res = await chain.call({ query: "What up" });
|
|
25
|
-
console.log({ res });
|
|
26
|
-
});
|
|
27
|
-
test("Test VectorDBQAChain from LLM", async () => {
|
|
28
|
-
const model = new OpenAI({ modelName: "gpt-3.5-turbo-instruct" });
|
|
29
|
-
const vectorStore = await MemoryVectorStore.fromTexts(["Hello world", "Bye bye", "hello nice world", "bye", "hi"], [{ id: 2 }, { id: 1 }, { id: 3 }, { id: 4 }, { id: 5 }], new OpenAIEmbeddings());
|
|
30
|
-
const chain = VectorDBQAChain.fromLLM(model, vectorStore);
|
|
31
|
-
const res = await chain.call({ query: "What up" });
|
|
32
|
-
console.log({ res });
|
|
33
|
-
});
|
|
34
|
-
test("Test VectorDBQAChain from LLM with a filter function", async () => {
|
|
35
|
-
const model = new OpenAI({ modelName: "gpt-3.5-turbo-instruct" });
|
|
36
|
-
const vectorStore = await MemoryVectorStore.fromTexts(["Hello world", "Bye bye", "hello nice world", "bye", "hi"], [{ id: 2 }, { id: 1 }, { id: 3 }, { id: 4 }, { id: 5 }], new OpenAIEmbeddings());
|
|
37
|
-
const chain = VectorDBQAChain.fromLLM(model, vectorStore, {
|
|
38
|
-
returnSourceDocuments: true,
|
|
39
|
-
});
|
|
40
|
-
const res = await chain.call({
|
|
41
|
-
query: "What up",
|
|
42
|
-
filter: (document) => document.metadata.id === 3,
|
|
43
|
-
});
|
|
44
|
-
console.log({ res, sourceDocuments: res.sourceDocuments });
|
|
45
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
2
|
-
/* eslint-disable no-process-env */
|
|
3
|
-
import { expect, test } from "@jest/globals";
|
|
4
|
-
import { AudioSubtitleLoader, AudioTranscriptLoader, AudioTranscriptParagraphsLoader, AudioTranscriptSentencesLoader, } from "../web/assemblyai.js";
|
|
5
|
-
const transcriptId = process.env.ASSEMBLYAI_TRANSCRIPT_ID;
|
|
6
|
-
console.log(transcriptId);
|
|
7
|
-
describe.skip("AssemblyAI", () => {
|
|
8
|
-
test("Invalid API key", async () => {
|
|
9
|
-
const loader = new AudioTranscriptLoader({
|
|
10
|
-
audio: "https://storage.googleapis.com/aai-docs-samples/nbc.mp3",
|
|
11
|
-
}, { apiKey: "invalid" });
|
|
12
|
-
await expect(loader.load()).rejects.toThrow("Authentication error, API token missing/invalid");
|
|
13
|
-
});
|
|
14
|
-
test("Create and retrieve transcript", async () => {
|
|
15
|
-
const loader = new AudioTranscriptLoader({
|
|
16
|
-
audio: "https://storage.googleapis.com/aai-docs-samples/nbc.mp3",
|
|
17
|
-
});
|
|
18
|
-
const docs = await loader.load();
|
|
19
|
-
expect(docs).toHaveLength(1);
|
|
20
|
-
expect(docs[0].pageContent).not.toBeFalsy();
|
|
21
|
-
expect(docs[0].metadata).not.toBeFalsy();
|
|
22
|
-
});
|
|
23
|
-
test("Create and retrieve transcript (deprecated)", async () => {
|
|
24
|
-
const loader = new AudioTranscriptLoader({
|
|
25
|
-
audio_url: "https://storage.googleapis.com/aai-docs-samples/nbc.mp3",
|
|
26
|
-
});
|
|
27
|
-
const docs = await loader.load();
|
|
28
|
-
expect(docs).toHaveLength(1);
|
|
29
|
-
expect(docs[0].pageContent).not.toBeFalsy();
|
|
30
|
-
expect(docs[0].metadata).not.toBeFalsy();
|
|
31
|
-
});
|
|
32
|
-
test("Retrieve transcript by ID", async () => {
|
|
33
|
-
const loader = new AudioTranscriptLoader(transcriptId);
|
|
34
|
-
const docs = await loader.load();
|
|
35
|
-
expect(docs).toHaveLength(1);
|
|
36
|
-
expect(docs[0].pageContent).not.toBeFalsy();
|
|
37
|
-
expect(docs[0].metadata).not.toBeFalsy();
|
|
38
|
-
});
|
|
39
|
-
test("Create and retrieve paragraphs", async () => {
|
|
40
|
-
const loader = new AudioTranscriptParagraphsLoader({
|
|
41
|
-
audio: "https://storage.googleapis.com/aai-docs-samples/nbc.mp3",
|
|
42
|
-
});
|
|
43
|
-
const docs = await loader.load();
|
|
44
|
-
expect(docs.length).toBeGreaterThan(1);
|
|
45
|
-
expect(docs[0].pageContent).not.toBeFalsy();
|
|
46
|
-
expect(docs[0].metadata).not.toBeFalsy();
|
|
47
|
-
});
|
|
48
|
-
test("Create and retrieve paragraphs (deprecated)", async () => {
|
|
49
|
-
const loader = new AudioTranscriptParagraphsLoader({
|
|
50
|
-
audio_url: "https://storage.googleapis.com/aai-docs-samples/nbc.mp3",
|
|
51
|
-
});
|
|
52
|
-
const docs = await loader.load();
|
|
53
|
-
expect(docs.length).toBeGreaterThan(1);
|
|
54
|
-
expect(docs[0].pageContent).not.toBeFalsy();
|
|
55
|
-
expect(docs[0].metadata).not.toBeFalsy();
|
|
56
|
-
});
|
|
57
|
-
test("Retrieve paragraphs by ID", async () => {
|
|
58
|
-
const loader = new AudioTranscriptParagraphsLoader(transcriptId);
|
|
59
|
-
const docs = await loader.load();
|
|
60
|
-
expect(docs.length).toBeGreaterThan(1);
|
|
61
|
-
expect(docs[0].pageContent).not.toBeFalsy();
|
|
62
|
-
expect(docs[0].metadata).not.toBeFalsy();
|
|
63
|
-
});
|
|
64
|
-
test("Create and retrieve sentences", async () => {
|
|
65
|
-
const loader = new AudioTranscriptSentencesLoader({
|
|
66
|
-
audio: "https://storage.googleapis.com/aai-docs-samples/nbc.mp3",
|
|
67
|
-
});
|
|
68
|
-
const docs = await loader.load();
|
|
69
|
-
expect(docs.length).toBeGreaterThan(1);
|
|
70
|
-
expect(docs[0].pageContent).not.toBeFalsy();
|
|
71
|
-
expect(docs[0].metadata).not.toBeFalsy();
|
|
72
|
-
});
|
|
73
|
-
test("Create and retrieve sentences (deprecated)", async () => {
|
|
74
|
-
const loader = new AudioTranscriptSentencesLoader({
|
|
75
|
-
audio_url: "https://storage.googleapis.com/aai-docs-samples/nbc.mp3",
|
|
76
|
-
});
|
|
77
|
-
const docs = await loader.load();
|
|
78
|
-
expect(docs.length).toBeGreaterThan(1);
|
|
79
|
-
expect(docs[0].pageContent).not.toBeFalsy();
|
|
80
|
-
expect(docs[0].metadata).not.toBeFalsy();
|
|
81
|
-
});
|
|
82
|
-
test("Retrieve sentences by ID", async () => {
|
|
83
|
-
const loader = new AudioTranscriptSentencesLoader(transcriptId);
|
|
84
|
-
const docs = await loader.load();
|
|
85
|
-
expect(docs.length).toBeGreaterThan(1);
|
|
86
|
-
expect(docs[0].pageContent).not.toBeFalsy();
|
|
87
|
-
expect(docs[0].metadata).not.toBeFalsy();
|
|
88
|
-
});
|
|
89
|
-
test("Create and retrieve subtitles", async () => {
|
|
90
|
-
const loader = new AudioSubtitleLoader({
|
|
91
|
-
audio: "https://storage.googleapis.com/aai-docs-samples/nbc.mp3",
|
|
92
|
-
}, "srt");
|
|
93
|
-
const docs = await loader.load();
|
|
94
|
-
expect(docs).toHaveLength(1);
|
|
95
|
-
expect(docs[0].pageContent).not.toBeFalsy();
|
|
96
|
-
});
|
|
97
|
-
test("Create and retrieve subtitles (deprecated)", async () => {
|
|
98
|
-
const loader = new AudioSubtitleLoader({
|
|
99
|
-
audio_url: "https://storage.googleapis.com/aai-docs-samples/nbc.mp3",
|
|
100
|
-
}, "srt");
|
|
101
|
-
const docs = await loader.load();
|
|
102
|
-
expect(docs).toHaveLength(1);
|
|
103
|
-
expect(docs[0].pageContent).not.toBeFalsy();
|
|
104
|
-
});
|
|
105
|
-
test("Retrieve subtitles by ID", async () => {
|
|
106
|
-
const loader = new AudioSubtitleLoader(transcriptId, "srt");
|
|
107
|
-
const docs = await loader.load();
|
|
108
|
-
expect(docs).toHaveLength(1);
|
|
109
|
-
expect(docs[0].pageContent).not.toBeFalsy();
|
|
110
|
-
});
|
|
111
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,30 +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 { Document } from "@langchain/core/documents";
|
|
6
|
-
import { ChatGPTLoader } from "../fs/chatgpt.js";
|
|
7
|
-
test("Test ChatGPT loader from blob to load all documents", async () => {
|
|
8
|
-
const filePath = path.resolve(path.dirname(url.fileURLToPath(import.meta.url)), "./example_data/chatgpt/example_conversations.json");
|
|
9
|
-
const loader = new ChatGPTLoader(new Blob([await fs.readFile(filePath)], { type: "application/json" }));
|
|
10
|
-
const docs = await loader.load();
|
|
11
|
-
expect(docs.length).toBe(2);
|
|
12
|
-
expect(docs[0]).toEqual(new Document({
|
|
13
|
-
metadata: { source: "blob", blobType: "application/json", logIndex: 1 },
|
|
14
|
-
pageContent: "Example Usage - user on 2023-10-16 23:40:17: Hello, what is your name?\n\nExample Usage - assistant on 2023-10-16 23:40:23: Hello! I'm just a computer program created by OpenAI, so I don't have a personal name. You can call me ChatGPT or simply ask me any questions or chat about topics you're interested in. How can I assist you today?\n\n",
|
|
15
|
-
}));
|
|
16
|
-
expect(docs[1]).toEqual(new Document({
|
|
17
|
-
metadata: { source: "blob", blobType: "application/json", logIndex: 2 },
|
|
18
|
-
pageContent: "Example Usage 2 - user on 2023-10-13 23:02:19: What should I do today?\n\nExample Usage 2 - assistant on 2023-10-13 23:02:27: You should contribute to LangChain!\n\nExample Usage 2 - user on 2023-10-13 23:03:30: How can I start?\n\nExample Usage 2 - assistant on 2023-10-13 23:03:38: You can take a look at the current LangChain issues and see if you can contribute to any! Don't forget to read the contributing.md file.\n\nExample Usage 2 - user on 2023-10-13 23:09:24: Thank you!\n\nExample Usage 2 - assistant on 2023-10-13 23:09:34: You're welcome! If you have any more questions or need further assistance in the future, feel free to reach out.\n\n",
|
|
19
|
-
}));
|
|
20
|
-
});
|
|
21
|
-
test("Test ChatGPT loader from blob to only load 1 document", async () => {
|
|
22
|
-
const filePath = path.resolve(path.dirname(url.fileURLToPath(import.meta.url)), "./example_data/chatgpt/example_conversations.json");
|
|
23
|
-
const loader = new ChatGPTLoader(new Blob([await fs.readFile(filePath)], { type: "application/json" }), 1);
|
|
24
|
-
const docs = await loader.load();
|
|
25
|
-
expect(docs.length).toBe(1);
|
|
26
|
-
expect(docs[0]).toEqual(new Document({
|
|
27
|
-
metadata: { source: "blob", blobType: "application/json", logIndex: 1 },
|
|
28
|
-
pageContent: "Example Usage - user on 2023-10-16 23:40:17: Hello, what is your name?\n\nExample Usage - assistant on 2023-10-16 23:40:23: Hello! I'm just a computer program created by OpenAI, so I don't have a personal name. You can call me ChatGPT or simply ask me any questions or chat about topics you're interested in. How can I assist you today?\n\n",
|
|
29
|
-
}));
|
|
30
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,29 +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 { Document } from "@langchain/core/documents";
|
|
5
|
-
import { ChatGPTLoader } from "../fs/chatgpt.js";
|
|
6
|
-
test("Test ChatGPT loader to load all documents", async () => {
|
|
7
|
-
const filePath = path.resolve(path.dirname(url.fileURLToPath(import.meta.url)), "./example_data/chatgpt/example_conversations.json");
|
|
8
|
-
const loader = new ChatGPTLoader(filePath);
|
|
9
|
-
const docs = await loader.load();
|
|
10
|
-
expect(docs.length).toBe(2);
|
|
11
|
-
expect(docs[0]).toEqual(new Document({
|
|
12
|
-
metadata: { source: filePath, logIndex: 1 },
|
|
13
|
-
pageContent: "Example Usage - user on 2023-10-16 23:40:17: Hello, what is your name?\n\nExample Usage - assistant on 2023-10-16 23:40:23: Hello! I'm just a computer program created by OpenAI, so I don't have a personal name. You can call me ChatGPT or simply ask me any questions or chat about topics you're interested in. How can I assist you today?\n\n",
|
|
14
|
-
}));
|
|
15
|
-
expect(docs[1]).toEqual(new Document({
|
|
16
|
-
metadata: { source: filePath, logIndex: 2 },
|
|
17
|
-
pageContent: "Example Usage 2 - user on 2023-10-13 23:02:19: What should I do today?\n\nExample Usage 2 - assistant on 2023-10-13 23:02:27: You should contribute to LangChain!\n\nExample Usage 2 - user on 2023-10-13 23:03:30: How can I start?\n\nExample Usage 2 - assistant on 2023-10-13 23:03:38: You can take a look at the current LangChain issues and see if you can contribute to any! Don't forget to read the contributing.md file.\n\nExample Usage 2 - user on 2023-10-13 23:09:24: Thank you!\n\nExample Usage 2 - assistant on 2023-10-13 23:09:34: You're welcome! If you have any more questions or need further assistance in the future, feel free to reach out.\n\n",
|
|
18
|
-
}));
|
|
19
|
-
});
|
|
20
|
-
test("Test ChatGPT loader to only load 1 document", async () => {
|
|
21
|
-
const filePath = path.resolve(path.dirname(url.fileURLToPath(import.meta.url)), "./example_data/chatgpt/example_conversations.json");
|
|
22
|
-
const loader = new ChatGPTLoader(filePath, 1);
|
|
23
|
-
const docs = await loader.load();
|
|
24
|
-
expect(docs.length).toBe(1);
|
|
25
|
-
expect(docs[0]).toEqual(new Document({
|
|
26
|
-
metadata: { source: filePath, logIndex: 1 },
|
|
27
|
-
pageContent: "Example Usage - user on 2023-10-16 23:40:17: Hello, what is your name?\n\nExample Usage - assistant on 2023-10-16 23:40:23: Hello! I'm just a computer program created by OpenAI, so I don't have a personal name. You can call me ChatGPT or simply ask me any questions or chat about topics you're interested in. How can I assist you today?\n\n",
|
|
28
|
-
}));
|
|
29
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { expect, test } from "@jest/globals";
|
|
2
|
-
import { CheerioWebBaseLoader } from "../web/cheerio.js";
|
|
3
|
-
test("Test cheerio web scraper loader", async () => {
|
|
4
|
-
const loader = new CheerioWebBaseLoader("https://news.ycombinator.com/item?id=34817881");
|
|
5
|
-
await loader.load();
|
|
6
|
-
});
|
|
7
|
-
test("Test cheerio web scraper loader with selector", async () => {
|
|
8
|
-
const selectH1 = "h1";
|
|
9
|
-
const loader = new CheerioWebBaseLoader("https://about.google/commitments/", {
|
|
10
|
-
selector: selectH1,
|
|
11
|
-
});
|
|
12
|
-
const doc = await loader.load();
|
|
13
|
-
expect(doc[0].pageContent.trim()).toBe("Committed to significantly improving the lives of as many people as possible.");
|
|
14
|
-
});
|
|
15
|
-
test("Test cheerio web scraper loader with textDecoder", async () => {
|
|
16
|
-
const loader = new CheerioWebBaseLoader("https://corp.163.com/gb/about/management.html", {
|
|
17
|
-
textDecoder: new TextDecoder("gbk"),
|
|
18
|
-
});
|
|
19
|
-
const doc = await loader.load();
|
|
20
|
-
expect(doc[0].pageContent.trim()).toEqual(expect.stringContaining("网易"));
|
|
21
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { test } from "@jest/globals";
|
|
2
|
-
import { CollegeConfidentialLoader } from "../web/college_confidential.js";
|
|
3
|
-
test("Test College confidential loader", async () => {
|
|
4
|
-
const loader = new CollegeConfidentialLoader("https://www.collegeconfidential.com/colleges/brown-university/");
|
|
5
|
-
await loader.load();
|
|
6
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { test, jest, expect } from "@jest/globals";
|
|
2
|
-
import { ConfluencePagesLoader, } from "../web/confluence.js";
|
|
3
|
-
test("Test ConfluenceLoader and fetchConfluenceData calls", async () => {
|
|
4
|
-
// Stub the fetchConfluenceData method to return a fake response
|
|
5
|
-
// As the Confluence API requires authentication
|
|
6
|
-
const fakeResponse = [
|
|
7
|
-
{
|
|
8
|
-
id: "1",
|
|
9
|
-
title: "Page 1",
|
|
10
|
-
body: { storage: { value: "<p>Content of Page 1</p>" } },
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
id: "2",
|
|
14
|
-
title: "Page 2",
|
|
15
|
-
body: { storage: { value: "<p>Content of Page 2</p>" } },
|
|
16
|
-
},
|
|
17
|
-
];
|
|
18
|
-
// Initialize the loader and load the documents
|
|
19
|
-
const loader = new ConfluencePagesLoader({
|
|
20
|
-
baseUrl: "https://example.atlassian.net/wiki",
|
|
21
|
-
spaceKey: "SPACEKEY",
|
|
22
|
-
username: "username@email.com",
|
|
23
|
-
accessToken: "accessToken",
|
|
24
|
-
});
|
|
25
|
-
// Our fetchConfluenceData function is called recursively
|
|
26
|
-
// until the size of the response is 0
|
|
27
|
-
const fetchConfluenceDataMock = jest
|
|
28
|
-
.spyOn(loader, "fetchConfluenceData")
|
|
29
|
-
.mockImplementationOnce(() =>
|
|
30
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
31
|
-
Promise.resolve({ size: 2, results: fakeResponse }))
|
|
32
|
-
.mockImplementationOnce(() =>
|
|
33
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
34
|
-
Promise.resolve({ size: 2, results: fakeResponse }))
|
|
35
|
-
.mockImplementationOnce(() => Promise.resolve({ size: 0, results: [] }));
|
|
36
|
-
const documents = await loader.load();
|
|
37
|
-
// Validate the test results
|
|
38
|
-
expect(documents.length).toBe(4);
|
|
39
|
-
expect(documents[0].metadata.title).toBeDefined();
|
|
40
|
-
expect(documents[0].metadata.url).toBeDefined();
|
|
41
|
-
// Ensure fetchConfluenceData is called three times
|
|
42
|
-
expect(fetchConfluenceDataMock).toHaveBeenCalledTimes(3);
|
|
43
|
-
// Ensure the arguments are correct for each call
|
|
44
|
-
expect(fetchConfluenceDataMock).toHaveBeenNthCalledWith(1, "https://example.atlassian.net/wiki/rest/api/content?spaceKey=SPACEKEY&limit=25&start=0&expand=body.storage,version");
|
|
45
|
-
expect(fetchConfluenceDataMock).toHaveBeenNthCalledWith(2, "https://example.atlassian.net/wiki/rest/api/content?spaceKey=SPACEKEY&limit=25&start=2&expand=body.storage,version");
|
|
46
|
-
expect(fetchConfluenceDataMock).toHaveBeenNthCalledWith(3, "https://example.atlassian.net/wiki/rest/api/content?spaceKey=SPACEKEY&limit=25&start=4&expand=body.storage,version");
|
|
47
|
-
// Check if the generated URLs in the metadata are correct
|
|
48
|
-
expect(documents[0].metadata.url).toBe("https://example.atlassian.net/wiki/spaces/SPACEKEY/pages/1");
|
|
49
|
-
expect(documents[1].metadata.url).toBe("https://example.atlassian.net/wiki/spaces/SPACEKEY/pages/2");
|
|
50
|
-
// Restore the mock to its original behavior
|
|
51
|
-
fetchConfluenceDataMock.mockRestore();
|
|
52
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { test, expect } from "@jest/globals";
|
|
2
|
-
import { Cluster } from "couchbase";
|
|
3
|
-
import { CouchbaseDocumentLoader } from "../web/couchbase.js";
|
|
4
|
-
test("Test Couchbase Cluster connection ", async () => {
|
|
5
|
-
const connectionString = "<enter-valid-couchbase-connection-string>";
|
|
6
|
-
const databaseUsername = "<enter-valid-couchbase-user>";
|
|
7
|
-
const databasePassword = "<enter-valid-couchbase-password>";
|
|
8
|
-
const query = `
|
|
9
|
-
SELECT h.* FROM \`travel-sample\`.inventory.hotel h
|
|
10
|
-
WHERE h.country = 'United States'
|
|
11
|
-
LIMIT 10
|
|
12
|
-
`;
|
|
13
|
-
const validPageContentFields = ["country", "name", "description"];
|
|
14
|
-
const validMetadataFields = ["id"];
|
|
15
|
-
const couchbaseClient = await Cluster.connect(connectionString, {
|
|
16
|
-
username: databaseUsername,
|
|
17
|
-
password: databasePassword,
|
|
18
|
-
configProfile: "wanDevelopment",
|
|
19
|
-
});
|
|
20
|
-
const loader = new CouchbaseDocumentLoader(couchbaseClient, query, validPageContentFields, validMetadataFields);
|
|
21
|
-
const docs = await loader.load();
|
|
22
|
-
expect(docs.length).toBeGreaterThan(0);
|
|
23
|
-
for (const doc of docs) {
|
|
24
|
-
expect(doc.pageContent).not.toBe(""); // Assuming valid page content fields
|
|
25
|
-
expect(doc.metadata).toHaveProperty("id"); // Assuming metadata has id field
|
|
26
|
-
expect(doc.metadata.id).not.toBe("");
|
|
27
|
-
}
|
|
28
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,53 +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 { Document } from "@langchain/core/documents";
|
|
6
|
-
import { CSVLoader } from "../fs/csv.js";
|
|
7
|
-
test("Test CSV loader from blob", async () => {
|
|
8
|
-
const filePath = path.resolve(path.dirname(url.fileURLToPath(import.meta.url)), "./example_data/Star_Wars_The_Clone_Wars_S06E07_Crisis_at_the_Heart.csv");
|
|
9
|
-
const loader = new CSVLoader(new Blob([await fs.readFile(filePath)], { type: "text/csv" }), "html");
|
|
10
|
-
const docs = await loader.load();
|
|
11
|
-
expect(docs.length).toBe(32);
|
|
12
|
-
expect(docs[0]).toEqual(new Document({
|
|
13
|
-
metadata: { source: "blob", blobType: "text/csv", line: 1 },
|
|
14
|
-
pageContent: "<i>Corruption discovered at the core of the Banking Clan!</i>",
|
|
15
|
-
}));
|
|
16
|
-
expect(docs[1]).toEqual(new Document({
|
|
17
|
-
metadata: { source: "blob", blobType: "text/csv", line: 2 },
|
|
18
|
-
pageContent: "<i>Reunited, Rush Clovis and Senator Amidala</i>",
|
|
19
|
-
}));
|
|
20
|
-
});
|
|
21
|
-
test("Test CSV loader from blob", async () => {
|
|
22
|
-
const loader = new CSVLoader(new Blob([
|
|
23
|
-
`id,text
|
|
24
|
-
1,This is a sentence.
|
|
25
|
-
2,This is another sentence.`,
|
|
26
|
-
], { type: "text/csv" }));
|
|
27
|
-
const docs = await loader.load();
|
|
28
|
-
expect(docs.length).toBe(2);
|
|
29
|
-
expect(docs[0]).toMatchInlineSnapshot(`
|
|
30
|
-
Document {
|
|
31
|
-
"id": undefined,
|
|
32
|
-
"metadata": {
|
|
33
|
-
"blobType": "text/csv",
|
|
34
|
-
"line": 1,
|
|
35
|
-
"source": "blob",
|
|
36
|
-
},
|
|
37
|
-
"pageContent": "id: 1
|
|
38
|
-
text: This is a sentence.",
|
|
39
|
-
}
|
|
40
|
-
`);
|
|
41
|
-
expect(docs[1]).toMatchInlineSnapshot(`
|
|
42
|
-
Document {
|
|
43
|
-
"id": undefined,
|
|
44
|
-
"metadata": {
|
|
45
|
-
"blobType": "text/csv",
|
|
46
|
-
"line": 2,
|
|
47
|
-
"source": "blob",
|
|
48
|
-
},
|
|
49
|
-
"pageContent": "id: 2
|
|
50
|
-
text: This is another sentence.",
|
|
51
|
-
}
|
|
52
|
-
`);
|
|
53
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,41 +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 { Document } from "@langchain/core/documents";
|
|
5
|
-
import { CSVLoader } from "../fs/csv.js";
|
|
6
|
-
test("Test CSV loader from file with column arg", 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.csv");
|
|
8
|
-
const loader = new CSVLoader(filePath, "html");
|
|
9
|
-
const docs = await loader.load();
|
|
10
|
-
expect(docs.length).toBe(32);
|
|
11
|
-
expect(docs[0]).toEqual(new Document({
|
|
12
|
-
metadata: { source: filePath, line: 1 },
|
|
13
|
-
pageContent: "<i>Corruption discovered at the core of the Banking Clan!</i>",
|
|
14
|
-
}));
|
|
15
|
-
expect(docs[1]).toEqual(new Document({
|
|
16
|
-
metadata: { source: filePath, line: 2 },
|
|
17
|
-
pageContent: "<i>Reunited, Rush Clovis and Senator Amidala</i>",
|
|
18
|
-
}));
|
|
19
|
-
});
|
|
20
|
-
test("Test CSV loader without column arg", async () => {
|
|
21
|
-
const filePath = path.resolve(path.dirname(url.fileURLToPath(import.meta.url)), "./example_data/Star_Wars_The_Clone_Wars_S06E07_Crisis_at_the_Heart.csv");
|
|
22
|
-
const loader = new CSVLoader(filePath);
|
|
23
|
-
const docs = await loader.load();
|
|
24
|
-
expect(docs.length).toBe(32);
|
|
25
|
-
expect(docs[0]).toEqual(new Document({
|
|
26
|
-
metadata: { source: filePath, line: 1 },
|
|
27
|
-
pageContent: `id: 1
|
|
28
|
-
html: <i>Corruption discovered at the core of the Banking Clan!</i>`,
|
|
29
|
-
}));
|
|
30
|
-
});
|
|
31
|
-
test("Test CSV loader from file with separator arg", async () => {
|
|
32
|
-
const filePath = path.resolve(path.dirname(url.fileURLToPath(import.meta.url)), "./example_data/example_separator.csv");
|
|
33
|
-
const loader = new CSVLoader(filePath, { separator: "|" });
|
|
34
|
-
const docs = await loader.load();
|
|
35
|
-
expect(docs.length).toBe(32);
|
|
36
|
-
expect(docs[0]).toEqual(new Document({
|
|
37
|
-
metadata: { source: filePath, line: 1 },
|
|
38
|
-
pageContent: `id: 1
|
|
39
|
-
html: <i>Corruption discovered at the core of the Banking Clan!</i>`,
|
|
40
|
-
}));
|
|
41
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|