-
Notifications
You must be signed in to change notification settings - Fork 1
feat: initial #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Signed-off-by: Isac Byeonghoon Yoo <isac@runbear.io>
| ## Other Web server frameworks | ||
|
|
||
| Although it does not yet provide an interface as convenient as FastAPI, it can be directly linked to PlugBear. | ||
|
|
||
| ### Installation | ||
|
|
||
| To install the PlugBear Python SDK, run the following command: | ||
|
|
||
| ```bash | ||
| pip install plugbear | ||
| ``` | ||
|
|
||
| ### Usage | ||
|
|
||
| ```python | ||
| from fastapi import FastAPI | ||
|
|
||
| import plugbear | ||
| import plugbear.fastapi | ||
|
|
||
| app = FastAPI() | ||
| PLUGBEAR_API_KEY = "" | ||
| PLUGBEAR_ENDPOINT = "/plugbear" | ||
|
|
||
|
|
||
| @app.on_event("startup") | ||
| async def _startup(): | ||
| await plugbear.fastapi.register( | ||
| app, | ||
| llm_func=some_llm, | ||
| api_key=PLUGBEAR_API_KEY, | ||
| endpoint=PLUGBEAR_ENDPOINT, | ||
| ) | ||
|
|
||
|
|
||
| async def some_llm(context: plugbear.Request) -> str: | ||
| # template prompt using `context` to your own LLM | ||
| # and return result | ||
| result: str = ... | ||
| return result | ||
| ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
만들고보니 인터페이스를 나눠놔서 꼭 fastapi가 아니더라도 api handler에 잘 붙이기만하면 연동될 것 같아서 이 항목도 넣었는데 어떠신가요? usage 항목은 간단한 django예시를 적어놓으면 어떨까 생각했습니다..!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, I like it! Also, as we're publishing this package, let's ensure all communications in this repository are in English for consistency and clarity.
thefron
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
| ## Other Web server frameworks | ||
|
|
||
| Although it does not yet provide an interface as convenient as FastAPI, it can be directly linked to PlugBear. | ||
|
|
||
| ### Installation | ||
|
|
||
| To install the PlugBear Python SDK, run the following command: | ||
|
|
||
| ```bash | ||
| pip install plugbear | ||
| ``` | ||
|
|
||
| ### Usage | ||
|
|
||
| ```python | ||
| from fastapi import FastAPI | ||
|
|
||
| import plugbear | ||
| import plugbear.fastapi | ||
|
|
||
| app = FastAPI() | ||
| PLUGBEAR_API_KEY = "" | ||
| PLUGBEAR_ENDPOINT = "/plugbear" | ||
|
|
||
|
|
||
| @app.on_event("startup") | ||
| async def _startup(): | ||
| await plugbear.fastapi.register( | ||
| app, | ||
| llm_func=some_llm, | ||
| api_key=PLUGBEAR_API_KEY, | ||
| endpoint=PLUGBEAR_ENDPOINT, | ||
| ) | ||
|
|
||
|
|
||
| async def some_llm(context: plugbear.Request) -> str: | ||
| # template prompt using `context` to your own LLM | ||
| # and return result | ||
| result: str = ... | ||
| return result | ||
| ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, I like it! Also, as we're publishing this package, let's ensure all communications in this repository are in English for consistency and clarity.
| async def register(app: fastapi.FastAPI, *, llm_func: LLMHandler, api_key: str, endpoint: str) -> None: | ||
| pb = await plugbear.PlugBear.init(api_key=api_key) | ||
|
|
||
| if inspect.iscoroutinefunction(llm_func): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like we support both coroutine and regular subroutine.
우선 ci 빼고 코드만 리뷰 요청드려요.