Skip to content
Merged
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/qwenpaw/providers/openai_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@

from __future__ import annotations

import importlib.util
import json
import logging
import os
import time
from typing import TYPE_CHECKING, Any, List

from agentscope.model import ChatModelBase
from openai import APIError, AsyncOpenAI
from openai import APIError

from qwenpaw.providers.provider import ModelInfo, Provider

Expand All @@ -21,6 +23,16 @@
DASHSCOPE_BASE_URL = "https://dashscope.aliyuncs.com/compatible-mode/v1"
CODING_DASHSCOPE_BASE_URL = "https://coding.dashscope.aliyuncs.com/v1"

if os.environ.get("LANGFUSE_SECRET_KEY") and importlib.util.find_spec("langfuse"):
from langfuse.openai import AsyncOpenAI # type: ignore[import]
else:
if os.environ.get("LANGFUSE_SECRET_KEY"):
logger.warning(
"LANGFUSE_SECRET_KEY is set but langfuse is not installed; "
"install with `pip install langfuse` to enable tracing"
)
Comment thread
xieyxclack marked this conversation as resolved.
Outdated
from openai import AsyncOpenAI


class OpenAIProvider(Provider):
"""Provider implementation for OpenAI API and compatible endpoints."""
Expand Down
Loading