Multi-tenant headless RAG chat bot.
This is a simple implementation of a multi-tenant chat bot that uses the Retrieval Augmented Generation.
Some of this code came from Wanderling, but all the game specific functions and rules-engine has been trimmed out (not ready to open source that one yet)
Copy the example.env
file to .env
Update the values for openai and pinecone.
make dev
open http://localhost:8080/swagger-ui/index.html
- Namespaced vector storage for multi-tenant preparation
- OAuth authentication via JWT header
- User session isolation
- User session history and continuation
- Adding documents to vector storage with a simple embedding pipeline
- Retrieval Augmented Generation as default chat experience
- Anonymous
- JWT
- OAuth2
- H2
- Postgres
- Pinecone
- OpenSearch
- In Memory
- OpenAI
- OpenSearch
- Replicate
Spring Profiles are used to configure the application.
See some example configurations (./src/main/resources/)[./src/main/resources/]
The configuration can be set in YAML, Properties, or Environment variables.
OPENAI_ENABLED=true
OPENAI_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxx
OPENAI_CHAT_MODEL_ID=gpt-3.5-turbo
PINECONE_ENABLED=true
PINECONE_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
PINECONE_PROJECT_NAME=my-project
PINECONE_INDEX=my-index
PINECONE_ENVIRONMENT=us-east4-gcp
APP_SECURITY_ENABLED=false
See the application configuration in application-opensearch.yml for more details.
SPRING_PROFILES_ACTIVE=opensearch
OPENAI_ENABLED=true
OPENAI_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxx
OPENAI_CHAT_MODEL_ID=gpt-3.5-turbo
OPENSEARCH_URL=https://localhost:9200
If you store documents in your repository, you can easily upload them to mainbot.
Leverage the GitHub Action to upload text/markdown files directly to mainbot.
name: Upload Files to Mainbot
on:
workflow_dispatch: {} # Manually trigger the workflow
push:
branches:
- main
paths:
- 'docs/**'
- 'README.md'
jobs:
upload:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Upload Files
uses: savantly-net/mainbot-github-action@main
with:
glob-patterns: '*.md' # Set your file pattern here
namespace: '/mainbot-documents'
api-url: 'https://mainbot.my-company.apps.savantly.cloud'
client-id: ${{ secrets.MAINBOT_CLIENT_ID }}
client-secret: ${{ secrets.MAINBOT_CLIENT_SECRET }}
token-endpoint: https://oidc.apps.savantly.cloud/realms/savantly/protocol/openid-connect/token
We've also built a Backstage plugin to integrate with mainbot.
Combining the Github action and the Techdocs plugin, you can make all of your documentation immediately available in Backstage and searchable in mainbot.