(self)
| 2593 | return self |
| 2594 | |
| 2595 | def normalized_input(self) -> List[Union[str, List[int]]]: |
| 2596 | if isinstance(self.input, str): |
| 2597 | return [self._validate_text_input(self.input)] |
| 2598 | if all(isinstance(token, int) for token in self.input): |
| 2599 | return [self._validate_token_input(cast(List[int], self.input))] |
| 2600 | if all(isinstance(item, str) for item in self.input): |
| 2601 | if len(self.input) > 2048: |
| 2602 | raise ValueError("embedding input array must not exceed 2048 items") |
| 2603 | return [ |
| 2604 | self._validate_text_input(item) |
| 2605 | for item in cast(List[str], self.input) |
| 2606 | ] |
| 2607 | if all( |
| 2608 | isinstance(item, list) |
| 2609 | and all(isinstance(token, int) for token in item) |
| 2610 | for item in self.input |
| 2611 | ): |
| 2612 | if len(self.input) > 2048: |
| 2613 | raise ValueError("embedding input array must not exceed 2048 items") |
| 2614 | return [ |
| 2615 | self._validate_token_input(item) |
| 2616 | for item in cast(List[List[int]], self.input) |
| 2617 | ] |
| 2618 | raise ValueError( |
| 2619 | "embedding input must be a string, list of strings, token ids, or list of token-id lists" |
| 2620 | ) |
| 2621 | |
| 2622 | |
| 2623 | class EmbeddingDataResponse(BaseModel): |
no test coverage detected