feat: support beaver llm provider mode

This commit is contained in:
0Xiao0
2026-06-02 11:50:14 +08:00
parent af261d3b63
commit 34cf1b9736
4 changed files with 241 additions and 2 deletions

View File

@ -8,6 +8,7 @@ from collections.abc import AsyncIterable
from dataclasses import dataclass
from pathlib import Path
from beaver_llm import BeaverLLM
from dotenv import load_dotenv
from hermes_gateway import GatewaySessionState, HermesGatewayLLM
from memory import MemoryRecallClient
@ -643,7 +644,14 @@ async def entrypoint(ctx: JobContext) -> None:
TEXT_LLM_MODEL = os.getenv("CUSTOM_TEXT_LLM_MODEL", LLM_MODEL)
VISION_LLM_MODEL = os.getenv("CUSTOM_VISION_LLM_MODEL", LLM_MODEL)
INPUT_MODE = _normalize_input_mode(os.getenv("CUSTOM_AGENT_INPUT_MODE"))
if LLM_PROVIDER not in {"openai", "openai-compatible", "hermes", "hermes_gateway", "openclaw"}:
if LLM_PROVIDER not in {
"openai",
"openai-compatible",
"hermes",
"hermes_gateway",
"openclaw",
"beaver",
}:
raise RuntimeError(f"Unsupported CUSTOM_LLM_PROVIDER={LLM_PROVIDER!r}")
if LLM_PROVIDER in {"openai", "openai-compatible"} and not LLM_API_KEY:
raise RuntimeError(f"CUSTOM_LLM_API_KEY is not set in {CUSTOM_ENV_PATH}")
@ -677,7 +685,36 @@ async def entrypoint(ctx: JobContext) -> None:
)
stt_stream = stt.StreamAdapter(stt=blackbox_stt, vad=ctx.proc.userdata["vad"])
if LLM_PROVIDER in {"hermes", "hermes_gateway", "openclaw"}:
if LLM_PROVIDER == "beaver":
beaver_url = os.getenv("CUSTOM_BEAVER_WS_URL") or os.getenv("BEAVER_WS_URL", "").strip()
if not beaver_url:
raise RuntimeError(f"CUSTOM_BEAVER_WS_URL or BEAVER_WS_URL is not set in {CUSTOM_ENV_PATH}")
beaver_peer_id = (
os.getenv("CUSTOM_BEAVER_PEER_ID")
or os.getenv("BEAVER_PEER_ID")
or f"livekit-{ctx.room.name}"
)
beaver_device_name = (
os.getenv("CUSTOM_BEAVER_DEVICE_NAME")
or os.getenv("BEAVER_DEVICE_NAME")
or "livekit-custom-agent"
)
base_llm = BeaverLLM(
url=beaver_url,
peer_id=beaver_peer_id,
device_name=beaver_device_name,
model_name=os.getenv("CUSTOM_BEAVER_MODEL", "beaver-terminal"),
)
text_llm = base_llm
vision_llm = base_llm
logger.info(
"Using Beaver gateway url=%s peer_id=%s device_name=%s",
beaver_url,
beaver_peer_id,
beaver_device_name,
)
elif LLM_PROVIDER in {"hermes", "hermes_gateway", "openclaw"}:
gateway_url = os.getenv("CUSTOM_HERMES_GATEWAY_URL", "").strip()
if not gateway_url:
raise RuntimeError(f"CUSTOM_HERMES_GATEWAY_URL is not set in {CUSTOM_ENV_PATH}")