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,130 +0,0 @@
|
|
|
1
|
-
import { test } from "@jest/globals";
|
|
2
|
-
import { ChatOpenAI } from "@langchain/openai";
|
|
3
|
-
import { createOpenAPIChain } from "../openapi.js";
|
|
4
|
-
test("OpenAPI chain with a provided full spec", async () => {
|
|
5
|
-
const chain = await createOpenAPIChain({
|
|
6
|
-
openapi: "3.0.1",
|
|
7
|
-
info: { version: "v0", title: "Open AI Klarna product Api" },
|
|
8
|
-
servers: [{ url: "https://www.klarna.com/us/shopping" }],
|
|
9
|
-
tags: [
|
|
10
|
-
{
|
|
11
|
-
name: "open-ai-product-endpoint",
|
|
12
|
-
description: "Open AI Product Endpoint. Query for products.",
|
|
13
|
-
},
|
|
14
|
-
],
|
|
15
|
-
paths: {
|
|
16
|
-
"/public/openai/v0/products": {
|
|
17
|
-
get: {
|
|
18
|
-
tags: ["open-ai-product-endpoint"],
|
|
19
|
-
summary: "API for fetching Klarna product information",
|
|
20
|
-
operationId: "productsUsingGET",
|
|
21
|
-
parameters: [
|
|
22
|
-
{
|
|
23
|
-
name: "countryCode",
|
|
24
|
-
in: "query",
|
|
25
|
-
description: "ISO 3166 country code with 2 characters based on the user location. Currently, only US, GB, DE, SE and DK are supported.",
|
|
26
|
-
required: true,
|
|
27
|
-
schema: { type: "string" },
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
name: "q",
|
|
31
|
-
in: "query",
|
|
32
|
-
description: "A precise query that matches one very small category or product that needs to be searched for to find the products the user is looking for. If the user explicitly stated what they want, use that as a query. The query is as specific as possible to the product name or category mentioned by the user in its singular form, and don't contain any clarifiers like latest, newest, cheapest, budget, premium, expensive or similar. The query is always taken from the latest topic, if there is a new topic a new query is started. If the user speaks another language than English, translate their request into English (example: translate fia med knuff to ludo board game)!",
|
|
33
|
-
required: true,
|
|
34
|
-
schema: { type: "string" },
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
name: "size",
|
|
38
|
-
in: "query",
|
|
39
|
-
description: "number of products returned",
|
|
40
|
-
required: false,
|
|
41
|
-
schema: { type: "integer" },
|
|
42
|
-
},
|
|
43
|
-
{
|
|
44
|
-
name: "min_price",
|
|
45
|
-
in: "query",
|
|
46
|
-
description: "(Optional) Minimum price in local currency for the product searched for. Either explicitly stated by the user or implicitly inferred from a combination of the user's request and the kind of product searched for.",
|
|
47
|
-
required: false,
|
|
48
|
-
schema: { type: "integer" },
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
name: "max_price",
|
|
52
|
-
in: "query",
|
|
53
|
-
description: "(Optional) Maximum price in local currency for the product searched for. Either explicitly stated by the user or implicitly inferred from a combination of the user's request and the kind of product searched for.",
|
|
54
|
-
required: false,
|
|
55
|
-
schema: { type: "integer" },
|
|
56
|
-
},
|
|
57
|
-
],
|
|
58
|
-
responses: {
|
|
59
|
-
"200": {
|
|
60
|
-
description: "Products found",
|
|
61
|
-
content: {
|
|
62
|
-
"application/json": {
|
|
63
|
-
schema: { $ref: "#/components/schemas/ProductResponse" },
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
"503": { description: "one or more services are unavailable" },
|
|
68
|
-
},
|
|
69
|
-
deprecated: false,
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
components: {
|
|
74
|
-
schemas: {
|
|
75
|
-
Product: {
|
|
76
|
-
type: "object",
|
|
77
|
-
properties: {
|
|
78
|
-
attributes: { type: "array", items: { type: "string" } },
|
|
79
|
-
name: { type: "string" },
|
|
80
|
-
price: { type: "string" },
|
|
81
|
-
url: { type: "string" },
|
|
82
|
-
},
|
|
83
|
-
title: "Product",
|
|
84
|
-
},
|
|
85
|
-
ProductResponse: {
|
|
86
|
-
type: "object",
|
|
87
|
-
properties: {
|
|
88
|
-
products: {
|
|
89
|
-
type: "array",
|
|
90
|
-
items: { $ref: "#/components/schemas/Product" },
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
|
-
title: "ProductResponse",
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
},
|
|
97
|
-
}, { llm: new ChatOpenAI({ modelName: "gpt-4-0613", temperature: 0 }) });
|
|
98
|
-
const result = await chain.run(`What are some options for a men's large blue button down shirt`);
|
|
99
|
-
console.log(result);
|
|
100
|
-
});
|
|
101
|
-
test("OpenAPI chain with yml spec from a URL", async () => {
|
|
102
|
-
const chain = await createOpenAPIChain("https://gist.githubusercontent.com/roaldnefs/053e505b2b7a807290908fe9aa3e1f00/raw/0a212622ebfef501163f91e23803552411ed00e4/openapi.yaml", {
|
|
103
|
-
llm: new ChatOpenAI({ modelName: "gpt-4-0613", temperature: 0 }),
|
|
104
|
-
});
|
|
105
|
-
const result = await chain.run(`What's today's comic?`);
|
|
106
|
-
console.log(result);
|
|
107
|
-
});
|
|
108
|
-
test("OpenAPI chain with yml spec from a URL with a path parameter", async () => {
|
|
109
|
-
const chain = await createOpenAPIChain("https://gist.githubusercontent.com/roaldnefs/053e505b2b7a807290908fe9aa3e1f00/raw/0a212622ebfef501163f91e23803552411ed00e4/openapi.yaml", {
|
|
110
|
-
llm: new ChatOpenAI({ modelName: "gpt-4-0613", temperature: 0 }),
|
|
111
|
-
});
|
|
112
|
-
const result = await chain.run(`What comic has id 2184?`);
|
|
113
|
-
console.log(result);
|
|
114
|
-
});
|
|
115
|
-
test("OpenAPI chain with yml spec from a URL requiring a POST request", async () => {
|
|
116
|
-
const chain = await createOpenAPIChain("https://api.speak.com/openapi.yaml", {
|
|
117
|
-
llm: new ChatOpenAI({ modelName: "gpt-4-0613", temperature: 0 }),
|
|
118
|
-
});
|
|
119
|
-
const result = await chain.run(`How would you say no thanks in Russian?`);
|
|
120
|
-
console.log(result);
|
|
121
|
-
});
|
|
122
|
-
test("OpenAPI chain with a longer spec and tricky query required params", async () => {
|
|
123
|
-
const chain = await createOpenAPIChain("https://scholar-ai.net/openapi.yaml", {
|
|
124
|
-
params: {
|
|
125
|
-
sort: "cited_by_count",
|
|
126
|
-
},
|
|
127
|
-
});
|
|
128
|
-
const result = await chain.run("Can you find and explain some articles about the intersection of AI and VR?");
|
|
129
|
-
console.log(result);
|
|
130
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
import { test, expect } from "@jest/globals";
|
|
2
|
-
import { OpenAPIV3 } from "openapi-types";
|
|
3
|
-
import { OpenAPISpec } from "../../../util/openapi.js";
|
|
4
|
-
import { convertOpenAPISchemaToJSONSchema } from "../openapi.js";
|
|
5
|
-
test("Test convert OpenAPI params to JSON Schema", async () => {
|
|
6
|
-
const spec = new OpenAPISpec({
|
|
7
|
-
openapi: "3.1.0",
|
|
8
|
-
info: {
|
|
9
|
-
title: "A fake spec for testing",
|
|
10
|
-
version: "0.0.1",
|
|
11
|
-
},
|
|
12
|
-
paths: {
|
|
13
|
-
"/widgets": {
|
|
14
|
-
post: {
|
|
15
|
-
operationId: "createWidget",
|
|
16
|
-
description: "Create a widget",
|
|
17
|
-
parameters: [
|
|
18
|
-
{
|
|
19
|
-
name: "stringParam",
|
|
20
|
-
in: "query",
|
|
21
|
-
schema: {
|
|
22
|
-
type: "string",
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
name: "objectParam",
|
|
27
|
-
in: "query",
|
|
28
|
-
schema: {
|
|
29
|
-
type: "object",
|
|
30
|
-
properties: {
|
|
31
|
-
foo: {
|
|
32
|
-
type: "string",
|
|
33
|
-
},
|
|
34
|
-
bar: {
|
|
35
|
-
type: "number",
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
name: "stringArrayParam",
|
|
42
|
-
in: "query",
|
|
43
|
-
schema: {
|
|
44
|
-
type: "array",
|
|
45
|
-
items: {
|
|
46
|
-
type: "string",
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
name: "nestedObjectInArrayParam",
|
|
52
|
-
in: "query",
|
|
53
|
-
schema: {
|
|
54
|
-
type: "array",
|
|
55
|
-
items: {
|
|
56
|
-
type: "object",
|
|
57
|
-
properties: {
|
|
58
|
-
baz: {
|
|
59
|
-
type: "number",
|
|
60
|
-
},
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
{
|
|
66
|
-
name: "nestedArrayInObjectParam",
|
|
67
|
-
in: "query",
|
|
68
|
-
schema: {
|
|
69
|
-
type: "object",
|
|
70
|
-
properties: {
|
|
71
|
-
qux: {
|
|
72
|
-
type: "array",
|
|
73
|
-
items: {
|
|
74
|
-
type: "string",
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
name: "inceptionParam",
|
|
82
|
-
in: "query",
|
|
83
|
-
schema: {
|
|
84
|
-
type: "array",
|
|
85
|
-
items: {
|
|
86
|
-
type: "object",
|
|
87
|
-
properties: {
|
|
88
|
-
nestedArray: {
|
|
89
|
-
type: "array",
|
|
90
|
-
items: {
|
|
91
|
-
type: "object",
|
|
92
|
-
properties: {
|
|
93
|
-
nestedObject: {
|
|
94
|
-
type: "object",
|
|
95
|
-
properties: {
|
|
96
|
-
inception: {
|
|
97
|
-
type: "number",
|
|
98
|
-
},
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
},
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
},
|
|
108
|
-
],
|
|
109
|
-
responses: {
|
|
110
|
-
"200": {
|
|
111
|
-
description: "OK",
|
|
112
|
-
content: {
|
|
113
|
-
"application/json": {
|
|
114
|
-
schema: {
|
|
115
|
-
properties: {
|
|
116
|
-
success: {
|
|
117
|
-
type: "boolean",
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
|
-
},
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
|
-
},
|
|
124
|
-
},
|
|
125
|
-
},
|
|
126
|
-
},
|
|
127
|
-
},
|
|
128
|
-
});
|
|
129
|
-
const createWidget = spec.getOperation("/widgets", OpenAPIV3.HttpMethods.POST);
|
|
130
|
-
expect(createWidget).not.toBeUndefined();
|
|
131
|
-
if (!createWidget) {
|
|
132
|
-
throw new Error(`Operation not found`);
|
|
133
|
-
}
|
|
134
|
-
function getParamSchema(operation, paramName) {
|
|
135
|
-
const param = spec
|
|
136
|
-
.getParametersForOperation(operation)
|
|
137
|
-
.find((param) => param.name === paramName);
|
|
138
|
-
if (!param) {
|
|
139
|
-
throw new Error(`Param not found`);
|
|
140
|
-
}
|
|
141
|
-
if (!param.schema) {
|
|
142
|
-
throw new Error(`Param schema not found`);
|
|
143
|
-
}
|
|
144
|
-
return spec.getSchema(param.schema);
|
|
145
|
-
}
|
|
146
|
-
function expectType(type, schema) {
|
|
147
|
-
if (!schema || !("type" in schema)) {
|
|
148
|
-
throw new Error(`Schema has no type`);
|
|
149
|
-
}
|
|
150
|
-
if (schema.type !== type) {
|
|
151
|
-
throw new Error(`Unexpected type: ${schema.type}`);
|
|
152
|
-
}
|
|
153
|
-
return schema;
|
|
154
|
-
}
|
|
155
|
-
const stringParamSchema = convertOpenAPISchemaToJSONSchema(getParamSchema(createWidget, "stringParam"), spec);
|
|
156
|
-
expectType("string", stringParamSchema);
|
|
157
|
-
const objectParamSchema = convertOpenAPISchemaToJSONSchema(getParamSchema(createWidget, "objectParam"), spec);
|
|
158
|
-
const typedObjectParamSchema = expectType("object", objectParamSchema);
|
|
159
|
-
expectType("string", typedObjectParamSchema.properties.foo);
|
|
160
|
-
expectType("number", typedObjectParamSchema.properties.bar);
|
|
161
|
-
const stringArrayParamSchema = convertOpenAPISchemaToJSONSchema(getParamSchema(createWidget, "stringArrayParam"), spec);
|
|
162
|
-
const typedStringArrayParamSchema = expectType("array", stringArrayParamSchema);
|
|
163
|
-
expect(typedStringArrayParamSchema.items).not.toBeUndefined();
|
|
164
|
-
expectType("string", typedStringArrayParamSchema.items);
|
|
165
|
-
const nestedObjectInArrayParamSchema = convertOpenAPISchemaToJSONSchema(getParamSchema(createWidget, "nestedObjectInArrayParam"), spec);
|
|
166
|
-
expectType("number", expectType("object", expectType("array", nestedObjectInArrayParamSchema).items).properties.baz);
|
|
167
|
-
const nestedArrayInObjectParamSchema = convertOpenAPISchemaToJSONSchema(getParamSchema(createWidget, "nestedArrayInObjectParam"), spec);
|
|
168
|
-
expectType("string", expectType("array", expectType("object", nestedArrayInObjectParamSchema).properties.qux).items);
|
|
169
|
-
const inceptionParamSchema = convertOpenAPISchemaToJSONSchema(getParamSchema(createWidget, "inceptionParam"), spec);
|
|
170
|
-
expectType("number", expectType("object", expectType("object", expectType("array", expectType("object", expectType("array", inceptionParamSchema).items)
|
|
171
|
-
.properties.nestedArray).items).properties.nestedObject).properties.inception);
|
|
172
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { test, expect } from "@jest/globals";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
import { ChatOpenAI } from "@langchain/openai";
|
|
4
|
-
import { ChatPromptTemplate, SystemMessagePromptTemplate, HumanMessagePromptTemplate, } from "@langchain/core/prompts";
|
|
5
|
-
import { createStructuredOutputChainFromZod } from "../structured_output.js";
|
|
6
|
-
test("structured output chain", async () => {
|
|
7
|
-
const chain = createStructuredOutputChainFromZod(z.object({
|
|
8
|
-
name: z.string().describe("Human name"),
|
|
9
|
-
surname: z.string().describe("Human surname"),
|
|
10
|
-
age: z.number().describe("Human age"),
|
|
11
|
-
appearance: z.string().describe("Human appearance description"),
|
|
12
|
-
shortBio: z.string().describe("Short bio secription"),
|
|
13
|
-
university: z.string().optional().describe("University name if attended"),
|
|
14
|
-
gender: z.string().describe("Gender of the human"),
|
|
15
|
-
interests: z
|
|
16
|
-
.array(z.string())
|
|
17
|
-
.describe("json array of strings human interests"),
|
|
18
|
-
}), {
|
|
19
|
-
prompt: new ChatPromptTemplate({
|
|
20
|
-
promptMessages: [
|
|
21
|
-
SystemMessagePromptTemplate.fromTemplate("Generate details of a hypothetical person."),
|
|
22
|
-
HumanMessagePromptTemplate.fromTemplate("Person description: {inputText}"),
|
|
23
|
-
],
|
|
24
|
-
inputVariables: ["inputText"],
|
|
25
|
-
}),
|
|
26
|
-
llm: new ChatOpenAI({ modelName: "gpt-3.5-turbo-0613", temperature: 0 }),
|
|
27
|
-
outputKey: "person",
|
|
28
|
-
});
|
|
29
|
-
const response = await chain.call({ inputText: "A man, living in Poland." });
|
|
30
|
-
console.log("response", response);
|
|
31
|
-
expect(response.person).toHaveProperty("name");
|
|
32
|
-
expect(response.person).toHaveProperty("surname");
|
|
33
|
-
expect(response.person).toHaveProperty("age");
|
|
34
|
-
expect(response.person).toHaveProperty("appearance");
|
|
35
|
-
expect(response.person).toHaveProperty("shortBio");
|
|
36
|
-
expect(response.person).toHaveProperty("age");
|
|
37
|
-
expect(response.person).toHaveProperty("gender");
|
|
38
|
-
expect(response.person).toHaveProperty("interests");
|
|
39
|
-
expect(response.person.interests.length).toBeGreaterThan(0);
|
|
40
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { test, expect } from "@jest/globals";
|
|
2
|
-
import { z } from "zod";
|
|
3
|
-
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
4
|
-
import { AIMessage } from "@langchain/core/messages";
|
|
5
|
-
import { FunctionCallStructuredOutputParser } from "../structured_output.js";
|
|
6
|
-
test("structured output parser", async () => {
|
|
7
|
-
const parser = new FunctionCallStructuredOutputParser(zodToJsonSchema(z.object({
|
|
8
|
-
name: z.string().describe("Human name"),
|
|
9
|
-
surname: z.string().describe("Human surname"),
|
|
10
|
-
age: z.number().describe("Human age"),
|
|
11
|
-
appearance: z.string().describe("Human appearance description"),
|
|
12
|
-
shortBio: z.string().describe("Short bio secription"),
|
|
13
|
-
university: z
|
|
14
|
-
.string()
|
|
15
|
-
.optional()
|
|
16
|
-
.describe("University name if attended"),
|
|
17
|
-
gender: z.string().describe("Gender of the human"),
|
|
18
|
-
interests: z
|
|
19
|
-
.array(z.string())
|
|
20
|
-
.describe("json array of strings human interests"),
|
|
21
|
-
})));
|
|
22
|
-
const result = await parser.parseResult([
|
|
23
|
-
{
|
|
24
|
-
text: "",
|
|
25
|
-
message: new AIMessage({
|
|
26
|
-
content: "",
|
|
27
|
-
additional_kwargs: {
|
|
28
|
-
function_call: {
|
|
29
|
-
name: "",
|
|
30
|
-
arguments: JSON.stringify({
|
|
31
|
-
name: "Anna",
|
|
32
|
-
surname: "Kowalska",
|
|
33
|
-
age: 30,
|
|
34
|
-
appearance: "Anna has shoulder-length brown hair and green eyes. She has a slim build and stands at around 5'6\" tall.",
|
|
35
|
-
shortBio: "Anna is a kind and compassionate person who loves to help others. She works as a nurse at a local hospital in Poland. In her free time, she enjoys reading, cooking, and spending time with her friends and family. Anna is also passionate about traveling and exploring new places.",
|
|
36
|
-
university: null,
|
|
37
|
-
gender: "female",
|
|
38
|
-
interests: ["reading", "cooking", "traveling"],
|
|
39
|
-
}),
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
}),
|
|
43
|
-
},
|
|
44
|
-
]);
|
|
45
|
-
console.log("result", result);
|
|
46
|
-
expect(result.name).toEqual("Anna");
|
|
47
|
-
expect(result.surname).toEqual("Kowalska");
|
|
48
|
-
expect(result.age).toEqual(30);
|
|
49
|
-
expect(result).toHaveProperty("appearance");
|
|
50
|
-
expect(result).toHaveProperty("shortBio");
|
|
51
|
-
expect(result).not.toHaveProperty("university");
|
|
52
|
-
expect(result.gender).toEqual("female");
|
|
53
|
-
expect(result.interests.length).toEqual(3);
|
|
54
|
-
});
|
|
55
|
-
test("structured output parser with Zod input", async () => {
|
|
56
|
-
const parser = new FunctionCallStructuredOutputParser({
|
|
57
|
-
zodSchema: z.object({
|
|
58
|
-
name: z.string().describe("Human name"),
|
|
59
|
-
surname: z.string().describe("Human surname"),
|
|
60
|
-
age: z.number().describe("Human age"),
|
|
61
|
-
appearance: z.string().describe("Human appearance description"),
|
|
62
|
-
shortBio: z.string().describe("Short bio secription"),
|
|
63
|
-
university: z.string().optional().describe("University name if attended"),
|
|
64
|
-
gender: z.string().describe("Gender of the human"),
|
|
65
|
-
interests: z
|
|
66
|
-
.array(z.string())
|
|
67
|
-
.describe("json array of strings human interests"),
|
|
68
|
-
}),
|
|
69
|
-
});
|
|
70
|
-
const result = await parser.parseResult([
|
|
71
|
-
{
|
|
72
|
-
text: "",
|
|
73
|
-
message: new AIMessage({
|
|
74
|
-
content: "",
|
|
75
|
-
additional_kwargs: {
|
|
76
|
-
function_call: {
|
|
77
|
-
name: "",
|
|
78
|
-
arguments: JSON.stringify({
|
|
79
|
-
name: "Anna",
|
|
80
|
-
surname: "Kowalska",
|
|
81
|
-
age: 30,
|
|
82
|
-
appearance: "Anna has shoulder-length brown hair and green eyes. She has a slim build and stands at around 5'6\" tall.",
|
|
83
|
-
shortBio: "Anna is a kind and compassionate person who loves to help others. She works as a nurse at a local hospital in Poland. In her free time, she enjoys reading, cooking, and spending time with her friends and family. Anna is also passionate about traveling and exploring new places.",
|
|
84
|
-
university: null,
|
|
85
|
-
gender: "female",
|
|
86
|
-
interests: ["reading", "cooking", "traveling"],
|
|
87
|
-
}),
|
|
88
|
-
},
|
|
89
|
-
},
|
|
90
|
-
}),
|
|
91
|
-
},
|
|
92
|
-
]);
|
|
93
|
-
console.log("result", result);
|
|
94
|
-
expect(result.name).toEqual("Anna");
|
|
95
|
-
expect(result.surname).toEqual("Kowalska");
|
|
96
|
-
expect(result.age).toEqual(30);
|
|
97
|
-
expect(result).toHaveProperty("appearance");
|
|
98
|
-
expect(result).toHaveProperty("shortBio");
|
|
99
|
-
expect(result).not.toHaveProperty("university");
|
|
100
|
-
expect(result.gender).toEqual("female");
|
|
101
|
-
expect(result.interests.length).toEqual(3);
|
|
102
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { test, expect } from "@jest/globals";
|
|
2
|
-
import { ChatOpenAI } from "@langchain/openai";
|
|
3
|
-
import { createTaggingChain } from "../tagging.js";
|
|
4
|
-
test("tagging chain", async () => {
|
|
5
|
-
const chain = createTaggingChain({
|
|
6
|
-
type: "object",
|
|
7
|
-
properties: {
|
|
8
|
-
sentiment: { type: "string" },
|
|
9
|
-
tone: { type: "string" },
|
|
10
|
-
language: { type: "string" },
|
|
11
|
-
},
|
|
12
|
-
required: ["tone"],
|
|
13
|
-
}, new ChatOpenAI({ modelName: "gpt-4-0613", temperature: 0 }));
|
|
14
|
-
const result = await chain.run(`Estoy increiblemente contento de haberte conocido! Creo que seremos muy buenos amigos!`);
|
|
15
|
-
expect(result).toMatchInlineSnapshot(`
|
|
16
|
-
{
|
|
17
|
-
"language": "Spanish",
|
|
18
|
-
"tone": "positive",
|
|
19
|
-
}
|
|
20
|
-
`);
|
|
21
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { test } from "@jest/globals";
|
|
2
|
-
import { OpenAI } from "@langchain/openai";
|
|
3
|
-
import { loadQueryConstructorRunnable } from "../index.js";
|
|
4
|
-
import { Comparators, Comparison, Operation, Operators, StructuredQuery, } from "../ir.js";
|
|
5
|
-
import { BasicTranslator } from "../../../retrievers/self_query/base.js";
|
|
6
|
-
test("Query Chain Test", async () => {
|
|
7
|
-
const sq1 = new StructuredQuery("", new Comparison(Comparators.lt, "length", 90));
|
|
8
|
-
const sq3 = new StructuredQuery("", new Comparison(Comparators.gt, "rating", 8.5));
|
|
9
|
-
const sq4 = new StructuredQuery("", new Comparison(Comparators.eq, "director", "Greta Gerwig"));
|
|
10
|
-
const sq5 = new StructuredQuery("", new Operation(Operators.and, [
|
|
11
|
-
new Operation(Operators.or, [
|
|
12
|
-
new Comparison(Comparators.eq, "genre", "comedy"),
|
|
13
|
-
new Comparison(Comparators.eq, "genre", "drama"),
|
|
14
|
-
]),
|
|
15
|
-
new Comparison(Comparators.lt, "length", 90),
|
|
16
|
-
]));
|
|
17
|
-
const filter1 = { length: { $lt: 90 } };
|
|
18
|
-
const filter3 = { rating: { $gt: 8.5 } };
|
|
19
|
-
const filter4 = { director: { $eq: "Greta Gerwig" } };
|
|
20
|
-
const filter5 = {
|
|
21
|
-
$and: [
|
|
22
|
-
{ $or: [{ genre: { $eq: "comedy" } }, { genre: { $eq: "drama" } }] },
|
|
23
|
-
{ length: { $lt: 90 } },
|
|
24
|
-
],
|
|
25
|
-
};
|
|
26
|
-
const attributeInfo = [
|
|
27
|
-
{
|
|
28
|
-
name: "genre",
|
|
29
|
-
description: "The genre of the movie",
|
|
30
|
-
type: "string or array of strings",
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
name: "year",
|
|
34
|
-
description: "The year the movie was released",
|
|
35
|
-
type: "number",
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
name: "director",
|
|
39
|
-
description: "The director of the movie",
|
|
40
|
-
type: "string",
|
|
41
|
-
},
|
|
42
|
-
{
|
|
43
|
-
name: "rating",
|
|
44
|
-
description: "The rating of the movie (1-10)",
|
|
45
|
-
type: "number",
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
name: "length",
|
|
49
|
-
description: "The length of the movie in minutes",
|
|
50
|
-
type: "number",
|
|
51
|
-
},
|
|
52
|
-
];
|
|
53
|
-
const documentContents = "Brief summary of a movie";
|
|
54
|
-
const allowedComparators = Object.values(Comparators);
|
|
55
|
-
const allowedOperators = Object.values(Operators);
|
|
56
|
-
const llm = new OpenAI({
|
|
57
|
-
modelName: "gpt-3.5-turbo-instruct",
|
|
58
|
-
temperature: 0,
|
|
59
|
-
});
|
|
60
|
-
const queryChain = loadQueryConstructorRunnable({
|
|
61
|
-
llm,
|
|
62
|
-
documentContents,
|
|
63
|
-
attributeInfo,
|
|
64
|
-
allowedComparators,
|
|
65
|
-
allowedOperators,
|
|
66
|
-
});
|
|
67
|
-
const c1 = queryChain.invoke({
|
|
68
|
-
query: "Which movies are less than 90 minutes?",
|
|
69
|
-
});
|
|
70
|
-
const c3 = queryChain.invoke({
|
|
71
|
-
query: "Which movies are rated higher than 8.5?",
|
|
72
|
-
});
|
|
73
|
-
const c4 = queryChain.invoke({
|
|
74
|
-
query: "Which movies are directed by Greta Gerwig?",
|
|
75
|
-
});
|
|
76
|
-
const c5 = queryChain.invoke({
|
|
77
|
-
query: "Which movies are either comedy or drama and are less than 90 minutes?",
|
|
78
|
-
});
|
|
79
|
-
const [r1, r3, r4, r5] = await Promise.all([c1, c3, c4, c5]);
|
|
80
|
-
expect(r1).toMatchObject(sq1);
|
|
81
|
-
expect(r3).toMatchObject(sq3);
|
|
82
|
-
expect(r4).toMatchObject(sq4);
|
|
83
|
-
expect(r5).toMatchObject(sq5);
|
|
84
|
-
const testTranslator = new BasicTranslator();
|
|
85
|
-
const { filter: parsedFilter1 } = testTranslator.visitStructuredQuery(r1);
|
|
86
|
-
const { filter: parsedFilter3 } = testTranslator.visitStructuredQuery(r3);
|
|
87
|
-
const { filter: parsedFilter4 } = testTranslator.visitStructuredQuery(r4);
|
|
88
|
-
const { filter: parsedFilter5 } = testTranslator.visitStructuredQuery(r5);
|
|
89
|
-
expect(parsedFilter1).toMatchObject(filter1);
|
|
90
|
-
expect(parsedFilter3).toMatchObject(filter3);
|
|
91
|
-
expect(parsedFilter4).toMatchObject(filter4);
|
|
92
|
-
expect(parsedFilter5).toMatchObject(filter5);
|
|
93
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { test } from "@jest/globals";
|
|
2
|
-
import { StructuredQueryOutputParser } from "../index.js";
|
|
3
|
-
import { Comparators, Comparison, Operation, Operators, StructuredQuery, } from "../ir.js";
|
|
4
|
-
const correctQuery = new StructuredQuery("teenager love", new Operation(Operators.and, [
|
|
5
|
-
new Operation(Operators.or, [
|
|
6
|
-
new Comparison(Comparators.eq, "artist", "Taylor Swift"),
|
|
7
|
-
new Comparison(Comparators.eq, "artist", "Katy Perry"),
|
|
8
|
-
]),
|
|
9
|
-
new Comparison(Comparators.lt, "length", 180),
|
|
10
|
-
new Comparison(Comparators.eq, "genre", "pop"),
|
|
11
|
-
]));
|
|
12
|
-
test("StructuredQueryOutputParser test", async () => {
|
|
13
|
-
const queryParser = StructuredQueryOutputParser.fromComponents([
|
|
14
|
-
Comparators.eq,
|
|
15
|
-
Comparators.gte,
|
|
16
|
-
Comparators.gt,
|
|
17
|
-
Comparators.lte,
|
|
18
|
-
Comparators.lt,
|
|
19
|
-
], [Operators.and, Operators.or, Operators.not]);
|
|
20
|
-
const exampleOutput = `json\`\`\`
|
|
21
|
-
{
|
|
22
|
-
"query": "teenager love",
|
|
23
|
-
"filter": "and(or(eq(\\"artist\\", \\"Taylor Swift\\"), eq(\\"artist\\", \\"Katy Perry\\")), lt(\\"length\\", 180), eq(\\"genre\\", \\"pop\\"))"
|
|
24
|
-
}
|
|
25
|
-
\`\`\``;
|
|
26
|
-
const parsedOutput = await queryParser.parse(exampleOutput);
|
|
27
|
-
expect(parsedOutput).toMatchObject(correctQuery);
|
|
28
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { test } from "@jest/globals";
|
|
2
|
-
import { OpenAI } from "@langchain/openai";
|
|
3
|
-
import { Document } from "@langchain/core/documents";
|
|
4
|
-
import { loadQAMapReduceChain, loadQARefineChain, loadQAStuffChain, } from "../load.js";
|
|
5
|
-
test("Test loadQAStuffChain", async () => {
|
|
6
|
-
const model = new OpenAI({ modelName: "gpt-3.5-turbo-instruct" });
|
|
7
|
-
const chain = loadQAStuffChain(model);
|
|
8
|
-
const docs = [
|
|
9
|
-
new Document({ pageContent: "foo" }),
|
|
10
|
-
new Document({ pageContent: "bar" }),
|
|
11
|
-
new Document({ pageContent: "baz" }),
|
|
12
|
-
];
|
|
13
|
-
const res = await chain.call({ input_documents: docs, question: "Whats up" });
|
|
14
|
-
console.log({ res });
|
|
15
|
-
});
|
|
16
|
-
test("Test loadQAMapReduceChain", async () => {
|
|
17
|
-
const model = new OpenAI({ modelName: "gpt-3.5-turbo-instruct" });
|
|
18
|
-
const chain = loadQAMapReduceChain(model);
|
|
19
|
-
const docs = [
|
|
20
|
-
new Document({ pageContent: "foo" }),
|
|
21
|
-
new Document({ pageContent: "bar" }),
|
|
22
|
-
new Document({ pageContent: "baz" }),
|
|
23
|
-
];
|
|
24
|
-
const res = await chain.call({ input_documents: docs, question: "Whats up" });
|
|
25
|
-
console.log({ res });
|
|
26
|
-
});
|
|
27
|
-
test("Test loadQARefineChain", async () => {
|
|
28
|
-
const model = new OpenAI({ modelName: "gpt-3.5-turbo-instruct" });
|
|
29
|
-
const chain = loadQARefineChain(model);
|
|
30
|
-
const docs = [
|
|
31
|
-
new Document({ pageContent: "Harrison went to Harvard." }),
|
|
32
|
-
new Document({ pageContent: "Ankush went to Princeton." }),
|
|
33
|
-
];
|
|
34
|
-
const res = await chain.call({
|
|
35
|
-
input_documents: docs,
|
|
36
|
-
question: "Where did Harrison go to college?",
|
|
37
|
-
});
|
|
38
|
-
console.log({ res });
|
|
39
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|