Skip to content

Commit

Permalink
doc: improvide contributing guide (langchain-ai#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
sullivan-sean authored Feb 17, 2023
1 parent d8de70e commit d4f7d34
Showing 1 changed file with 55 additions and 41 deletions.
96 changes: 55 additions & 41 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ good code into the codebase.

# TODO:
As of now, LangChain has an ad hoc release process: releases are cut with high frequency via by
a developer and published to [PyPI](https://pypi.org/project/langchain/).
a developer and published to [npm](https://www.npmjs.com/package/langchain).

LangChain follows the [semver](https://semver.org/) versioning standard. However, as pre-1.0 software,
even patch releases may contain [non-backwards-compatible changes](https://semver.org/#spec-item-4).
Expand All @@ -58,78 +58,92 @@ If you have a Twitter account you would like us to mention, please let us know i

## 🚀Quick Start

# TODO
### Tooling

This project uses [Poetry](https://python-poetry.org/) as a dependency manager. Check out Poetry's [documentation on how to install it](https://python-poetry.org/docs/#installation) on your system before proceeding.
This project uses the following tools, which are worth getting familiar
with if you plan to contribute:

❗Note: If you use `Conda` or `Pyenv` as your environment / package manager, avoid dependency conflicts by doing the following first:
1. *Before installing Poetry*, create and activate a new Conda env (e.g. `conda create -n langchain python=3.9`)
2. Install Poetry (see above)
3. Tell Poetry to use the virtualenv python environment (`poetry config virtualenvs.prefer-active-python true`)
4. Continue with the following steps.
- **[yarn](https://yarnpkg.com/) (v3.4.1)** - dependency management
- **[eslint](https://eslint.org/)** - enforcing standard lint rules
- **[prettier](https://prettier.io/)** - enforcing standard code formatting
- **[jest](https://jestjs.io/)** - testing code
- **[TypeDoc](https://typedoc.org/)** - reference doc generation from
comments
- **[Docusaurus](https://docusaurus.io/)** - static site generation for documentation

To install requirements:

```bash
poetry install -E all
```

This will install all requirements for running the package, examples, linting, formatting, tests, and coverage. Note the `-E all` flag will install all optional dependencies necessary for integration testing.

Now, you should be able to run the common tasks in the following section.

## ✅Common Tasks

### Testing

**Unit tests** cover modular logic that does not require calls to outside APIs.

If you add new logic, please add a unit test.

**Integration tests** cover logic that requires making calls to outside APIs (often integration with other services).

### Testing: TODO
If you add support for a new external API, please add a new integration test.

Unit tests cover modular logic that does not require calls to outside APIs.
Tests should be added within a `tests/` folder alongside the modules they
are testing.

To run unit tests:
To run tests, run:

```bash
make test
yarn test
```

If you add new logic, please add a unit test.
### Running examples

Integration tests cover logic that requires making calls to outside APIs (often integration with other services).
If you add a new major piece of functionality, it is helpful to add an
example to showcase how to use it. Most of our users find examples to be the
most helpful kind of documentation.

To run integration tests:
Examples can be added in the `examples/src` directory, e.g.
`examples/src/path/to/example` and should export a `run` function. This
example can then be invoked with `yarn example path/to/example` at the top
level of the repo.

```bash
make integration_tests
### Adding an Entrypoint

Langchain let's user import from multiple subpaths, e.g.

```ts
import { OpenAI } from "langchain/llms"
```

If you add support for a new external API, please add a new integration test.
In order to declare a new entrypoint that users can import from, you
should edit the `langchain/create-entrypoints.js` script. To add an
entrypoint `tools` that imports from `agents/tools/index.ts` you could add
the following to the `entrypoints` variable:

```ts
const entrypoints = {
// ...
"tools": "agents/tools/index.ts",
}
```

This will make sure the entrypoint is included in the published package,
and in generated documentation.

## Documentation: TODO
## Documentation

### Contribute Documentation

Docs are largely autogenerated by [sphinx](https://www.sphinx-doc.org/en/master/) from the code.
Docs are largely autogenerated by [TypeDoc](https://typedoc.org/) from the code.

For that reason, we ask that you add good documentation to all classes and methods.

Similar to linting, we recognize documentation can be annoying. If you do not want to do it, please contact a project maintainer, and they can help you with it. We do not want this to be a blocker for good code getting contributed.

### Build Documentation Locally

Before building the documentation, it is always a good idea to clean the build directory:

```bash
make docs_clean
```

Next, you can run the linkchecker to make sure all links are valid:

```bash
make docs_linkcheck
```

Finally, you can build the documentation as outlined below:
You can run a hot-reloading dev version of the docs static site by
running:

```bash
make docs_build
cd docs && yarn start
```

0 comments on commit d4f7d34

Please sign in to comment.