Skip to content
Merged
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
45 changes: 22 additions & 23 deletions src/llama_stack_client/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,22 @@

from __future__ import annotations

import json

import os
from typing import Any, Union, Mapping
from typing_extensions import Self, override
from typing import Any, Mapping, Union

import httpx
from typing_extensions import override, Self

from . import resources, _exceptions
from . import _exceptions, resources
from ._base_client import AsyncAPIClient, DEFAULT_MAX_RETRIES, SyncAPIClient
from ._exceptions import APIStatusError
from ._qs import Querystring
from ._types import (
NOT_GIVEN,
Omit,
Timeout,
NotGiven,
Transport,
ProxiesTypes,
RequestOptions,
)
from ._utils import (
is_given,
get_async_library,
)
from ._streaming import AsyncStream as AsyncStream, Stream as Stream
from ._types import NOT_GIVEN, NotGiven, Omit, ProxiesTypes, RequestOptions, Timeout, Transport
from ._utils import get_async_library, is_given
from ._version import __version__
from ._streaming import Stream as Stream, AsyncStream as AsyncStream
from ._exceptions import APIStatusError
from ._base_client import (
DEFAULT_MAX_RETRIES,
SyncAPIClient,
AsyncAPIClient,
)

__all__ = [
"Timeout",
Expand Down Expand Up @@ -91,13 +78,19 @@ def __init__(
# outlining your use-case to help us decide if it should be
# part of our public interface in the future.
_strict_response_validation: bool = False,
provider_data: Mapping[str, Any] | None = None,
) -> None:
"""Construct a new synchronous llama-stack-client client instance."""
if base_url is None:
base_url = os.environ.get("LLAMA_STACK_CLIENT_BASE_URL")
if base_url is None:
base_url = f"http://any-hosted-llama-stack.com"

if provider_data:
if default_headers is None:
default_headers = {}
default_headers["X-LlamaStack-ProviderData"] = json.dumps(provider_data)

super().__init__(
version=__version__,
base_url=base_url,
Expand Down Expand Up @@ -274,13 +267,19 @@ def __init__(
# outlining your use-case to help us decide if it should be
# part of our public interface in the future.
_strict_response_validation: bool = False,
provider_data: Mapping[str, Any] | None = None,
) -> None:
"""Construct a new async llama-stack-client client instance."""
if base_url is None:
base_url = os.environ.get("LLAMA_STACK_CLIENT_BASE_URL")
if base_url is None:
base_url = f"http://any-hosted-llama-stack.com"

if provider_data:
if default_headers is None:
default_headers = {}
default_headers["X-LlamaStack-ProviderData"] = json.dumps(provider_data)

super().__init__(
version=__version__,
base_url=base_url,
Expand Down