Skip to content

Commit

Permalink
Allow you to monitor GPT4All-API with Sentry (nomic-ai#1271)
Browse files Browse the repository at this point in the history
  • Loading branch information
AndriyMulyar authored Jul 25, 2023
1 parent 545c23b commit 14f4b52
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions gpt4all-api/gpt4all_api/app/api_v1/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class Settings(BaseSettings):
gpt4all_path: str = '/models'
inference_mode: str = "cpu"
hf_inference_server_host: str = "http://gpt4all_gpu:80/generate"
sentry_dns: str = None

temp: float = 0.18
top_p: float = 1.0
Expand Down
12 changes: 12 additions & 0 deletions gpt4all-api/gpt4all_api/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,23 @@ async def startup():
logger.info(f"GPT4All API is ready to infer from {settings.model} on CPU.")



@app.on_event("shutdown")
async def shutdown():
logger.info("Shutting down API")


if settings.sentry_dns is not None:
import sentry_sdk

def traces_sampler(sampling_context):
if 'health' in sampling_context['transaction_context']['name']:
return False

sentry_sdk.init(
dsn=settings.sentry_dns, traces_sample_rate=0.1, traces_sampler=traces_sampler, send_default_pii=False
)

# This is needed to get logs to show up in the app
if "gunicorn" in os.environ.get("SERVER_SOFTWARE", ""):
gunicorn_error_logger = logging.getLogger("gunicorn.error")
Expand Down

0 comments on commit 14f4b52

Please sign in to comment.