Skip to content
Customization

Customization

Authentication

Check how we handle authentication in:

Observability

You can use sentry (opens in a new tab) for error reporting. You can set your own sentry config in config.yaml

config.yaml

sentry: YOUR_DSN

Custom database

You need to implement the abstract class VectorDatabase found here (opens in a new tab) and then use it like:

from embedbase import get_app
 
from embedbase.database.supabase_db import Supabase
from embedbase.embedding.openai import OpenAI
 
from .my_custom_db import MyCustomDb
 
app = (
    get_app()
    .use_embedder(OpenAI("<your key>"))
    .use_db(MyCustomDb())
).run()

Custom middleware

Example production middlewares:

You can a custom middleware like this:

from embedbase import get_app
 
from embedbase.database.postgres_db import Postgres
from embedbase.embedding.openai import OpenAI
 
async def process_time(request, call_next):
    start_time = time.time()
    response = await call_next(request)
    process_time = time.time() - start_time
    response.headers["X-Process-Time"] = str(process_time)
    
    return response
 
app = (
    get_app()
    .use_middleware(process_time)
    .use_embedder(OpenAI("<your key>"))
    .use_db(Postgres())
).run()
 
curl -X POST -H "Content-Type: application/json" -d '{"query": "Bob"}' http://localhost:8080/v1/people/search
{
  "query": "Bob",
  "similarities": [
    {
      "score": 0.828773,
      "id": "ABCU75FEBE",
      "data": "Elon is sipping a tea on Mars",
    }
  ],
  "headers": {
    "x-process-time": "0.0001239776611328125"
  }
}

Custom Embedder

You need to implement the abstract class Embedder found here (opens in a new tab) and then use it like:

from embedbase import get_app
 
from embedbase.database.postgres_db import Postgres
 
from .my_custom_embedder import MyCustomEmbedder
 
app = (
    get_app()
    .use_db(Postgres())
    .use_embedder(MyCustomEmbedder())
).run()

Check this example (opens in a new tab).