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,599 @@
|
|
|
1
|
+
# ----------------------------------------------------------------------------------------------------
|
|
2
|
+
# IBM Confidential
|
|
3
|
+
# Licensed Materials - Property of IBM
|
|
4
|
+
# 5737-H76, 5900-A3Q
|
|
5
|
+
# © Copyright IBM Corp. 2025 All Rights Reserved.
|
|
6
|
+
# US Government Users Restricted Rights - Use, duplication or disclosure restricted by
|
|
7
|
+
# GSA ADPSchedule Contract with IBM Corp.
|
|
8
|
+
# ----------------------------------------------------------------------------------------------------
|
|
9
|
+
import warnings
|
|
10
|
+
|
|
11
|
+
from pydantic import BaseModel, Field, model_validator
|
|
12
|
+
from typing import Optional, Dict, Any, Annotated, Union, List, Type
|
|
13
|
+
from pydantic_core import PydanticCustomError
|
|
14
|
+
from ..utils.constants import ServiceProviderType
|
|
15
|
+
from ibm_watsonx_gov.tools.utils.constants import CustomToolType, PatchOperationTypes, Framework, Categories
|
|
16
|
+
from ibm_watsonx_gov.tools.utils.python_utils import get_base64_encoding
|
|
17
|
+
from ...utils.python_utils import get
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
class AIAgentParentApplication(BaseModel):
|
|
22
|
+
inventory_id: Annotated[
|
|
23
|
+
str,
|
|
24
|
+
Field(
|
|
25
|
+
...,
|
|
26
|
+
description="Inventory ID of the parent application."
|
|
27
|
+
)
|
|
28
|
+
]
|
|
29
|
+
agent_id: Annotated[
|
|
30
|
+
str,
|
|
31
|
+
Field(
|
|
32
|
+
...,
|
|
33
|
+
description="Agent ID of the parent application"
|
|
34
|
+
)
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
@model_validator(mode="before")
|
|
38
|
+
@classmethod
|
|
39
|
+
def populate_agent_id_from_asset_id(cls,data):
|
|
40
|
+
if "asset_id" in data and "agent_id" not in data:
|
|
41
|
+
data["agent_id"] = data["asset_id"]
|
|
42
|
+
return data
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class AIAgentUsedInApplication(BaseModel):
|
|
46
|
+
inventory_id: Annotated[
|
|
47
|
+
str,
|
|
48
|
+
Field(
|
|
49
|
+
...,
|
|
50
|
+
description="Inventory ID of the application where the agent is used."
|
|
51
|
+
)
|
|
52
|
+
]
|
|
53
|
+
agent_id: Annotated[
|
|
54
|
+
str,
|
|
55
|
+
Field(
|
|
56
|
+
...,
|
|
57
|
+
description="Agent ID of the application where the agent is used."
|
|
58
|
+
)
|
|
59
|
+
]
|
|
60
|
+
|
|
61
|
+
@model_validator(mode="before")
|
|
62
|
+
@classmethod
|
|
63
|
+
def populate_agent_id_from_asset_id(cls,data):
|
|
64
|
+
if "asset_id" in data and "agent_id" not in data:
|
|
65
|
+
data["agent_id"] = data["asset_id"]
|
|
66
|
+
return data
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
class AIAgentRuntimeDetails(BaseModel):
|
|
70
|
+
engine: Annotated[
|
|
71
|
+
str,
|
|
72
|
+
Field(
|
|
73
|
+
...,
|
|
74
|
+
description="Python version required by the agent."
|
|
75
|
+
)
|
|
76
|
+
]
|
|
77
|
+
cpu_capacity: Annotated[
|
|
78
|
+
Optional[str],
|
|
79
|
+
Field(
|
|
80
|
+
default=None,
|
|
81
|
+
description="CPU capacity required by the agent."
|
|
82
|
+
)
|
|
83
|
+
]
|
|
84
|
+
memory: Annotated[
|
|
85
|
+
Optional[str],
|
|
86
|
+
Field(
|
|
87
|
+
default=None,
|
|
88
|
+
description="Memory required by the agent."
|
|
89
|
+
)
|
|
90
|
+
]
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
class AIAgentCodePayload(BaseModel):
|
|
94
|
+
source: Annotated[
|
|
95
|
+
Optional[str],
|
|
96
|
+
Field(
|
|
97
|
+
default=None,
|
|
98
|
+
description="Source location of the agent's code."
|
|
99
|
+
)
|
|
100
|
+
]
|
|
101
|
+
commit: Annotated[
|
|
102
|
+
Optional[str],
|
|
103
|
+
Field(
|
|
104
|
+
default=None
|
|
105
|
+
)
|
|
106
|
+
]
|
|
107
|
+
language: Annotated[
|
|
108
|
+
Optional[str],
|
|
109
|
+
Field(
|
|
110
|
+
default="python",
|
|
111
|
+
description="Language used in the code"
|
|
112
|
+
)
|
|
113
|
+
]
|
|
114
|
+
source_code: Annotated[
|
|
115
|
+
Optional[str],
|
|
116
|
+
Field(
|
|
117
|
+
...,
|
|
118
|
+
description="Source code encoded in Base64 format.",
|
|
119
|
+
alias="source_code_base64"
|
|
120
|
+
)
|
|
121
|
+
]
|
|
122
|
+
run_time_details: Annotated[
|
|
123
|
+
AIAgentRuntimeDetails,
|
|
124
|
+
Field(
|
|
125
|
+
...,
|
|
126
|
+
description="Runtime details required for executing the source code."
|
|
127
|
+
)
|
|
128
|
+
]
|
|
129
|
+
|
|
130
|
+
@model_validator(mode='before')
|
|
131
|
+
@classmethod
|
|
132
|
+
def accept_multiple_field_names(cls, data):
|
|
133
|
+
if "source_code" in data and "source_code_base64" not in data:
|
|
134
|
+
data["source_code_base64"] = data["source_code"]
|
|
135
|
+
return data
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
class AIAgentEndpointPayload(BaseModel):
|
|
139
|
+
url: Annotated[
|
|
140
|
+
str,
|
|
141
|
+
Field(
|
|
142
|
+
...,
|
|
143
|
+
description="URL to access the endpoint."
|
|
144
|
+
)
|
|
145
|
+
]
|
|
146
|
+
headers: Annotated[
|
|
147
|
+
Dict[str, str],
|
|
148
|
+
Field(
|
|
149
|
+
...,
|
|
150
|
+
description="Headers required to call the endpoint."
|
|
151
|
+
)
|
|
152
|
+
]
|
|
153
|
+
method: Annotated[
|
|
154
|
+
str,
|
|
155
|
+
Field(
|
|
156
|
+
...,
|
|
157
|
+
description="Method to call the endpoint."
|
|
158
|
+
)
|
|
159
|
+
]
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
class AIAgentTool(BaseModel):
|
|
163
|
+
inventory_id: Annotated[
|
|
164
|
+
str,
|
|
165
|
+
Field(
|
|
166
|
+
...,
|
|
167
|
+
description="Inventory ID of the tool where the application is used."
|
|
168
|
+
)
|
|
169
|
+
]
|
|
170
|
+
tool_id: Annotated[
|
|
171
|
+
str,
|
|
172
|
+
Field(
|
|
173
|
+
...,
|
|
174
|
+
description="Tool ID of the tool where the application is used."
|
|
175
|
+
)
|
|
176
|
+
]
|
|
177
|
+
|
|
178
|
+
@model_validator(mode="before")
|
|
179
|
+
@classmethod
|
|
180
|
+
def populate_tool_id_from_asset_id(cls,data):
|
|
181
|
+
if "asset_id" in data and "tool_id" not in data:
|
|
182
|
+
data["tool_id"] = data["asset_id"]
|
|
183
|
+
return data
|
|
184
|
+
|
|
185
|
+
class AIAgentDependencies(BaseModel):
|
|
186
|
+
remote_services: Annotated[
|
|
187
|
+
list[str],
|
|
188
|
+
Field(
|
|
189
|
+
...,
|
|
190
|
+
)
|
|
191
|
+
]
|
|
192
|
+
run_time_packages: Annotated[
|
|
193
|
+
list[str],
|
|
194
|
+
Field(
|
|
195
|
+
...,
|
|
196
|
+
)
|
|
197
|
+
]
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
class AIAgentSchema(BaseModel):
|
|
201
|
+
title: Annotated[
|
|
202
|
+
Optional[str],
|
|
203
|
+
Field(
|
|
204
|
+
default=None,
|
|
205
|
+
description="Title for schema."
|
|
206
|
+
)]
|
|
207
|
+
type: Annotated[
|
|
208
|
+
Optional[str],
|
|
209
|
+
Field(
|
|
210
|
+
default=None,
|
|
211
|
+
description="Type of schema."
|
|
212
|
+
)]
|
|
213
|
+
properties: Annotated[
|
|
214
|
+
dict,
|
|
215
|
+
Field(
|
|
216
|
+
...,
|
|
217
|
+
description="Properties for schema."
|
|
218
|
+
)]
|
|
219
|
+
required: Annotated[
|
|
220
|
+
Optional[list],
|
|
221
|
+
Field(
|
|
222
|
+
default=None,
|
|
223
|
+
description="Required for schema."
|
|
224
|
+
)]
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
class AgentRegistrationPayload(BaseModel):
|
|
228
|
+
display_name: Annotated[
|
|
229
|
+
Optional[str],
|
|
230
|
+
Field(
|
|
231
|
+
default=None,
|
|
232
|
+
description="Unique name for displaying the agent."
|
|
233
|
+
)
|
|
234
|
+
]
|
|
235
|
+
agent_name: Annotated[
|
|
236
|
+
str,
|
|
237
|
+
Field(
|
|
238
|
+
...,
|
|
239
|
+
description="Unique name for the agent"
|
|
240
|
+
)
|
|
241
|
+
]
|
|
242
|
+
description: Annotated[
|
|
243
|
+
str,
|
|
244
|
+
Field(
|
|
245
|
+
...,
|
|
246
|
+
description="Short description about the agent."
|
|
247
|
+
)
|
|
248
|
+
]
|
|
249
|
+
inventory_id: Annotated[
|
|
250
|
+
Optional[str],
|
|
251
|
+
Field(
|
|
252
|
+
default=None,
|
|
253
|
+
description="Inventory ID in which the asset needs to be created."
|
|
254
|
+
)
|
|
255
|
+
]
|
|
256
|
+
summary: Annotated[
|
|
257
|
+
Optional[str],
|
|
258
|
+
Field(
|
|
259
|
+
default=None,
|
|
260
|
+
description="Summary of the agent."
|
|
261
|
+
)
|
|
262
|
+
]
|
|
263
|
+
service_provider_type: Annotated[
|
|
264
|
+
Optional[ServiceProviderType],
|
|
265
|
+
Field(
|
|
266
|
+
default=ServiceProviderType.CUSTOM,
|
|
267
|
+
description=f"Service provider type. Allowed values are: {ServiceProviderType.values()}."
|
|
268
|
+
)
|
|
269
|
+
]
|
|
270
|
+
framework: Annotated[
|
|
271
|
+
Optional[list[Framework]],
|
|
272
|
+
Field(
|
|
273
|
+
default_factory=lambda: [Framework.LANGGRAPH],
|
|
274
|
+
description="Specify the framework used by the agent."
|
|
275
|
+
)
|
|
276
|
+
]
|
|
277
|
+
category: Annotated[
|
|
278
|
+
Optional[list[Categories]],
|
|
279
|
+
Field(
|
|
280
|
+
default_factory=lambda: [Categories.OTHER],
|
|
281
|
+
description=f"Specify the category under which the agent will be classified. Allowed values are {Categories.values()}."
|
|
282
|
+
)
|
|
283
|
+
]
|
|
284
|
+
agent_type: Annotated[
|
|
285
|
+
Optional[CustomToolType],
|
|
286
|
+
Field(
|
|
287
|
+
default=CustomToolType.ENDPOINT,
|
|
288
|
+
description=f"Type of the agent. Allowed agent types are: {CustomToolType.values()}."
|
|
289
|
+
)
|
|
290
|
+
]
|
|
291
|
+
development_implementation_url: Annotated[
|
|
292
|
+
Optional[str],
|
|
293
|
+
Field(
|
|
294
|
+
default=None,
|
|
295
|
+
)
|
|
296
|
+
]
|
|
297
|
+
validation_implementation_url: Annotated[
|
|
298
|
+
Optional[str],
|
|
299
|
+
Field(
|
|
300
|
+
default=None,
|
|
301
|
+
)
|
|
302
|
+
]
|
|
303
|
+
implementation_url: Annotated[
|
|
304
|
+
Optional[str],
|
|
305
|
+
Field(
|
|
306
|
+
default=None,
|
|
307
|
+
)
|
|
308
|
+
]
|
|
309
|
+
reusable: Annotated[
|
|
310
|
+
bool,
|
|
311
|
+
Field(
|
|
312
|
+
default=False,
|
|
313
|
+
description="Specify the agent will be reusable."
|
|
314
|
+
)
|
|
315
|
+
]
|
|
316
|
+
version: Annotated[
|
|
317
|
+
Optional[str],
|
|
318
|
+
Field(
|
|
319
|
+
default=None,
|
|
320
|
+
)
|
|
321
|
+
]
|
|
322
|
+
parent_applications: Annotated[
|
|
323
|
+
Optional[list[AIAgentParentApplication]],
|
|
324
|
+
Field(
|
|
325
|
+
default=None,
|
|
326
|
+
description="List of parent applications"
|
|
327
|
+
)
|
|
328
|
+
]
|
|
329
|
+
tools: Annotated[
|
|
330
|
+
Optional[list[AIAgentTool]],
|
|
331
|
+
Field(
|
|
332
|
+
default=None,
|
|
333
|
+
description="List of tools used in this applications"
|
|
334
|
+
)
|
|
335
|
+
]
|
|
336
|
+
used_in_applications: Annotated[
|
|
337
|
+
Optional[list[AIAgentUsedInApplication]],
|
|
338
|
+
Field(
|
|
339
|
+
default=None,
|
|
340
|
+
description="List of applications where this application is used."
|
|
341
|
+
)
|
|
342
|
+
]
|
|
343
|
+
code: Annotated[
|
|
344
|
+
Optional[AIAgentCodePayload],
|
|
345
|
+
Field(
|
|
346
|
+
default=None,
|
|
347
|
+
description="Code-related information for the agent."
|
|
348
|
+
)
|
|
349
|
+
]
|
|
350
|
+
endpoint: Annotated[
|
|
351
|
+
Optional[AIAgentEndpointPayload],
|
|
352
|
+
Field(
|
|
353
|
+
default=None,
|
|
354
|
+
description="Endpoint-related information for the agent."
|
|
355
|
+
)
|
|
356
|
+
]
|
|
357
|
+
dependencies: Annotated[
|
|
358
|
+
Optional[AIAgentDependencies],
|
|
359
|
+
Field(
|
|
360
|
+
default=None,
|
|
361
|
+
description="Dependencies required by this agent."
|
|
362
|
+
)
|
|
363
|
+
]
|
|
364
|
+
metrics: Annotated[
|
|
365
|
+
Optional[dict],
|
|
366
|
+
Field(
|
|
367
|
+
default=None,
|
|
368
|
+
description="Metrics and their respective values."
|
|
369
|
+
)
|
|
370
|
+
]
|
|
371
|
+
benchmark_test: Annotated[
|
|
372
|
+
Optional[dict],
|
|
373
|
+
Field(
|
|
374
|
+
default=None,
|
|
375
|
+
description="Benchmark test details."
|
|
376
|
+
)
|
|
377
|
+
]
|
|
378
|
+
pricing: Annotated[
|
|
379
|
+
Optional[dict],
|
|
380
|
+
Field(
|
|
381
|
+
default=None,
|
|
382
|
+
description="Type of currency and its corresponding price."
|
|
383
|
+
)
|
|
384
|
+
]
|
|
385
|
+
schema_: Annotated[
|
|
386
|
+
Optional[AIAgentSchema],
|
|
387
|
+
Field(
|
|
388
|
+
default=None,
|
|
389
|
+
description="Schema information for this agent.",
|
|
390
|
+
alias="schema"
|
|
391
|
+
)
|
|
392
|
+
]
|
|
393
|
+
|
|
394
|
+
environment_variables: Annotated[
|
|
395
|
+
Optional[list[str]],
|
|
396
|
+
Field(
|
|
397
|
+
default=None,
|
|
398
|
+
description="Environment variables required by this agent."
|
|
399
|
+
)
|
|
400
|
+
]
|
|
401
|
+
|
|
402
|
+
@model_validator(mode="before")
|
|
403
|
+
@classmethod
|
|
404
|
+
def check_required_fields(cls, values):
|
|
405
|
+
if 'agent_name' not in values or not values['agent_name']:
|
|
406
|
+
raise ValueError("Missing required field: 'agent_name'. Please provide a unique name for the agent.")
|
|
407
|
+
if "agent_type" not in values:
|
|
408
|
+
values["agent_type"] = CustomToolType.ENDPOINT.value
|
|
409
|
+
if values["agent_type"] == CustomToolType.ENDPOINT.value and "code" in values:
|
|
410
|
+
values["code"] = None
|
|
411
|
+
if values["agent_type"] == CustomToolType.CODE.value and "endpoint" in values:
|
|
412
|
+
values["endpoint"] = None
|
|
413
|
+
|
|
414
|
+
# Converting list[tools] to AIAgentTool pydantic model
|
|
415
|
+
if "tools" in values:
|
|
416
|
+
tools = values.get("tools")
|
|
417
|
+
if isinstance(tools, list) and all(isinstance(tool, str) for tool in tools):
|
|
418
|
+
values["tools"] = generate_agent_assets(asset_names=tools, asset_type=AIAgentTool)
|
|
419
|
+
|
|
420
|
+
# Converting list[agent] to AIAgentParentApplication pydantic model
|
|
421
|
+
if "parent_applications" in values:
|
|
422
|
+
parent_applications = values.get("parent_applications")
|
|
423
|
+
if isinstance(parent_applications, list) and all(isinstance(agent, str) for agent in parent_applications):
|
|
424
|
+
values["parent_applications"] = generate_agent_assets(asset_names=parent_applications,
|
|
425
|
+
asset_type=AIAgentParentApplication)
|
|
426
|
+
|
|
427
|
+
# Converting list[agent] to AIAgentUsedInApplication pydantic model
|
|
428
|
+
if "used_in_applications" in values:
|
|
429
|
+
used_in_applications = values.get("used_in_applications")
|
|
430
|
+
if isinstance(used_in_applications, list) and all(isinstance(agent, str) for agent in used_in_applications):
|
|
431
|
+
values["used_in_applications"] = generate_agent_assets(asset_names=used_in_applications,
|
|
432
|
+
asset_type=AIAgentUsedInApplication)
|
|
433
|
+
|
|
434
|
+
return values
|
|
435
|
+
|
|
436
|
+
@model_validator(mode="after")
|
|
437
|
+
def validate_post_payload(self):
|
|
438
|
+
if self.agent_type == CustomToolType.CODE and not self.code:
|
|
439
|
+
raise PydanticCustomError(
|
|
440
|
+
"missing code_payload", 'agent_type is "code", but code field missing in payload.'
|
|
441
|
+
)
|
|
442
|
+
|
|
443
|
+
if self.agent_type == CustomToolType.ENDPOINT and not self.endpoint:
|
|
444
|
+
raise PydanticCustomError(
|
|
445
|
+
"missing_endpoint_payload", 'agent_type is "endpoint", but endpoint field missing payload'
|
|
446
|
+
)
|
|
447
|
+
|
|
448
|
+
if self.code and self.code.source_code:
|
|
449
|
+
self.code.source_code = get_base64_encoding(tool_code=self.code.source_code)
|
|
450
|
+
|
|
451
|
+
if not self.display_name:
|
|
452
|
+
self.display_name = self.agent_name
|
|
453
|
+
|
|
454
|
+
return self
|
|
455
|
+
|
|
456
|
+
|
|
457
|
+
class PatchPayload(BaseModel):
|
|
458
|
+
op: Annotated[
|
|
459
|
+
PatchOperationTypes,
|
|
460
|
+
Field(
|
|
461
|
+
...,
|
|
462
|
+
description="Type of operation to be performed."
|
|
463
|
+
)
|
|
464
|
+
]
|
|
465
|
+
path: Annotated[
|
|
466
|
+
str,
|
|
467
|
+
Field(
|
|
468
|
+
...,
|
|
469
|
+
description="Path of the field on which the operation needs to be performed."
|
|
470
|
+
)
|
|
471
|
+
]
|
|
472
|
+
value: Annotated[
|
|
473
|
+
Any,
|
|
474
|
+
Field(
|
|
475
|
+
...,
|
|
476
|
+
description="The value to be applied during the specified operation on the given field path."
|
|
477
|
+
)
|
|
478
|
+
]
|
|
479
|
+
|
|
480
|
+
@model_validator(mode="after")
|
|
481
|
+
def validate_patch_payload(self):
|
|
482
|
+
if "source_code_base64" in self.path:
|
|
483
|
+
self.value = get_base64_encoding(tool_code=self.value)
|
|
484
|
+
|
|
485
|
+
elif "tools" in self.path:
|
|
486
|
+
# Converting list[tools] to AIAgentTool pydantic model
|
|
487
|
+
tools = self.value
|
|
488
|
+
if isinstance(tools, list) and all(isinstance(tool, str) for tool in tools):
|
|
489
|
+
self.value = generate_agent_assets(asset_names=tools, asset_type=AIAgentTool)
|
|
490
|
+
|
|
491
|
+
elif "parent_applications" in self.path:
|
|
492
|
+
# Converting list[agent] to AIAgentParentApplication pydantic model
|
|
493
|
+
parent_applications = self.value
|
|
494
|
+
if isinstance(parent_applications, list) and all(isinstance(agent, str) for agent in parent_applications):
|
|
495
|
+
self.value = generate_agent_assets(asset_names=parent_applications, asset_type=AIAgentParentApplication)
|
|
496
|
+
|
|
497
|
+
elif "used_in_applications" in self.path:
|
|
498
|
+
# Converting list[agent] to AIAgentUsedInApplication pydantic model
|
|
499
|
+
used_in_applications = self.value
|
|
500
|
+
if isinstance(used_in_applications, list) and all(isinstance(agent, str) for agent in used_in_applications):
|
|
501
|
+
self.value = generate_agent_assets(asset_names=used_in_applications, asset_type=AIAgentUsedInApplication)
|
|
502
|
+
|
|
503
|
+
return self
|
|
504
|
+
|
|
505
|
+
class AgentUpdatePayload(BaseModel):
|
|
506
|
+
payload: Annotated[
|
|
507
|
+
list[PatchPayload],
|
|
508
|
+
Field(
|
|
509
|
+
...,
|
|
510
|
+
description="List of patch payloads used to perform the patch operation."
|
|
511
|
+
)
|
|
512
|
+
]
|
|
513
|
+
|
|
514
|
+
@model_validator(mode='before')
|
|
515
|
+
@classmethod
|
|
516
|
+
def validate_ai_agent_patch_payload(cls, values):
|
|
517
|
+
if "payload" not in values or not isinstance(values.get("payload"), list):
|
|
518
|
+
raise PydanticCustomError(
|
|
519
|
+
"Invalid_payload",
|
|
520
|
+
"The payload is either missing or not in a valid list format."
|
|
521
|
+
)
|
|
522
|
+
return values
|
|
523
|
+
|
|
524
|
+
|
|
525
|
+
def generate_agent_assets(
|
|
526
|
+
asset_names: List[str],
|
|
527
|
+
asset_type: Type[Union[AIAgentTool, AIAgentParentApplication, AIAgentUsedInApplication]]
|
|
528
|
+
) -> List[Any]:
|
|
529
|
+
"""
|
|
530
|
+
Retrieves agent/tool asset objects (AIAgentTool, AIAgentParentApplication, or AIAgentUsedInApplication)
|
|
531
|
+
for the given asset names.
|
|
532
|
+
|
|
533
|
+
This function performs a bulk fetch of assets (either tools or agents) and
|
|
534
|
+
converts each matching result into the specified Pydantic model type.
|
|
535
|
+
|
|
536
|
+
Behavior:
|
|
537
|
+
- If `asset_type` is AIAgentTool:
|
|
538
|
+
- Calls `list_tools()` once with all provided names.
|
|
539
|
+
- Extracts `tool_id` (from `metadata.id`) and `inventory_id` (from `entity.inventory_id`)
|
|
540
|
+
for each found tool.
|
|
541
|
+
- If `asset_type` is AIAgentParentApplication or AIAgentUsedInApplication:
|
|
542
|
+
- Calls `list_agents()` once with all provided names.
|
|
543
|
+
- Extracts `agent_id` and `inventory_id` for each found agent.
|
|
544
|
+
- Missing asset names:
|
|
545
|
+
- If no assets are found at all, raises an Exception.
|
|
546
|
+
- If some assets are missing, raises a Warning after processing the found ones.
|
|
547
|
+
|
|
548
|
+
Args:
|
|
549
|
+
asset_names (List[str]):
|
|
550
|
+
A list of tool or agent names to retrieve.
|
|
551
|
+
asset_type (Type[Union[AIAgentTool, AIAgentParentApplication, AIAgentUsedInApplication]]):
|
|
552
|
+
The Pydantic model class representing the desired asset type.
|
|
553
|
+
|
|
554
|
+
Returns:
|
|
555
|
+
List[Any]:
|
|
556
|
+
A list of instances of the specified asset type, one for each found asset.
|
|
557
|
+
|
|
558
|
+
Raises:
|
|
559
|
+
Exception:
|
|
560
|
+
If none of the provided asset names are found in the corresponding list API.
|
|
561
|
+
Warning:
|
|
562
|
+
If one or more asset names cannot be found, but at least one valid asset is returned.
|
|
563
|
+
"""
|
|
564
|
+
from ..clients.ai_agent_client import list_agents
|
|
565
|
+
from ibm_watsonx_gov.tools.clients.ai_tool_client import list_tools
|
|
566
|
+
|
|
567
|
+
response = []
|
|
568
|
+
missing_names = set(asset_names)
|
|
569
|
+
|
|
570
|
+
if asset_type is AIAgentTool:
|
|
571
|
+
current_assets_type = "tools"
|
|
572
|
+
result = list_tools(tool_name=asset_names)
|
|
573
|
+
else:
|
|
574
|
+
current_assets_type = "agents"
|
|
575
|
+
result = list_agents(agent_name=asset_names)
|
|
576
|
+
|
|
577
|
+
if not result or not result.get(current_assets_type):
|
|
578
|
+
raise Exception(
|
|
579
|
+
f"An error occurred while converting list[{current_assets_type}] to dict objects: "
|
|
580
|
+
f"None of the {current_assets_type} '{asset_names}' were found."
|
|
581
|
+
)
|
|
582
|
+
|
|
583
|
+
for asset in result.get(current_assets_type, []):
|
|
584
|
+
response.append(asset_type(
|
|
585
|
+
asset_id=get(asset, "metadata.id"),
|
|
586
|
+
inventory_id=get(asset, "entity.inventory_id")
|
|
587
|
+
))
|
|
588
|
+
missing_names.discard(get(asset, "entity.asset_name")) # Remove if found
|
|
589
|
+
|
|
590
|
+
if missing_names:
|
|
591
|
+
warnings.warn(
|
|
592
|
+
f"An error occurred while converting list[{current_assets_type}] to dict objects: "
|
|
593
|
+
f"{current_assets_type} {missing_names} were not found.",
|
|
594
|
+
UserWarning
|
|
595
|
+
)
|
|
596
|
+
|
|
597
|
+
return response
|
|
598
|
+
|
|
599
|
+
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# ----------------------------------------------------------------------------------------------------
|
|
2
|
+
# IBM Confidential
|
|
3
|
+
# Licensed Materials - Property of IBM
|
|
4
|
+
# 5737-H76, 5900-A3Q
|
|
5
|
+
# © Copyright IBM Corp. 2025 All Rights Reserved.
|
|
6
|
+
# US Government Users Restricted Rights - Use, duplication or disclosure restricted by
|
|
7
|
+
# GSA ADPSchedule Contract with IBM Corp.
|
|
8
|
+
# ----------------------------------------------------------------------------------------------------
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# ----------------------------------------------------------------------------------------------------
|
|
2
|
+
# IBM Confidential
|
|
3
|
+
# Licensed Materials - Property of IBM
|
|
4
|
+
# 5737-H76, 5900-A3Q
|
|
5
|
+
# © Copyright IBM Corp. 2025 All Rights Reserved.
|
|
6
|
+
# US Government Users Restricted Rights - Use, duplication or disclosure restricted by
|
|
7
|
+
# GSA ADPSchedule Contract with IBM Corp.
|
|
8
|
+
# ----------------------------------------------------------------------------------------------------
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
from enum import Enum
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class ServiceProviderType(Enum):
|
|
15
|
+
WML = "wml"
|
|
16
|
+
CUSTOM = "custom"
|
|
17
|
+
|
|
18
|
+
@classmethod
|
|
19
|
+
def values(cls):
|
|
20
|
+
return [member.value for member in cls]
|
|
21
|
+
|
|
22
|
+
class AgentType(Enum):
|
|
23
|
+
CODE = "code"
|
|
24
|
+
ENDPOINT = "endpoint"
|
|
25
|
+
|
|
26
|
+
@classmethod
|
|
27
|
+
def values(cls):
|
|
28
|
+
return [member.value for member in cls]
|
|
29
|
+
|
|
30
|
+
class Framework(Enum):
|
|
31
|
+
LANGCHAIN = "langchain"
|
|
32
|
+
LANGGRAPH = "langgraph"
|
|
33
|
+
|
|
34
|
+
@classmethod
|
|
35
|
+
def values(cls):
|
|
36
|
+
return [member.value for member in cls]
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# ----------------------------------------------------------------------------------------------------
|
|
2
|
+
# IBM Confidential
|
|
3
|
+
# Licensed Materials - Property of IBM
|
|
4
|
+
# 5737-H76, 5900-A3Q
|
|
5
|
+
# © Copyright IBM Corp. 2025 All Rights Reserved.
|
|
6
|
+
# US Government Users Restricted Rights - Use, duplication or disclosure restricted by
|
|
7
|
+
# GSA ADPSchedule Contract with IBM Corp.
|
|
8
|
+
# ----------------------------------------------------------------------------------------------------
|
|
9
|
+
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
|
|
12
|
+
import nbformat
|
|
13
|
+
from IPython.display import display
|
|
14
|
+
from pandas import json_normalize
|
|
15
|
+
|
|
16
|
+
from ..clients.ai_agent_client import list_agents
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def get_all_code_from_notebook(notebook_path: str, main_method_name: str) -> str:
|
|
20
|
+
"""
|
|
21
|
+
Reads all code cells from a Jupyter notebook and returns combined Python code.
|
|
22
|
+
|
|
23
|
+
Args:
|
|
24
|
+
notebook_path: Path of the notebook
|
|
25
|
+
main_method_name: Name of the method to stop reading after this method in the notebook
|
|
26
|
+
Returns:
|
|
27
|
+
str: collected code from notebook cells
|
|
28
|
+
"""
|
|
29
|
+
notebook_path = Path(notebook_path).expanduser().resolve()
|
|
30
|
+
|
|
31
|
+
with open(notebook_path, 'r', encoding='utf-8') as f:
|
|
32
|
+
nb = nbformat.read(f, as_version=4)
|
|
33
|
+
|
|
34
|
+
code_cells = [cell.source for cell in nb.cells if cell.cell_type == 'code']
|
|
35
|
+
collected_code = []
|
|
36
|
+
|
|
37
|
+
for cell_code in code_cells:
|
|
38
|
+
if "pip" in cell_code:
|
|
39
|
+
continue
|
|
40
|
+
collected_code.append(cell_code)
|
|
41
|
+
if main_method_name in cell_code:
|
|
42
|
+
break # Stop after reaching the main method
|
|
43
|
+
|
|
44
|
+
return "\n\n".join(collected_code)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def display_agents(search_text: str = None, limit: int = None):
|
|
48
|
+
"""
|
|
49
|
+
Display the agents output in a dataframe
|
|
50
|
+
|
|
51
|
+
Args:
|
|
52
|
+
search_text (str, optional): text to search in the agents name, display name, description and summary fields
|
|
53
|
+
limit (int, optional): The maximum number of tools to display
|
|
54
|
+
"""
|
|
55
|
+
|
|
56
|
+
try:
|
|
57
|
+
agent_resp = list_agents(search_text=search_text, limit=limit)
|
|
58
|
+
rename_columns = {'entity.asset_name': 'agent_name', 'entity.category': 'category',
|
|
59
|
+
'entity.service_provider_type': 'service_provider_type'}
|
|
60
|
+
selected_columns = ["agent_name", "category", "service_provider_type"]
|
|
61
|
+
df = json_normalize(agent_resp['agents'], sep='.')
|
|
62
|
+
# Rename the columns for clarity
|
|
63
|
+
df.rename(columns=rename_columns, inplace=True)
|
|
64
|
+
df = df.dropna()
|
|
65
|
+
df = (df[selected_columns])
|
|
66
|
+
# Display table
|
|
67
|
+
display(df)
|
|
68
|
+
except Exception as e:
|
|
69
|
+
raise Exception(
|
|
70
|
+
f"Failed to display agents dataframe table. Reason: {e}")
|