ibm-watsonx-gov 1.3.3__cp313-cp313-macosx_11_0_arm64.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.
- ibm_watsonx_gov/__init__.py +8 -0
- ibm_watsonx_gov/agent_catalog/__init__.py +8 -0
- ibm_watsonx_gov/agent_catalog/clients/__init__.py +14 -0
- ibm_watsonx_gov/agent_catalog/clients/ai_agent_client.py +333 -0
- ibm_watsonx_gov/agent_catalog/core/__init__.py +8 -0
- ibm_watsonx_gov/agent_catalog/core/agent_loader.py +202 -0
- ibm_watsonx_gov/agent_catalog/core/agents.py +134 -0
- ibm_watsonx_gov/agent_catalog/entities/__init__.py +8 -0
- ibm_watsonx_gov/agent_catalog/entities/ai_agent.py +599 -0
- ibm_watsonx_gov/agent_catalog/utils/__init__.py +8 -0
- ibm_watsonx_gov/agent_catalog/utils/constants.py +36 -0
- ibm_watsonx_gov/agent_catalog/utils/notebook_utils.py +70 -0
- ibm_watsonx_gov/ai_experiments/__init__.py +8 -0
- ibm_watsonx_gov/ai_experiments/ai_experiments_client.py +980 -0
- ibm_watsonx_gov/ai_experiments/utils/__init__.py +8 -0
- ibm_watsonx_gov/ai_experiments/utils/ai_experiment_utils.py +139 -0
- ibm_watsonx_gov/clients/__init__.py +0 -0
- ibm_watsonx_gov/clients/api_client.py +99 -0
- ibm_watsonx_gov/clients/segment_client.py +46 -0
- ibm_watsonx_gov/clients/usage_client.cpython-313-darwin.so +0 -0
- ibm_watsonx_gov/clients/wx_ai_client.py +87 -0
- ibm_watsonx_gov/config/__init__.py +14 -0
- ibm_watsonx_gov/config/agentic_ai_configuration.py +225 -0
- ibm_watsonx_gov/config/gen_ai_configuration.py +129 -0
- ibm_watsonx_gov/config/model_risk_configuration.py +173 -0
- ibm_watsonx_gov/config/predictive_ai_configuration.py +20 -0
- ibm_watsonx_gov/entities/__init__.py +8 -0
- ibm_watsonx_gov/entities/agentic_app.py +209 -0
- ibm_watsonx_gov/entities/agentic_evaluation_result.py +185 -0
- ibm_watsonx_gov/entities/ai_evaluation.py +290 -0
- ibm_watsonx_gov/entities/ai_experiment.py +419 -0
- ibm_watsonx_gov/entities/base_classes.py +134 -0
- ibm_watsonx_gov/entities/container.py +54 -0
- ibm_watsonx_gov/entities/credentials.py +633 -0
- ibm_watsonx_gov/entities/criteria.py +508 -0
- ibm_watsonx_gov/entities/enums.py +274 -0
- ibm_watsonx_gov/entities/evaluation_result.py +444 -0
- ibm_watsonx_gov/entities/foundation_model.py +490 -0
- ibm_watsonx_gov/entities/llm_judge.py +44 -0
- ibm_watsonx_gov/entities/locale.py +17 -0
- ibm_watsonx_gov/entities/mapping.py +49 -0
- ibm_watsonx_gov/entities/metric.py +211 -0
- ibm_watsonx_gov/entities/metric_threshold.py +36 -0
- ibm_watsonx_gov/entities/model_provider.py +329 -0
- ibm_watsonx_gov/entities/model_risk_result.py +43 -0
- ibm_watsonx_gov/entities/monitor.py +71 -0
- ibm_watsonx_gov/entities/prompt_setup.py +40 -0
- ibm_watsonx_gov/entities/state.py +22 -0
- ibm_watsonx_gov/entities/utils.py +99 -0
- ibm_watsonx_gov/evaluators/__init__.py +26 -0
- ibm_watsonx_gov/evaluators/agentic_evaluator.py +2725 -0
- ibm_watsonx_gov/evaluators/agentic_traces_evaluator.py +115 -0
- ibm_watsonx_gov/evaluators/base_evaluator.py +22 -0
- ibm_watsonx_gov/evaluators/impl/__init__.py +0 -0
- ibm_watsonx_gov/evaluators/impl/evaluate_metrics_impl.cpython-313-darwin.so +0 -0
- ibm_watsonx_gov/evaluators/impl/evaluate_model_risk_impl.cpython-313-darwin.so +0 -0
- ibm_watsonx_gov/evaluators/metrics_evaluator.py +187 -0
- ibm_watsonx_gov/evaluators/model_risk_evaluator.py +89 -0
- ibm_watsonx_gov/evaluators/traces_evaluator.py +93 -0
- ibm_watsonx_gov/metric_groups/answer_quality/answer_quality_decorator.py +66 -0
- ibm_watsonx_gov/metric_groups/content_safety/content_safety_decorator.py +76 -0
- ibm_watsonx_gov/metric_groups/readability/readability_decorator.py +59 -0
- ibm_watsonx_gov/metric_groups/retrieval_quality/retrieval_quality_decorator.py +63 -0
- ibm_watsonx_gov/metric_groups/usage/usage_decorator.py +58 -0
- ibm_watsonx_gov/metrics/__init__.py +74 -0
- ibm_watsonx_gov/metrics/answer_relevance/__init__.py +8 -0
- ibm_watsonx_gov/metrics/answer_relevance/answer_relevance_decorator.py +63 -0
- ibm_watsonx_gov/metrics/answer_relevance/answer_relevance_metric.py +260 -0
- ibm_watsonx_gov/metrics/answer_similarity/__init__.py +0 -0
- ibm_watsonx_gov/metrics/answer_similarity/answer_similarity_decorator.py +66 -0
- ibm_watsonx_gov/metrics/answer_similarity/answer_similarity_metric.py +219 -0
- ibm_watsonx_gov/metrics/average_precision/__init__.py +0 -0
- ibm_watsonx_gov/metrics/average_precision/average_precision_decorator.py +62 -0
- ibm_watsonx_gov/metrics/average_precision/average_precision_metric.py +174 -0
- ibm_watsonx_gov/metrics/base_metric_decorator.py +193 -0
- ibm_watsonx_gov/metrics/context_relevance/__init__.py +8 -0
- ibm_watsonx_gov/metrics/context_relevance/context_relevance_decorator.py +60 -0
- ibm_watsonx_gov/metrics/context_relevance/context_relevance_metric.py +414 -0
- ibm_watsonx_gov/metrics/cost/__init__.py +8 -0
- ibm_watsonx_gov/metrics/cost/cost_decorator.py +58 -0
- ibm_watsonx_gov/metrics/cost/cost_metric.py +155 -0
- ibm_watsonx_gov/metrics/duration/__init__.py +8 -0
- ibm_watsonx_gov/metrics/duration/duration_decorator.py +59 -0
- ibm_watsonx_gov/metrics/duration/duration_metric.py +111 -0
- ibm_watsonx_gov/metrics/evasiveness/__init__.py +8 -0
- ibm_watsonx_gov/metrics/evasiveness/evasiveness_decorator.py +61 -0
- ibm_watsonx_gov/metrics/evasiveness/evasiveness_metric.py +103 -0
- ibm_watsonx_gov/metrics/faithfulness/__init__.py +8 -0
- ibm_watsonx_gov/metrics/faithfulness/faithfulness_decorator.py +65 -0
- ibm_watsonx_gov/metrics/faithfulness/faithfulness_metric.py +254 -0
- ibm_watsonx_gov/metrics/hap/__init__.py +16 -0
- ibm_watsonx_gov/metrics/hap/hap_decorator.py +58 -0
- ibm_watsonx_gov/metrics/hap/hap_metric.py +98 -0
- ibm_watsonx_gov/metrics/hap/input_hap_metric.py +104 -0
- ibm_watsonx_gov/metrics/hap/output_hap_metric.py +110 -0
- ibm_watsonx_gov/metrics/harm/__init__.py +8 -0
- ibm_watsonx_gov/metrics/harm/harm_decorator.py +60 -0
- ibm_watsonx_gov/metrics/harm/harm_metric.py +103 -0
- ibm_watsonx_gov/metrics/harm_engagement/__init__.py +8 -0
- ibm_watsonx_gov/metrics/harm_engagement/harm_engagement_decorator.py +61 -0
- ibm_watsonx_gov/metrics/harm_engagement/harm_engagement_metric.py +103 -0
- ibm_watsonx_gov/metrics/hit_rate/__init__.py +0 -0
- ibm_watsonx_gov/metrics/hit_rate/hit_rate_decorator.py +59 -0
- ibm_watsonx_gov/metrics/hit_rate/hit_rate_metric.py +167 -0
- ibm_watsonx_gov/metrics/input_token_count/__init__.py +8 -0
- ibm_watsonx_gov/metrics/input_token_count/input_token_count_decorator.py +58 -0
- ibm_watsonx_gov/metrics/input_token_count/input_token_count_metric.py +112 -0
- ibm_watsonx_gov/metrics/jailbreak/__init__.py +8 -0
- ibm_watsonx_gov/metrics/jailbreak/jailbreak_decorator.py +60 -0
- ibm_watsonx_gov/metrics/jailbreak/jailbreak_metric.py +103 -0
- ibm_watsonx_gov/metrics/keyword_detection/keyword_detection_decorator.py +58 -0
- ibm_watsonx_gov/metrics/keyword_detection/keyword_detection_metric.py +111 -0
- ibm_watsonx_gov/metrics/llm_validation/__init__.py +8 -0
- ibm_watsonx_gov/metrics/llm_validation/evaluation_criteria.py +84 -0
- ibm_watsonx_gov/metrics/llm_validation/llm_validation_constants.py +24 -0
- ibm_watsonx_gov/metrics/llm_validation/llm_validation_decorator.py +54 -0
- ibm_watsonx_gov/metrics/llm_validation/llm_validation_impl.py +525 -0
- ibm_watsonx_gov/metrics/llm_validation/llm_validation_metric.py +258 -0
- ibm_watsonx_gov/metrics/llm_validation/llm_validation_prompts.py +106 -0
- ibm_watsonx_gov/metrics/llmaj/__init__.py +0 -0
- ibm_watsonx_gov/metrics/llmaj/llmaj_metric.py +298 -0
- ibm_watsonx_gov/metrics/ndcg/__init__.py +0 -0
- ibm_watsonx_gov/metrics/ndcg/ndcg_decorator.py +61 -0
- ibm_watsonx_gov/metrics/ndcg/ndcg_metric.py +166 -0
- ibm_watsonx_gov/metrics/output_token_count/__init__.py +8 -0
- ibm_watsonx_gov/metrics/output_token_count/output_token_count_decorator.py +58 -0
- ibm_watsonx_gov/metrics/output_token_count/output_token_count_metric.py +112 -0
- ibm_watsonx_gov/metrics/pii/__init__.py +16 -0
- ibm_watsonx_gov/metrics/pii/input_pii_metric.py +102 -0
- ibm_watsonx_gov/metrics/pii/output_pii_metric.py +107 -0
- ibm_watsonx_gov/metrics/pii/pii_decorator.py +59 -0
- ibm_watsonx_gov/metrics/pii/pii_metric.py +96 -0
- ibm_watsonx_gov/metrics/profanity/__init__.py +8 -0
- ibm_watsonx_gov/metrics/profanity/profanity_decorator.py +60 -0
- ibm_watsonx_gov/metrics/profanity/profanity_metric.py +103 -0
- ibm_watsonx_gov/metrics/prompt_safety_risk/__init__.py +8 -0
- ibm_watsonx_gov/metrics/prompt_safety_risk/prompt_safety_risk_decorator.py +57 -0
- ibm_watsonx_gov/metrics/prompt_safety_risk/prompt_safety_risk_metric.py +128 -0
- ibm_watsonx_gov/metrics/reciprocal_rank/__init__.py +0 -0
- ibm_watsonx_gov/metrics/reciprocal_rank/reciprocal_rank_decorator.py +62 -0
- ibm_watsonx_gov/metrics/reciprocal_rank/reciprocal_rank_metric.py +162 -0
- ibm_watsonx_gov/metrics/regex_detection/regex_detection_decorator.py +58 -0
- ibm_watsonx_gov/metrics/regex_detection/regex_detection_metric.py +106 -0
- ibm_watsonx_gov/metrics/retrieval_precision/__init__.py +0 -0
- ibm_watsonx_gov/metrics/retrieval_precision/retrieval_precision_decorator.py +62 -0
- ibm_watsonx_gov/metrics/retrieval_precision/retrieval_precision_metric.py +170 -0
- ibm_watsonx_gov/metrics/sexual_content/__init__.py +8 -0
- ibm_watsonx_gov/metrics/sexual_content/sexual_content_decorator.py +61 -0
- ibm_watsonx_gov/metrics/sexual_content/sexual_content_metric.py +103 -0
- ibm_watsonx_gov/metrics/social_bias/__init__.py +8 -0
- ibm_watsonx_gov/metrics/social_bias/social_bias_decorator.py +62 -0
- ibm_watsonx_gov/metrics/social_bias/social_bias_metric.py +103 -0
- ibm_watsonx_gov/metrics/status/__init__.py +0 -0
- ibm_watsonx_gov/metrics/status/status_metric.py +113 -0
- ibm_watsonx_gov/metrics/text_grade_level/__init__.py +8 -0
- ibm_watsonx_gov/metrics/text_grade_level/text_grade_level_decorator.py +59 -0
- ibm_watsonx_gov/metrics/text_grade_level/text_grade_level_metric.py +127 -0
- ibm_watsonx_gov/metrics/text_reading_ease/__init__.py +8 -0
- ibm_watsonx_gov/metrics/text_reading_ease/text_reading_ease_decorator.py +59 -0
- ibm_watsonx_gov/metrics/text_reading_ease/text_reading_ease_metric.py +123 -0
- ibm_watsonx_gov/metrics/tool_call_accuracy/__init__.py +0 -0
- ibm_watsonx_gov/metrics/tool_call_accuracy/tool_call_accuracy_decorator.py +67 -0
- ibm_watsonx_gov/metrics/tool_call_accuracy/tool_call_accuracy_metric.py +162 -0
- ibm_watsonx_gov/metrics/tool_call_parameter_accuracy/__init__.py +0 -0
- ibm_watsonx_gov/metrics/tool_call_parameter_accuracy/tool_call_parameter_accuracy_decorator.py +68 -0
- ibm_watsonx_gov/metrics/tool_call_parameter_accuracy/tool_call_parameter_accuracy_metric.py +151 -0
- ibm_watsonx_gov/metrics/tool_call_relevance/__init__.py +0 -0
- ibm_watsonx_gov/metrics/tool_call_relevance/tool_call_relevance_decorator.py +71 -0
- ibm_watsonx_gov/metrics/tool_call_relevance/tool_call_relevance_metric.py +166 -0
- ibm_watsonx_gov/metrics/tool_call_syntactic_accuracy/__init__.py +0 -0
- ibm_watsonx_gov/metrics/tool_call_syntactic_accuracy/tool_call_syntactic_accuracy_decorator.py +66 -0
- ibm_watsonx_gov/metrics/tool_call_syntactic_accuracy/tool_call_syntactic_accuracy_metric.py +121 -0
- ibm_watsonx_gov/metrics/topic_relevance/__init__.py +8 -0
- ibm_watsonx_gov/metrics/topic_relevance/topic_relevance_decorator.py +57 -0
- ibm_watsonx_gov/metrics/topic_relevance/topic_relevance_metric.py +106 -0
- ibm_watsonx_gov/metrics/unethical_behavior/__init__.py +8 -0
- ibm_watsonx_gov/metrics/unethical_behavior/unethical_behavior_decorator.py +61 -0
- ibm_watsonx_gov/metrics/unethical_behavior/unethical_behavior_metric.py +103 -0
- ibm_watsonx_gov/metrics/unsuccessful_requests/__init__.py +0 -0
- ibm_watsonx_gov/metrics/unsuccessful_requests/unsuccessful_requests_decorator.py +66 -0
- ibm_watsonx_gov/metrics/unsuccessful_requests/unsuccessful_requests_metric.py +128 -0
- ibm_watsonx_gov/metrics/user_id/__init__.py +0 -0
- ibm_watsonx_gov/metrics/user_id/user_id_metric.py +111 -0
- ibm_watsonx_gov/metrics/utils.py +440 -0
- ibm_watsonx_gov/metrics/violence/__init__.py +8 -0
- ibm_watsonx_gov/metrics/violence/violence_decorator.py +60 -0
- ibm_watsonx_gov/metrics/violence/violence_metric.py +103 -0
- ibm_watsonx_gov/prompt_evaluator/__init__.py +9 -0
- ibm_watsonx_gov/prompt_evaluator/impl/__init__.py +8 -0
- ibm_watsonx_gov/prompt_evaluator/impl/prompt_evaluator_impl.py +554 -0
- ibm_watsonx_gov/prompt_evaluator/impl/pta_lifecycle_evaluator.py +2332 -0
- ibm_watsonx_gov/prompt_evaluator/prompt_evaluator.py +262 -0
- ibm_watsonx_gov/providers/__init__.py +8 -0
- ibm_watsonx_gov/providers/detectors_provider.cpython-313-darwin.so +0 -0
- ibm_watsonx_gov/providers/detectors_provider.py +415 -0
- ibm_watsonx_gov/providers/eval_assist_provider.cpython-313-darwin.so +0 -0
- ibm_watsonx_gov/providers/eval_assist_provider.py +266 -0
- ibm_watsonx_gov/providers/inference_engines/__init__.py +0 -0
- ibm_watsonx_gov/providers/inference_engines/custom_inference_engine.py +165 -0
- ibm_watsonx_gov/providers/inference_engines/portkey_inference_engine.py +57 -0
- ibm_watsonx_gov/providers/llmevalkit/__init__.py +0 -0
- ibm_watsonx_gov/providers/llmevalkit/ciso_agent/main.py +516 -0
- ibm_watsonx_gov/providers/llmevalkit/ciso_agent/preprocess_log.py +111 -0
- ibm_watsonx_gov/providers/llmevalkit/ciso_agent/utils.py +186 -0
- ibm_watsonx_gov/providers/llmevalkit/function_calling/README.md +411 -0
- ibm_watsonx_gov/providers/llmevalkit/function_calling/__init__.py +27 -0
- ibm_watsonx_gov/providers/llmevalkit/function_calling/comparison/README.md +306 -0
- ibm_watsonx_gov/providers/llmevalkit/function_calling/comparison/__init__.py +89 -0
- ibm_watsonx_gov/providers/llmevalkit/function_calling/comparison/comparators/__init__.py +30 -0
- ibm_watsonx_gov/providers/llmevalkit/function_calling/comparison/comparators/base.py +411 -0
- ibm_watsonx_gov/providers/llmevalkit/function_calling/comparison/comparators/code_agent.py +1254 -0
- ibm_watsonx_gov/providers/llmevalkit/function_calling/comparison/comparators/exact_match.py +134 -0
- ibm_watsonx_gov/providers/llmevalkit/function_calling/comparison/comparators/fuzzy_string.py +104 -0
- ibm_watsonx_gov/providers/llmevalkit/function_calling/comparison/comparators/hybrid.py +516 -0
- ibm_watsonx_gov/providers/llmevalkit/function_calling/comparison/comparators/llm_judge.py +1882 -0
- ibm_watsonx_gov/providers/llmevalkit/function_calling/comparison/pipeline.py +387 -0
- ibm_watsonx_gov/providers/llmevalkit/function_calling/comparison/types.py +178 -0
- ibm_watsonx_gov/providers/llmevalkit/function_calling/comparison/utils.py +298 -0
- ibm_watsonx_gov/providers/llmevalkit/function_calling/consts.py +33 -0
- ibm_watsonx_gov/providers/llmevalkit/function_calling/metrics/__init__.py +31 -0
- ibm_watsonx_gov/providers/llmevalkit/function_calling/metrics/base.py +26 -0
- ibm_watsonx_gov/providers/llmevalkit/function_calling/metrics/function_call/__init__.py +4 -0
- ibm_watsonx_gov/providers/llmevalkit/function_calling/metrics/function_call/general.py +46 -0
- ibm_watsonx_gov/providers/llmevalkit/function_calling/metrics/function_call/general_metrics.json +783 -0
- ibm_watsonx_gov/providers/llmevalkit/function_calling/metrics/function_call/general_metrics_runtime.json +580 -0
- ibm_watsonx_gov/providers/llmevalkit/function_calling/metrics/function_selection/__init__.py +6 -0
- ibm_watsonx_gov/providers/llmevalkit/function_calling/metrics/function_selection/function_selection.py +28 -0
- ibm_watsonx_gov/providers/llmevalkit/function_calling/metrics/function_selection/function_selection_metrics.json +599 -0
- ibm_watsonx_gov/providers/llmevalkit/function_calling/metrics/function_selection/function_selection_metrics_runtime.json +477 -0
- ibm_watsonx_gov/providers/llmevalkit/function_calling/metrics/loader.py +259 -0
- ibm_watsonx_gov/providers/llmevalkit/function_calling/metrics/parameter/__init__.py +7 -0
- ibm_watsonx_gov/providers/llmevalkit/function_calling/metrics/parameter/parameter.py +52 -0
- ibm_watsonx_gov/providers/llmevalkit/function_calling/metrics/parameter/parameter_metrics.json +613 -0
- ibm_watsonx_gov/providers/llmevalkit/function_calling/metrics/parameter/parameter_metrics_runtime.json +489 -0
- ibm_watsonx_gov/providers/llmevalkit/function_calling/metrics/trajectory/__init__.py +7 -0
- ibm_watsonx_gov/providers/llmevalkit/function_calling/metrics/trajectory/trajectory.py +43 -0
- ibm_watsonx_gov/providers/llmevalkit/function_calling/metrics/trajectory/trajectory_metrics.json +161 -0
- ibm_watsonx_gov/providers/llmevalkit/function_calling/pipeline/__init__.py +0 -0
- ibm_watsonx_gov/providers/llmevalkit/function_calling/pipeline/adapters.py +102 -0
- ibm_watsonx_gov/providers/llmevalkit/function_calling/pipeline/pipeline.py +355 -0
- ibm_watsonx_gov/providers/llmevalkit/function_calling/pipeline/semantic_checker.py +816 -0
- ibm_watsonx_gov/providers/llmevalkit/function_calling/pipeline/static_checker.py +297 -0
- ibm_watsonx_gov/providers/llmevalkit/function_calling/pipeline/transformation_prompts.py +509 -0
- ibm_watsonx_gov/providers/llmevalkit/function_calling/pipeline/types.py +596 -0
- ibm_watsonx_gov/providers/llmevalkit/llm/README.md +375 -0
- ibm_watsonx_gov/providers/llmevalkit/llm/__init__.py +137 -0
- ibm_watsonx_gov/providers/llmevalkit/llm/base.py +426 -0
- ibm_watsonx_gov/providers/llmevalkit/llm/output_parser.py +364 -0
- ibm_watsonx_gov/providers/llmevalkit/llm/providers/__init__.py +0 -0
- ibm_watsonx_gov/providers/llmevalkit/llm/providers/consts.py +7 -0
- ibm_watsonx_gov/providers/llmevalkit/llm/providers/ibm_watsonx_ai/__init__.py +0 -0
- ibm_watsonx_gov/providers/llmevalkit/llm/providers/ibm_watsonx_ai/ibm_watsonx_ai.py +656 -0
- ibm_watsonx_gov/providers/llmevalkit/llm/providers/litellm/__init__.py +0 -0
- ibm_watsonx_gov/providers/llmevalkit/llm/providers/litellm/litellm.py +509 -0
- ibm_watsonx_gov/providers/llmevalkit/llm/providers/litellm/rits.py +224 -0
- ibm_watsonx_gov/providers/llmevalkit/llm/providers/litellm/watsonx.py +60 -0
- ibm_watsonx_gov/providers/llmevalkit/llm/providers/mock_llm_client.py +75 -0
- ibm_watsonx_gov/providers/llmevalkit/llm/providers/openai/__init__.py +0 -0
- ibm_watsonx_gov/providers/llmevalkit/llm/providers/openai/openai.py +639 -0
- ibm_watsonx_gov/providers/llmevalkit/llm/providers/wxo_ai_gateway/__init__.py +0 -0
- ibm_watsonx_gov/providers/llmevalkit/llm/providers/wxo_ai_gateway/wxo_ai_gateway.py +134 -0
- ibm_watsonx_gov/providers/llmevalkit/llm/providers/wxo_ai_gateway/wxo_ai_gateway_inference.py +214 -0
- ibm_watsonx_gov/providers/llmevalkit/llm/types.py +136 -0
- ibm_watsonx_gov/providers/llmevalkit/metrics/__init__.py +4 -0
- ibm_watsonx_gov/providers/llmevalkit/metrics/field.py +255 -0
- ibm_watsonx_gov/providers/llmevalkit/metrics/metric.py +332 -0
- ibm_watsonx_gov/providers/llmevalkit/metrics/metrics_runner.py +188 -0
- ibm_watsonx_gov/providers/llmevalkit/metrics/prompt.py +403 -0
- ibm_watsonx_gov/providers/llmevalkit/metrics/utils.py +46 -0
- ibm_watsonx_gov/providers/llmevalkit/prompt/__init__.py +0 -0
- ibm_watsonx_gov/providers/llmevalkit/prompt/runner.py +144 -0
- ibm_watsonx_gov/providers/tool_call_metric_provider.py +455 -0
- ibm_watsonx_gov/providers/unitxt_provider.cpython-313-darwin.so +0 -0
- ibm_watsonx_gov/tools/__init__.py +10 -0
- ibm_watsonx_gov/tools/clients/__init__.py +11 -0
- ibm_watsonx_gov/tools/clients/ai_tool_client.py +405 -0
- ibm_watsonx_gov/tools/clients/detector_client.py +82 -0
- ibm_watsonx_gov/tools/core/__init__.py +8 -0
- ibm_watsonx_gov/tools/core/tool_loader.py +237 -0
- ibm_watsonx_gov/tools/entities/__init__.py +8 -0
- ibm_watsonx_gov/tools/entities/ai_tools.py +435 -0
- ibm_watsonx_gov/tools/onboarding/create/answer_relevance_detector.json +57 -0
- ibm_watsonx_gov/tools/onboarding/create/chromadb_retrieval_tool.json +63 -0
- ibm_watsonx_gov/tools/onboarding/create/context_relevance_detector.json +57 -0
- ibm_watsonx_gov/tools/onboarding/create/duduckgo_search_tool.json +53 -0
- ibm_watsonx_gov/tools/onboarding/create/google_search_tool.json +62 -0
- ibm_watsonx_gov/tools/onboarding/create/hap_detector.json +70 -0
- ibm_watsonx_gov/tools/onboarding/create/jailbreak_detector.json +70 -0
- ibm_watsonx_gov/tools/onboarding/create/pii_detector.json +36 -0
- ibm_watsonx_gov/tools/onboarding/create/prompt_safety_risk_detector.json +69 -0
- ibm_watsonx_gov/tools/onboarding/create/topic_relevance_detector.json +57 -0
- ibm_watsonx_gov/tools/onboarding/create/weather_tool.json +39 -0
- ibm_watsonx_gov/tools/onboarding/create/webcrawler_tool.json +34 -0
- ibm_watsonx_gov/tools/onboarding/create/wikipedia_search_tool.json +53 -0
- ibm_watsonx_gov/tools/onboarding/delete/delete_tools.json +4 -0
- ibm_watsonx_gov/tools/onboarding/update/google_search_tool.json +38 -0
- ibm_watsonx_gov/tools/ootb/__init__.py +8 -0
- ibm_watsonx_gov/tools/ootb/detectors/__init__.py +8 -0
- ibm_watsonx_gov/tools/ootb/detectors/hap_detector_tool.py +109 -0
- ibm_watsonx_gov/tools/ootb/detectors/jailbreak_detector_tool.py +104 -0
- ibm_watsonx_gov/tools/ootb/detectors/pii_detector_tool.py +83 -0
- ibm_watsonx_gov/tools/ootb/detectors/prompt_safety_risk_detector_tool.py +111 -0
- ibm_watsonx_gov/tools/ootb/detectors/topic_relevance_detector_tool.py +101 -0
- ibm_watsonx_gov/tools/ootb/rag/__init__.py +8 -0
- ibm_watsonx_gov/tools/ootb/rag/answer_relevance_detector_tool.py +119 -0
- ibm_watsonx_gov/tools/ootb/rag/context_relevance_detector_tool.py +118 -0
- ibm_watsonx_gov/tools/ootb/search/__init__.py +8 -0
- ibm_watsonx_gov/tools/ootb/search/duckduckgo_search_tool.py +62 -0
- ibm_watsonx_gov/tools/ootb/search/google_search_tool.py +105 -0
- ibm_watsonx_gov/tools/ootb/search/weather_tool.py +95 -0
- ibm_watsonx_gov/tools/ootb/search/web_crawler_tool.py +69 -0
- ibm_watsonx_gov/tools/ootb/search/wikipedia_search_tool.py +63 -0
- ibm_watsonx_gov/tools/ootb/vectordb/__init__.py +8 -0
- ibm_watsonx_gov/tools/ootb/vectordb/chromadb_retriever_tool.py +111 -0
- ibm_watsonx_gov/tools/rest_api/__init__.py +10 -0
- ibm_watsonx_gov/tools/rest_api/restapi_tool.py +72 -0
- ibm_watsonx_gov/tools/schemas/__init__.py +10 -0
- ibm_watsonx_gov/tools/schemas/search_tool_schema.py +46 -0
- ibm_watsonx_gov/tools/schemas/vectordb_retrieval_schema.py +55 -0
- ibm_watsonx_gov/tools/utils/__init__.py +14 -0
- ibm_watsonx_gov/tools/utils/constants.py +69 -0
- ibm_watsonx_gov/tools/utils/display_utils.py +38 -0
- ibm_watsonx_gov/tools/utils/environment.py +108 -0
- ibm_watsonx_gov/tools/utils/package_utils.py +40 -0
- ibm_watsonx_gov/tools/utils/platform_url_mapping.cpython-313-darwin.so +0 -0
- ibm_watsonx_gov/tools/utils/python_utils.py +68 -0
- ibm_watsonx_gov/tools/utils/tool_utils.py +206 -0
- ibm_watsonx_gov/traces/__init__.py +8 -0
- ibm_watsonx_gov/traces/span_exporter.py +195 -0
- ibm_watsonx_gov/traces/span_node.py +251 -0
- ibm_watsonx_gov/traces/span_util.py +153 -0
- ibm_watsonx_gov/traces/trace_utils.py +1074 -0
- ibm_watsonx_gov/utils/__init__.py +8 -0
- ibm_watsonx_gov/utils/aggregation_util.py +346 -0
- ibm_watsonx_gov/utils/async_util.py +62 -0
- ibm_watsonx_gov/utils/authenticator.py +144 -0
- ibm_watsonx_gov/utils/constants.py +15 -0
- ibm_watsonx_gov/utils/errors.py +40 -0
- ibm_watsonx_gov/utils/gov_sdk_logger.py +39 -0
- ibm_watsonx_gov/utils/insights_generator.py +1285 -0
- ibm_watsonx_gov/utils/python_utils.py +425 -0
- ibm_watsonx_gov/utils/rest_util.py +73 -0
- ibm_watsonx_gov/utils/segment_batch_manager.py +162 -0
- ibm_watsonx_gov/utils/singleton_meta.py +25 -0
- ibm_watsonx_gov/utils/url_mapping.cpython-313-darwin.so +0 -0
- ibm_watsonx_gov/utils/validation_util.py +126 -0
- ibm_watsonx_gov/visualizations/__init__.py +13 -0
- ibm_watsonx_gov/visualizations/metric_descriptions.py +57 -0
- ibm_watsonx_gov/visualizations/model_insights.py +1304 -0
- ibm_watsonx_gov/visualizations/visualization_utils.py +75 -0
- ibm_watsonx_gov-1.3.3.dist-info/METADATA +93 -0
- ibm_watsonx_gov-1.3.3.dist-info/RECORD +353 -0
- ibm_watsonx_gov-1.3.3.dist-info/WHEEL +6 -0
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import os
|
|
3
|
+
from typing import Any, List, Optional
|
|
4
|
+
from .litellm import (
|
|
5
|
+
LiteLLMClient,
|
|
6
|
+
LiteLLMClientOutputVal,
|
|
7
|
+
)
|
|
8
|
+
from llmevalkit.llm.base import Hook, register_llm
|
|
9
|
+
from ..consts import RITS_API_KEY, RITS_API_URL, XGRAMMAR
|
|
10
|
+
|
|
11
|
+
import requests
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def get_rits_model_list():
|
|
15
|
+
url = "https://rits.fmaas.res.ibm.com/ritsapi/inferenceinfo"
|
|
16
|
+
response = requests.get(url, headers={RITS_API_KEY: os.getenv(RITS_API_KEY, "")})
|
|
17
|
+
if response.status_code == 200:
|
|
18
|
+
return {m["model_name"]: m["endpoint"].split("/")[-1] for m in response.json()}
|
|
19
|
+
else:
|
|
20
|
+
raise Exception(f"Failed getting RITS model list:\n\n{response.text}")
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@register_llm("litellm.rits")
|
|
24
|
+
class RITSLiteLLMClient(LiteLLMClient):
|
|
25
|
+
"""
|
|
26
|
+
Specialized LiteLLMClient for RITS-hosted models.
|
|
27
|
+
|
|
28
|
+
Automatically injects:
|
|
29
|
+
- model_name = "hosted_vllm/{model_name}"
|
|
30
|
+
- api_base URL = "{api_url}/{model_url}/v1"
|
|
31
|
+
- authentication headers with RITS_API_KEY
|
|
32
|
+
- guided_decoding_backend
|
|
33
|
+
"""
|
|
34
|
+
|
|
35
|
+
def __init__(
|
|
36
|
+
self,
|
|
37
|
+
model_name: str,
|
|
38
|
+
api_key: Optional[str] = None,
|
|
39
|
+
model_url: Optional[str] = None,
|
|
40
|
+
api_url: Optional[str] = None,
|
|
41
|
+
guided_decoding_backend: Optional[str] = XGRAMMAR,
|
|
42
|
+
*,
|
|
43
|
+
hooks: Optional[List[Hook]] = None,
|
|
44
|
+
**lite_kwargs: Any,
|
|
45
|
+
) -> None:
|
|
46
|
+
"""
|
|
47
|
+
Initialize the RITS LiteLLM client.
|
|
48
|
+
|
|
49
|
+
Args:
|
|
50
|
+
model_name: Name of the hosted RITS model (e.g. "my-model").
|
|
51
|
+
api_key: RITS API key (falls back to env var RITS_API_KEY).
|
|
52
|
+
model_url: URL fragment for the model; derived from model_name if omitted.
|
|
53
|
+
api_url: Base RITS API URL (defaults to None).
|
|
54
|
+
guided_decoding_backend: Backend identifier for guided decoding (defaults to XGRAMMAR).
|
|
55
|
+
hooks: Optional observability hooks to receive events.
|
|
56
|
+
lite_kwargs: Additional parameters passed to the underlying LiteLLM constructor.
|
|
57
|
+
|
|
58
|
+
Raises:
|
|
59
|
+
ValueError: If model_url derivation fails.
|
|
60
|
+
EnvironmentError: If API key is missing.
|
|
61
|
+
"""
|
|
62
|
+
# Derive model_url from model_name if not provided
|
|
63
|
+
if not model_url:
|
|
64
|
+
try:
|
|
65
|
+
model_url = get_rits_model_list().get(model_name)
|
|
66
|
+
except Exception as e:
|
|
67
|
+
raise ValueError(f"Unable to derive model_url from '{model_name}': {e}")
|
|
68
|
+
|
|
69
|
+
# Obtain API key from environment if still not provided
|
|
70
|
+
if not api_key:
|
|
71
|
+
api_key = os.getenv(RITS_API_KEY)
|
|
72
|
+
if not api_key:
|
|
73
|
+
raise EnvironmentError(
|
|
74
|
+
f"Missing API key; please set the '{RITS_API_KEY}' environment variable."
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
# Ensure api_url is set, if not provided, it tries to obtain it from the environment variable, otherwise it raises an error.
|
|
78
|
+
if not api_url:
|
|
79
|
+
api_url = os.getenv(RITS_API_URL)
|
|
80
|
+
if not api_url:
|
|
81
|
+
raise EnvironmentError(
|
|
82
|
+
f"Missing API URL; please set the '{RITS_API_URL}' environment variable."
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
# Construct the full API base endpoint
|
|
86
|
+
api_base = f"{api_url.rstrip('/')}/{model_url}/v1"
|
|
87
|
+
|
|
88
|
+
# Call parent constructor with all required lite parameters
|
|
89
|
+
super().__init__(
|
|
90
|
+
model_name=f"hosted_vllm/{model_name}",
|
|
91
|
+
hooks=hooks,
|
|
92
|
+
api_base=api_base,
|
|
93
|
+
api_key=api_key,
|
|
94
|
+
headers={RITS_API_KEY: api_key},
|
|
95
|
+
guided_decoding_backend=guided_decoding_backend,
|
|
96
|
+
**lite_kwargs,
|
|
97
|
+
)
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
@register_llm("litellm.rits.output_val")
|
|
101
|
+
class RITSLiteLLMClientOutputVal(LiteLLMClientOutputVal):
|
|
102
|
+
"""
|
|
103
|
+
Specialized LiteLLMClientOutputVal for RITS-hosted models.
|
|
104
|
+
|
|
105
|
+
Automatically injects:
|
|
106
|
+
- model_path = "hosted_vllm/{model_name}"
|
|
107
|
+
- api_base URL = "{api_url}/{model_url}/v1"
|
|
108
|
+
- authentication headers with RITS_API_KEY
|
|
109
|
+
- guided_decoding_backend
|
|
110
|
+
|
|
111
|
+
Inherits full JSON / Pydantic / type-based output validation,
|
|
112
|
+
retry logic, batch & async support from LiteLLMClientOutputVal.
|
|
113
|
+
"""
|
|
114
|
+
|
|
115
|
+
def __init__(
|
|
116
|
+
self,
|
|
117
|
+
model_name: str,
|
|
118
|
+
api_key: Optional[str] = None,
|
|
119
|
+
model_url: Optional[str] = None,
|
|
120
|
+
api_url: Optional[str] = None,
|
|
121
|
+
guided_decoding_backend: Optional[str] = XGRAMMAR,
|
|
122
|
+
*,
|
|
123
|
+
hooks: Optional[List[Hook]] = None,
|
|
124
|
+
**lite_kwargs: Any,
|
|
125
|
+
) -> None:
|
|
126
|
+
"""
|
|
127
|
+
Initialize the RITS LiteLLM client with output validation.
|
|
128
|
+
|
|
129
|
+
Args:
|
|
130
|
+
model_name: Name of the hosted RITS model (e.g. "my-model").
|
|
131
|
+
api_key: RITS API key (falls back to env var RITS_API_KEY).
|
|
132
|
+
model_url: URL fragment for the model; derived from model_name if omitted.
|
|
133
|
+
api_url: Base RITS API URL (defaults to None).
|
|
134
|
+
guided_decoding_backend: Backend identifier for guided decoding (defaults to XGRAMMAR).
|
|
135
|
+
hooks: Optional observability hooks to receive events.
|
|
136
|
+
lite_kwargs: Additional parameters passed to the underlying LiteLLM constructor.
|
|
137
|
+
|
|
138
|
+
Raises:
|
|
139
|
+
ValueError: If model_url derivation fails.
|
|
140
|
+
EnvironmentError: If API key is missing.
|
|
141
|
+
"""
|
|
142
|
+
# Derive model_url from model_name if not provided
|
|
143
|
+
if not model_url:
|
|
144
|
+
try:
|
|
145
|
+
model_url = get_rits_model_list().get(model_name)
|
|
146
|
+
except Exception as e:
|
|
147
|
+
raise ValueError(f"Unable to derive model_url from '{model_name}': {e}")
|
|
148
|
+
|
|
149
|
+
# Obtain API key from environment if still not provided
|
|
150
|
+
if not api_key:
|
|
151
|
+
api_key = os.getenv(RITS_API_KEY)
|
|
152
|
+
if not api_key:
|
|
153
|
+
raise EnvironmentError(
|
|
154
|
+
f"Missing API key; please set the '{RITS_API_KEY}' environment variable."
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
# Ensure api_url is set, if not provided, it tries to obtain it from the environment variable, otherwise it raises an error.
|
|
158
|
+
if not api_url:
|
|
159
|
+
api_url = os.getenv(RITS_API_URL)
|
|
160
|
+
if not api_url:
|
|
161
|
+
raise EnvironmentError(
|
|
162
|
+
f"Missing API URL; please set the '{RITS_API_URL}' environment variable."
|
|
163
|
+
)
|
|
164
|
+
|
|
165
|
+
# Construct the full API base endpoint
|
|
166
|
+
api_base = f"{api_url.rstrip('/')}/{model_url}/v1"
|
|
167
|
+
|
|
168
|
+
# Call parent constructor with all required lite parameters
|
|
169
|
+
super().__init__(
|
|
170
|
+
model_name=f"hosted_vllm/{model_name}",
|
|
171
|
+
hooks=hooks,
|
|
172
|
+
api_base=api_base,
|
|
173
|
+
api_key=api_key,
|
|
174
|
+
headers={RITS_API_KEY: api_key},
|
|
175
|
+
guided_decoding_backend=guided_decoding_backend,
|
|
176
|
+
**lite_kwargs,
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
def generate(
|
|
180
|
+
self,
|
|
181
|
+
**kwargs: Any,
|
|
182
|
+
) -> Any:
|
|
183
|
+
"""
|
|
184
|
+
Synchronous chat generation with validation + retries.
|
|
185
|
+
This method is a wrapper around the generate method of the parent class,
|
|
186
|
+
ensuring that the schema_field is set to None, as RITS has problems with litellm schema validation.
|
|
187
|
+
Therefore, we disable schema validation for RITS models, and use the default validation.
|
|
188
|
+
|
|
189
|
+
Args:
|
|
190
|
+
**kwargs: Additional keyword arguments passed to the generate method.
|
|
191
|
+
Returns:
|
|
192
|
+
Any: The generated response from the model.
|
|
193
|
+
"""
|
|
194
|
+
|
|
195
|
+
# Delegate to ValidatingLLMClient.generate
|
|
196
|
+
return super().generate(
|
|
197
|
+
**{
|
|
198
|
+
"schema_field": None,
|
|
199
|
+
**kwargs,
|
|
200
|
+
}
|
|
201
|
+
)
|
|
202
|
+
|
|
203
|
+
async def generate_async(
|
|
204
|
+
self,
|
|
205
|
+
**kwargs: Any,
|
|
206
|
+
) -> Any:
|
|
207
|
+
"""
|
|
208
|
+
Asynchronous chat generation with validation + retries.
|
|
209
|
+
This method is a wrapper around the generate_async method of the parent class,
|
|
210
|
+
ensuring that the schema_field is set to None, as RITS has problems with litellm schema validation.
|
|
211
|
+
Therefore, we disable schema validation for RITS models, and use the default validation.
|
|
212
|
+
|
|
213
|
+
Args:
|
|
214
|
+
**kwargs: Additional keyword arguments passed to the generate_async method.
|
|
215
|
+
Returns:
|
|
216
|
+
Any: The generated response from the model.
|
|
217
|
+
"""
|
|
218
|
+
|
|
219
|
+
return await super().generate_async(
|
|
220
|
+
**{
|
|
221
|
+
"schema_field": None,
|
|
222
|
+
**kwargs,
|
|
223
|
+
}
|
|
224
|
+
)
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
from typing import Any, List, Optional
|
|
2
|
+
from .litellm import (
|
|
3
|
+
LiteLLMClient,
|
|
4
|
+
LiteLLMClientOutputVal,
|
|
5
|
+
)
|
|
6
|
+
from llmevalkit.llm.base import Hook, register_llm
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
@register_llm("litellm.watsonx")
|
|
10
|
+
class WatsonxLiteLLMClient(LiteLLMClient):
|
|
11
|
+
"""
|
|
12
|
+
Specialized LiteLLM client for Watsox models.
|
|
13
|
+
|
|
14
|
+
Automatically prefixes the model path with "watsonx/".
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
def __init__(
|
|
18
|
+
self, model_name: str, hooks: Optional[List[Hook]] = None, **lite_kwargs: Any
|
|
19
|
+
) -> None:
|
|
20
|
+
"""
|
|
21
|
+
Initialize a Watsonx LiteLLM client.
|
|
22
|
+
|
|
23
|
+
Args:
|
|
24
|
+
model_name: Watsonx model identifier (e.g. "gpt-j-6b").
|
|
25
|
+
hooks: Optional observability hooks (callable(event, payload)).
|
|
26
|
+
lite_kwargs: Additional keyword args passed to the underlying LiteLLM constructor.
|
|
27
|
+
"""
|
|
28
|
+
# Construct the model_path for Watsonx
|
|
29
|
+
model_path = f"watsonx/{model_name}"
|
|
30
|
+
|
|
31
|
+
# Delegate to the validating LiteLLMClient
|
|
32
|
+
super().__init__(model_name=model_path, hooks=hooks, **lite_kwargs)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
@register_llm("litellm.watsonx.output_val")
|
|
36
|
+
class WatsonxLiteLLMClientOutputVal(LiteLLMClientOutputVal):
|
|
37
|
+
"""
|
|
38
|
+
Validating LiteLLM client for IBM Watsonx models.
|
|
39
|
+
|
|
40
|
+
Inherits all JSON/Pydantic/type-based output validation, retry logic,
|
|
41
|
+
and batch/async support from LiteLLMClientOutputVal. Automatically
|
|
42
|
+
prefixes the model path with "watsonx/".
|
|
43
|
+
"""
|
|
44
|
+
|
|
45
|
+
def __init__(
|
|
46
|
+
self, model_name: str, hooks: Optional[List[Hook]] = None, **lite_kwargs: Any
|
|
47
|
+
) -> None:
|
|
48
|
+
"""
|
|
49
|
+
Initialize a Watsonx LiteLLM client with output validation.
|
|
50
|
+
|
|
51
|
+
Args:
|
|
52
|
+
model_name: Watsonx model identifier (e.g. "gpt-j-6b").
|
|
53
|
+
hooks: Optional observability hooks (callable(event, payload)).
|
|
54
|
+
lite_kwargs: Additional keyword args passed to the underlying LiteLLM constructor.
|
|
55
|
+
"""
|
|
56
|
+
# Construct the model_path for Watsonx
|
|
57
|
+
model_path = f"watsonx/{model_name}"
|
|
58
|
+
|
|
59
|
+
# Delegate to the validating LiteLLMClient
|
|
60
|
+
super().__init__(model_name=model_path, hooks=hooks, **lite_kwargs)
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
from typing import Any, Dict, List, Optional, Union
|
|
2
|
+
|
|
3
|
+
from llmevalkit.llm.output_parser import ValidatingLLMClient
|
|
4
|
+
from ..base import (
|
|
5
|
+
GenerationMode,
|
|
6
|
+
GenerationArgs,
|
|
7
|
+
register_llm,
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@register_llm("mock.output_val")
|
|
12
|
+
class MockLLMClient(ValidatingLLMClient):
|
|
13
|
+
"""
|
|
14
|
+
Mock implementation of LLMClient for testing purposes.
|
|
15
|
+
Assumes that the reflection is done in runtime (i.e., the generate output does not contain actionable recommendations).
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
def __init__(self, *args, **kwargs):
|
|
19
|
+
super().__init__(*args, **kwargs)
|
|
20
|
+
self._client = None # No real client needed for mock
|
|
21
|
+
|
|
22
|
+
@classmethod
|
|
23
|
+
def provider_class(cls):
|
|
24
|
+
# Return a dummy class for type checking
|
|
25
|
+
class DummyProvider:
|
|
26
|
+
pass
|
|
27
|
+
|
|
28
|
+
return DummyProvider
|
|
29
|
+
|
|
30
|
+
def _register_methods(self) -> None:
|
|
31
|
+
# Register mock method configs
|
|
32
|
+
self.set_method_config("text", "mock_text", "prompt")
|
|
33
|
+
self.set_method_config("chat", "mock_chat", "prompt")
|
|
34
|
+
self.set_method_config("text_async", "mock_text_async", "prompt")
|
|
35
|
+
self.set_method_config("chat_async", "mock_chat_async", "prompt")
|
|
36
|
+
|
|
37
|
+
def _setup_parameter_mapper(self) -> None:
|
|
38
|
+
# No parameter mapping needed for mock
|
|
39
|
+
pass
|
|
40
|
+
|
|
41
|
+
def _parse_llm_response(self, raw: Any) -> str:
|
|
42
|
+
# Return the raw value as the mock response
|
|
43
|
+
return str(raw)
|
|
44
|
+
|
|
45
|
+
def generate(
|
|
46
|
+
self,
|
|
47
|
+
prompt: Union[str, List[Dict[str, Any]]],
|
|
48
|
+
mode: Union[str, GenerationMode] = GenerationMode.CHAT,
|
|
49
|
+
generation_args: Optional[GenerationArgs] = None,
|
|
50
|
+
**kwargs: Any,
|
|
51
|
+
) -> Dict[str, Any]:
|
|
52
|
+
# Return a mock response resembling expected model output
|
|
53
|
+
return {
|
|
54
|
+
"evidence": f"Assistant message: 'Logged in as user 55; auth token acquired.'",
|
|
55
|
+
"explanation": "The user_id=55 parameter is properly grounded in the conversation history, as evidenced by the assistant's explicit statement 'Logged in as user 55.'",
|
|
56
|
+
"output": 3,
|
|
57
|
+
"confidence": 0.95,
|
|
58
|
+
"correction": {},
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async def generate_async(
|
|
62
|
+
self,
|
|
63
|
+
prompt: Union[str, List[Dict[str, Any]]],
|
|
64
|
+
mode: Union[str, GenerationMode] = GenerationMode.CHAT_ASYNC,
|
|
65
|
+
generation_args: Optional[GenerationArgs] = None,
|
|
66
|
+
**kwargs: Any,
|
|
67
|
+
) -> Dict[str, Any]:
|
|
68
|
+
# Return a mock async response resembling expected model output
|
|
69
|
+
return {
|
|
70
|
+
"evidence": f"Assistant message: 'Logged in as user 55; auth token acquired.'",
|
|
71
|
+
"explanation": "The user_id=55 parameter is properly grounded in the conversation history, as evidenced by the assistant's explicit statement 'Logged in as user 55.'",
|
|
72
|
+
"output": 3,
|
|
73
|
+
"confidence": 0.95,
|
|
74
|
+
"correction": {},
|
|
75
|
+
}
|
|
File without changes
|