Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/langchain-ai/langchainjs in…
Browse files Browse the repository at this point in the history
…to nc/31jul/runnable-abort-signal
  • Loading branch information
jacoblee93 committed Aug 2, 2024
2 parents de8df00 + 5f4323d commit 632ad31
Show file tree
Hide file tree
Showing 85 changed files with 7,845 additions and 1,438 deletions.
11 changes: 9 additions & 2 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,21 @@
"zod": "npm:/zod",
"zod-to-json-schema": "npm:/zod-to-json-schema",
"node-llama-cpp": "npm:/node-llama-cpp",
"ml-distance": "npm:/ml-distance",
"pdf-parse": "npm:/pdf-parse",
"peggy": "npm:/peggy",
"readline": "https://deno.land/x/[email protected]/mod.ts",
"uuid": "npm:/uuid",
"youtubei.js": "npm:/youtubei.js",
"youtube-transcript": "npm:/youtube-transcript",
"neo4j-driver": "npm:/neo4j-driver",
"axios": "npm:/axios"
"axios": "npm:/axios",
"@mendable/firecrawl-js": "npm:/@mendable/firecrawl-js",
"@aws-crypto/sha256-js": "npm:/@aws-crypto/sha256-js",
"@aws-sdk/credential-provider-node": "npm:/@aws-sdk/credential-provider-node",
"@smithy/protocol-http": "npm:/@smithy/protocol-http",
"@smithy/signature-v4": "npm:/@smithy/signature-v4",
"@smithy/eventstream-codec": "npm:/@smithy/eventstream-codec",
"@smithy/util-utf8": "npm:/@smithy/util-utf8",
"@aws-sdk/types": "npm:/@aws-sdk/types"
}
}
64 changes: 43 additions & 21 deletions docs/core_docs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,26 @@ yarn-error.log*

