🐛 fix(langfuse.py): handle ImportError when importing Langfuse to prevent crashes when Langfuse is not installed
✨ feat(langfuse.py): set cls._instance to None when no Langfuse credentials are found to improve error handling and prevent crashes
This commit is contained in:
parent
a3c2a0d13a
commit
5590dfe8f3
1 changed files with 19 additions and 15 deletions
|
|
@ -17,6 +17,7 @@ class LangfuseInstance:
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create(cls):
|
def create(cls):
|
||||||
|
try:
|
||||||
logger.debug("Creating Langfuse instance")
|
logger.debug("Creating Langfuse instance")
|
||||||
from langfuse import Langfuse # type: ignore
|
from langfuse import Langfuse # type: ignore
|
||||||
|
|
||||||
|
|
@ -35,6 +36,9 @@ class LangfuseInstance:
|
||||||
else:
|
else:
|
||||||
logger.debug("No Langfuse credentials found")
|
logger.debug("No Langfuse credentials found")
|
||||||
cls._instance = None
|
cls._instance = None
|
||||||
|
except ImportError:
|
||||||
|
logger.debug("Langfuse not installed")
|
||||||
|
cls._instance = None
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def update(cls):
|
def update(cls):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue