File tree 2 files changed +13
-1
lines changed
2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -174,6 +174,7 @@ def init_runtime(self) -> "Runtime":
174
174
raise ValueError (
175
175
f'Failed to check availability of requested model "{ self .model } ": { e } '
176
176
)
177
+
177
178
return self
178
179
179
180
def get_llm_response (self , messages : List [Dict [str , str ]]) -> str :
@@ -343,6 +344,7 @@ def init_runtime(self) -> "Runtime":
343
344
raise ValueError (
344
345
f'Failed to check availability of requested model "{ self .model } ": { e } '
345
346
)
347
+
346
348
return self
347
349
348
350
@field_validator ("concurrency" , mode = "before" )
@@ -355,6 +357,10 @@ def check_concurrency(cls, value) -> int:
355
357
)
356
358
return value
357
359
360
+ @property
361
+ def is_custom_openai_endpoint (self ) -> bool :
362
+ return self .model .startswith ("openai/" ) and self .model_extra .get ("base_url" )
363
+
358
364
async def batch_to_batch (
359
365
self ,
360
366
batch : InternalDataFrame ,
@@ -383,6 +389,12 @@ async def batch_to_batch(
383
389
).tolist ()
384
390
385
391
retries = AsyncRetrying (** RETRY_POLICY )
392
+ if self .is_custom_openai_endpoint :
393
+ # TODO: most of the custom openai endpoints do not support tools mode but json mode
394
+ # we should make it more performant by not creating instructor client on every request
395
+ async_instructor_client = instructor .from_litellm (
396
+ litellm .acompletion , mode = instructor .Mode .JSON
397
+ )
386
398
387
399
tasks = [
388
400
asyncio .ensure_future (
Original file line number Diff line number Diff line change @@ -267,7 +267,7 @@ def extract_indices(self, df):
267
267
input_field_name = self ._get_input_field_name ()
268
268
output_field_name = self ._get_output_field_name ()
269
269
for i , row in df .iterrows ():
270
- if row .get (' _adala_error' ):
270
+ if row .get (" _adala_error" ):
271
271
logger .warning (f"Error in row { i } : { row ['_adala_message' ]} " )
272
272
continue
273
273
text = row [input_field_name ]
You can’t perform that action at this time.
0 commit comments