Skip to content

Conversation

@isac322
Copy link
Member

@isac322 isac322 commented Dec 19, 2023

우선 ci 빼고 코드만 리뷰 요청드려요.

Signed-off-by: Isac Byeonghoon Yoo <isac@runbear.io>
@isac322 isac322 requested a review from thefron December 19, 2023 05:55
@isac322 isac322 self-assigned this Dec 19, 2023
Comment on lines +47 to +87
## 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
```
Copy link
Member Author

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예시를 적어놓으면 어떨까 생각했습니다..!

Copy link
Member

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.

Copy link
Member

@thefron thefron left a comment

Choose a reason for hiding this comment

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

LGTM!

Comment on lines +47 to +87
## 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
```
Copy link
Member

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):
Copy link
Member

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.

@isac322 isac322 merged commit 3824c0f into master Dec 19, 2023
@isac322 isac322 deleted the init branch December 19, 2023 06:23
@isac322 isac322 mentioned this pull request Dec 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants