feat(provider): 添加 Langfuse 观测平台的集成支持

feat(provider): 添加 Langfuse 观测平台的集成支持
This commit is contained in:
lang07123 2026-03-31 11:51:57 +08:00 committed by Xubin Ren
parent c88d97c652
commit 4e06e12ab6

View File

@ -4,6 +4,7 @@ from __future__ import annotations
import asyncio
import hashlib
import importlib
import os
import secrets
import string
@ -12,7 +13,15 @@ from collections.abc import Awaitable, Callable
from typing import TYPE_CHECKING, Any
import json_repair
from openai import AsyncOpenAI
if os.environ.get("LANGFUSE_SECRET_KEY"):
LANGFUSE_AVAILABLE = importlib.util.find_spec("langfuse") is not None
if not LANGFUSE_AVAILABLE:
raise ImportError("Langfuse is not available; please install it with `pip install langfuse`")
from langfuse.openai import AsyncOpenAI
else:
from openai import AsyncOpenAI
from nanobot.providers.base import LLMProvider, LLMResponse, ToolCallRequest