From 72ad01ff2feb299c7e66b2383d781e4203304edb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20Hells=C3=A9n?= Date: Mon, 8 Jun 2026 19:09:20 +0200 Subject: [PATCH] Add logfire integration --- .vscode/settings.json | 4 +++- main.py | 10 ++++++---- pyproject.toml | 1 + 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index d5a5404..5a6898d 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -6,6 +6,7 @@ "automerge", "buildx", "CLAHE", + "deepseek", "Denoise", "denoising", "docstrings", @@ -26,6 +27,7 @@ "killyoy", "levelname", "Licka", + "logfire", "Lördagsgodis", "lovibot", "Lovinator", @@ -57,4 +59,4 @@ "Waifu", "Zenless" ] -} +} \ No newline at end of file diff --git a/main.py b/main.py index 534ac2b..02e65cd 100644 --- a/main.py +++ b/main.py @@ -8,6 +8,7 @@ import os import re from collections import deque from dataclasses import dataclass +from logging import basicConfig from typing import TYPE_CHECKING from typing import Any from typing import Literal @@ -17,6 +18,7 @@ from typing import TypeVar import cv2 import discord import httpx +import logfire import numpy as np import ollama import openai @@ -58,10 +60,10 @@ sentry_sdk.init( send_default_pii=True, ) +logfire.configure() +basicConfig(handlers=[logfire.LogfireLoggingHandler()], level=logging.DEBUG) logger: logging.Logger = logging.getLogger(__name__) -logger.setLevel(logging.DEBUG) - discord_token: str = os.getenv("DISCORD_TOKEN", "") os.environ["OPENAI_API_KEY"] = os.getenv("OPENAI_TOKEN", "") @@ -521,11 +523,11 @@ async def chat( # noqa: PLR0913, PLR0917 ): if author_name != bot_name: message_history.append( - ModelRequest(parts=[UserPromptPart(content=message_content)]), + ModelRequest([UserPromptPart(content=message_content)]), ) else: message_history.append( - ModelResponse(parts=[TextPart(content=message_content)]), + ModelResponse([TextPart(content=message_content)]), ) # Compact history to avoid exceeding model context limits diff --git a/pyproject.toml b/pyproject.toml index 89bb4ad..06e67e5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,6 +8,7 @@ dependencies = [ "audioop-lts", "discord-py", "httpx", + "logfire[httpx]", "numpy", "ollama", "openai",