Skip to content
Merged
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
2 changes: 1 addition & 1 deletion scripts/mock

Large diffs are not rendered by default.

14 changes: 12 additions & 2 deletions src/sambanova/resources/embeddings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

from __future__ import annotations

from typing import Union
from typing import Union, Optional
from typing_extensions import Literal

import httpx

from ..types import embedding_create_params
from .._types import Body, Query, Headers, NotGiven, SequenceNotStr, not_given
from .._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given
from .._utils import maybe_transform, async_maybe_transform
from .._compat import cached_property
from .._resource import SyncAPIResource, AsyncAPIResource
Expand Down Expand Up @@ -49,6 +49,7 @@ def create(
*,
input: Union[str, SequenceNotStr[str]],
model: Union[str, Literal["E5-Mistral-7B-Instruct"]],
encoding_format: Optional[Literal["float", "base64"]] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand All @@ -67,6 +68,9 @@ def create(
model: The model ID to use See available
[models](https://docs.sambanova.ai/docs/en/models/sambacloud-models)

encoding_format: The format to return the embeddings in. Can be either `float` or `base64`.
Omitted from the request when not set.

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request
Expand All @@ -81,6 +85,7 @@ def create(
{
"input": input,
"model": model,
"encoding_format": encoding_format,
},
embedding_create_params.EmbeddingCreateParams,
),
Expand Down Expand Up @@ -116,6 +121,7 @@ async def create(
*,
input: Union[str, SequenceNotStr[str]],
model: Union[str, Literal["E5-Mistral-7B-Instruct"]],
encoding_format: Optional[Literal["float", "base64"]] | Omit = omit,
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
# The extra values given here take precedence over values defined on the client or passed to this method.
extra_headers: Headers | None = None,
Expand All @@ -134,6 +140,9 @@ async def create(
model: The model ID to use See available
[models](https://docs.sambanova.ai/docs/en/models/sambacloud-models)

encoding_format: The format to return the embeddings in. Can be either `float` or `base64`.
Omitted from the request when not set.

extra_headers: Send extra headers

extra_query: Add additional query parameters to the request
Expand All @@ -148,6 +157,7 @@ async def create(
{
"input": input,
"model": model,
"encoding_format": encoding_format,
},
embedding_create_params.EmbeddingCreateParams,
),
Expand Down
8 changes: 7 additions & 1 deletion src/sambanova/types/embedding_create_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from __future__ import annotations

from typing import Union
from typing import Union, Optional
from typing_extensions import Literal, Required, TypedDict

from .._types import SequenceNotStr
Expand All @@ -23,3 +23,9 @@ class EmbeddingCreateParams(TypedDict, total=False):
The model ID to use See available
[models](https://docs.sambanova.ai/docs/en/models/sambacloud-models)
"""

encoding_format: Optional[Literal["float", "base64"]]
"""The format to return the embeddings in.

Can be either `float` or `base64`. Omitted from the request when not set.
"""
18 changes: 18 additions & 0 deletions tests/api_resources/test_embeddings.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ def test_method_create(self, client: SambaNova) -> None:
)
assert_matches_type(EmbeddingsResponse, embedding, path=["response"])

@parametrize
def test_method_create_with_all_params(self, client: SambaNova) -> None:
embedding = client.embeddings.create(
input=["text to embed number 1", "text to embed number 2"],
model="E5-Mistral-7B-Instruct",
encoding_format="float",
)
assert_matches_type(EmbeddingsResponse, embedding, path=["response"])

@parametrize
def test_raw_response_create(self, client: SambaNova) -> None:
response = client.embeddings.with_raw_response.create(
Expand Down Expand Up @@ -65,6 +74,15 @@ async def test_method_create(self, async_client: AsyncSambaNova) -> None:
)
assert_matches_type(EmbeddingsResponse, embedding, path=["response"])

@parametrize
async def test_method_create_with_all_params(self, async_client: AsyncSambaNova) -> None:
embedding = await async_client.embeddings.create(
input=["text to embed number 1", "text to embed number 2"],
model="E5-Mistral-7B-Instruct",
encoding_format="float",
)
assert_matches_type(EmbeddingsResponse, embedding, path=["response"])

@parametrize
async def test_raw_response_create(self, async_client: AsyncSambaNova) -> None:
response = await async_client.embeddings.with_raw_response.create(
Expand Down
Loading