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.
add docs for templates (langchain-ai#12346)
- Loading branch information
Showing
4 changed files
with
69 additions
and
44 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
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,18 @@ | ||
# Contributing | ||
|
||
To add a new project: | ||
|
||
Make sure you have `langchain-cli` installed. | ||
|
||
```shell | ||
pip install -U langchain-cli | ||
``` | ||
|
||
Create a new package | ||
|
||
```shell | ||
langchain hub new $PROJECT_NAME | ||
``` | ||
|
||
This will set up the skeleton of a package. | ||
You can then edit the contents of the package as you desire. |
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
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,71 +1,74 @@ | ||
# LangServe Hub | ||
# LangServe Templates | ||
|
||
Packages that can be easily hosted by LangServe using the `langserve` cli. | ||
Templates for a fully functioning app that can be hosted by LangServe. | ||
|
||
## Using LangServe Hub | ||
## Usage | ||
|
||
You can install the `langservehub` CLI and use it as follows: | ||
```bash | ||
# install langservehub CLI | ||
pip install --upgrade langservehub | ||
To use, first install the LangChain CLI. | ||
|
||
langservehub new my-app | ||
cd my-app | ||
```shell | ||
pip install -U langchain-cli | ||
``` | ||
|
||
poetry install | ||
Then, install `langserve`: | ||
|
||
# if you have problems with poe, use `poetry run poe ...` instead | ||
```shell | ||
pip install "langserve[all]" | ||
``` | ||
|
||
# add the simple-pirate package | ||
poe add --repo=pingpong-templates/hub simple-pirate | ||
Next, create a new LangChain project: | ||
|
||
# adding other GitHub repo packages, defaults to repo root | ||
poe add --repo=hwchase17/chain-of-verification | ||
```shell | ||
langchain serve new my-app | ||
``` | ||
|
||
# with a custom api mount point (defaults to `/{package_name}`) | ||
poe add --repo=pingpong-templates/hub simple-translator --api_path=/my/custom/path/translator | ||
This will create a new directory called `my-app` with two folders: | ||
|
||
poe list | ||
- `app`: This is where LangServe code will live | ||
- `packages`: This is where your chains or agents will live | ||
|
||
poe start | ||
^C | ||
To pull in an existing template as a package, you first need to go into your new project: | ||
|
||
# remove packages by their api path: | ||
poe remove my/custom/path/translator | ||
```shell | ||
cd my-app | ||
``` | ||
|
||
## Creating New Packages | ||
And you can the add a template as a project | ||
|
||
You can also create new packages with the `langservehub package new` command | ||
|
||
```bash | ||
# starting from this directory in langserve-hub | ||
langservehub package new simple-newpackage | ||
```shell | ||
langchain serve add $PROJECT_NAME | ||
``` | ||
|
||
Now you can edit the chain in `simple-newpackage/simple_newpackage/chain.py` and put up a PR! | ||
|
||
Your package will be usable as `poe add --repo=pingpong-templates/hub simple-newpackage` when it's merged in. | ||
This will pull in the specified template into `packages/$PROJECT_NAME` | ||
|
||
## Data Format | ||
You then need to install this package so you can use it in the langserve app: | ||
|
||
What makes these packages work? | ||
```shell | ||
pip install -e packages/$PROJECT_NAME | ||
``` | ||
|
||
- Poetry | ||
- pyproject.toml files | ||
We install it with `-e` so that if we modify the template at all (which we likely will) the changes are updated. | ||
|
||