langchain 0.2.10 → 0.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/chat_models/universal.cjs +1 -0
- package/chat_models/universal.d.cts +1 -0
- package/chat_models/universal.d.ts +1 -0
- package/chat_models/universal.js +1 -0
- package/dist/chat_models/universal.cjs +600 -0
- package/dist/chat_models/universal.d.ts +115 -0
- package/dist/chat_models/universal.js +595 -0
- package/dist/document_loaders/web/assemblyai.cjs +9 -1
- package/dist/document_loaders/web/assemblyai.js +9 -1
- package/dist/experimental/chrome_ai/app/dist/bundle.cjs +1250 -0
- package/dist/experimental/chrome_ai/app/dist/bundle.d.ts +1 -0
- package/dist/experimental/chrome_ai/app/dist/bundle.js +1249 -0
- package/dist/load/import_constants.cjs +1 -0
- package/dist/load/import_constants.js +1 -0
- package/package.json +65 -6
- package/dist/agents/tests/agent.int.test.d.ts +0 -1
- package/dist/agents/tests/agent.int.test.js +0 -309
- package/dist/agents/tests/chat_convo_output_parser.test.d.ts +0 -1
- package/dist/agents/tests/chat_convo_output_parser.test.js +0 -91
- package/dist/agents/tests/create_openai_functions_agent.int.test.d.ts +0 -2
- package/dist/agents/tests/create_openai_functions_agent.int.test.js +0 -71
- package/dist/agents/tests/create_openai_tools_agent.int.test.d.ts +0 -1
- package/dist/agents/tests/create_openai_tools_agent.int.test.js +0 -75
- package/dist/agents/tests/create_react_agent.int.test.d.ts +0 -1
- package/dist/agents/tests/create_react_agent.int.test.js +0 -32
- package/dist/agents/tests/create_structured_chat_agent.int.test.d.ts +0 -1
- package/dist/agents/tests/create_structured_chat_agent.int.test.js +0 -32
- package/dist/agents/tests/create_tool_calling_agent.int.test.d.ts +0 -1
- package/dist/agents/tests/create_tool_calling_agent.int.test.js +0 -122
- package/dist/agents/tests/create_xml_agent.int.test.d.ts +0 -1
- package/dist/agents/tests/create_xml_agent.int.test.js +0 -32
- package/dist/agents/tests/json.test.d.ts +0 -1
- package/dist/agents/tests/json.test.js +0 -74
- package/dist/agents/tests/react.test.d.ts +0 -1
- package/dist/agents/tests/react.test.js +0 -44
- package/dist/agents/tests/runnable.int.test.d.ts +0 -1
- package/dist/agents/tests/runnable.int.test.js +0 -104
- package/dist/agents/tests/sql.test.d.ts +0 -1
- package/dist/agents/tests/sql.test.js +0 -133
- package/dist/agents/tests/structured_chat_output_parser.test.d.ts +0 -1
- package/dist/agents/tests/structured_chat_output_parser.test.js +0 -35
- package/dist/agents/tests/structured_chat_output_parser_with_retries.int.test.d.ts +0 -1
- package/dist/agents/tests/structured_chat_output_parser_with_retries.int.test.js +0 -44
- package/dist/agents/tests/structured_output_runnables.int.test.d.ts +0 -1
- package/dist/agents/tests/structured_output_runnables.int.test.js +0 -112
- package/dist/agents/toolkits/tests/conversational_retrieval.int.test.d.ts +0 -1
- package/dist/agents/toolkits/tests/conversational_retrieval.int.test.js +0 -41
- package/dist/cache/tests/file_system.int.test.d.ts +0 -1
- package/dist/cache/tests/file_system.int.test.js +0 -32
- package/dist/chains/openai_functions/tests/create_runnable_chains.int.test.d.ts +0 -1
- package/dist/chains/openai_functions/tests/create_runnable_chains.int.test.js +0 -139
- package/dist/chains/openai_functions/tests/extraction.int.test.d.ts +0 -1
- package/dist/chains/openai_functions/tests/extraction.int.test.js +0 -33
- package/dist/chains/openai_functions/tests/openapi.int.test.d.ts +0 -1
- package/dist/chains/openai_functions/tests/openapi.int.test.js +0 -130
- package/dist/chains/openai_functions/tests/openapi.test.d.ts +0 -1
- package/dist/chains/openai_functions/tests/openapi.test.js +0 -172
- package/dist/chains/openai_functions/tests/structured_output.int.test.d.ts +0 -1
- package/dist/chains/openai_functions/tests/structured_output.int.test.js +0 -40
- package/dist/chains/openai_functions/tests/structured_output.test.d.ts +0 -1
- package/dist/chains/openai_functions/tests/structured_output.test.js +0 -102
- package/dist/chains/openai_functions/tests/tagging.int.test.d.ts +0 -1
- package/dist/chains/openai_functions/tests/tagging.int.test.js +0 -21
- package/dist/chains/query_constructor/tests/query_chain.int.test.d.ts +0 -1
- package/dist/chains/query_constructor/tests/query_chain.int.test.js +0 -93
- package/dist/chains/query_constructor/tests/query_parser.test.d.ts +0 -1
- package/dist/chains/query_constructor/tests/query_parser.test.js +0 -28
- package/dist/chains/question_answering/tests/load.int.test.d.ts +0 -1
- package/dist/chains/question_answering/tests/load.int.test.js +0 -39
- package/dist/chains/router/tests/multi_prompt.int.test.d.ts +0 -1
- package/dist/chains/router/tests/multi_prompt.int.test.js +0 -45
- package/dist/chains/router/tests/multi_prompt.test.d.ts +0 -1
- package/dist/chains/router/tests/multi_prompt.test.js +0 -62
- package/dist/chains/router/tests/multi_retrieval_qa.int.test.d.ts +0 -1
- package/dist/chains/router/tests/multi_retrieval_qa.int.test.js +0 -67
- package/dist/chains/router/tests/multi_retrieval_qa.test.d.ts +0 -1
- package/dist/chains/router/tests/multi_retrieval_qa.test.js +0 -125
- package/dist/chains/summarization/tests/load.int.test.d.ts +0 -1
- package/dist/chains/summarization/tests/load.int.test.js +0 -37
- package/dist/chains/tests/api_chain.int.test.d.ts +0 -1
- package/dist/chains/tests/api_chain.int.test.js +0 -55
- package/dist/chains/tests/combine_docs_chain.int.test.d.ts +0 -1
- package/dist/chains/tests/combine_docs_chain.int.test.js +0 -50
- package/dist/chains/tests/combine_docs_chain.test.d.ts +0 -1
- package/dist/chains/tests/combine_docs_chain.test.js +0 -98
- package/dist/chains/tests/constitutional_chain.int.test.d.ts +0 -1
- package/dist/chains/tests/constitutional_chain.int.test.js +0 -30
- package/dist/chains/tests/constitutional_chain.test.d.ts +0 -1
- package/dist/chains/tests/constitutional_chain.test.js +0 -63
- package/dist/chains/tests/conversation_chain.int.test.d.ts +0 -1
- package/dist/chains/tests/conversation_chain.int.test.js +0 -9
- package/dist/chains/tests/conversational_retrieval_chain.int.test.d.ts +0 -1
- package/dist/chains/tests/conversational_retrieval_chain.int.test.js +0 -243
- package/dist/chains/tests/example_data/open_meteo_docs.d.ts +0 -1
- package/dist/chains/tests/example_data/open_meteo_docs.js +0 -29
- package/dist/chains/tests/history_aware_retriever.int.test.d.ts +0 -1
- package/dist/chains/tests/history_aware_retriever.int.test.js +0 -41
- package/dist/chains/tests/history_aware_retriever.test.d.ts +0 -1
- package/dist/chains/tests/history_aware_retriever.test.js +0 -27
- package/dist/chains/tests/llm_chain.int.test.d.ts +0 -1
- package/dist/chains/tests/llm_chain.int.test.js +0 -119
- package/dist/chains/tests/openai_moderation.int.test.d.ts +0 -1
- package/dist/chains/tests/openai_moderation.int.test.js +0 -30
- package/dist/chains/tests/retrieval_chain.int.test.d.ts +0 -1
- package/dist/chains/tests/retrieval_chain.int.test.js +0 -69
- package/dist/chains/tests/retrieval_chain.test.d.ts +0 -1
- package/dist/chains/tests/retrieval_chain.test.js +0 -36
- package/dist/chains/tests/sequential_chain.int.test.d.ts +0 -1
- package/dist/chains/tests/sequential_chain.int.test.js +0 -88
- package/dist/chains/tests/sequential_chain.test.d.ts +0 -1
- package/dist/chains/tests/sequential_chain.test.js +0 -295
- package/dist/chains/tests/simple_sequential_chain.int.test.d.ts +0 -1
- package/dist/chains/tests/simple_sequential_chain.int.test.js +0 -81
- package/dist/chains/tests/simple_sequential_chain.test.d.ts +0 -1
- package/dist/chains/tests/simple_sequential_chain.test.js +0 -128
- package/dist/chains/tests/sql_db_chain.int.test.d.ts +0 -1
- package/dist/chains/tests/sql_db_chain.int.test.js +0 -125
- package/dist/chains/tests/transform.test.d.ts +0 -1
- package/dist/chains/tests/transform.test.js +0 -12
- package/dist/chains/tests/vector_db_qa_chain.int.test.d.ts +0 -1
- package/dist/chains/tests/vector_db_qa_chain.int.test.js +0 -45
- package/dist/document_loaders/tests/assemblyai.int.test.d.ts +0 -1
- package/dist/document_loaders/tests/assemblyai.int.test.js +0 -111
- package/dist/document_loaders/tests/chatgpt-blob.test.d.ts +0 -1
- package/dist/document_loaders/tests/chatgpt-blob.test.js +0 -30
- package/dist/document_loaders/tests/chatgpt.test.d.ts +0 -1
- package/dist/document_loaders/tests/chatgpt.test.js +0 -29
- package/dist/document_loaders/tests/cheerio.int.test.d.ts +0 -1
- package/dist/document_loaders/tests/cheerio.int.test.js +0 -21
- package/dist/document_loaders/tests/college_confidential.int.test.d.ts +0 -1
- package/dist/document_loaders/tests/college_confidential.int.test.js +0 -6
- package/dist/document_loaders/tests/confluence.test.d.ts +0 -1
- package/dist/document_loaders/tests/confluence.test.js +0 -52
- package/dist/document_loaders/tests/couchbase.int.test.d.ts +0 -1
- package/dist/document_loaders/tests/couchbase.int.test.js +0 -28
- package/dist/document_loaders/tests/csv-blob.test.d.ts +0 -1
- package/dist/document_loaders/tests/csv-blob.test.js +0 -53
- package/dist/document_loaders/tests/csv.test.d.ts +0 -1
- package/dist/document_loaders/tests/csv.test.js +0 -41
- package/dist/document_loaders/tests/directory.test.d.ts +0 -1
- package/dist/document_loaders/tests/directory.test.js +0 -38
- package/dist/document_loaders/tests/docx.test.d.ts +0 -1
- package/dist/document_loaders/tests/docx.test.js +0 -11
- package/dist/document_loaders/tests/epub.test.d.ts +0 -1
- package/dist/document_loaders/tests/epub.test.js +0 -18
- package/dist/document_loaders/tests/example_data/github_api_responses.d.ts +0 -5
- package/dist/document_loaders/tests/example_data/github_api_responses.js +0 -91
- package/dist/document_loaders/tests/figma.int.test.d.ts +0 -1
- package/dist/document_loaders/tests/figma.int.test.js +0 -13
- package/dist/document_loaders/tests/firecrawl.int.test.d.ts +0 -1
- package/dist/document_loaders/tests/firecrawl.int.test.js +0 -30
- package/dist/document_loaders/tests/gitbook.int.test.d.ts +0 -1
- package/dist/document_loaders/tests/gitbook.int.test.js +0 -14
- package/dist/document_loaders/tests/github.int.test.d.ts +0 -1
- package/dist/document_loaders/tests/github.int.test.js +0 -86
- package/dist/document_loaders/tests/github.test.d.ts +0 -1
- package/dist/document_loaders/tests/github.test.js +0 -51
- package/dist/document_loaders/tests/hn.int.test.d.ts +0 -1
- package/dist/document_loaders/tests/hn.int.test.js +0 -6
- package/dist/document_loaders/tests/imsdb.test.d.ts +0 -1
- package/dist/document_loaders/tests/imsdb.test.js +0 -6
- package/dist/document_loaders/tests/json-blob.test.d.ts +0 -1
- package/dist/document_loaders/tests/json-blob.test.js +0 -91
- package/dist/document_loaders/tests/json.test.d.ts +0 -1
- package/dist/document_loaders/tests/json.test.js +0 -69
- package/dist/document_loaders/tests/jsonl-blob.test.d.ts +0 -1
- package/dist/document_loaders/tests/jsonl-blob.test.js +0 -46
- package/dist/document_loaders/tests/jsonl.test.d.ts +0 -1
- package/dist/document_loaders/tests/jsonl.test.js +0 -15
- package/dist/document_loaders/tests/multi_file.test.d.ts +0 -1
- package/dist/document_loaders/tests/multi_file.test.js +0 -49
- package/dist/document_loaders/tests/notion.test.d.ts +0 -1
- package/dist/document_loaders/tests/notion.test.js +0 -11
- package/dist/document_loaders/tests/notionapi.int.test.d.ts +0 -1
- package/dist/document_loaders/tests/notionapi.int.test.js +0 -80
- package/dist/document_loaders/tests/notionapi.test.d.ts +0 -1
- package/dist/document_loaders/tests/notionapi.test.js +0 -84
- package/dist/document_loaders/tests/notiondb.int.test.d.ts +0 -1
- package/dist/document_loaders/tests/notiondb.int.test.js +0 -13
- package/dist/document_loaders/tests/obsidian.test.d.ts +0 -1
- package/dist/document_loaders/tests/obsidian.test.js +0 -119
- package/dist/document_loaders/tests/pdf-blob.test.d.ts +0 -1
- package/dist/document_loaders/tests/pdf-blob.test.js +0 -44
- package/dist/document_loaders/tests/pdf.test.d.ts +0 -1
- package/dist/document_loaders/tests/pdf.test.js +0 -25
- package/dist/document_loaders/tests/playwright_web.int.test.d.ts +0 -1
- package/dist/document_loaders/tests/playwright_web.int.test.js +0 -27
- package/dist/document_loaders/tests/pptx.test.d.ts +0 -1
- package/dist/document_loaders/tests/pptx.test.js +0 -17
- package/dist/document_loaders/tests/puppeteer.int.test.d.ts +0 -1
- package/dist/document_loaders/tests/puppeteer.int.test.js +0 -47
- package/dist/document_loaders/tests/recursive_url.int.test.d.ts +0 -1
- package/dist/document_loaders/tests/recursive_url.int.test.js +0 -64
- package/dist/document_loaders/tests/s3.int.test.d.ts +0 -1
- package/dist/document_loaders/tests/s3.int.test.js +0 -48
- package/dist/document_loaders/tests/searchapi.test.d.ts +0 -1
- package/dist/document_loaders/tests/searchapi.test.js +0 -29
- package/dist/document_loaders/tests/serpapi.test.d.ts +0 -1
- package/dist/document_loaders/tests/serpapi.test.js +0 -21
- package/dist/document_loaders/tests/sitemap.int.test.d.ts +0 -1
- package/dist/document_loaders/tests/sitemap.int.test.js +0 -28
- package/dist/document_loaders/tests/sonix_audio.int.test.d.ts +0 -1
- package/dist/document_loaders/tests/sonix_audio.int.test.js +0 -55
- package/dist/document_loaders/tests/sort_xyz_blockchain.int.test.d.ts +0 -1
- package/dist/document_loaders/tests/sort_xyz_blockchain.int.test.js +0 -38
- package/dist/document_loaders/tests/srt-blob.test.d.ts +0 -1
- package/dist/document_loaders/tests/srt-blob.test.js +0 -18
- package/dist/document_loaders/tests/srt.test.d.ts +0 -1
- package/dist/document_loaders/tests/srt.test.js +0 -16
- package/dist/document_loaders/tests/text-blob.test.d.ts +0 -1
- package/dist/document_loaders/tests/text-blob.test.js +0 -14
- package/dist/document_loaders/tests/text.test.d.ts +0 -1
- package/dist/document_loaders/tests/text.test.js +0 -22
- package/dist/document_loaders/tests/unstructured.int.test.d.ts +0 -1
- package/dist/document_loaders/tests/unstructured.int.test.js +0 -58
- package/dist/document_loaders/tests/webpdf.int.test.d.ts +0 -1
- package/dist/document_loaders/tests/webpdf.int.test.js +0 -90
- package/dist/document_transformers/tests/openai_functions.int.test.d.ts +0 -1
- package/dist/document_transformers/tests/openai_functions.int.test.js +0 -40
- package/dist/embeddings/tests/cache.test.d.ts +0 -1
- package/dist/embeddings/tests/cache.test.js +0 -24
- package/dist/embeddings/tests/fake.test.d.ts +0 -1
- package/dist/embeddings/tests/fake.test.js +0 -34
- package/dist/evaluation/agents/tests/trajectory_eval_chain.int.test.d.ts +0 -1
- package/dist/evaluation/agents/tests/trajectory_eval_chain.int.test.js +0 -33
- package/dist/evaluation/comparison/tests/pairwise_eval_chain.int.test.d.ts +0 -1
- package/dist/evaluation/comparison/tests/pairwise_eval_chain.int.test.js +0 -46
- package/dist/evaluation/criteria/tests/criteria_eval_chain.int.test.d.ts +0 -1
- package/dist/evaluation/criteria/tests/criteria_eval_chain.int.test.js +0 -108
- package/dist/evaluation/embedding_distance/tests/embedding_distance_eval_chain.int.test.d.ts +0 -1
- package/dist/evaluation/embedding_distance/tests/embedding_distance_eval_chain.int.test.js +0 -26
- package/dist/evaluation/qa/tests/eval_chain.int.test.d.ts +0 -1
- package/dist/evaluation/qa/tests/eval_chain.int.test.js +0 -27
- package/dist/experimental/autogpt/tests/output_parser.test.d.ts +0 -1
- package/dist/experimental/autogpt/tests/output_parser.test.js +0 -8
- package/dist/experimental/autogpt/tests/prompt.test.d.ts +0 -1
- package/dist/experimental/autogpt/tests/prompt.test.js +0 -69
- package/dist/experimental/autogpt/tests/prompt_generator.test.d.ts +0 -1
- package/dist/experimental/autogpt/tests/prompt_generator.test.js +0 -91
- package/dist/experimental/chains/tests/violation_of_expectations_chain.int.test.d.ts +0 -1
- package/dist/experimental/chains/tests/violation_of_expectations_chain.int.test.js +0 -26
- package/dist/experimental/generative_agents/tests/generative_agent.int.test.d.ts +0 -1
- package/dist/experimental/generative_agents/tests/generative_agent.int.test.js +0 -304
- package/dist/experimental/masking/tests/masking-extended.test.d.ts +0 -1
- package/dist/experimental/masking/tests/masking-extended.test.js +0 -58
- package/dist/experimental/masking/tests/masking.test.d.ts +0 -1
- package/dist/experimental/masking/tests/masking.test.js +0 -388
- package/dist/experimental/openai_assistant/tests/openai_assistant.int.test.d.ts +0 -1
- package/dist/experimental/openai_assistant/tests/openai_assistant.int.test.js +0 -203
- package/dist/experimental/openai_files/tests/openai_file.int.test.d.ts +0 -1
- package/dist/experimental/openai_files/tests/openai_file.int.test.js +0 -87
- package/dist/experimental/plan_and_execute/tests/plan_and_execute.int.test.d.ts +0 -1
- package/dist/experimental/plan_and_execute/tests/plan_and_execute.int.test.js +0 -54
- package/dist/experimental/prompts/tests/handlebars.test.d.ts +0 -1
- package/dist/experimental/prompts/tests/handlebars.test.js +0 -24
- package/dist/experimental/tools/tests/pyinterpreter.int.test.d.ts +0 -1
- package/dist/experimental/tools/tests/pyinterpreter.int.test.js +0 -22
- package/dist/load/tests/cross_language.test.d.ts +0 -1
- package/dist/load/tests/cross_language.test.js +0 -83
- package/dist/load/tests/load.int.test.d.ts +0 -1
- package/dist/load/tests/load.int.test.js +0 -9
- package/dist/load/tests/load.test.d.ts +0 -1
- package/dist/load/tests/load.test.js +0 -412
- package/dist/memory/tests/buffer_memory.test.d.ts +0 -1
- package/dist/memory/tests/buffer_memory.test.js +0 -34
- package/dist/memory/tests/buffer_token_memory.int.test.d.ts +0 -1
- package/dist/memory/tests/buffer_token_memory.int.test.js +0 -47
- package/dist/memory/tests/buffer_window_memory.test.d.ts +0 -1
- package/dist/memory/tests/buffer_window_memory.test.js +0 -42
- package/dist/memory/tests/combined_memory.int.test.d.ts +0 -1
- package/dist/memory/tests/combined_memory.int.test.js +0 -74
- package/dist/memory/tests/entity_memory.int.test.d.ts +0 -1
- package/dist/memory/tests/entity_memory.int.test.js +0 -79
- package/dist/memory/tests/entity_memory.test.d.ts +0 -1
- package/dist/memory/tests/entity_memory.test.js +0 -48
- package/dist/memory/tests/summary.int.test.d.ts +0 -1
- package/dist/memory/tests/summary.int.test.js +0 -50
- package/dist/memory/tests/summary_buffer.int.test.d.ts +0 -1
- package/dist/memory/tests/summary_buffer.int.test.js +0 -55
- package/dist/memory/tests/vector_store_memory.int.test.d.ts +0 -1
- package/dist/memory/tests/vector_store_memory.int.test.js +0 -55
- package/dist/output_parsers/tests/combining.int.test.d.ts +0 -1
- package/dist/output_parsers/tests/combining.int.test.js +0 -26
- package/dist/output_parsers/tests/combining.test.d.ts +0 -1
- package/dist/output_parsers/tests/combining.test.js +0 -54
- package/dist/output_parsers/tests/datetime.test.d.ts +0 -1
- package/dist/output_parsers/tests/datetime.test.js +0 -14
- package/dist/output_parsers/tests/expression.test.d.ts +0 -1
- package/dist/output_parsers/tests/expression.test.js +0 -339
- package/dist/output_parsers/tests/http_response.test.d.ts +0 -1
- package/dist/output_parsers/tests/http_response.test.js +0 -39
- package/dist/output_parsers/tests/list.test.d.ts +0 -1
- package/dist/output_parsers/tests/list.test.js +0 -27
- package/dist/output_parsers/tests/openai_functions.int.test.d.ts +0 -1
- package/dist/output_parsers/tests/openai_functions.int.test.js +0 -89
- package/dist/output_parsers/tests/openai_tools.int.test.d.ts +0 -1
- package/dist/output_parsers/tests/openai_tools.int.test.js +0 -36
- package/dist/output_parsers/tests/structured.int.test.d.ts +0 -1
- package/dist/output_parsers/tests/structured.int.test.js +0 -150
- package/dist/prompts/tests/selectors.test.d.ts +0 -1
- package/dist/prompts/tests/selectors.test.js +0 -59
- package/dist/retrievers/self_query/tests/memory_self_query.int.test.d.ts +0 -1
- package/dist/retrievers/self_query/tests/memory_self_query.int.test.js +0 -330
- package/dist/retrievers/tests/chain_extract.int.test.d.ts +0 -1
- package/dist/retrievers/tests/chain_extract.int.test.js +0 -32
- package/dist/retrievers/tests/ensemble_retriever.int.test.d.ts +0 -1
- package/dist/retrievers/tests/ensemble_retriever.int.test.js +0 -74
- package/dist/retrievers/tests/hyde.int.test.d.ts +0 -1
- package/dist/retrievers/tests/hyde.int.test.js +0 -44
- package/dist/retrievers/tests/matryoshka_retriever.int.test.d.ts +0 -1
- package/dist/retrievers/tests/matryoshka_retriever.int.test.js +0 -113
- package/dist/retrievers/tests/multi_query.int.test.d.ts +0 -1
- package/dist/retrievers/tests/multi_query.int.test.js +0 -45
- package/dist/retrievers/tests/parent_document.int.test.d.ts +0 -1
- package/dist/retrievers/tests/parent_document.int.test.js +0 -122
- package/dist/retrievers/tests/score_threshold.int.test.d.ts +0 -1
- package/dist/retrievers/tests/score_threshold.int.test.js +0 -83
- package/dist/retrievers/tests/time_weighted.test.d.ts +0 -1
- package/dist/retrievers/tests/time_weighted.test.js +0 -320
- package/dist/retrievers/tests/vectorstores.test.d.ts +0 -1
- package/dist/retrievers/tests/vectorstores.test.js +0 -50
- package/dist/smith/tests/run_on_dataset.int.test.d.ts +0 -1
- package/dist/smith/tests/run_on_dataset.int.test.js +0 -257
- package/dist/smith/tests/runner_utils.int.test.d.ts +0 -9
- package/dist/smith/tests/runner_utils.int.test.js +0 -234
- package/dist/storage/tests/file_system.test.d.ts +0 -1
- package/dist/storage/tests/file_system.test.js +0 -81
- package/dist/tools/tests/chain.test.d.ts +0 -1
- package/dist/tools/tests/chain.test.js +0 -136
- package/dist/tools/tests/webbrowser.int.test.d.ts +0 -1
- package/dist/tools/tests/webbrowser.int.test.js +0 -80
- package/dist/tools/tests/webbrowser.test.d.ts +0 -1
- package/dist/tools/tests/webbrowser.test.js +0 -21
- package/dist/util/tests/async_caller.int.test.d.ts +0 -1
- package/dist/util/tests/async_caller.int.test.js +0 -34
- package/dist/util/tests/azure.test.d.ts +0 -1
- package/dist/util/tests/azure.test.js +0 -42
- package/dist/util/tests/openai-stream.test.d.ts +0 -1
- package/dist/util/tests/openai-stream.test.js +0 -135
- package/dist/util/tests/set.test.d.ts +0 -1
- package/dist/util/tests/set.test.js +0 -36
- package/dist/util/tests/sql_utils.test.d.ts +0 -1
- package/dist/util/tests/sql_utils.test.js +0 -50
- package/dist/vectorstores/tests/memory.test.d.ts +0 -1
- package/dist/vectorstores/tests/memory.test.js +0 -78
|
@@ -1,339 +0,0 @@
|
|
|
1
|
-
import { test } from "@jest/globals";
|
|
2
|
-
import { ExpressionParser } from "../expression.js";
|
|
3
|
-
const correctExps = [
|
|
4
|
-
{ type: "call_expression", funcCall: "hello", args: [] },
|
|
5
|
-
{
|
|
6
|
-
type: "call_expression",
|
|
7
|
-
funcCall: "hello",
|
|
8
|
-
args: [{ type: "string_literal", value: "world" }],
|
|
9
|
-
},
|
|
10
|
-
{
|
|
11
|
-
type: "call_expression",
|
|
12
|
-
funcCall: "hello",
|
|
13
|
-
args: [
|
|
14
|
-
{ type: "string_literal", value: "world" },
|
|
15
|
-
{ type: "string_literal", value: "hello" },
|
|
16
|
-
],
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
type: "call_expression",
|
|
20
|
-
funcCall: "hello",
|
|
21
|
-
args: [
|
|
22
|
-
{ type: "string_literal", value: "world" },
|
|
23
|
-
{ type: "string_literal", value: "hello" },
|
|
24
|
-
{
|
|
25
|
-
type: "array_literal",
|
|
26
|
-
values: [
|
|
27
|
-
{ type: "string_literal", value: "hello" },
|
|
28
|
-
{ type: "string_literal", value: "world" },
|
|
29
|
-
{ type: "numeric_literal", value: 1 },
|
|
30
|
-
{ type: "numeric_literal", value: 2.1 },
|
|
31
|
-
{ type: "numeric_literal", value: 3 },
|
|
32
|
-
],
|
|
33
|
-
},
|
|
34
|
-
],
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
type: "call_expression",
|
|
38
|
-
funcCall: "hello",
|
|
39
|
-
args: [
|
|
40
|
-
{ type: "string_literal", value: "world" },
|
|
41
|
-
{ type: "string_literal", value: "hello" },
|
|
42
|
-
{
|
|
43
|
-
type: "array_literal",
|
|
44
|
-
values: [
|
|
45
|
-
{ type: "string_literal", value: "hello" },
|
|
46
|
-
{ type: "string_literal", value: "world" },
|
|
47
|
-
{ type: "numeric_literal", value: 1 },
|
|
48
|
-
{ type: "numeric_literal", value: 2.1 },
|
|
49
|
-
{ type: "numeric_literal", value: 3 },
|
|
50
|
-
],
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
type: "object_literal",
|
|
54
|
-
values: [
|
|
55
|
-
{
|
|
56
|
-
type: "property_assignment",
|
|
57
|
-
identifier: "hello",
|
|
58
|
-
value: { type: "string_literal", value: "world" },
|
|
59
|
-
},
|
|
60
|
-
],
|
|
61
|
-
},
|
|
62
|
-
],
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
type: "call_expression",
|
|
66
|
-
funcCall: "hello",
|
|
67
|
-
args: [
|
|
68
|
-
{ type: "string_literal", value: "world" },
|
|
69
|
-
{ type: "string_literal", value: "hello" },
|
|
70
|
-
{
|
|
71
|
-
type: "array_literal",
|
|
72
|
-
values: [
|
|
73
|
-
{ type: "string_literal", value: "hello" },
|
|
74
|
-
{ type: "string_literal", value: "world" },
|
|
75
|
-
{ type: "numeric_literal", value: 1 },
|
|
76
|
-
{ type: "numeric_literal", value: 2.1 },
|
|
77
|
-
{ type: "numeric_literal", value: 3 },
|
|
78
|
-
],
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
type: "object_literal",
|
|
82
|
-
values: [
|
|
83
|
-
{
|
|
84
|
-
type: "property_assignment",
|
|
85
|
-
identifier: "hello",
|
|
86
|
-
value: { type: "string_literal", value: "world" },
|
|
87
|
-
},
|
|
88
|
-
],
|
|
89
|
-
},
|
|
90
|
-
{ type: "numeric_literal", value: 1 },
|
|
91
|
-
{ type: "numeric_literal", value: 2.1 },
|
|
92
|
-
{ type: "numeric_literal", value: 3 },
|
|
93
|
-
],
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
type: "call_expression",
|
|
97
|
-
funcCall: "hello",
|
|
98
|
-
args: [
|
|
99
|
-
{ type: "string_literal", value: "world" },
|
|
100
|
-
{ type: "string_literal", value: "hello" },
|
|
101
|
-
{
|
|
102
|
-
type: "array_literal",
|
|
103
|
-
values: [
|
|
104
|
-
{ type: "string_literal", value: "hello" },
|
|
105
|
-
{ type: "string_literal", value: "world" },
|
|
106
|
-
{ type: "numeric_literal", value: 1 },
|
|
107
|
-
{ type: "numeric_literal", value: 2.1 },
|
|
108
|
-
{ type: "numeric_literal", value: 3 },
|
|
109
|
-
],
|
|
110
|
-
},
|
|
111
|
-
{
|
|
112
|
-
type: "object_literal",
|
|
113
|
-
values: [
|
|
114
|
-
{
|
|
115
|
-
type: "property_assignment",
|
|
116
|
-
identifier: "hello",
|
|
117
|
-
value: { type: "string_literal", value: "world" },
|
|
118
|
-
},
|
|
119
|
-
],
|
|
120
|
-
},
|
|
121
|
-
{ type: "numeric_literal", value: 1 },
|
|
122
|
-
{ type: "numeric_literal", value: 2.1 },
|
|
123
|
-
{ type: "numeric_literal", value: 3 },
|
|
124
|
-
{
|
|
125
|
-
type: "call_expression",
|
|
126
|
-
funcCall: "world",
|
|
127
|
-
args: [
|
|
128
|
-
{ type: "string_literal", value: "hello" },
|
|
129
|
-
{ type: "string_literal", value: "world" },
|
|
130
|
-
{
|
|
131
|
-
type: "array_literal",
|
|
132
|
-
values: [
|
|
133
|
-
{
|
|
134
|
-
type: "object_literal",
|
|
135
|
-
values: [
|
|
136
|
-
{
|
|
137
|
-
type: "property_assignment",
|
|
138
|
-
identifier: "hello",
|
|
139
|
-
value: { type: "string_literal", value: "world" },
|
|
140
|
-
},
|
|
141
|
-
],
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
type: "object_literal",
|
|
145
|
-
values: [
|
|
146
|
-
{
|
|
147
|
-
type: "property_assignment",
|
|
148
|
-
identifier: "hello",
|
|
149
|
-
value: {
|
|
150
|
-
type: "call_expression",
|
|
151
|
-
funcCall: "hello",
|
|
152
|
-
args: [{ type: "string_literal", value: "world" }],
|
|
153
|
-
},
|
|
154
|
-
},
|
|
155
|
-
],
|
|
156
|
-
},
|
|
157
|
-
],
|
|
158
|
-
},
|
|
159
|
-
],
|
|
160
|
-
},
|
|
161
|
-
],
|
|
162
|
-
},
|
|
163
|
-
{
|
|
164
|
-
type: "call_expression",
|
|
165
|
-
funcCall: {
|
|
166
|
-
type: "member_expression",
|
|
167
|
-
identifier: "hello",
|
|
168
|
-
property: "world",
|
|
169
|
-
},
|
|
170
|
-
args: [
|
|
171
|
-
{ type: "string_literal", value: "hello" },
|
|
172
|
-
{ type: "string_literal", value: "world" },
|
|
173
|
-
{
|
|
174
|
-
type: "array_literal",
|
|
175
|
-
values: [
|
|
176
|
-
{ type: "string_literal", value: "hello" },
|
|
177
|
-
{ type: "string_literal", value: "world" },
|
|
178
|
-
],
|
|
179
|
-
},
|
|
180
|
-
{
|
|
181
|
-
type: "object_literal",
|
|
182
|
-
values: [
|
|
183
|
-
{
|
|
184
|
-
type: "property_assignment",
|
|
185
|
-
identifier: "hello",
|
|
186
|
-
value: { type: "string_literal", value: "world" },
|
|
187
|
-
},
|
|
188
|
-
],
|
|
189
|
-
},
|
|
190
|
-
],
|
|
191
|
-
},
|
|
192
|
-
{
|
|
193
|
-
type: "call_expression",
|
|
194
|
-
funcCall: {
|
|
195
|
-
type: "member_expression",
|
|
196
|
-
identifier: "hello",
|
|
197
|
-
property: "world",
|
|
198
|
-
},
|
|
199
|
-
args: [
|
|
200
|
-
{ type: "string_literal", value: "hello" },
|
|
201
|
-
{ type: "string_literal", value: "world" },
|
|
202
|
-
{
|
|
203
|
-
type: "array_literal",
|
|
204
|
-
values: [
|
|
205
|
-
{ type: "string_literal", value: "hello" },
|
|
206
|
-
{ type: "string_literal", value: "world" },
|
|
207
|
-
],
|
|
208
|
-
},
|
|
209
|
-
],
|
|
210
|
-
},
|
|
211
|
-
{
|
|
212
|
-
type: "call_expression",
|
|
213
|
-
funcCall: "a",
|
|
214
|
-
args: [
|
|
215
|
-
{ type: "identifier", value: "b" },
|
|
216
|
-
{
|
|
217
|
-
type: "call_expression",
|
|
218
|
-
funcCall: "c",
|
|
219
|
-
args: [
|
|
220
|
-
{ type: "identifier", value: "d" },
|
|
221
|
-
{ type: "identifier", value: "e" },
|
|
222
|
-
{
|
|
223
|
-
type: "array_literal",
|
|
224
|
-
values: [
|
|
225
|
-
{ type: "identifier", value: "f" },
|
|
226
|
-
{ type: "identifier", value: "g" },
|
|
227
|
-
],
|
|
228
|
-
},
|
|
229
|
-
{
|
|
230
|
-
type: "object_literal",
|
|
231
|
-
values: [
|
|
232
|
-
{
|
|
233
|
-
type: "property_assignment",
|
|
234
|
-
identifier: "h",
|
|
235
|
-
value: { type: "identifier", value: "i" },
|
|
236
|
-
},
|
|
237
|
-
],
|
|
238
|
-
},
|
|
239
|
-
],
|
|
240
|
-
},
|
|
241
|
-
],
|
|
242
|
-
},
|
|
243
|
-
{
|
|
244
|
-
type: "call_expression",
|
|
245
|
-
funcCall: "and",
|
|
246
|
-
args: [
|
|
247
|
-
{
|
|
248
|
-
type: "call_expression",
|
|
249
|
-
funcCall: "in",
|
|
250
|
-
args: [
|
|
251
|
-
{ type: "string_literal", value: "a" },
|
|
252
|
-
{
|
|
253
|
-
type: "array_literal",
|
|
254
|
-
values: [
|
|
255
|
-
{ type: "string_literal", value: "a" },
|
|
256
|
-
{ type: "string_literal", value: "b" },
|
|
257
|
-
{ type: "string_literal", value: "c" },
|
|
258
|
-
],
|
|
259
|
-
},
|
|
260
|
-
],
|
|
261
|
-
},
|
|
262
|
-
{
|
|
263
|
-
type: "call_expression",
|
|
264
|
-
funcCall: "eq",
|
|
265
|
-
args: [
|
|
266
|
-
{ type: "string_literal", value: "a" },
|
|
267
|
-
{ type: "string_literal", value: "b" },
|
|
268
|
-
],
|
|
269
|
-
},
|
|
270
|
-
],
|
|
271
|
-
},
|
|
272
|
-
{
|
|
273
|
-
type: "call_expression",
|
|
274
|
-
funcCall: "with",
|
|
275
|
-
args: [
|
|
276
|
-
{
|
|
277
|
-
type: "call_expression",
|
|
278
|
-
funcCall: "const",
|
|
279
|
-
args: [
|
|
280
|
-
{ type: "string_literal", value: "a" },
|
|
281
|
-
{
|
|
282
|
-
type: "array_literal",
|
|
283
|
-
values: [
|
|
284
|
-
{ type: "string_literal", value: "a" },
|
|
285
|
-
{ type: "string_literal", value: "b" },
|
|
286
|
-
{ type: "string_literal", value: "c" },
|
|
287
|
-
],
|
|
288
|
-
},
|
|
289
|
-
],
|
|
290
|
-
},
|
|
291
|
-
{
|
|
292
|
-
type: "call_expression",
|
|
293
|
-
funcCall: "eq",
|
|
294
|
-
args: [
|
|
295
|
-
{ type: "string_literal", value: "a" },
|
|
296
|
-
{ type: "string_literal", value: "b" },
|
|
297
|
-
{ type: "boolean_literal", value: true },
|
|
298
|
-
],
|
|
299
|
-
},
|
|
300
|
-
],
|
|
301
|
-
},
|
|
302
|
-
];
|
|
303
|
-
test("ExpressionParser multiple expressions test", async () => {
|
|
304
|
-
const parser = new ExpressionParser();
|
|
305
|
-
await parser.ensureParser();
|
|
306
|
-
const expressions = [
|
|
307
|
-
`hello()`,
|
|
308
|
-
`hello("world")`,
|
|
309
|
-
`hello("world", "hello")`,
|
|
310
|
-
`hello("world", "hello", ["hello", "world", 1, 2.1, 3])`,
|
|
311
|
-
`hello("world", "hello", ["hello", "world", 1, 2.1, 3], { hello: "world" })`,
|
|
312
|
-
`hello("world", "hello", ["hello", "world", 1, 2.1, 3], { hello: "world" }, 1, 2.1, 3)`,
|
|
313
|
-
`hello("world", "hello", ["hello", "world", 1, 2.1, 3], { hello: "world" }, 1, 2.1, 3, world("hello", "world", [{hello: "world"}, {"hello": hello("world")}]))`,
|
|
314
|
-
`hello.world("hello", "world", ["hello", "world"], {"hello": "world"})`,
|
|
315
|
-
`hello["world"]("hello", "world", ["hello", "world"])`,
|
|
316
|
-
`a(b, c(d, e, [f, g], {h: i}))`,
|
|
317
|
-
`and(in("a", ["a", "b", "c"]), eq("a", "b"))`,
|
|
318
|
-
`with(const("a", ["a", "b", "c"]), eq("a", "b", true))`,
|
|
319
|
-
];
|
|
320
|
-
const badExpressions = [
|
|
321
|
-
`hello(`,
|
|
322
|
-
`hello("world", ["hello", "world", 1, 2, 3 { hello: "world" })`,
|
|
323
|
-
`hello("world", ["hello, "world", { hello: "world" )`,
|
|
324
|
-
`l:::"""(}))))++===/...`,
|
|
325
|
-
];
|
|
326
|
-
const parsedPromise = expressions.map((expression) => parser.parse(expression));
|
|
327
|
-
const badExpressionsPromise = badExpressions.map((expression) => parser.parse(expression).catch(() => "bad"));
|
|
328
|
-
await Promise.allSettled(badExpressionsPromise).then((errors) => {
|
|
329
|
-
errors.forEach((err) => {
|
|
330
|
-
if (err.status === "fulfilled") {
|
|
331
|
-
expect(err.value).toBe("bad");
|
|
332
|
-
}
|
|
333
|
-
});
|
|
334
|
-
});
|
|
335
|
-
const parsed = await Promise.all(parsedPromise);
|
|
336
|
-
parsed.forEach((expression, index) => {
|
|
337
|
-
expect(expression).toMatchObject(correctExps[index]);
|
|
338
|
-
});
|
|
339
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { FakeStreamingLLM } from "@langchain/core/utils/testing";
|
|
2
|
-
import { HttpResponseOutputParser } from "../http_response.js";
|
|
3
|
-
test("text/plain stream", async () => {
|
|
4
|
-
const llm = new FakeStreamingLLM({});
|
|
5
|
-
const stream = await llm
|
|
6
|
-
.pipe(new HttpResponseOutputParser())
|
|
7
|
-
.stream("Hi there!");
|
|
8
|
-
const chunks = [];
|
|
9
|
-
const decoder = new TextDecoder();
|
|
10
|
-
for await (const chunk of stream) {
|
|
11
|
-
chunks.push(decoder.decode(chunk));
|
|
12
|
-
}
|
|
13
|
-
expect(chunks.length).toEqual("Hi there!".length);
|
|
14
|
-
expect(chunks.join("")).toEqual("Hi there!");
|
|
15
|
-
});
|
|
16
|
-
test("text/event-stream stream", async () => {
|
|
17
|
-
const llm = new FakeStreamingLLM({});
|
|
18
|
-
const stream = await llm
|
|
19
|
-
.pipe(new HttpResponseOutputParser({ contentType: "text/event-stream" }))
|
|
20
|
-
.stream("Hi there!");
|
|
21
|
-
const chunks = [];
|
|
22
|
-
const decoder = new TextDecoder();
|
|
23
|
-
for await (const chunk of stream) {
|
|
24
|
-
chunks.push(decoder.decode(chunk));
|
|
25
|
-
}
|
|
26
|
-
expect(chunks.length).toEqual("Hi there!".length + 1);
|
|
27
|
-
expect(chunks).toEqual([
|
|
28
|
-
`event: data\ndata: "H"\n\n`,
|
|
29
|
-
`event: data\ndata: "i"\n\n`,
|
|
30
|
-
`event: data\ndata: " "\n\n`,
|
|
31
|
-
`event: data\ndata: "t"\n\n`,
|
|
32
|
-
`event: data\ndata: "h"\n\n`,
|
|
33
|
-
`event: data\ndata: "e"\n\n`,
|
|
34
|
-
`event: data\ndata: "r"\n\n`,
|
|
35
|
-
`event: data\ndata: "e"\n\n`,
|
|
36
|
-
`event: data\ndata: "!"\n\n`,
|
|
37
|
-
`event: end\n\n`,
|
|
38
|
-
]);
|
|
39
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { test, expect } from "@jest/globals";
|
|
2
|
-
import { OutputParserException, CommaSeparatedListOutputParser, CustomListOutputParser, } from "@langchain/core/output_parsers";
|
|
3
|
-
test("CommaSeparatedListOutputParser", async () => {
|
|
4
|
-
const parser = new CommaSeparatedListOutputParser();
|
|
5
|
-
expect(await parser.parse("hello, bye")).toEqual(["hello", "bye"]);
|
|
6
|
-
expect(await parser.parse("hello,bye")).toEqual(["hello", "bye"]);
|
|
7
|
-
expect(await parser.parse("hello")).toEqual(["hello"]);
|
|
8
|
-
});
|
|
9
|
-
test("CustomListOutputParser", async () => {
|
|
10
|
-
const parser1 = new CustomListOutputParser({ length: 3, separator: ";" });
|
|
11
|
-
expect(await parser1.parse("a; b;c")).toEqual(["a", "b", "c"]);
|
|
12
|
-
await expect(() => parser1.parse("a; b c")).rejects.toThrow(OutputParserException);
|
|
13
|
-
await expect(() => parser1.parse("a; b; c; d")).rejects.toThrow(OutputParserException);
|
|
14
|
-
const parser2 = new CustomListOutputParser({ separator: "\n" });
|
|
15
|
-
expect(await parser2.parse("a\nb\nc\nd")).toEqual(["a", "b", "c", "d"]);
|
|
16
|
-
const parser3 = new CustomListOutputParser({ length: 8 });
|
|
17
|
-
expect(await parser3.parse("a,b,c,d,e,f,g,h")).toEqual([
|
|
18
|
-
"a",
|
|
19
|
-
"b",
|
|
20
|
-
"c",
|
|
21
|
-
"d",
|
|
22
|
-
"e",
|
|
23
|
-
"f",
|
|
24
|
-
"g",
|
|
25
|
-
"h",
|
|
26
|
-
]);
|
|
27
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
import { expect, test } from "@jest/globals";
|
|
3
|
-
import { z } from "zod";
|
|
4
|
-
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
5
|
-
import { applyPatch } from "@langchain/core/utils/json_patch";
|
|
6
|
-
import { ChatOpenAI } from "@langchain/openai";
|
|
7
|
-
import { ChatPromptTemplate } from "@langchain/core/prompts";
|
|
8
|
-
import { JsonOutputFunctionsParser } from "../openai_functions.js";
|
|
9
|
-
import { HttpResponseOutputParser } from "../http_response.js";
|
|
10
|
-
const schema = z.object({
|
|
11
|
-
setup: z.string().describe("The setup for the joke"),
|
|
12
|
-
punchline: z.string().describe("The punchline to the joke"),
|
|
13
|
-
});
|
|
14
|
-
const modelParams = {
|
|
15
|
-
functions: [
|
|
16
|
-
{
|
|
17
|
-
name: "joke",
|
|
18
|
-
description: "A joke",
|
|
19
|
-
parameters: zodToJsonSchema(schema),
|
|
20
|
-
},
|
|
21
|
-
],
|
|
22
|
-
function_call: { name: "joke" },
|
|
23
|
-
};
|
|
24
|
-
test("Streaming JSON patch", async () => {
|
|
25
|
-
const prompt = ChatPromptTemplate.fromTemplate(`tell me a long joke about {foo}`);
|
|
26
|
-
const model = new ChatOpenAI({
|
|
27
|
-
temperature: 0,
|
|
28
|
-
}).bind(modelParams);
|
|
29
|
-
const parser = new JsonOutputFunctionsParser({ diff: true });
|
|
30
|
-
const chain = prompt.pipe(model).pipe(parser);
|
|
31
|
-
const stream = await chain.stream({
|
|
32
|
-
foo: "bears",
|
|
33
|
-
});
|
|
34
|
-
const chunks = [];
|
|
35
|
-
let aggregate = {};
|
|
36
|
-
for await (const chunk of stream) {
|
|
37
|
-
console.log(chunk);
|
|
38
|
-
chunks.push(chunk);
|
|
39
|
-
aggregate = applyPatch(aggregate, chunk).newDocument;
|
|
40
|
-
}
|
|
41
|
-
expect(chunks.length).toBeGreaterThan(1);
|
|
42
|
-
console.log(aggregate);
|
|
43
|
-
expect(aggregate.setup.length).toBeGreaterThan(1);
|
|
44
|
-
expect(aggregate.punchline.length).toBeGreaterThan(1);
|
|
45
|
-
});
|
|
46
|
-
test("Streaming JSON patch with an event stream output parser", async () => {
|
|
47
|
-
const prompt = ChatPromptTemplate.fromTemplate(`tell me a long joke about {foo}`);
|
|
48
|
-
const model = new ChatOpenAI({
|
|
49
|
-
temperature: 0,
|
|
50
|
-
}).bind(modelParams);
|
|
51
|
-
const jsonParser = new JsonOutputFunctionsParser({ diff: true });
|
|
52
|
-
const parser = new HttpResponseOutputParser({
|
|
53
|
-
outputParser: jsonParser,
|
|
54
|
-
contentType: "text/event-stream",
|
|
55
|
-
});
|
|
56
|
-
const chain = prompt.pipe(model).pipe(parser);
|
|
57
|
-
const stream = await chain.stream({
|
|
58
|
-
foo: "bears",
|
|
59
|
-
});
|
|
60
|
-
const chunks = [];
|
|
61
|
-
const decoder = new TextDecoder();
|
|
62
|
-
for await (const chunk of stream) {
|
|
63
|
-
console.log(decoder.decode(chunk));
|
|
64
|
-
chunks.push(chunk);
|
|
65
|
-
}
|
|
66
|
-
expect(chunks.length).toBeGreaterThan(1);
|
|
67
|
-
});
|
|
68
|
-
test("Streaming aggregated JSON", async () => {
|
|
69
|
-
const prompt = ChatPromptTemplate.fromTemplate(`tell me a long joke about {foo}`);
|
|
70
|
-
const model = new ChatOpenAI({
|
|
71
|
-
temperature: 0,
|
|
72
|
-
}).bind(modelParams);
|
|
73
|
-
const parser = new JsonOutputFunctionsParser();
|
|
74
|
-
const chain = prompt.pipe(model).pipe(parser);
|
|
75
|
-
const stream = await chain.stream({
|
|
76
|
-
foo: "bears",
|
|
77
|
-
});
|
|
78
|
-
const chunks = [];
|
|
79
|
-
let aggregate = {};
|
|
80
|
-
for await (const chunk of stream) {
|
|
81
|
-
console.log(chunk);
|
|
82
|
-
chunks.push(chunk);
|
|
83
|
-
aggregate = chunk;
|
|
84
|
-
}
|
|
85
|
-
expect(chunks.length).toBeGreaterThan(1);
|
|
86
|
-
console.log(aggregate);
|
|
87
|
-
expect(aggregate.setup.length).toBeGreaterThan(1);
|
|
88
|
-
expect(aggregate.punchline.length).toBeGreaterThan(1);
|
|
89
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
import { expect, test } from "@jest/globals";
|
|
3
|
-
import { z } from "zod";
|
|
4
|
-
import { zodToJsonSchema } from "zod-to-json-schema";
|
|
5
|
-
import { ChatOpenAI } from "@langchain/openai";
|
|
6
|
-
import { ChatPromptTemplate } from "@langchain/core/prompts";
|
|
7
|
-
import { JsonOutputToolsParser } from "../openai_tools.js";
|
|
8
|
-
const schema = z.object({
|
|
9
|
-
setup: z.string().describe("The setup for the joke"),
|
|
10
|
-
punchline: z.string().describe("The punchline to the joke"),
|
|
11
|
-
});
|
|
12
|
-
test("Extraction", async () => {
|
|
13
|
-
const prompt = ChatPromptTemplate.fromTemplate(`tell me two jokes about {foo}`);
|
|
14
|
-
const model = new ChatOpenAI({
|
|
15
|
-
modelName: "gpt-3.5-turbo-1106",
|
|
16
|
-
temperature: 0,
|
|
17
|
-
}).bind({
|
|
18
|
-
tools: [
|
|
19
|
-
{
|
|
20
|
-
type: "function",
|
|
21
|
-
function: {
|
|
22
|
-
name: "joke",
|
|
23
|
-
description: "A joke",
|
|
24
|
-
parameters: zodToJsonSchema(schema),
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
],
|
|
28
|
-
});
|
|
29
|
-
const parser = new JsonOutputToolsParser();
|
|
30
|
-
const chain = prompt.pipe(model).pipe(parser);
|
|
31
|
-
const res = await chain.invoke({
|
|
32
|
-
foo: "bears",
|
|
33
|
-
});
|
|
34
|
-
console.log(res);
|
|
35
|
-
expect(res.length).toBe(2);
|
|
36
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|