Skip to content

Commit 032c4f6

Browse files
authored
docs[minor]: Simplify docs build (#4607)
* Simplify docs build * Update package.json
1 parent b388128 commit 032c4f6

File tree

7 files changed

+101
-86
lines changed

7 files changed

+101
-86
lines changed

docs/core_docs/.gitignore

+15-2
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,32 @@ yarn-error.log*
3131
!.yarn/versions
3232

3333
/.quarto/
34-
3534
# AUTO_GENERATED_DOCS
35+
docs/expression_language/streaming.md
3636
docs/expression_language/streaming.mdx
37+
docs/use_cases/tool_use/human_in_the_loop.md
3738
docs/use_cases/tool_use/human_in_the_loop.mdx
39+
docs/use_cases/question_answering/streaming.md
3840
docs/use_cases/question_answering/streaming.mdx
41+
docs/use_cases/question_answering/sources.md
3942
docs/use_cases/question_answering/sources.mdx
43+
docs/use_cases/question_answering/quickstart.md
4044
docs/use_cases/question_answering/quickstart.mdx
45+
docs/use_cases/question_answering/local_retrieval_qa.md
4146
docs/use_cases/question_answering/local_retrieval_qa.mdx
47+
docs/use_cases/question_answering/conversational_retrieval_agents.md
4248
docs/use_cases/question_answering/conversational_retrieval_agents.mdx
49+
docs/use_cases/question_answering/citations.md
4350
docs/use_cases/question_answering/citations.mdx
51+
docs/use_cases/question_answering/chat_history.md
4452
docs/use_cases/question_answering/chat_history.mdx
53+
docs/modules/model_io/output_parsers/custom.md
4554
docs/modules/model_io/output_parsers/custom.mdx
46-
docs/modules/memory/chat_messages/custom.mdx
55+
docs/modules/model_io/chat/function_calling.md
4756
docs/modules/model_io/chat/function_calling.mdx
57+
docs/modules/memory/chat_messages/custom.md
58+
docs/modules/memory/chat_messages/custom.mdx
59+
docs/modules/data_connection/vectorstores/custom.md
4860
docs/modules/data_connection/vectorstores/custom.mdx
61+
docs/modules/model_io/output_parsers/types/openai_tools.md
4962
docs/modules/model_io/output_parsers/types/openai_tools.mdx

docs/core_docs/docs/modules/model_io/chat/function_calling.ipynb

+9-7
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@
66
"source": [
77
"# Function calling\n",
88
"\n",
9-
"import Tabs from \"@theme/Tabs\";\n",
10-
"import TabItem from \"@theme/TabItem\";\n",
11-
"\n",
129
"A growing number of chat models, like [OpenAI](/docs/integrations/chat/openai#tool-calling), [Mistral](/docs/integrations/chat/mistral#tool-calling), etc., have a function-calling\n",
1310
"API that lets you describe functions and their arguments, and have the model return a JSON object with a function to invoke and the inputs to that function.\n",
1411
"Function-calling is extremely useful for building [tool-using chains and agents](/docs/use_cases/tool_use/), and for getting structured outputs from models more generally.\n",
@@ -30,18 +27,23 @@
3027
"cell_type": "markdown",
3128
"metadata": {},
3229
"source": [
30+
"```{=mdx}\n",
3331
"import IntegrationInstallTooltip from \"@mdx_components/integration_install_tooltip.mdx\";\n",
32+
"import Npm2Yarn from \"@theme/Npm2Yarn\";\n",
3433
"\n",
3534
"<IntegrationInstallTooltip></IntegrationInstallTooltip>\n",
3635
"\n",
37-
"```bash\n",
38-
"npm install @langchain/core\n",
36+
"<Npm2Yarn>\n",
37+
" @langchain/core\n",
38+
"</Npm2Yarn>\n",
3939
"```\n",
4040
"\n",
4141
"We'll also use `zod-to-json-schema` frequently throughout this doc for converting Zod schemas to JSON schemas. Make sure you have it installed:\n",
4242
"\n",
43-
"```bash\n",
44-
"npm install zod-to-json-schema\n",
43+
"```{=mdx}\n",
44+
"<Npm2Yarn>\n",
45+
" zod-to-json-schema\n",
46+
"</Npm2Yarn>\n",
4547
"```"
4648
]
4749
},

docs/core_docs/docs/use_cases/tool_use/human_in_the_loop.ipynb

+10-3
Original file line numberDiff line numberDiff line change
@@ -157,12 +157,19 @@
157157
"source": [
158158
"## Adding human approval\n",
159159
"\n",
160-
"We can add a simple human approval step to our toolChain function:\n",
161-
"\n",
160+
"We can add a simple human approval step to our `toolChain` function:"
161+
]
162+
},
163+
{
164+
"cell_type": "markdown",
165+
"metadata": {},
166+
"source": [
167+
"```{=mdx}\n",
162168
"import CodeBlock from \"@theme/CodeBlock\";\n",
163169
"import HumanFeedback from \"@examples/use_cases/human_in_the_loop/accept-feedback.ts\";\n",
164170
"\n",
165-
"<CodeBlock language=\"typescript\">{HumanFeedback}</CodeBlock>"
171+
"<CodeBlock language=\"typescript\">{HumanFeedback}</CodeBlock>\n",
172+
"```"
166173
]
167174
},
168175
{

docs/core_docs/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"private": true,
55
"scripts": {
66
"docusaurus": "docusaurus",
7-
"start": "yarn build:typedoc && rimraf ./docs/api && NODE_OPTIONS=--max-old-space-size=7168 docusaurus start",
7+
"start": "yarn build:typedoc && yarn quarto && rimraf ./docs/api && NODE_OPTIONS=--max-old-space-size=7168 docusaurus start",
88
"build": "yarn clean && yarn build:typedoc && yarn quarto && rimraf ./build && NODE_OPTIONS=--max-old-space-size=7168 DOCUSAURUS_SSR_CONCURRENCY=4 docusaurus build",
99
"build:vercel": "yarn clean && yarn build:typedoc:vercel && yarn quarto:vercel && rimraf ./build && NODE_OPTIONS=--max-old-space-size=7168 DOCUSAURUS_SSR_CONCURRENCY=4 docusaurus build",
1010
"build:typedoc": "yarn workspace api_refs build",
@@ -22,8 +22,8 @@
2222
"format": "prettier --write \"**/*.{js,jsx,ts,tsx,md,mdx}\"",
2323
"format:check": "prettier --check \"**/*.{js,jsx,ts,tsx,md,mdx}\"",
2424
"clean": "rm -rf .docusaurus/ .turbo/ .build/",
25-
"quarto": "quarto render docs/ && node ./scripts/quatro-build.js",
26-
"quarto:vercel": "bash ./scripts/vercel_build.sh && node ./scripts/quatro-build.js"
25+
"quarto": "quarto render docs/ && node ./scripts/quarto-build.js",
26+
"quarto:vercel": "bash ./scripts/vercel_build.sh && node ./scripts/quarto-build.js"
2727
},
2828
"dependencies": {
2929
"@docusaurus/core": "2.4.3",
+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
const fs = require("node:fs");
2+
const { glob } = require("glob");
3+
const { execSync } = require("node:child_process");
4+
5+
async function main() {
6+
const allIpynb = await glob("./docs/**/*.ipynb");
7+
8+
const allRenames = allIpynb.flatMap((filename) => [
9+
filename.replace(".ipynb", ".md"),
10+
filename.replace(".ipynb", ".mdx"),
11+
]);
12+
const pathToRootGitignore = ".gitignore";
13+
let gitignore = fs.readFileSync(pathToRootGitignore, "utf-8");
14+
gitignore = gitignore.split("# AUTO_GENERATED_DOCS")[0];
15+
gitignore += "# AUTO_GENERATED_DOCS\n";
16+
gitignore += allRenames.join("\n");
17+
fs.writeFileSync(pathToRootGitignore, gitignore);
18+
19+
try {
20+
/**
21+
* Run Prettier on all generated .ipynb -> .mdx because we don't
22+
* currently have another way to format code written in notebooks.
23+
*/
24+
const command = `yarn prettier --write ${allRenames
25+
.filter((filename) => fs.existsSync(filename))
26+
.join(" ")}`;
27+
execSync(command);
28+
} catch (error) {
29+
console.error(
30+
{
31+
error,
32+
stdout: error?.stderr?.toString(),
33+
},
34+
"Failed to format notebooks"
35+
);
36+
}
37+
}
38+
39+
main().catch((e) => {
40+
console.error(e);
41+
process.exit(1);
42+
});

docs/core_docs/scripts/quatro-build.js

-71
This file was deleted.

docs/core_docs/src/theme/Npm2Yarn.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import React from "react";
2+
import Tabs from "@theme/Tabs";
3+
import TabItem from "@theme/TabItem";
4+
import CodeBlock from "@theme-original/CodeBlock";
5+
6+
// Substitute component for Jupyter notebooks since Quarto has trouble
7+
// parsing built-in npm2yarn markdown blocks
8+
export default function Npm2Yarn({ children }) {
9+
return (
10+
<Tabs>
11+
<TabItem value="npm" label="npm">
12+
<CodeBlock language="bash">npm i {children}</CodeBlock>
13+
</TabItem>
14+
<TabItem value="yarn" label="yarn" default>
15+
<CodeBlock language="bash">yarn add {children}</CodeBlock>
16+
</TabItem>
17+
<TabItem value="pnpm" label="pnpm">
18+
<CodeBlock language="bash">pnpm add {children}</CodeBlock>
19+
</TabItem>
20+
</Tabs>
21+
);
22+
}

0 commit comments

Comments
 (0)