Skip to content

Commit

Permalink
Merge pull request #16 from msoedov/fix
Browse files Browse the repository at this point in the history
feat(raise RuntimeError if improperly configured):
  • Loading branch information
msoedov authored May 15, 2023
2 parents 7296480 + ad52d1c commit 952bc85
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
5 changes: 4 additions & 1 deletion langcorn/__main__.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import os
import sys

import fire
import uvicorn

from langcorn.server import api


class T:
def server(self, *lc: str, port=8718, auth_token=""):
sys.path.append(os.path.dirname(__file__))
app = api.create_service(*lc, auth_token=auth_token)
config = uvicorn.Config(app, port=port, log_level="info")
server = uvicorn.Server(config)
Expand Down
5 changes: 4 additions & 1 deletion langcorn/server/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,10 @@ def create_service(*lc_apps, auth_token: str = "", app: FastAPI = None):
endpoints = ["/docs"]

_authenticate_or_401 = Depends(authenticate_or_401(auth_token=auth_token))

if lc_apps and isinstance(import_from_string(lc_apps[0]), FastAPI):
raise RuntimeError(
"Improperly configured: FastAPI instance passed instead of LangChain interface"
)
for lang_app in lc_apps:
chain = import_from_string(lang_app)
inn, out = derive_fields(chain)
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.7"
version = "0.0.8"
description = "A Python package creating rest api interface for LangChain"
authors = ["Alexander Miasoiedov <msoedov@gmail.com>"]
maintainers = [
Expand Down

1 comment on commit 952bc85

@vercel
Copy link

@vercel vercel bot commented on 952bc85 May 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

langcorn – ./

langcorn-git-main-msoedov.vercel.app
langcorn.vercel.app
langcorn-msoedov.vercel.app

Please sign in to comment.