(backend) use langfuse to monitor AI actions

We want to monitor AI actions. For this we choose to use langfuse. As
this usage is optional, we load langfuse sdk only if settings are
configured. Also, the openai client from langfuse is a dropin
replacement of openai client, so we only have to change how openai is
imported.
This commit is contained in:
Manuel Raynaud
2026-01-09 15:38:56 +01:00
committed by GitHub
parent 39b9c8b5a9
commit 55fe73d001
5 changed files with 21 additions and 2 deletions

View File

@@ -3,10 +3,14 @@
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from openai import OpenAI
from core import enums
if settings.LANGFUSE_PUBLIC_KEY:
from langfuse.openai import OpenAI
else:
from openai import OpenAI
AI_ACTIONS = {
"prompt": (
"Answer the prompt using markdown formatting for structure and emphasis. "