Python Application
With Runbear Python SDK, you can easily connect your custom LLM apps to Slack, Discord, and other channels. You can find working examples in the Runbear SDK Examples repository.
Installation
To install the Runbear Python SDK, run the following command:
pip install 'plugbear[fastapi]'
Step 1. Getting Runbear API Key
To obtain your API key, visit the Runbear API Keys page accessible via the Profile menu and copy the generated key.
Step 2. Configure your Python LLM Application
Here's a simple example to get you started:
import contextlib
import plugbear.fastapi
from fastapi import FastAPI
PLUGBEAR_API_KEY = "YOUR_PLUGBEAR_API_KEY_HERE"
PLUGBEAR_ENDPOINT = "/plugbear"
@contextlib.asynccontextmanager
async def lifespan(app: FastAPI):
await plugbear.fastapi.register(
app,
llm_func=some_llm,
api_key=PLUGBEAR_API_KEY,
endpoint=PLUGBEAR_ENDPOINT,
)
yield
app = FastAPI(lifespan=lifespan)
async def some_llm(context: plugbear.fastapi.Request) -> str:
# template prompt using `context` to your own LLM
# and return result
result: str = ...
return result
For more examples, refer to our examples on GitHub
Step 3. Configure Your App in Runbear
- Navigate to the Assistants menu and click Add App.
- Select Runbear Python SDK as your app type.
- In the Your LLM App Endpoint field, enter the endpoint with the path you set earlier. e.g.,
https://your.domain.com/runbear
What's Next
Connect the app you added to communication channels. Check Connecting Channels with LLM Apps for more details.