forked from langchain-ai/langchain
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request langchain-ai#1 from langchain-ai/wfh/add_docs
Add docs
- Loading branch information
Showing
62 changed files
with
13,292 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Dependencies | ||
/node_modules | ||
|
||
# Production | ||
/build | ||
|
||
# Generated files | ||
.docusaurus | ||
.cache-loader | ||
docs/api | ||
|
||
# Misc | ||
.DS_Store | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# ESLint | ||
.eslintcache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,49 @@ | ||
# langsmith-docs | ||
Documentation for langsmith | ||
# Website | ||
|
||
This website is built using [Docusaurus 2](https://docusaurus.io/), a modern static website generator. | ||
|
||
### Installation | ||
|
||
``` | ||
$ yarn | ||
``` | ||
|
||
### Local Development | ||
|
||
``` | ||
$ yarn start | ||
``` | ||
|
||
This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server. | ||
|
||
### Build | ||
|
||
``` | ||
$ yarn build | ||
``` | ||
|
||
This command generates static content into the `build` directory and can be served using any static contents hosting service. | ||
|
||
### Deployment | ||
|
||
Using SSH: | ||
|
||
``` | ||
$ USE_SSH=true yarn deploy | ||
``` | ||
|
||
Not using SSH: | ||
|
||
``` | ||
$ GIT_USER=<Your GitHub username> yarn deploy | ||
``` | ||
|
||
If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch. | ||
|
||
### Continuous Integration | ||
|
||
Some common defaults for linting/formatting have been set for you. If you integrate your project with an open source Continuous Integration system (e.g. Travis CI, CircleCI), you may check for issues using the following command. | ||
|
||
``` | ||
$ yarn ci | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @format | ||
*/ | ||
|
||
module.exports = { | ||
presets: [require.resolve("@docusaurus/core/lib/babel/preset")], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/* eslint-disable prefer-template */ | ||
/* eslint-disable no-param-reassign */ | ||
// eslint-disable-next-line import/no-extraneous-dependencies | ||
const babel = require("@babel/core"); | ||
const path = require("path"); | ||
const fs = require("fs"); | ||
|
||
/** | ||
* | ||
* @param {string|Buffer} content Content of the resource file | ||
* @param {object} [map] SourceMap data consumable by https://github.com/mozilla/source-map | ||
* @param {any} [meta] Meta data, could be anything | ||
*/ | ||
async function webpackLoader(content, map, meta) { | ||
const cb = this.async(); | ||
|
||
if (!this.resourcePath.endsWith(".ts")) { | ||
cb(null, JSON.stringify({ content, imports: [] }), map, meta); | ||
return; | ||
} | ||
|
||
try { | ||
const result = await babel.parseAsync(content, { | ||
sourceType: "module", | ||
filename: this.resourcePath, | ||
}); | ||
|
||
const imports = []; | ||
|
||
result.program.body.forEach((node) => { | ||
if (node.type === "ImportDeclaration") { | ||
const source = node.source.value; | ||
|
||
if (!source.startsWith("langchain")) { | ||
return; | ||
} | ||
|
||
node.specifiers.forEach((specifier) => { | ||
if (specifier.type === "ImportSpecifier") { | ||
const local = specifier.local.name; | ||
const imported = specifier.imported.name; | ||
imports.push({ local, imported, source }); | ||
} else { | ||
throw new Error("Unsupported import type"); | ||
} | ||
}); | ||
} | ||
}); | ||
|
||
imports.forEach((imp) => { | ||
const { imported, source } = imp; | ||
const moduleName = source.split("/").slice(1).join("_"); | ||
const docsPath = path.resolve(__dirname, "docs", "api", moduleName); | ||
const available = fs.readdirSync(docsPath, { withFileTypes: true }); | ||
const found = available.find( | ||
(dirent) => | ||
dirent.isDirectory() && | ||
fs.existsSync(path.resolve(docsPath, dirent.name, imported + ".md")) | ||
); | ||
if (found) { | ||
imp.docs = | ||
"/" + path.join("docs", "api", moduleName, found.name, imported); | ||
} else { | ||
throw new Error( | ||
`Could not find docs for ${source}.${imported} in docs/api/` | ||
); | ||
} | ||
}); | ||
|
||
cb(null, JSON.stringify({ content, imports }), map, meta); | ||
} catch (err) { | ||
cb(err); | ||
} | ||
} | ||
|
||
module.exports = webpackLoader; |
Oops, something went wrong.