Description
Confirm this is a feature request for the Python library and not the underlying OpenAI API.
- This is a feature request for the Python library
Describe the feature or improvement you're requesting
Currently the type for input
in Embeddings.create is: Union[str, List[str], Iterable[int], Iterable[Iterable[int]]]
. It would be nice if the documented type could be expanded to support tuple[str]
as well. Passing a tuple of strings works in local testing. The narrow type definition makes type checking tools complain needlessly. Supporting a tuple is useful because it allows for combining with itertools.batched
to break large inputs into acceptable blocks.
Current alternatives are to convert the tuple to a list (unnecessary copy), or input=cast(list[str], input)
(type hole/fragility).
Additional context
Specific function being discussed:
openai-python/src/openai/resources/embeddings.py
Lines 46 to 60 in 995cce0
And the async variant:
openai-python/src/openai/resources/embeddings.py
Lines 158 to 172 in 995cce0