Skip to content

Commit

Permalink
feat(Update doc and publish 0.0.5):
Browse files Browse the repository at this point in the history
  • Loading branch information
msoedov committed Apr 18, 2023
1 parent 5f746b9 commit 1a87f67
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 13 deletions.
27 changes: 19 additions & 8 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,12 @@ Run your LangCorn FastAPI server:
langcorn server examples.ex1:chain


[INFO] 2023-04-14 23:28:57.52 | api:create_service:81 | Endpoint: /docs
[INFO] 2023-04-14 23:28:57.52 | api:create_service:81 | Endpoint: /examples.ex1/run
INFO: Started server process [87033]
[INFO] 2023-04-18 14:34:56.32 | api:create_service:75 | Creating service
[INFO] 2023-04-18 14:34:57.51 | api:create_service:85 | lang_app='examples.ex1:chain':LLMChain(['product'])
[INFO] 2023-04-18 14:34:57.51 | api:create_service:104 | Serving
[INFO] 2023-04-18 14:34:57.51 | api:create_service:106 | Endpoint: /docs
[INFO] 2023-04-18 14:34:57.51 | api:create_service:106 | Endpoint: /examples.ex1/run
INFO: Started server process [27843]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://127.0.0.1:8718 (Press CTRL+C to quit)
Expand All @@ -73,11 +76,14 @@ Run multiple chains
python -m langcorn server examples.ex1:chain examples.ex2:chain



[INFO] 2023-04-14 23:28:57.52 | api:create_service:81 | Endpoint: /docs
[INFO] 2023-04-14 23:28:57.52 | api:create_service:81 | Endpoint: /examples.ex1/run
[INFO] 2023-04-14 23:28:57.52 | api:create_service:81 | Endpoint: /examples.ex2/run
INFO: Started server process [87033]
[INFO] 2023-04-18 14:35:21.11 | api:create_service:75 | Creating service
[INFO] 2023-04-18 14:35:21.82 | api:create_service:85 | lang_app='examples.ex1:chain':LLMChain(['product'])
[INFO] 2023-04-18 14:35:21.82 | api:create_service:85 | lang_app='examples.ex2:chain':SimpleSequentialChain(['input'])
[INFO] 2023-04-18 14:35:21.82 | api:create_service:104 | Serving
[INFO] 2023-04-18 14:35:21.82 | api:create_service:106 | Endpoint: /docs
[INFO] 2023-04-18 14:35:21.82 | api:create_service:106 | Endpoint: /examples.ex1/run
[INFO] 2023-04-18 14:35:21.82 | api:create_service:106 | Endpoint: /examples.ex2/run
INFO: Started server process [27863]
INFO: Waiting for application startup.
INFO: Application startup complete.
INFO: Uvicorn running on http://127.0.0.1:8718 (Press CTRL+C to quit)
Expand Down Expand Up @@ -112,6 +118,11 @@ uvicorn main:app --host 0.0.0.0 --port 8000

Now, your LangChain models and pipelines are accessible via the LangCorn API server.

## Docs

Automatically served FastAPI doc
![](https://res.cloudinary.com/dq0w2rtm9/image/upload/c_pad,b_auto:predominant,fl_preserve_transparency/v1681817836/Screen_Shot_2023-04-18_at_14.36.00_ms2thb.jpg?_s=public-apps)

## Auth

It possible to add a static api token auth by specifying `auth_token`
Expand Down
7 changes: 3 additions & 4 deletions langcorn/server/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,13 @@ def create_service(*lc_apps, auth_token: str = ""):

for lang_app in lc_apps:
chain = import_from_string(lang_app)
logger.info(f"{lang_app=}")
logger.info(f"{chain=}")
inn, out = derive_fields(chain)
logger.info(f"{inn=}")
logger.debug(f"inputs:{inn=}")
logger.info(f"{lang_app=}:{chain.__class__.__name__}({inn})")
endpoint_prefix = lang_app.split(":")[0]
cls_name = "".join([c.capitalize() for c in endpoint_prefix.split(".")])
request_cls = derive_class(cls_name, inn)
logger.info(f"{request_cls=}")
logger.debug(f"{request_cls=}")

endpoints.append(f"/{endpoint_prefix}/run")
# avoid hoisting issues with handler(request)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "langcorn"
version = "0.0.4"
version = "0.0.5"
description = "A Python package creating rest api interface for LangChain"
authors = ["Alexander Miasoiedov <[email protected]>"]
maintainers = [
Expand Down

0 comments on commit 1a87f67

Please sign in to comment.