Skip to content
Open
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
14 changes: 11 additions & 3 deletions src/openai/resources/embeddings.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from __future__ import annotations

import base64
from typing import List, Union, Iterable, cast
from typing import List, Tuple, Union, Iterable, cast
from typing_extensions import Literal

import httpx
Expand Down Expand Up @@ -46,7 +46,7 @@ def with_streaming_response(self) -> EmbeddingsWithStreamingResponse:
def create(
self,
*,
input: Union[str, List[str], Iterable[int], Iterable[Iterable[int]]],
input: Union[str, List[str], Tuple[str, ...], Iterable[int], Iterable[Iterable[int]]],
model: Union[str, EmbeddingModel],
dimensions: int | NotGiven = NOT_GIVEN,
encoding_format: Literal["float", "base64"] | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -94,6 +94,10 @@ def create(

timeout: Override the client-level default timeout for this request, in seconds
"""

if isinstance(input, tuple) and all(isinstance(item, str) for item in input):
input = list(input)

params = {
"input": input,
"model": model,
Expand Down Expand Up @@ -158,7 +162,7 @@ def with_streaming_response(self) -> AsyncEmbeddingsWithStreamingResponse:
async def create(
self,
*,
input: Union[str, List[str], Iterable[int], Iterable[Iterable[int]]],
input: Union[str, List[str], Tuple[str, ...], Iterable[int], Iterable[Iterable[int]]],
model: Union[str, EmbeddingModel],
dimensions: int | NotGiven = NOT_GIVEN,
encoding_format: Literal["float", "base64"] | NotGiven = NOT_GIVEN,
Expand Down Expand Up @@ -206,6 +210,10 @@ async def create(

timeout: Override the client-level default timeout for this request, in seconds
"""

if isinstance(input, tuple) and all(isinstance(item, str) for item in input):
input = list(input)

params = {
"input": input,
"model": model,
Expand Down