mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-04-08 12:13:36 +00:00
feat(provider): 添加 Langfuse 观测平台的集成支持
feat(provider): 添加 Langfuse 观测平台的集成支持
This commit is contained in:
parent
c88d97c652
commit
4e06e12ab6
@ -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
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user