Skip to content

Commit

Permalink
Release core 1.2.3 chore(core): move sentry out of core and into hosted
Browse files Browse the repository at this point in the history
  • Loading branch information
louis030195 committed May 30, 2023
1 parent 8555213 commit 529cda8
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 26 deletions.
19 changes: 1 addition & 18 deletions embedbase/api.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,12 @@
import os
from typing import Optional
from embedbase.app import Embedbase

from embedbase.app import Embedbase
from embedbase.settings import Settings


def get_app(settings: Optional[Settings] = None) -> Embedbase:
app = Embedbase(settings)

if settings and settings.sentry:
app.logger.info("Enabling Sentry")
import sentry_sdk

sentry_sdk.init(
dsn=settings.sentry,
# Set traces_sample_rate to 1.0 to capture 100%
# of transactions for performance monitoring.
# We recommend adjusting this value in production,
traces_sample_rate=0.2,
environment=os.environ.get("ENVIRONMENT", "development"),
_experiments={
"profiles_sample_rate": 1.0,
},
)

if settings and settings.auth == "firebase":
from embedbase.firebase_auth import enable_firebase_auth

Expand Down
1 change: 0 additions & 1 deletion embedbase/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ class Settings(YamlModel):

log_level: str = "INFO"
auth: typing.Optional[str] = None
sentry: typing.Optional[str] = None
firebase_service_account_path: typing.Optional[str] = None

@lru_cache()
Expand Down
3 changes: 2 additions & 1 deletion hosted/.dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
!docker-entrypoint.sh
!middlewares/**/*.py
!requirements.txt
!main.py
!main.py
!version.txt
1 change: 1 addition & 0 deletions hosted/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ RUN apt-get update && apt-get install -y git gcc && apt-get clean && \
COPY ./middlewares/auth_api_key/auth_api_key.py /middlewares/auth_api_key/auth_api_key.py
COPY main.py main.py
COPY docker-entrypoint.sh docker/docker-entrypoint.sh
COPY version.txt version.txt

ENTRYPOINT ["docker/docker-entrypoint.sh"]
CMD ["embedbase"]
28 changes: 23 additions & 5 deletions hosted/main.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import os
from embedbase import get_app
from embedbase.settings import get_settings_from_file

import sentry_sdk
from embedbase_internet_search import internet_search
from fastapi import Request
from fastapi.responses import JSONResponse
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import JSONResponse
from middlewares.auth_api_key.auth_api_key import AuthApiKey

from embedbase import get_app
from embedbase.database.supabase_db import Supabase
from embedbase.embedding.openai import OpenAI
from embedbase_internet_search import internet_search
from embedbase.settings import get_settings_from_file

config_path = "config.yaml"
SECRET_PATH = "/secrets" if os.path.exists("/secrets") else ".."
Expand All @@ -21,6 +24,20 @@

settings = get_settings_from_file(os.path.join(SECRET_PATH, config_path))

version = open("version.txt").read()

sentry_sdk.init(
dsn=settings.sentry,
# Set traces_sample_rate to 1.0 to capture 100%
# of transactions for performance monitoring.
# We recommend adjusting this value in production,
traces_sample_rate=0.1,
environment=os.environ.get("ENVIRONMENT", "development"),
_experiments={
"profiles_sample_rate": 0.1,
},
)

app = (
get_app(settings)
.use_embedder(OpenAI(settings.openai_api_key, settings.openai_organization))
Expand All @@ -37,6 +54,7 @@

app.add_api_route("/v1/search/internet", internet_search, methods=["POST"])


@app.exception_handler(Exception)
async def custom_exception_handler(request: Request, exc: Exception):
return JSONResponse(
Expand All @@ -47,4 +65,4 @@ async def custom_exception_handler(request: Request, exc: Exception):
"Access-Control-Allow-Methods": "*",
"Access-Control-Allow-Headers": "*",
},
)
)
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ in-project = true

[tool.poetry]
name = "embedbase"
version = "1.2.2"
version = "1.2.3"
description = "Open-source API & SDK to integrate your data and easily hook them up to LLMs."
readme = "README.md"
authors = ["Different AI <[email protected]>"]
Expand Down

2 comments on commit 529cda8

@vercel
Copy link

@vercel vercel bot commented on 529cda8 May 30, 2023

Choose a reason for hiding this comment

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

@vercel
Copy link

@vercel vercel bot commented on 529cda8 May 30, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

embedbase – ./dashboard

embedbase.vercel.app
embedbase-git-main-prologe.vercel.app
embedbase-prologe.vercel.app
app.embedbase.xyz

Please sign in to comment.