feat(provider): 添加 Langfuse 观测平台的集成支持
feat(provider): 添加 Langfuse 观测平台的集成支持
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user