|
10 | 10 | import litellm |
11 | 11 | import time, logging, asyncio |
12 | 12 | import json, traceback, ast, hashlib |
13 | | -from typing import Optional, Literal, List, Union, Any |
| 13 | +from typing import Optional, Literal, List, Union, Any, BinaryIO |
14 | 14 | from openai._models import BaseModel as OpenAIObject |
15 | 15 | from litellm._logging import verbose_logger |
16 | 16 |
|
@@ -765,8 +765,24 @@ def __init__( |
765 | 765 | password: Optional[str] = None, |
766 | 766 | similarity_threshold: Optional[float] = None, |
767 | 767 | supported_call_types: Optional[ |
768 | | - List[Literal["completion", "acompletion", "embedding", "aembedding"]] |
769 | | - ] = ["completion", "acompletion", "embedding", "aembedding"], |
| 768 | + List[ |
| 769 | + Literal[ |
| 770 | + "completion", |
| 771 | + "acompletion", |
| 772 | + "embedding", |
| 773 | + "aembedding", |
| 774 | + "atranscription", |
| 775 | + "transcription", |
| 776 | + ] |
| 777 | + ] |
| 778 | + ] = [ |
| 779 | + "completion", |
| 780 | + "acompletion", |
| 781 | + "embedding", |
| 782 | + "aembedding", |
| 783 | + "atranscription", |
| 784 | + "transcription", |
| 785 | + ], |
770 | 786 | # s3 Bucket, boto3 configuration |
771 | 787 | s3_bucket_name: Optional[str] = None, |
772 | 788 | s3_region_name: Optional[str] = None, |
@@ -881,9 +897,14 @@ def get_cache_key(self, *args, **kwargs): |
881 | 897 | "input", |
882 | 898 | "encoding_format", |
883 | 899 | ] # embedding kwargs = model, input, user, encoding_format. Model, user are checked in completion_kwargs |
884 | | - |
| 900 | + transcription_only_kwargs = [ |
| 901 | + "file", |
| 902 | + "language", |
| 903 | + ] |
885 | 904 | # combined_kwargs - NEEDS to be ordered across get_cache_key(). Do not use a set() |
886 | | - combined_kwargs = completion_kwargs + embedding_only_kwargs |
| 905 | + combined_kwargs = ( |
| 906 | + completion_kwargs + embedding_only_kwargs + transcription_only_kwargs |
| 907 | + ) |
887 | 908 | for param in combined_kwargs: |
888 | 909 | # ignore litellm params here |
889 | 910 | if param in kwargs: |
@@ -915,6 +936,17 @@ def get_cache_key(self, *args, **kwargs): |
915 | 936 | param_value = ( |
916 | 937 | caching_group or model_group or kwargs[param] |
917 | 938 | ) # use caching_group, if set then model_group if it exists, else use kwargs["model"] |
| 939 | + elif param == "file": |
| 940 | + metadata_file_name = kwargs.get("metadata", {}).get( |
| 941 | + "file_name", None |
| 942 | + ) |
| 943 | + litellm_params_file_name = kwargs.get("litellm_params", {}).get( |
| 944 | + "file_name", None |
| 945 | + ) |
| 946 | + if metadata_file_name is not None: |
| 947 | + param_value = metadata_file_name |
| 948 | + elif litellm_params_file_name is not None: |
| 949 | + param_value = litellm_params_file_name |
918 | 950 | else: |
919 | 951 | if kwargs[param] is None: |
920 | 952 | continue # ignore None params |
@@ -1144,8 +1176,24 @@ def enable_cache( |
1144 | 1176 | port: Optional[str] = None, |
1145 | 1177 | password: Optional[str] = None, |
1146 | 1178 | supported_call_types: Optional[ |
1147 | | - List[Literal["completion", "acompletion", "embedding", "aembedding"]] |
1148 | | - ] = ["completion", "acompletion", "embedding", "aembedding"], |
| 1179 | + List[ |
| 1180 | + Literal[ |
| 1181 | + "completion", |
| 1182 | + "acompletion", |
| 1183 | + "embedding", |
| 1184 | + "aembedding", |
| 1185 | + "atranscription", |
| 1186 | + "transcription", |
| 1187 | + ] |
| 1188 | + ] |
| 1189 | + ] = [ |
| 1190 | + "completion", |
| 1191 | + "acompletion", |
| 1192 | + "embedding", |
| 1193 | + "aembedding", |
| 1194 | + "atranscription", |
| 1195 | + "transcription", |
| 1196 | + ], |
1149 | 1197 | **kwargs, |
1150 | 1198 | ): |
1151 | 1199 | """ |
@@ -1193,8 +1241,24 @@ def update_cache( |
1193 | 1241 | port: Optional[str] = None, |
1194 | 1242 | password: Optional[str] = None, |
1195 | 1243 | supported_call_types: Optional[ |
1196 | | - List[Literal["completion", "acompletion", "embedding", "aembedding"]] |
1197 | | - ] = ["completion", "acompletion", "embedding", "aembedding"], |
| 1244 | + List[ |
| 1245 | + Literal[ |
| 1246 | + "completion", |
| 1247 | + "acompletion", |
| 1248 | + "embedding", |
| 1249 | + "aembedding", |
| 1250 | + "atranscription", |
| 1251 | + "transcription", |
| 1252 | + ] |
| 1253 | + ] |
| 1254 | + ] = [ |
| 1255 | + "completion", |
| 1256 | + "acompletion", |
| 1257 | + "embedding", |
| 1258 | + "aembedding", |
| 1259 | + "atranscription", |
| 1260 | + "transcription", |
| 1261 | + ], |
1198 | 1262 | **kwargs, |
1199 | 1263 | ): |
1200 | 1264 | """ |
|
0 commit comments