This commit is contained in:
0Xiao0
2026-05-13 15:35:04 +08:00
parent 6ec16bf68e
commit 746053fd58

View File

@ -66,11 +66,11 @@ async def entrypoint(ctx: JobContext) -> None:
ASR_LANGUAGE = os.getenv("CUSTOM_ASR_LANGUAGE", "auto") ASR_LANGUAGE = os.getenv("CUSTOM_ASR_LANGUAGE", "auto")
ASR_OUTPUT_LANGUAGE = os.getenv("CUSTOM_ASR_OUTPUT_LANGUAGE", "zh") ASR_OUTPUT_LANGUAGE = os.getenv("CUSTOM_ASR_OUTPUT_LANGUAGE", "zh")
MINIMAX_BASE_URL = os.getenv("MINIMAX_LLM_BASE_URL", "https://oai.bwgdi.com/v1") LLM_BASE_URL = os.getenv("CUSTOM_LLM_BASE_URL")
MINIMAX_MODEL = os.getenv("MINIMAX_LLM_MODEL", "qwen-max") LLM_MODEL = os.getenv("CUSTOM_LLM_MODEL", "qwen-max")
MINIMAX_API_KEY = os.getenv("MINIMAX_API_KEY") LLM_API_KEY = os.getenv("CUSTOM_LLM_API_KEY")
if not MINIMAX_API_KEY: if not LLM_API_KEY:
raise RuntimeError(f"MINIMAX_API_KEY is not set in {CUSTOM_ENV_PATH}") raise RuntimeError(f"CUSTOM_LLM_API_KEY is not set in {CUSTOM_ENV_PATH}")
TTS_URL = os.getenv("CUSTOM_TTS_URL") or os.getenv( TTS_URL = os.getenv("CUSTOM_TTS_URL") or os.getenv(
"VOXCPM_TTS_URL", "http://localhost:5050/tts-blackbox" "VOXCPM_TTS_URL", "http://localhost:5050/tts-blackbox"
@ -94,22 +94,27 @@ async def entrypoint(ctx: JobContext) -> None:
import httpx import httpx
from openai import AsyncClient as OpenAIAsyncClient from openai import AsyncClient as OpenAIAsyncClient
# Create a custom HTTP client that disables SSL verification # OpenAI-compatible endpoints can be used by setting CUSTOM_LLM_BASE_URL.
http_client = httpx.AsyncClient(verify=False) http_client = httpx.AsyncClient(verify=_env_bool("CUSTOM_LLM_VERIFY_SSL", False))
# Create the OpenAI AsyncClient with the custom HTTP client if LLM_BASE_URL:
openai_client = OpenAIAsyncClient( openai_client = OpenAIAsyncClient(
api_key=MINIMAX_API_KEY, api_key=LLM_API_KEY,
base_url=MINIMAX_BASE_URL, base_url=LLM_BASE_URL,
http_client=http_client, http_client=http_client,
) )
else:
openai_client = OpenAIAsyncClient(
api_key=LLM_API_KEY,
http_client=http_client,
)
session: AgentSession = AgentSession( session: AgentSession = AgentSession(
# 1. Custom ASR blackbox with StreamAdapter # 1. Custom ASR blackbox with StreamAdapter
stt=stt_stream, stt=stt_stream,
# 2. Minimax LLM - Using OpenAI plugin with local base_url # 2. OpenAI-compatible LLM, e.g. MiniMax, Qwen, or OpenAI.
llm=openai.LLM( llm=openai.LLM(
model=MINIMAX_MODEL, model=LLM_MODEL,
client=openai_client, client=openai_client,
), ),
# 3. TTS blackbox # 3. TTS blackbox