/.quarto/
# AUTO_GENERATED_DOCS
docs/tutorials/rag.md
docs/tutorials/rag.mdx
docs/tutorials/query_analysis.md
docs/tutorials/query_analysis.mdx
docs/tutorials/qa_chat_history.md
docs/tutorials/qa_chat_history.mdx
docs/tutorials/pdf_qa.md
docs/tutorials/pdf_qa.mdx
docs/tutorials/local_rag.md
docs/tutorials/local_rag.mdx
docs/tutorials/llm_chain.md
docs/tutorials/llm_chain.mdx
docs/tutorials/graph.md
docs/tutorials/graph.mdx
docs/tutorials/extraction.md
docs/tutorials/extraction.mdx
docs/tutorials/classification.md
docs/tutorials/classification.mdx
docs/tutorials/chatbot.md
docs/tutorials/chatbot.mdx
docs/how_to/trim_messages.md
docs/how_to/trim_messages.mdx
docs/how_to/tools_prompting.md
Expand Down Expand Up @@ -188,27 +208,29 @@ docs/how_to/assign.md
docs/how_to/assign.mdx
docs/how_to/agent_executor.md
docs/how_to/agent_executor.mdx
docs/tutorials/rag.md
docs/tutorials/rag.mdx
docs/tutorials/query_analysis.md
docs/tutorials/query_analysis.mdx
docs/tutorials/qa_chat_history.md
docs/tutorials/qa_chat_history.mdx
docs/tutorials/pdf_qa.md
docs/tutorials/pdf_qa.mdx
docs/tutorials/local_rag.md
docs/tutorials/local_rag.mdx
docs/tutorials/llm_chain.md
docs/tutorials/llm_chain.mdx
docs/tutorials/graph.md
docs/tutorials/graph.mdx
docs/tutorials/extraction.md
docs/tutorials/extraction.mdx
docs/tutorials/classification.md
docs/tutorials/classification.mdx
docs/tutorials/chatbot.md
docs/tutorials/chatbot.mdx
docs/integrations/llms/mistral.md
docs/integrations/llms/mistral.mdx
docs/integrations/chat/togetherai.md
docs/integrations/chat/togetherai.mdx
docs/integrations/chat/openai.md
docs/integrations/chat/openai.mdx
docs/integrations/chat/ollama.md
docs/integrations/chat/ollama.mdx
docs/integrations/chat/mistral.md
docs/integrations/chat/mistral.mdx
docs/integrations/chat/mistral.mdx
docs/integrations/chat/groq.md
docs/integrations/chat/groq.mdx
docs/integrations/chat/google_vertex_ai.md
docs/integrations/chat/google_vertex_ai.mdx
docs/integrations/chat/google_generativeai.md
docs/integrations/chat/google_generativeai.mdx
docs/integrations/chat/fireworks.md
docs/integrations/chat/fireworks.mdx
docs/integrations/chat/cohere.md
docs/integrations/chat/cohere.mdx
docs/integrations/chat/azure.md
docs/integrations/chat/azure.mdx
docs/integrations/chat/anthropic.md
docs/integrations/chat/anthropic.mdx
docs/integrations/document_loaders/web_loaders/web_cheerio.md
docs/integrations/document_loaders/web_loaders/web_cheerio.mdx
16 changes: 6 additions & 10 deletions docs/core_docs/docs/integrations/chat/google_generativeai.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -326,23 +326,19 @@
"```{=mdx}\n",
"\n",
":::caution\n",
"\n",
"The Google GenerativeAI API does not allow tool schemas to contain an object with unknown properties.\n",
"\n",
"For example, the following Zod schema will throw an error:\n",
"For example, the following Zod schemas will throw an error:\n",
"\n",
"```typescript\n",
"const schema = z.object({\n",
" properties: z.record(z.unknown()), // Not allowed\n",
"});\n",
"```\n",
"`const invalidSchema = z.object({ properties: z.record(z.unknown()) });`\n",
"\n",
"or\n",
"and\n",
"\n",
"```typescript\n",
"const schema = z.record(z.unknown()); // Not allowed\n",
"```\n",
"`const invalidSchema2 = z.record(z.unknown());`\n",
"\n",
"Instead, you should explicitly define the properties of the object field.\n",
"\n",
":::\n",
"\n",
"```\n"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,226 @@
{
"cells": [
{
"cell_type": "raw",
"metadata": {
"vscode": {
"languageId": "raw"
}
},
"source": [
"---\n",
"sidebar_label: CSV\n",
"sidebar_class_name: node-only\n",
"---"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# CSVLoader\n",
"\n",
"```{=mdx}\n",
"\n",
":::tip Compatibility\n",
"\n",
"Only available on Node.js.\n",
"\n",
":::\n",
"\n",
"```\n",
"\n",
"This notebook provides a quick overview for getting started with `CSVLoader` [document loaders](/docs/concepts/#document-loaders). For detailed documentation of all `CSVLoader` features and configurations head to the [API reference](https://api.js.langchain.com/classes/langchain_community_document_loaders_fs_csv.CSVLoader.html).\n",
"\n",
"This example goes over how to load data from CSV files. The second argument is the `column` name to extract from the CSV file. One document will be created for each row in the CSV file. When `column` is not specified, each row is converted into a key/value pair with each key/value pair outputted to a new line in the document's `pageContent`. When `column` is specified, one document is created for each row, and the value of the specified column is used as the document's `pageContent`.\n",
"\n",
"## Overview\n",
"### Integration details\n",
"\n",
"| Class | Package | Compatibility | Local | [PY support](https://python.langchain.com/docs/integrations/document_loaders/csv)| \n",
"| :--- | :--- | :---: | :---: | :---: |\n",
"| [CSVLoader](https://api.js.langchain.com/classes/langchain_community_document_loaders_fs_csv.CSVLoader.html) | [@langchain/community](https://api.js.langchain.com/modules/langchain_community_document_loaders_fs_csv.html) | Node-only | ✅ | ✅ |\n",
"\n",
"## Setup\n",
"\n",
"To access `CSVLoader` document loader you'll need to install the `@langchain/community` integration, along with the `d3-dsv@2` peer dependency.\n",
"\n",
"### Installation\n",
"\n",
"The LangChain CSVLoader integration lives in the `@langchain/community` integration package.\n",
"\n",
"```{=mdx}\n",
"import IntegrationInstallTooltip from \"@mdx_components/integration_install_tooltip.mdx\";\n",
"import Npm2Yarn from \"@theme/Npm2Yarn\";\n",
"\n",
"<IntegrationInstallTooltip></IntegrationInstallTooltip>\n",
"\n",
"<Npm2Yarn>\n",
" @langchain/community d3-dsv@2\n",
"</Npm2Yarn>\n",
"\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Instantiation\n",
"\n",
"Now we can instantiate our model object and load documents:"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [],
"source": [
"import { CSVLoader } from \"@langchain/community/document_loaders/fs/csv\"\n",
"\n",
"const exampleCsvPath = \"../../../../../../langchain/src/document_loaders/tests/example_data/example_separator.csv\";\n",
"\n",
"const loader = new CSVLoader(exampleCsvPath)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Load"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Document {\n",
" pageContent: 'id|html: 1|\"<i>Corruption discovered at the core of the Banking Clan!</i>\"',\n",
" metadata: {\n",
" source: '../../../../../../langchain/src/document_loaders/tests/example_data/example_separator.csv',\n",
" line: 1\n",
" },\n",
" id: undefined\n",
"}\n"
]
}
],
"source": [
"const docs = await loader.load()\n",
"docs[0]"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{\n",
" source: '../../../../../../langchain/src/document_loaders/tests/example_data/example_separator.csv',\n",
" line: 1\n",
"}\n"
]
}
],
"source": [
"console.log(docs[0].metadata)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Usage, extracting a single column\n",
"\n",
"Example CSV file:\n",
"\n",
"```csv\n",
"id|html\n",
"1|\"<i>Corruption discovered at the core of the Banking Clan!</i>\"\n",
"2|\"<i>Reunited, Rush Clovis and Senator Amidala</i>\"\n",
"3|\"<i>discover the full extent of the deception.</i>\"\n",
"4|\"<i>Anakin Skywalker is sent to the rescue!</i>\"\n",
"```"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Document {\n",
" pageContent: '<i>Corruption discovered at the core of the Banking Clan!</i>',\n",
" metadata: {\n",
" source: '../../../../../../langchain/src/document_loaders/tests/example_data/example_separator.csv',\n",
" line: 1\n",
" },\n",
" id: undefined\n",
"}\n"
]
}
],
"source": [
"import { CSVLoader } from \"@langchain/community/document_loaders/fs/csv\";\n",
"\n",
"const singleColumnLoader = new CSVLoader(\n",
" exampleCsvPath,\n",
" {\n",
" column: \"html\",\n",
" separator:\"\"\n",
" }\n",
");\n",
"\n",
"const singleColumnDocs = await singleColumnLoader.load();\n",
"console.log(singleColumnDocs[0]);"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## API reference\n",
"\n",
"For detailed documentation of all CSVLoader features and configurations head to the API reference: https://api.js.langchain.com/classes/langchain_community_document_loaders_fs_csv.CSVLoader.html"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "TypeScript",
"language": "typescript",
"name": "tslab"
},
"language_info": {
"codemirror_mode": {
"mode": "typescript",
"name": "javascript",
"typescript": true
},
"file_extension": ".ts",
"mimetype": "text/typescript",
"name": "typescript",
"version": "3.7.2"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Loading

0 comments on commit 632ad31

Please sign in to comment.