LMStudioProvider
Base classes
| Name |
Children |
Inherits |
Provider pydantic_ai.providers Abstract class for a provider. |
|
|
â‹” Inheritance diagram
graph TD
199369848["lm_studio_provider.LMStudioProvider"]
1392801764["providers.Provider"]
925645236["abc.ABC"]
2751680898["builtins.object"]
3481597255["typing.Generic"]
1392801764 --> 199369848
925645236 --> 1392801764
2751680898 --> 925645236
3481597255 --> 1392801764
2751680898 --> 3481597255
🛈 DocStrings
Bases: Provider[AsyncOpenAI]
Provider for LM Studio local API.
Source code in src/llmling_models/providers/lm_studio_provider.py
| class LMStudioProvider(Provider[AsyncOpenAI]):
"""Provider for LM Studio local API."""
@property
def name(self) -> str:
"""The provider name."""
return "lm-studio"
@property
def base_url(self) -> str:
"""The base URL for the provider API."""
return os.environ.get("LM_STUDIO_BASE_URL", "http://localhost:1234/v1")
@property
def client(self) -> AsyncOpenAI:
"""Get a client configured for LM Studio."""
return self._client
@overload
def __init__(self) -> None: ...
@overload
def __init__(self, *, base_url: str) -> None: ...
@overload
def __init__(self, *, base_url: str, http_client: AsyncHTTPClient) -> None: ...
@overload
def __init__(self, *, openai_client: AsyncOpenAI | None = None) -> None: ...
def __init__(
self,
*,
base_url: str | None = None,
openai_client: AsyncOpenAI | None = None,
http_client: AsyncHTTPClient | None = None,
) -> None:
"""Initialize provider for LM Studio.
Args:
base_url: The base URL for the API, defaults to http://localhost:1234/v1
openai_client: An existing AsyncOpenAI client to use.
If provided, other parameters must be None.
http_client: An existing AsyncHTTPClient to use for making HTTP requests.
"""
self._base_url = base_url or self.base_url
if openai_client is not None:
assert http_client is None, "Cannot provide both `openai_client` and `http_client`"
assert base_url is None, "Cannot provide both `openai_client` and `base_url`"
self._client = openai_client
elif http_client is not None:
self._client = AsyncOpenAI(
base_url=self._base_url,
api_key="lm-studio", # Not actually used
http_client=http_client,
)
else:
self._client = AsyncOpenAI(
base_url=self._base_url,
api_key="lm-studio", # Not actually used
http_client=_create_http_client(),
)
|
base_url
property
The base URL for the provider API.
client
property
Get a client configured for LM Studio.
__init__
__init__(*, base_url: str) -> None
__init__(*, base_url: str, http_client: AsyncClient) -> None
__init__(*, openai_client: AsyncOpenAI | None = None) -> None
__init__(
*,
base_url: str | None = None,
openai_client: AsyncOpenAI | None = None,
http_client: AsyncClient | None = None,
) -> None
Initialize provider for LM Studio.
Parameters:
| Name |
Type |
Description |
Default |
base_url
|
str | None
|
The base URL for the API, defaults to http://localhost:1234/v1
|
None
|
openai_client
|
AsyncOpenAI | None
|
An existing AsyncOpenAI client to use.
If provided, other parameters must be None.
|
None
|
http_client
|
AsyncClient | None
|
An existing AsyncHTTPClient to use for making HTTP requests.
|
None
|
Source code in src/llmling_models/providers/lm_studio_provider.py
| def __init__(
self,
*,
base_url: str | None = None,
openai_client: AsyncOpenAI | None = None,
http_client: AsyncHTTPClient | None = None,
) -> None:
"""Initialize provider for LM Studio.
Args:
base_url: The base URL for the API, defaults to http://localhost:1234/v1
openai_client: An existing AsyncOpenAI client to use.
If provided, other parameters must be None.
http_client: An existing AsyncHTTPClient to use for making HTTP requests.
"""
self._base_url = base_url or self.base_url
if openai_client is not None:
assert http_client is None, "Cannot provide both `openai_client` and `http_client`"
assert base_url is None, "Cannot provide both `openai_client` and `base_url`"
self._client = openai_client
elif http_client is not None:
self._client = AsyncOpenAI(
base_url=self._base_url,
api_key="lm-studio", # Not actually used
http_client=http_client,
)
else:
self._client = AsyncOpenAI(
base_url=self._base_url,
api_key="lm-studio", # Not actually used
http_client=_create_http_client(),
)
|
:fa-brands-github: Show source on GitHub