datarobot-moderations 11.2.7__py3-none-any.whl → 11.2.9__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,6 +18,7 @@ import time
18
18
  import traceback
19
19
  import uuid
20
20
  from collections.abc import Iterable
21
+ from inspect import signature
21
22
  from typing import Optional
22
23
 
23
24
  import numpy as np
@@ -483,7 +484,15 @@ def run_user_chat_function(completion_create_params, model, pipeline, drum_chat_
483
484
  start_time = time.time()
484
485
 
485
486
  try:
486
- chat_completion = drum_chat_fn(completion_create_params, model, **kwargs)
487
+ # the standard chat hook takes only the first 2 parameters
488
+ # if so, passing in extra (such as headers=headers) will trigger a TypeError
489
+ # same logic is in DRUM PythonModelAdapter.chat()
490
+ chat_fn_params = signature(drum_chat_fn).parameters
491
+ if len(chat_fn_params) > 2:
492
+ chat_completion = drum_chat_fn(completion_create_params, model, **kwargs)
493
+ else:
494
+ _logger.debug("run_user_chat_function: chat hook takes 2 args; kwargs are discarded")
495
+ chat_completion = drum_chat_fn(completion_create_params, model)
487
496
  except Exception as e:
488
497
  _logger.error(f"Failed to execute user chat function: {e}")
489
498
  raise
@@ -369,7 +369,7 @@ def get_chat_nvidia_llm(api_key: str, base_url: str) -> ChatNVIDIA:
369
369
  # This registration is for the sake of NeMo guardrails to find
370
370
  # the datarobot LLM
371
371
  register_model(nim_model)
372
- return ChatNVIDIA(model=nim_model.id, api_key=api_key)
372
+ return ChatNVIDIA(model=nim_model.id, api_key=api_key, base_url=base_url)
373
373
 
374
374
 
375
375
  def calculate_faithfulness(
@@ -250,8 +250,17 @@ class ModerationIterator:
250
250
  self.aggregated_metrics_df = postscore_df_assembled
251
251
  postscore_df = postscore_df_assembled
252
252
 
253
+ # It's possible (but not a normal case) to get an empty first chunk where content is None
254
+ # This leads to KeyError: 'promptText' when attempting to merge
255
+ # Log a warning, and use postscore DF for moderations (as if not first chunk)
253
256
  if self.first_chunk:
254
- moderations_df = postscore_df.merge(self.prescore_df, on=list(self.input_df.columns))
257
+ try:
258
+ moderations_df = postscore_df.merge(
259
+ self.prescore_df, on=list(self.input_df.columns)
260
+ )
261
+ except KeyError as e:
262
+ self.logger.warning(f"received first chunk with possible empty content; {e}")
263
+ moderations_df = postscore_df
255
264
  self.first_chunk = False
256
265
  else:
257
266
  moderations_df = postscore_df
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: datarobot-moderations
3
- Version: 11.2.7
3
+ Version: 11.2.9
4
4
  Summary: DataRobot Monitoring and Moderation framework
5
5
  License: DataRobot Tool and Utility Agreement
6
6
  Author: DataRobot
@@ -2,10 +2,10 @@ datarobot_dome/__init__.py,sha256=B5Rx8_CNCNsOpxBbRj27XOXCfRZmvmrAR-NzlzIKnDw,58
2
2
  datarobot_dome/async_http_client.py,sha256=YVkzSSP7ItOEwEskjH0MAs1kJW0jXfbvJWkF_52K7CE,9863
3
3
  datarobot_dome/chat_helper.py,sha256=BzvtUyZSZxzOqq-5a2wQKhHhr2kMlcP1MFrHaDAeD_o,9671
4
4
  datarobot_dome/constants.py,sha256=jvgpHa3Wh_nZVZmfU-6ab8FHnKNW3KxOPYIIEb_oS6U,10662
5
- datarobot_dome/drum_integration.py,sha256=SLKpK-0pI9Dsi6iMBVhPv_w-SF0rqs2of-OYF3_KSPk,45983
5
+ datarobot_dome/drum_integration.py,sha256=XcQRaUKQWCGCX9WwiViQQnUy4ZGMzS_FKpkVygg3W1M,46511
6
6
  datarobot_dome/guard.py,sha256=xJds9hcbUaS-KD5nC1mn0GiPdBrileFUu6BuTAjDNuY,34668
7
7
  datarobot_dome/guard_executor.py,sha256=ox5_jOHcqMaxaaagIYJJHhCwEI7Wg-rUEiu5rutsfVU,35363
8
- datarobot_dome/guard_helpers.py,sha256=jfu8JTWCcxu4WD1MKxeP1n53DeebY3SSuP-t5sWyV1U,17187
8
+ datarobot_dome/guard_helpers.py,sha256=29bLktNjvtC7rU4StXADz_FQ1OwIF2xMEKf9GxUd77Q,17206
9
9
  datarobot_dome/guards/__init__.py,sha256=B5Rx8_CNCNsOpxBbRj27XOXCfRZmvmrAR-NzlzIKnDw,583
10
10
  datarobot_dome/guards/guard_llm_mixin.py,sha256=OIjOHeIAwJiM8BQOfqj1fY2jy-jJfc_CNToYrzG_6xk,11871
11
11
  datarobot_dome/llm.py,sha256=L02OvTrflmD34-FrfXebfF-zzKTeuin7fpne1Cl5psg,5719
@@ -18,7 +18,7 @@ datarobot_dome/pipeline/llm_pipeline.py,sha256=bindyorJq9VSPZt2X8w0-3REaXui7wIA-
18
18
  datarobot_dome/pipeline/pipeline.py,sha256=vCcP8dgu4TE-af6wUt7RqD4Xg7MzfwfK8njjC4XLnIA,19249
19
19
  datarobot_dome/pipeline/vdb_pipeline.py,sha256=zt5d_41oJjdT8qOtvpgz-l5uvImwKE9f6pQsAU_TdR4,9866
20
20
  datarobot_dome/runtime.py,sha256=FD8wXOweqoQVzbZMh-mucL66xT2kGxPsJUGAcJBgwxw,1468
21
- datarobot_dome/streaming.py,sha256=DkvKEH0yN0aPEWMTAjMFJB3Kx4iLGdjUMQU1pAplbeg,17751
22
- datarobot_moderations-11.2.7.dist-info/METADATA,sha256=RqNHfInWAiYqI346wVcJEwZj2sTvJ3qvC9FXZEEKLAE,4741
23
- datarobot_moderations-11.2.7.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
24
- datarobot_moderations-11.2.7.dist-info/RECORD,,
21
+ datarobot_dome/streaming.py,sha256=TusPJ5nf0HWvdUdfg_DGHfNCqnkFoEb3bmpVDh5fCLc,18240
22
+ datarobot_moderations-11.2.9.dist-info/METADATA,sha256=JBlItnj4n7fZmjh7rBOHZaKo_0Zi9z9EfVYkQ3hrJ9Q,4741
23
+ datarobot_moderations-11.2.9.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
24
+ datarobot_moderations-11.2.9.dist-info/RECORD,,