✨(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:
@@ -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. "
|
||||
|
||||
Reference in New Issue
Block a user