Skip to content

Commit b7a1559

Browse files
authored
Sync updates from stainless branch: hardikjshah/dev (#242)
Updated name of `EmbeddingsResponse` to `CreateEmbeddingsResponse` for endpoint - `v1/openai/v1/embeddings/`
1 parent 6d3dba0 commit b7a1559

File tree

6 files changed

+70
-50
lines changed

6 files changed

+70
-50
lines changed

src/llama_stack_client/resources/embeddings.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
async_to_streamed_response_wrapper,
1919
)
2020
from .._base_client import make_request_options
21-
from ..types.embeddings_response import EmbeddingsResponse
21+
from ..types.create_embeddings_response import CreateEmbeddingsResponse
2222

2323
__all__ = ["EmbeddingsResource", "AsyncEmbeddingsResource"]
2424

@@ -57,7 +57,7 @@ def create(
5757
extra_query: Query | None = None,
5858
extra_body: Body | None = None,
5959
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
60-
) -> EmbeddingsResponse:
60+
) -> CreateEmbeddingsResponse:
6161
"""
6262
Generate OpenAI-compatible embeddings for the given input using the specified
6363
model.
@@ -101,7 +101,7 @@ def create(
101101
options=make_request_options(
102102
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
103103
),
104-
cast_to=EmbeddingsResponse,
104+
cast_to=CreateEmbeddingsResponse,
105105
)
106106

107107

@@ -139,7 +139,7 @@ async def create(
139139
extra_query: Query | None = None,
140140
extra_body: Body | None = None,
141141
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
142-
) -> EmbeddingsResponse:
142+
) -> CreateEmbeddingsResponse:
143143
"""
144144
Generate OpenAI-compatible embeddings for the given input using the specified
145145
model.
@@ -183,7 +183,7 @@ async def create(
183183
options=make_request_options(
184184
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
185185
),
186-
cast_to=EmbeddingsResponse,
186+
cast_to=CreateEmbeddingsResponse,
187187
)
188188

189189

src/llama_stack_client/types/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@
119119
from .toolgroup_register_params import ToolgroupRegisterParams as ToolgroupRegisterParams
120120
from .vector_db_register_params import VectorDBRegisterParams as VectorDBRegisterParams
121121
from .completion_create_response import CompletionCreateResponse as CompletionCreateResponse
122+
from .create_embeddings_response import CreateEmbeddingsResponse as CreateEmbeddingsResponse
122123
from .eval_run_eval_alpha_params import EvalRunEvalAlphaParams as EvalRunEvalAlphaParams
123124
from .scoring_score_batch_params import ScoringScoreBatchParams as ScoringScoreBatchParams
124125
from .telemetry_log_event_params import TelemetryLogEventParams as TelemetryLogEventParams
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
from typing import List, Union
4+
from typing_extensions import Literal
5+
6+
from .._models import BaseModel
7+
8+
__all__ = ["CreateEmbeddingsResponse", "Data", "Usage"]
9+
10+
11+
class Data(BaseModel):
12+
embedding: Union[List[float], str]
13+
"""
14+
The embedding vector as a list of floats (when encoding_format="float") or as a
15+
base64-encoded string (when encoding_format="base64")
16+
"""
17+
18+
index: int
19+
"""The index of the embedding in the input list"""
20+
21+
object: Literal["embedding"]
22+
"""The object type, which will be "embedding" """
23+
24+
25+
class Usage(BaseModel):
26+
prompt_tokens: int
27+
"""The number of tokens in the input"""
28+
29+
total_tokens: int
30+
"""The total number of tokens used"""
31+
32+
33+
class CreateEmbeddingsResponse(BaseModel):
34+
data: List[Data]
35+
"""List of embedding data objects"""
36+
37+
model: str
38+
"""The model that was used to generate the embeddings"""
39+
40+
object: Literal["list"]
41+
"""The object type, which will be "list" """
42+
43+
usage: Usage
44+
"""Usage information"""

src/llama_stack_client/types/dataset_iterrows_response.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3-
from typing import Dict, List, Union
3+
from typing import Dict, List, Union, Optional
44

55
from .._models import BaseModel
66

@@ -13,3 +13,6 @@ class DatasetIterrowsResponse(BaseModel):
1313

1414
has_more: bool
1515
"""Whether there are more items available after this set"""
16+
17+
url: Optional[str] = None
18+
"""The URL for accessing this list"""
Lines changed: 7 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,16 @@
11
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
22

3-
from typing import List, Union
4-
from typing_extensions import Literal
3+
from typing import List
54

65
from .._models import BaseModel
76

8-
__all__ = ["EmbeddingsResponse", "Data", "Usage"]
9-
10-
11-
class Data(BaseModel):
12-
embedding: Union[List[float], str]
13-
"""
14-
The embedding vector as a list of floats (when encoding_format="float") or as a
15-
base64-encoded string (when encoding_format="base64")
16-
"""
17-
18-
index: int
19-
"""The index of the embedding in the input list"""
20-
21-
object: Literal["embedding"]
22-
"""The object type, which will be "embedding" """
23-
24-
25-
class Usage(BaseModel):
26-
prompt_tokens: int
27-
"""The number of tokens in the input"""
28-
29-
total_tokens: int
30-
"""The total number of tokens used"""
7+
__all__ = ["EmbeddingsResponse"]
318

