-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Harrison Chase <hw.chase.17@gmail.com>
- Loading branch information
Showing
31 changed files
with
5,549 additions
and
0 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,3 @@ | ||
dist | ||
__pycache__ | ||
.venv |
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,213 @@ | ||
# `langchain` | ||
|
||
**Usage**: | ||
|
||
```console | ||
$ langchain [OPTIONS] COMMAND [ARGS]... | ||
``` | ||
|
||
**Options**: | ||
|
||
* `--help`: Show this message and exit. | ||
|
||
**Commands**: | ||
|
||
* `hub`: Manage installable hub packages. | ||
* `serve`: Manage LangServe application projects. | ||
* `start`: Start the LangServe instance, whether it's... | ||
|
||
## `langchain hub` | ||
|
||
Manage installable hub packages. | ||
|
||
**Usage**: | ||
|
||
```console | ||
$ langchain hub [OPTIONS] COMMAND [ARGS]... | ||
``` | ||
|
||
**Options**: | ||
|
||
* `--help`: Show this message and exit. | ||
|
||
**Commands**: | ||
|
||
* `new`: Creates a new hub package. | ||
* `start`: Starts a demo LangServe instance for this... | ||
|
||
### `langchain hub new` | ||
|
||
Creates a new hub package. | ||
|
||
**Usage**: | ||
|
||
```console | ||
$ langchain hub new [OPTIONS] NAME | ||
``` | ||
|
||
**Arguments**: | ||
|
||
* `NAME`: [required] | ||
|
||
**Options**: | ||
|
||
* `--help`: Show this message and exit. | ||
|
||
### `langchain hub start` | ||
|
||
Starts a demo LangServe instance for this hub package. | ||
|
||
**Usage**: | ||
|
||
```console | ||
$ langchain hub start [OPTIONS] | ||
``` | ||
|
||
**Options**: | ||
|
||
* `--port INTEGER` | ||
* `--host TEXT` | ||
* `--help`: Show this message and exit. | ||
|
||
## `langchain serve` | ||
|
||
Manage LangServe application projects. | ||
|
||
**Usage**: | ||
|
||
```console | ||
$ langchain serve [OPTIONS] COMMAND [ARGS]... | ||
``` | ||
|
||
**Options**: | ||
|
||
* `--help`: Show this message and exit. | ||
|
||
**Commands**: | ||
|
||
* `add`: Adds the specified package to the current... | ||
* `install` | ||
* `list`: Lists all packages in the current... | ||
* `new`: Create a new LangServe application. | ||
* `remove`: Removes the specified package from the... | ||
* `start`: Starts the LangServe instance. | ||
|
||
### `langchain serve add` | ||
|
||
Adds the specified package to the current LangServe instance. | ||
|
||
e.g.: | ||
langchain serve add simple-pirate | ||
langchain serve add git+ssh://git@github.com/efriis/simple-pirate.git | ||
langchain serve add git+https://github.com/efriis/hub.git#devbranch#subdirectory=mypackage | ||
|
||
**Usage**: | ||
|
||
```console | ||
$ langchain serve add [OPTIONS] DEPENDENCIES... | ||
``` | ||
|
||
**Arguments**: | ||
|
||
* `DEPENDENCIES...`: [required] | ||
|
||
**Options**: | ||
|
||
* `--api-path TEXT` | ||
* `--project-dir PATH` | ||
* `--help`: Show this message and exit. | ||
|
||
### `langchain serve install` | ||
|
||
**Usage**: | ||
|
||
```console | ||
$ langchain serve install [OPTIONS] | ||
``` | ||
|
||
**Options**: | ||
|
||
* `--help`: Show this message and exit. | ||
|
||
### `langchain serve list` | ||
|
||
Lists all packages in the current LangServe instance. | ||
|
||
**Usage**: | ||
|
||
```console | ||
$ langchain serve list [OPTIONS] | ||
``` | ||
|
||
**Options**: | ||
|
||
* `--help`: Show this message and exit. | ||
|
||
### `langchain serve new` | ||
|
||
Create a new LangServe application. | ||
|
||
**Usage**: | ||
|
||
```console | ||
$ langchain serve new [OPTIONS] NAME | ||
``` | ||
|
||
**Arguments**: | ||
|
||
* `NAME`: [required] | ||
|
||
**Options**: | ||
|
||
* `--package TEXT` | ||
* `--help`: Show this message and exit. | ||
|
||
### `langchain serve remove` | ||
|
||
Removes the specified package from the current LangServe instance. | ||
|
||
**Usage**: | ||
|
||
```console | ||
$ langchain serve remove [OPTIONS] API_PATHS... | ||
``` | ||
|
||
**Arguments**: | ||
|
||
* `API_PATHS...`: [required] | ||
|
||
**Options**: | ||
|
||
* `--help`: Show this message and exit. | ||
|
||
### `langchain serve start` | ||
|
||
Starts the LangServe instance. | ||
|
||
**Usage**: | ||
|
||
```console | ||
$ langchain serve start [OPTIONS] | ||
``` | ||
|
||
**Options**: | ||
|
||
* `--port INTEGER` | ||
* `--host TEXT` | ||
* `--help`: Show this message and exit. | ||
|
||
## `langchain start` | ||
|
||
Start the LangServe instance, whether it's a hub package or a serve project. | ||
|
||
**Usage**: | ||
|
||
```console | ||
$ langchain start [OPTIONS] | ||
``` | ||
|
||
**Options**: | ||
|
||
* `--port INTEGER` | ||
* `--host TEXT` | ||
* `--help`: Show this message and exit. |
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,43 @@ | ||
# langchain-cli | ||
|
||
Install CLI | ||
|
||
`pip install -U --pre langchain-cli` | ||
|
||
Create new langchain app | ||
|
||
`langchain serve new my-app` | ||
|
||
Go into app | ||
|
||
`cd my-app` | ||
|
||
Install a package | ||
|
||
`langchain serve add extraction-summary` | ||
|
||
(Activate virtualenv) | ||
|
||
Install langserve | ||
|
||
`pip install "langserve[all]"` | ||
|
||
Install the langchain package | ||
|
||
`pip install -e packages/extraction-summary` | ||
|
||
Edit `app/server.py` to add that package to the routes | ||
|
||
```markdown | ||
from fastapi import FastAPI | ||
from langserve import add_routes | ||
from extraction_summary.chain import chain | ||
|
||
app = FastAPI() | ||
|
||
add_routes(app, chain) | ||
``` | ||
|
||
Run the app | ||
|
||
`python app/server.py` |
Empty file.
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,36 @@ | ||
import typer | ||
import subprocess | ||
from typing import Optional | ||
from typing_extensions import Annotated | ||
|
||
from langchain_cli.namespaces import hub | ||
from langchain_cli.namespaces import serve | ||
|
||
app = typer.Typer(no_args_is_help=True, add_completion=False) | ||
app.add_typer(hub.hub, name="hub", help=hub.__doc__) | ||
app.add_typer(serve.serve, name="serve", help=serve.__doc__) | ||
|
||
|
||
@app.command() | ||
def start( | ||
*, | ||
port: Annotated[ | ||
Optional[int], typer.Option(help="The port to run the server on") | ||
] = None, | ||
host: Annotated[ | ||
Optional[str], typer.Option(help="The host to run the server on") | ||
] = None, | ||
) -> None: | ||
""" | ||
Start the LangServe instance, whether it's a hub package or a serve project. | ||
""" | ||
cmd = ["poetry", "run", "poe", "start"] | ||
if port is not None: | ||
cmd += ["--port", str(port)] | ||
if host is not None: | ||
cmd += ["--host", host] | ||
subprocess.run(cmd) | ||
|
||
|
||
if __name__ == "__main__": | ||
app() |
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,2 @@ | ||
DEFAULT_GIT_REPO = "https://github.com/langchain-ai/langchain.git" | ||
DEFAULT_GIT_SUBDIRECTORY = "templates" |
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,17 @@ | ||
""" | ||
Development Scripts for Hub Packages | ||
""" | ||
|
||
from fastapi import FastAPI | ||
from langserve.packages import add_package_route | ||
from langchain_cli.utils.packages import get_package_root | ||
|
||
|
||
def create_demo_server(): | ||
""" | ||
Creates a demo server for the current hub package. | ||
""" | ||
app = FastAPI() | ||
package_root = get_package_root() | ||
add_package_route(app, package_root, "") | ||
return app |
Empty file.
Oops, something went wrong.