Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions livekit-agents/livekit/agents/inference/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ def __init__(
self._client = openai.AsyncClient(
api_key=create_access_token(self._opts.api_key, self._opts.api_secret),
base_url=self._opts.base_url,
max_retries=0,
http_client=httpx.AsyncClient(
timeout=httpx.Timeout(connect=15.0, read=5.0, write=5.0, pool=5.0),
follow_redirects=True,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@

from __future__ import annotations

import logging
import os
import warnings
from dataclasses import asdict, dataclass
from typing import Any, Literal
from urllib.parse import urlparse
Expand Down Expand Up @@ -57,6 +59,7 @@
)
from .utils import AsyncAzureADTokenProvider

logger = logging.getLogger(__name__)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
logger = logging.getLogger(__name__)

lk_oai_debug = int(os.getenv("LK_OPENAI_DEBUG", 0))

Verbosity = Literal["low", "medium", "high"]
Expand Down Expand Up @@ -155,13 +158,22 @@ def __init__(
" OPENAI_API_KEY environment variable"
)

if is_given(max_retries) and max_retries > 0:
warnings.warn(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We deprecate using the logger in other parts of the code:

"max_retries is deprecated for openai.LLM and will be ignored. "
"Retries are handled by the framework via APIConnectOptions.max_retry. "
"Setting max_retries on the SDK client causes compounding retries.",
DeprecationWarning,
stacklevel=2,
)

self._provider_fmt = _provider_fmt or "openai"
self._strict_tool_schema = _strict_tool_schema
self._owns_client = client is None
self._client = client or openai.AsyncClient(
api_key=api_key if is_given(api_key) else None,
base_url=base_url if is_given(base_url) else None,
max_retries=max_retries if is_given(max_retries) else 0,
max_retries=0,
http_client=httpx.AsyncClient(
timeout=timeout
if timeout
Expand Down
Loading