Skip to content

Commit

Permalink
Reorganize readme, add documentation to config hash endpoints (#241)
Browse files Browse the repository at this point in the history
* Re organize some sections in the readme
* Use more highlighting in the readme for sections where attention is
required
* Expand doc-strings for config hash endpoints 
 

![image](https://github.com/langchain-ai/langserve/assets/3205522/9cfb8039-b9e6-4079-b677-d8a298575763)
  • Loading branch information
eyurtsev authored Nov 16, 2023
1 parent 078453f commit 22831ca
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 22 deletions.
43 changes: 22 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@ We will be releasing a hosted version of LangServe for one-click deployments of
## Security

* Vulnerability in Versions 0.0.13 - 0.0.15 -- playground endpoint allows accessing arbitrary files on server. [Resolved in 0.0.16](https://github.com/langchain-ai/langserve/pull/98).

## Installation

For both client and server:

```bash
pip install "langserve[all]"
```

or `pip install "langserve[client]"` for client code, and `pip install "langserve[server]"` for server code.


## LangChain CLI 🛠️

Expand Down Expand Up @@ -110,17 +121,16 @@ if __name__ == "__main__":

If you've deployed the server above, you can view the generated OpenAPI docs using:

> ⚠️ If using pydantic v2, docs will not be generated for invoke/batch/stream/stream_log. See [Pydantic](#pydantic) section below for more details.
```sh
curl localhost:8000/docs
```

make sure to **add** the `/docs` suffix.

Below will return a 404 until you define a `@app.get("/")`

```sh
localhost:8000
```
> ⚠️ Index page `/` is not defined by **design**, so `curl localhost:8000` or visiting the URL
> will return a 404. If you want content at `/` define an endpoint `@app.get("/")`.
### Client

Expand Down Expand Up @@ -245,29 +255,13 @@ In addition, for configurable runnables, the playground will allow you to config
<img src="https://github.com/langchain-ai/langserve/assets/3205522/86ce9c59-f8e4-4d08-9fa3-62030e0f521d" width="50%">
</p>

## Installation

For both client and server:

```bash
pip install "langserve[all]"
```

or `pip install "langserve[client]"` for client code, and `pip install "langserve[server]"` for server code.

## Legacy Chains

LangServe works with both Runnables (constructed via [LangChain Expression Language](https://python.langchain.com/docs/expression_language/)) and legacy chains (inheriting from `Chain`).
However, some of the input schemas for legacy chains may be incomplete/incorrect, leading to errors.
This can be fixed by updating the `input_schema` property of those chains in LangChain.
If you encounter any errors, please open an issue on THIS repo, and we will work to address it.

## Handling Authentication

If you need to add authentication to your server,
please reference FastAPI's [security documentation](https://fastapi.tiangolo.com/tutorial/security/)
and [middleware documentation](https://fastapi.tiangolo.com/tutorial/middleware/).

## Deployment

### Deploy to GCP
Expand All @@ -289,6 +283,13 @@ Except for these limitations, we expect the API endpoints, the playground and an

## Advanced

## Handling Authentication

If you need to add authentication to your server,
please reference FastAPI's [security documentation](https://fastapi.tiangolo.com/tutorial/security/)
and [middleware documentation](https://fastapi.tiangolo.com/tutorial/middleware/).


### Files

LLM applications often deal with files. There are different architectures
Expand Down
33 changes: 32 additions & 1 deletion langserve/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,10 @@ def _route_name_with_config(name: str) -> str:
"name": route_tags_with_config[0],
"description": (
"Endpoints with a default configuration "
"set by `config_hash` path parameter."
"set by `config_hash` path parameter. "
"Used in conjunction with share links generated using the "
"LangServe UI playground. "
"The hash is an LZString compressed JSON string."
),
},
]
Expand Down Expand Up @@ -1101,6 +1104,13 @@ async def feedback(feedback_create_req: FeedbackCreateRequest) -> Feedback:
response_model=InvokeResponse,
tags=route_tags_with_config,
name=_route_name_with_config("invoke"),
description=(
"This endpoint is to be used with share links generated by the "
"LangServe playground. "
"The hash is an LZString compressed JSON string. "
"For regular use cases, use the /invoke endpoint without "
"the `c/{config_hash}` path parameter."
),
)
@app.post(
f"{namespace}/invoke",
Expand All @@ -1120,6 +1130,13 @@ async def _invoke_docs(
response_model=BatchResponse,
tags=route_tags_with_config,
name=_route_name_with_config("batch"),
description=(
"This endpoint is to be used with share links generated by the "
"LangServe playground. "
"The hash is an LZString compressed JSON string. "
"For regular use cases, use the /batch endpoint without "
"the `c/{config_hash}` path parameter."
),
)
@app.post(
f"{namespace}/batch",
Expand All @@ -1139,6 +1156,13 @@ async def _batch_docs(
include_in_schema=True,
tags=route_tags_with_config,
name=_route_name_with_config("stream"),
description=(
"This endpoint is to be used with share links generated by the "
"LangServe playground. "
"The hash is an LZString compressed JSON string. "
"For regular use cases, use the /stream endpoint without "
"the `c/{config_hash}` path parameter."
),
)
@app.post(
f"{namespace}/stream",
Expand Down Expand Up @@ -1198,6 +1222,13 @@ async def _stream_docs(
include_in_schema=True,
tags=route_tags_with_config,
name=_route_name_with_config("stream_log"),
description=(
"This endpoint is to be used with share links generated by the "
"LangServe playground. "
"The hash is an LZString compressed JSON string. "
"For regular use cases, use the /stream_log endpoint without "
"the `c/{config_hash}` path parameter."
),
)
@app.post(
f"{namespace}/stream_log",
Expand Down

0 comments on commit 22831ca

Please sign in to comment.