Compare commits

..

2 commits

Author SHA1 Message Date
72ad01ff2f
Add logfire integration
All checks were successful
CI / ci (push) Successful in 12s
2026-06-08 19:09:20 +02:00
8ea1fd9014
Update ruff-pre-commit hook version to v0.15.16 2026-06-08 19:08:29 +02:00
4 changed files with 11 additions and 6 deletions

View file

@ -21,7 +21,7 @@ repos:
- id: trailing-whitespace - id: trailing-whitespace
- repo: https://github.com/astral-sh/ruff-pre-commit - repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.15 rev: v0.15.16
hooks: hooks:
- id: ruff-check - id: ruff-check
args: ["--fix", "--exit-non-zero-on-fix"] args: ["--fix", "--exit-non-zero-on-fix"]

View file

@ -6,6 +6,7 @@
"automerge", "automerge",
"buildx", "buildx",
"CLAHE", "CLAHE",
"deepseek",
"Denoise", "Denoise",
"denoising", "denoising",
"docstrings", "docstrings",
@ -26,6 +27,7 @@
"killyoy", "killyoy",
"levelname", "levelname",
"Licka", "Licka",
"logfire",
"Lördagsgodis", "Lördagsgodis",
"lovibot", "lovibot",
"Lovinator", "Lovinator",
@ -57,4 +59,4 @@
"Waifu", "Waifu",
"Zenless" "Zenless"
] ]
} }

10
main.py
View file

@ -8,6 +8,7 @@ import os
import re import re
from collections import deque from collections import deque
from dataclasses import dataclass from dataclasses import dataclass
from logging import basicConfig
from typing import TYPE_CHECKING from typing import TYPE_CHECKING
from typing import Any from typing import Any
from typing import Literal from typing import Literal
@ -17,6 +18,7 @@ from typing import TypeVar
import cv2 import cv2
import discord import discord
import httpx import httpx
import logfire
import numpy as np import numpy as np
import ollama import ollama
import openai import openai
@ -58,10 +60,10 @@ sentry_sdk.init(
send_default_pii=True, send_default_pii=True,
) )
logfire.configure()
basicConfig(handlers=[logfire.LogfireLoggingHandler()], level=logging.DEBUG)
logger: logging.Logger = logging.getLogger(__name__) logger: logging.Logger = logging.getLogger(__name__)
logger.setLevel(logging.DEBUG)
discord_token: str = os.getenv("DISCORD_TOKEN", "") discord_token: str = os.getenv("DISCORD_TOKEN", "")
os.environ["OPENAI_API_KEY"] = os.getenv("OPENAI_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: if author_name != bot_name:
message_history.append( message_history.append(
ModelRequest(parts=[UserPromptPart(content=message_content)]), ModelRequest([UserPromptPart(content=message_content)]),
) )
else: else:
message_history.append( message_history.append(
ModelResponse(parts=[TextPart(content=message_content)]), ModelResponse([TextPart(content=message_content)]),
) )
# Compact history to avoid exceeding model context limits # Compact history to avoid exceeding model context limits

View file

@ -8,6 +8,7 @@ dependencies = [
"audioop-lts", "audioop-lts",
"discord-py", "discord-py",
"httpx", "httpx",
"logfire[httpx]",
"numpy", "numpy",
"ollama", "ollama",
"openai", "openai",