329

3310
class EmbeddingsResponse(BaseModel):
34-
data: List[Data]
35-
"""List of embedding data objects"""
11+
embeddings: List[List[float]]
12+
"""List of embedding vectors, one per input content.
3613
37-
model: str
38-
"""The model that was used to generate the embeddings"""
39-
40-
object: Literal["list"]
41-
"""The object type, which will be "list" """
42-
43-
usage: Usage
44-
"""Usage information"""
14+
Each embedding is a list of floats. The dimensionality of the embedding is
15+
model-specific; you can check model metadata using /models/{model_id}
16+
"""

tests/api_resources/test_embeddings.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
from tests.utils import assert_matches_type
1111
from llama_stack_client import LlamaStackClient, AsyncLlamaStackClient
12-
from llama_stack_client.types import EmbeddingsResponse
12+
from llama_stack_client.types import CreateEmbeddingsResponse
1313

1414
base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010")
1515

@@ -23,7 +23,7 @@ def test_method_create(self, client: LlamaStackClient) -> None:
2323
input="string",
2424
model="model",
2525
)
26-
assert_matches_type(EmbeddingsResponse, embedding, path=["response"])
26+
assert_matches_type(CreateEmbeddingsResponse, embedding, path=["response"])
2727

2828
@parametrize
2929
def test_method_create_with_all_params(self, client: LlamaStackClient) -> None:
@@ -34,7 +34,7 @@ def test_method_create_with_all_params(self, client: LlamaStackClient) -> None:
3434
encoding_format="encoding_format",
3535
user="user",
3636
)
37-
assert_matches_type(EmbeddingsResponse, embedding, path=["response"])
37+
assert_matches_type(CreateEmbeddingsResponse, embedding, path=["response"])
3838

3939
@parametrize
4040
def test_raw_response_create(self, client: LlamaStackClient) -> None:
@@ -46,7 +46,7 @@ def test_raw_response_create(self, client: LlamaStackClient) -> None:
4646
assert response.is_closed is True
4747
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
4848
embedding = response.parse()
49-
assert_matches_type(EmbeddingsResponse, embedding, path=["response"])
49+
assert_matches_type(CreateEmbeddingsResponse, embedding, path=["response"])
5050

5151
@parametrize
5252
def test_streaming_response_create(self, client: LlamaStackClient) -> None:
@@ -58,7 +58,7 @@ def test_streaming_response_create(self, client: LlamaStackClient) -> None:
5858
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
5959

6060
embedding = response.parse()
61-
assert_matches_type(EmbeddingsResponse, embedding, path=["response"])
61+
assert_matches_type(CreateEmbeddingsResponse, embedding, path=["response"])
6262

6363
assert cast(Any, response.is_closed) is True
6464

@@ -72,7 +72,7 @@ async def test_method_create(self, async_client: AsyncLlamaStackClient) -> None:
7272
input="string",
7373
model="model",
7474
)
75-
assert_matches_type(EmbeddingsResponse, embedding, path=["response"])
75+
assert_matches_type(CreateEmbeddingsResponse, embedding, path=["response"])
7676

7777
@parametrize
7878
async def test_method_create_with_all_params(self, async_client: AsyncLlamaStackClient) -> None:
@@ -83,7 +83,7 @@ async def test_method_create_with_all_params(self, async_client: AsyncLlamaStack
8383
encoding_format="encoding_format",
8484
user="user",
8585
)
86-
assert_matches_type(EmbeddingsResponse, embedding, path=["response"])
86+
assert_matches_type(CreateEmbeddingsResponse, embedding, path=["response"])
8787

8888
@parametrize
8989
async def test_raw_response_create(self, async_client: AsyncLlamaStackClient) -> None:
@@ -95,7 +95,7 @@ async def test_raw_response_create(self, async_client: AsyncLlamaStackClient) ->
9595
assert response.is_closed is True
9696
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
9797
embedding = await response.parse()
98-
assert_matches_type(EmbeddingsResponse, embedding, path=["response"])
98+
assert_matches_type(CreateEmbeddingsResponse, embedding, path=["response"])
9999

100100
@parametrize
101101
async def test_streaming_response_create(self, async_client: AsyncLlamaStackClient) -> None:
@@ -107,6 +107,6 @@ async def test_streaming_response_create(self, async_client: AsyncLlamaStackClie
107107
assert response.http_request.headers.get("X-Stainless-Lang") == "python"
108108

109109
embedding = await response.parse()
110-
assert_matches_type(EmbeddingsResponse, embedding, path=["response"])
110+
assert_matches_type(CreateEmbeddingsResponse, embedding, path=["response"])
111111

112112
assert cast(Any, response.is_closed) is True

0 commit comments

Comments
 (0)