oci 2.151.0__py3-none-any.whl → 2.152.1__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.
- oci/__init__.py +2 -2
- oci/access_governance_cp/access_governance_cp_client.py +8 -8
- oci/addons/__init__.py +20 -0
- oci/addons/adk/__init__.py +13 -0
- oci/addons/adk/agent.py +852 -0
- oci/addons/adk/agent_client.py +682 -0
- oci/addons/adk/agent_error.py +36 -0
- oci/addons/adk/auth/__init__.py +5 -0
- oci/addons/adk/auth/auth_provider.py +28 -0
- oci/addons/adk/auth/factory.py +78 -0
- oci/addons/adk/auth/oci/__init__.py +5 -0
- oci/addons/adk/auth/oci/instance_principal.py +53 -0
- oci/addons/adk/auth/oci/resource_principal.py +53 -0
- oci/addons/adk/auth/oci/session.py +91 -0
- oci/addons/adk/auth/oci/user_principal.py +64 -0
- oci/addons/adk/constants.py +17 -0
- oci/addons/adk/logger.py +163 -0
- oci/addons/adk/run/__init__.py +5 -0
- oci/addons/adk/run/response.py +56 -0
- oci/addons/adk/run/types.py +32 -0
- oci/addons/adk/tool/__init__.py +13 -0
- oci/addons/adk/tool/function_tool.py +334 -0
- oci/addons/adk/tool/prebuilt/__init__.py +8 -0
- oci/addons/adk/tool/prebuilt/agentic_rag_tool.py +49 -0
- oci/addons/adk/tool/prebuilt/calculator_toolkit.py +104 -0
- oci/addons/adk/tool/tool.py +37 -0
- oci/addons/adk/tool/toolkit.py +189 -0
- oci/addons/adk/tool/utils.py +120 -0
- oci/addons/adk/util.py +325 -0
- oci/adm/application_dependency_management_client.py +36 -36
- oci/ai_anomaly_detection/anomaly_detection_client.py +36 -36
- oci/ai_document/ai_service_document_client.py +26 -26
- oci/ai_language/ai_service_language_client.py +44 -44
- oci/ai_speech/ai_service_speech_client.py +19 -19
- oci/ai_vision/ai_service_vision_client.py +28 -28
- oci/analytics/analytics_client.py +24 -24
- oci/announcements_service/announcement_client.py +5 -5
- oci/announcements_service/announcement_subscription_client.py +9 -9
- oci/announcements_service/announcements_preferences_client.py +4 -4
- oci/announcements_service/service_client.py +1 -1
- oci/apigateway/api_gateway_client.py +21 -21
- oci/apigateway/deployment_client.py +6 -6
- oci/apigateway/gateway_client.py +6 -6
- oci/apigateway/subscribers_client.py +6 -6
- oci/apigateway/usage_plans_client.py +6 -6
- oci/apigateway/work_requests_client.py +5 -5
- oci/apm_config/config_client.py +12 -12
- oci/apm_control_plane/apm_domain_client.py +14 -14
- oci/apm_synthetics/apm_synthetic_client.py +28 -28
- oci/apm_traces/attributes_client.py +8 -8
- oci/apm_traces/query_client.py +2 -2
- oci/apm_traces/trace_client.py +4 -4
- oci/appmgmt_control/appmgmt_control_client.py +8 -8
- oci/artifacts/artifacts_client.py +32 -32
- oci/audit/audit_client.py +3 -3
- oci/autoscaling/auto_scaling_client.py +11 -11
- oci/bastion/bastion_client.py +15 -15
- oci/bds/bds_client.py +84 -84
- oci/blockchain/blockchain_platform_client.py +27 -27
- oci/budget/budget_client.py +10 -10
- oci/capacity_management/capacity_management_client.py +32 -32
- oci/certificates/certificates_client.py +5 -5
- oci/certificates_management/certificates_management_client.py +32 -32
- oci/cims/incident_client.py +6 -6
- oci/cloud_bridge/common_client.py +5 -5
- oci/cloud_bridge/discovery_client.py +15 -15
- oci/cloud_bridge/inventory_client.py +16 -16
- oci/cloud_bridge/ocb_agent_svc_client.py +23 -23
- oci/cloud_guard/cloud_guard_client.py +155 -155
- oci/cloud_migrations/migration_client.py +43 -43
- oci/cluster_placement_groups/cluster_placement_groups_cp_client.py +13 -13
- oci/compute_cloud_at_customer/compute_cloud_at_customer_client.py +12 -12
- oci/compute_instance_agent/compute_instance_agent_client.py +6 -6
- oci/compute_instance_agent/plugin_client.py +2 -2
- oci/compute_instance_agent/pluginconfig_client.py +1 -1
- oci/container_engine/container_engine_client.py +46 -46
- oci/container_instances/container_instance_client.py +18 -18
- oci/core/blockstorage_client.py +60 -60
- oci/core/compute_client.py +117 -117
- oci/core/compute_management_client.py +32 -32
- oci/core/virtual_network_client.py +258 -258
- oci/dashboard_service/dashboard_client.py +6 -6
- oci/dashboard_service/dashboard_group_client.py +6 -6
- oci/data_catalog/data_catalog_client.py +149 -149
- oci/data_flow/data_flow_client.py +45 -45
- oci/data_integration/data_integration_client.py +163 -163
- oci/data_labeling_service/data_labeling_management_client.py +17 -17
- oci/data_labeling_service_dataplane/data_labeling_client.py +15 -15
- oci/data_safe/data_safe_client.py +317 -317
- oci/data_science/data_science_client.py +145 -145
- oci/database/database_client.py +745 -469
- oci/database/models/__init__.py +2 -0
- oci/database/models/autonomous_db_version_summary.py +31 -0
- oci/database/models/backup.py +4 -2
- oci/database/models/backup_summary.py +4 -2
- oci/database/models/create_external_backup_job_details.py +4 -4
- oci/database/models/db_system.py +4 -2
- oci/database/models/db_system_summary.py +4 -2
- oci/database/models/db_system_upgrade_summary.py +152 -0
- oci/database/models/external_container_database.py +4 -2
- oci/database/models/external_container_database_summary.py +4 -2
- oci/database/models/external_database_base.py +4 -2
- oci/database/models/external_non_container_database.py +4 -2
- oci/database/models/external_non_container_database_summary.py +4 -2
- oci/database/models/external_pluggable_database.py +4 -2
- oci/database/models/external_pluggable_database_summary.py +4 -2
- oci/database_management/db_management_client.py +356 -230
- oci/database_management/db_management_client_composite_operations.py +44 -0
- oci/database_management/diagnosability_client.py +4 -4
- oci/database_management/managed_my_sql_databases_client.py +7 -247
- oci/database_management/models/__init__.py +0 -4
- oci/database_management/models/database_diagnostics_and_management_feature_details.py +35 -4
- oci/database_management/models/disable_database_management_feature_details.py +33 -2
- oci/database_management/models/disable_external_container_database_management_feature_details.py +33 -2
- oci/database_management/models/discovered_external_database.py +64 -2
- oci/database_management/models/exadata_infrastructure_lifecycle_state_values.py +40 -36
- oci/database_management/models/external_database_diagnostics_and_management_feature_details.py +64 -2
- oci/database_management/models/managed_database.py +2 -4
- oci/database_management/models/managed_database_summary.py +2 -4
- oci/database_management/models/modify_database_management_feature_details.py +1 -1
- oci/database_management/perfhub_client.py +1 -1
- oci/database_management/sql_tuning_client.py +17 -17
- oci/database_migration/database_migration_client.py +42 -42
- oci/database_tools/database_tools_client.py +23 -23
- oci/dblm/db_life_cycle_management_client.py +14 -14
- oci/delegate_access_control/delegate_access_control_client.py +26 -26
- oci/delegate_access_control/work_request_client.py +4 -4
- oci/demand_signal/occ_demand_signal_client.py +7 -7
- oci/desktops/desktop_service_client.py +21 -21
- oci/devops/devops_client.py +141 -141
- oci/disaster_recovery/disaster_recovery_client.py +31 -31
- oci/distributed_database/__init__.py +20 -0
- oci/distributed_database/distributed_autonomous_db_service_client.py +2315 -0
- oci/distributed_database/distributed_autonomous_db_service_client_composite_operations.py +605 -0
- oci/distributed_database/distributed_db_private_endpoint_service_client.py +944 -0
- oci/distributed_database/distributed_db_private_endpoint_service_client_composite_operations.py +238 -0
- oci/distributed_database/distributed_db_service_client.py +2435 -0
- oci/distributed_database/distributed_db_service_client_composite_operations.py +647 -0
- oci/distributed_database/distributed_db_work_request_service_client.py +654 -0
- oci/distributed_database/distributed_db_work_request_service_client_composite_operations.py +26 -0
- oci/distributed_database/models/__init__.py +158 -0
- oci/distributed_database/models/add_distributed_autonomous_database_gds_control_node_details.py +105 -0
- oci/distributed_database/models/add_distributed_database_gds_control_node_details.py +105 -0
- oci/distributed_database/models/catalog_peer_with_dedicated_infra.py +331 -0
- oci/distributed_database/models/catalog_peer_with_exadb_xs.py +331 -0
- oci/distributed_database/models/change_distributed_autonomous_database_compartment_details.py +74 -0
- oci/distributed_database/models/change_distributed_database_compartment_details.py +74 -0
- oci/distributed_database/models/change_distributed_database_private_endpoint_compartment_details.py +74 -0
- oci/distributed_database/models/change_distributed_db_backup_config_details.py +66 -0
- oci/distributed_database/models/configure_distributed_autonomous_database_gsms_details.py +103 -0
- oci/distributed_database/models/configure_distributed_database_gsms_details.py +103 -0
- oci/distributed_database/models/create_distributed_autonomous_database_catalog_details.py +101 -0
- oci/distributed_database/models/create_distributed_autonomous_database_catalog_with_dedicated_infra_details.py +342 -0
- oci/distributed_database/models/create_distributed_autonomous_database_details.py +799 -0
- oci/distributed_database/models/create_distributed_autonomous_database_shard_details.py +101 -0
- oci/distributed_database/models/create_distributed_autonomous_database_shard_with_dedicated_infra_details.py +377 -0
- oci/distributed_database/models/create_distributed_database_catalog_details.py +99 -0
- oci/distributed_database/models/create_distributed_database_catalog_with_exadb_xs_details.py +282 -0
- oci/distributed_database/models/create_distributed_database_details.py +810 -0
- oci/distributed_database/models/create_distributed_database_private_endpoint_details.py +260 -0
- oci/distributed_database/models/create_distributed_database_shard_details.py +99 -0
- oci/distributed_database/models/create_distributed_database_shard_with_exadb_xs_details.py +282 -0
- oci/distributed_database/models/distributed_autonomous_database.py +1143 -0
- oci/distributed_database/models/distributed_autonomous_database_associated_with_private_endpoint.py +105 -0
- oci/distributed_database/models/distributed_autonomous_database_catalog.py +194 -0
- oci/distributed_database/models/distributed_autonomous_database_catalog_with_dedicated_infra.py +559 -0
- oci/distributed_database/models/distributed_autonomous_database_collection.py +70 -0
- oci/distributed_database/models/distributed_autonomous_database_connection_string.py +70 -0
- oci/distributed_database/models/distributed_autonomous_database_gsm.py +385 -0
- oci/distributed_database/models/distributed_autonomous_database_gsm_image.py +105 -0
- oci/distributed_database/models/distributed_autonomous_database_shard.py +194 -0
- oci/distributed_database/models/distributed_autonomous_database_shard_with_dedicated_infra.py +592 -0
- oci/distributed_database/models/distributed_autonomous_database_summary.py +935 -0
- oci/distributed_database/models/distributed_autonomous_db_metadata.py +70 -0
- oci/distributed_database/models/distributed_database.py +1154 -0
- oci/distributed_database/models/distributed_database_associated_with_private_endpoint.py +105 -0
- oci/distributed_database/models/distributed_database_catalog.py +192 -0
- oci/distributed_database/models/distributed_database_catalog_with_exadb_xs.py +466 -0
- oci/distributed_database/models/distributed_database_collection.py +70 -0
- oci/distributed_database/models/distributed_database_gsm.py +385 -0
- oci/distributed_database/models/distributed_database_private_endpoint.py +639 -0
- oci/distributed_database/models/distributed_database_private_endpoint_collection.py +70 -0
- oci/distributed_database/models/distributed_database_private_endpoint_summary.py +479 -0
- oci/distributed_database/models/distributed_database_shard.py +192 -0
- oci/distributed_database/models/distributed_database_shard_with_exadb_xs.py +499 -0
- oci/distributed_database/models/distributed_database_summary.py +904 -0
- oci/distributed_database/models/distributed_db_backup_config.py +536 -0
- oci/distributed_database/models/distributed_db_backup_destination.py +362 -0
- oci/distributed_database/models/distributed_db_connection_string.py +70 -0
- oci/distributed_database/models/distributed_db_gsm_image.py +105 -0
- oci/distributed_database/models/distributed_db_metadata.py +70 -0
- oci/distributed_database/models/generate_distributed_autonomous_database_wallet_details.py +70 -0
- oci/distributed_database/models/generate_distributed_database_wallet_details.py +70 -0
- oci/distributed_database/models/patch_distributed_autonomous_database_details.py +73 -0
- oci/distributed_database/models/patch_distributed_database_details.py +73 -0
- oci/distributed_database/models/patch_insert_instruction.py +87 -0
- oci/distributed_database/models/patch_instruction.py +154 -0
- oci/distributed_database/models/patch_merge_instruction.py +95 -0
- oci/distributed_database/models/patch_remove_instruction.py +57 -0
- oci/distributed_database/models/shard_peer_with_dedicated_infra.py +331 -0
- oci/distributed_database/models/shard_peer_with_exadb_xs.py +331 -0
- oci/distributed_database/models/update_distributed_autonomous_database_details.py +136 -0
- oci/distributed_database/models/update_distributed_database_details.py +136 -0
- oci/distributed_database/models/update_distributed_database_private_endpoint_details.py +198 -0
- oci/distributed_database/models/upload_distributed_autonomous_database_signed_certificate_and_generate_wallet_details.py +71 -0
- oci/distributed_database/models/upload_distributed_database_signed_certificate_and_generate_wallet_details.py +71 -0
- oci/distributed_database/models/work_request.py +516 -0
- oci/distributed_database/models/work_request_error.py +134 -0
- oci/distributed_database/models/work_request_error_collection.py +70 -0
- oci/distributed_database/models/work_request_log_entry.py +101 -0
- oci/distributed_database/models/work_request_log_entry_collection.py +70 -0
- oci/distributed_database/models/work_request_resource.py +232 -0
- oci/distributed_database/models/work_request_summary.py +516 -0
- oci/distributed_database/models/work_request_summary_collection.py +70 -0
- oci/dns/dns_client.py +54 -54
- oci/dts/appliance_export_job_client.py +6 -6
- oci/dts/shipping_vendors_client.py +1 -1
- oci/dts/transfer_appliance_client.py +8 -8
- oci/dts/transfer_appliance_entitlement_client.py +3 -3
- oci/dts/transfer_device_client.py +5 -5
- oci/dts/transfer_job_client.py +6 -6
- oci/dts/transfer_package_client.py +7 -7
- oci/em_warehouse/em_warehouse_client.py +13 -13
- oci/email/email_client.py +31 -31
- oci/email_data_plane/email_dp_client.py +1 -1
- oci/events/events_client.py +6 -6
- oci/file_storage/file_storage_client.py +74 -74
- oci/fleet_apps_management/fleet_apps_management_admin_client.py +27 -27
- oci/fleet_apps_management/fleet_apps_management_catalog_client.py +7 -7
- oci/fleet_apps_management/fleet_apps_management_client.py +32 -32
- oci/fleet_apps_management/fleet_apps_management_maintenance_window_client.py +5 -5
- oci/fleet_apps_management/fleet_apps_management_operations_client.py +29 -29
- oci/fleet_apps_management/fleet_apps_management_provision_client.py +6 -6
- oci/fleet_apps_management/fleet_apps_management_runbooks_client.py +19 -19
- oci/fleet_apps_management/fleet_apps_management_work_request_client.py +4 -4
- oci/fleet_software_update/fleet_software_update_client.py +46 -46
- oci/functions/functions_invoke_client.py +1 -1
- oci/functions/functions_management_client.py +16 -16
- oci/fusion_apps/fusion_applications_client.py +41 -41
- oci/generative_ai/generative_ai_client.py +22 -22
- oci/generative_ai/models/create_dedicated_ai_cluster_details.py +4 -0
- oci/generative_ai/models/dedicated_ai_cluster.py +11 -3
- oci/generative_ai_agent/generative_ai_agent_client.py +38 -38
- oci/generative_ai_agent_runtime/generative_ai_agent_runtime_client.py +6 -6
- oci/generative_ai_inference/generative_ai_inference_client.py +6 -6
- oci/generic_artifacts_content/generic_artifacts_content_client.py +3 -3
- oci/globally_distributed_database/sharded_database_service_client.py +58 -58
- oci/golden_gate/golden_gate_client.py +89 -89
- oci/governance_rules_control_plane/governance_rule_client.py +15 -15
- oci/governance_rules_control_plane/work_request_client.py +5 -5
- oci/healthchecks/health_checks_client.py +17 -17
- oci/identity/identity_client.py +145 -145
- oci/identity_data_plane/dataplane_client.py +2 -2
- oci/identity_domains/identity_domains_client.py +311 -311
- oci/integration/integration_instance_client.py +19 -19
- oci/jms/java_management_service_client.py +79 -79
- oci/jms_java_downloads/java_download_client.py +25 -25
- oci/key_management/ekm_client.py +5 -5
- oci/key_management/kms_crypto_client.py +6 -6
- oci/key_management/kms_hsm_cluster_client.py +12 -12
- oci/key_management/kms_management_client.py +21 -21
- oci/key_management/kms_vault_client.py +14 -14
- oci/license_manager/license_manager_client.py +18 -18
- oci/limits/limits_client.py +4 -4
- oci/limits/quotas_client.py +7 -7
- oci/load_balancer/load_balancer_client.py +61 -61
- oci/lockbox/lockbox_client.py +24 -24
- oci/log_analytics/log_analytics_client.py +200 -200
- oci/logging/logging_management_client.py +30 -30
- oci/loggingingestion/logging_client.py +1 -1
- oci/loggingsearch/log_search_client.py +1 -1
- oci/lustre_file_storage/lustre_file_storage_client.py +11 -11
- oci/management_agent/management_agent_client.py +28 -28
- oci/management_dashboard/dashx_apis_client.py +14 -14
- oci/marketplace/account_client.py +2 -2
- oci/marketplace/marketplace_client.py +30 -30
- oci/marketplace_private_offer/attachment_client.py +5 -5
- oci/marketplace_private_offer/offer_client.py +6 -6
- oci/marketplace_publisher/attachment_client.py +5 -5
- oci/marketplace_publisher/marketplace_publisher_client.py +71 -71
- oci/marketplace_publisher/offer_client.py +6 -6
- oci/media_services/media_services_client.py +60 -60
- oci/media_services/media_stream_client.py +2 -2
- oci/mngdmac/mac_device_client.py +3 -3
- oci/mngdmac/mac_order_client.py +11 -11
- oci/model_deployment/__init__.py +14 -0
- oci/model_deployment/model_deployment_client.py +331 -0
- oci/model_deployment/model_deployment_client_composite_operations.py +26 -0
- oci/model_deployment/models/__init__.py +14 -0
- oci/model_deployment/models/inference_result.py +70 -0
- oci/monitoring/monitoring_client.py +18 -18
- oci/mysql/channels_client.py +7 -7
- oci/mysql/db_backups_client.py +7 -7
- oci/mysql/db_system_client.py +17 -17
- oci/mysql/models/create_db_system_details.py +31 -0
- oci/mysql/models/db_system.py +31 -0
- oci/mysql/models/db_system_snapshot.py +31 -0
- oci/mysql/models/replica.py +31 -0
- oci/mysql/models/replica_overrides.py +33 -2
- oci/mysql/models/replica_summary.py +31 -0
- oci/mysql/models/update_db_system_details.py +31 -0
- oci/mysql/mysqlaas_client.py +7 -7
- oci/mysql/replicas_client.py +5 -5
- oci/mysql/work_requests_client.py +4 -4
- oci/network_firewall/network_firewall_client.py +86 -86
- oci/network_load_balancer/network_load_balancer_client.py +35 -35
- oci/nosql/nosql_client.py +24 -24
- oci/object_storage/object_storage_client.py +55 -55
- oci/oce/oce_instance_client.py +10 -10
- oci/oci_control_center/occ_metrics_client.py +3 -3
- oci/ocvp/cluster_client.py +5 -5
- oci/ocvp/esxi_host_client.py +8 -8
- oci/ocvp/sddc_client.py +14 -14
- oci/ocvp/work_request_client.py +4 -4
- oci/oda/management_client.py +59 -59
- oci/oda/oda_client.py +17 -17
- oci/oda/odapackage_client.py +7 -7
- oci/onesubscription/billing_schedule_client.py +1 -1
- oci/onesubscription/commitment_client.py +2 -2
- oci/onesubscription/computed_usage_client.py +3 -3
- oci/onesubscription/invoice_summary_client.py +2 -2
- oci/onesubscription/organization_subscription_client.py +1 -1
- oci/onesubscription/ratecard_client.py +1 -1
- oci/onesubscription/subscribed_service_client.py +2 -2
- oci/onesubscription/subscription_client.py +1 -1
- oci/ons/notification_control_plane_client.py +6 -6
- oci/ons/notification_data_plane_client.py +10 -10
- oci/opa/opa_instance_client.py +13 -13
- oci/opensearch/models/__init__.py +2 -0
- oci/opensearch/models/create_opensearch_cluster_details.py +291 -0
- oci/opensearch/models/create_opensearch_cluster_pipeline_details.py +31 -0
- oci/opensearch/models/opensearch_cluster.py +291 -0
- oci/opensearch/models/opensearch_cluster_pipeline.py +31 -0
- oci/opensearch/models/opensearch_cluster_pipeline_summary.py +31 -0
- oci/opensearch/models/resize_opensearch_cluster_horizontal_details.py +31 -0
- oci/opensearch/models/resize_opensearch_cluster_vertical_details.py +217 -0
- oci/opensearch/models/shapes_details.py +70 -0
- oci/opensearch/models/update_cluster_specs_details.py +186 -0
- oci/opensearch/models/update_opensearch_cluster_pipeline_details.py +31 -0
- oci/opensearch/opensearch_cluster_backup_client.py +4 -4
- oci/opensearch/opensearch_cluster_client.py +87 -16
- oci/opensearch/opensearch_cluster_pipeline_client.py +5 -5
- oci/operator_access_control/access_requests_client.py +10 -10
- oci/operator_access_control/operator_actions_client.py +2 -2
- oci/operator_access_control/operator_control_assignment_client.py +8 -8
- oci/operator_access_control/operator_control_client.py +6 -6
- oci/opsi/operations_insights_client.py +181 -181
- oci/optimizer/optimizer_client.py +26 -26
- oci/os_management/event_client.py +8 -8
- oci/os_management/os_management_client.py +69 -69
- oci/os_management_hub/event_client.py +8 -8
- oci/os_management_hub/lifecycle_environment_client.py +13 -13
- oci/os_management_hub/managed_instance_client.py +33 -33
- oci/os_management_hub/managed_instance_group_client.py +26 -26
- oci/os_management_hub/management_station_client.py +10 -10
- oci/os_management_hub/onboarding_client.py +13 -13
- oci/os_management_hub/reporting_managed_instance_client.py +3 -3
- oci/os_management_hub/scheduled_job_client.py +7 -7
- oci/os_management_hub/software_source_client.py +33 -33
- oci/os_management_hub/work_request_client.py +5 -5
- oci/osp_gateway/address_rule_service_client.py +1 -1
- oci/osp_gateway/address_service_client.py +2 -2
- oci/osp_gateway/invoice_service_client.py +5 -5
- oci/osp_gateway/subscription_service_client.py +5 -5
- oci/osub_billing_schedule/billing_schedule_client.py +1 -1
- oci/osub_organization_subscription/organization_subscription_client.py +1 -1
- oci/osub_subscription/commitment_client.py +2 -2
- oci/osub_subscription/ratecard_client.py +1 -1
- oci/osub_subscription/subscription_client.py +1 -1
- oci/osub_usage/computed_usage_client.py +3 -3
- oci/psql/postgresql_client.py +34 -34
- oci/queue/queue_admin_client.py +11 -11
- oci/queue/queue_client.py +8 -8
- oci/recovery/database_recovery_client.py +26 -26
- oci/redis/redis_cluster_client.py +12 -12
- oci/resource_manager/resource_manager_client.py +52 -52
- oci/resource_scheduler/schedule_client.py +14 -14
- oci/resource_search/resource_search_client.py +3 -3
- oci/rover/rover_bundle_client.py +8 -8
- oci/rover/rover_cluster_client.py +8 -8
- oci/rover/rover_entitlement_client.py +6 -6
- oci/rover/rover_node_client.py +15 -15
- oci/rover/shape_client.py +1 -1
- oci/rover/work_requests_client.py +5 -5
- oci/sch/connector_plugins_client.py +2 -2
- oci/sch/service_connector_client.py +12 -12
- oci/secrets/secrets_client.py +3 -3
- oci/security_attribute/security_attribute_client.py +18 -18
- oci/service_catalog/service_catalog_client.py +26 -26
- oci/service_manager_proxy/service_manager_proxy_client.py +2 -2
- oci/service_mesh/service_mesh_client.py +48 -48
- oci/stack_monitoring/stack_monitoring_client.py +87 -87
- oci/streaming/stream_admin_client.py +18 -18
- oci/streaming/stream_client.py +8 -8
- oci/tenant_manager_control_plane/domain_client.py +5 -5
- oci/tenant_manager_control_plane/domain_governance_client.py +5 -5
- oci/tenant_manager_control_plane/governance_client.py +2 -2
- oci/tenant_manager_control_plane/link_client.py +3 -3
- oci/tenant_manager_control_plane/orders_client.py +2 -2
- oci/tenant_manager_control_plane/organization_client.py +10 -10
- oci/tenant_manager_control_plane/recipient_invitation_client.py +5 -5
- oci/tenant_manager_control_plane/sender_invitation_client.py +5 -5
- oci/tenant_manager_control_plane/subscription_client.py +11 -11
- oci/tenant_manager_control_plane/work_request_client.py +4 -4
- oci/threat_intelligence/threatintel_client.py +5 -5
- oci/usage/resources_client.py +2 -2
- oci/usage/rewards_client.py +6 -6
- oci/usage/usagelimits_client.py +1 -1
- oci/usage_api/usageapi_client.py +33 -33
- oci/vault/vaults_client.py +13 -13
- oci/vbs_inst/vbs_instance_client.py +10 -10
- oci/version.py +1 -1
- oci/visual_builder/vb_instance_client.py +14 -14
- oci/vn_monitoring/vn_monitoring_client.py +12 -12
- oci/vulnerability_scanning/vulnerability_scanning_client.py +58 -58
- oci/waa/waa_client.py +13 -13
- oci/waa/work_request_client.py +4 -4
- oci/waas/redirect_client.py +6 -6
- oci/waas/waas_client.py +66 -66
- oci/waf/waf_client.py +24 -24
- oci/work_requests/work_request_client.py +4 -4
- oci/zpr/zpr_client.py +15 -15
- {oci-2.151.0.dist-info → oci-2.152.1.dist-info}/METADATA +6 -1
- {oci-2.151.0.dist-info → oci-2.152.1.dist-info}/RECORD +428 -313
- oci/database_management/models/disable_external_mysql_associated_service_details.py +0 -144
- oci/database_management/models/enable_external_mysql_associated_service_details.py +0 -144
- {oci-2.151.0.dist-info → oci-2.152.1.dist-info}/LICENSE.txt +0 -0
- {oci-2.151.0.dist-info → oci-2.152.1.dist-info}/THIRD_PARTY_LICENSES.txt +0 -0
- {oci-2.151.0.dist-info → oci-2.152.1.dist-info}/WHEEL +0 -0
- {oci-2.151.0.dist-info → oci-2.152.1.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,189 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved.
|
3
|
+
# This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license.
|
4
|
+
|
5
|
+
import inspect
|
6
|
+
import json
|
7
|
+
from types import MethodType
|
8
|
+
from typing import Any, Callable, Dict, List
|
9
|
+
|
10
|
+
from pydantic import BaseModel, Field
|
11
|
+
|
12
|
+
from oci.addons.adk.logger import default_logger as logger
|
13
|
+
from oci.addons.adk.tool import FunctionTool
|
14
|
+
|
15
|
+
|
16
|
+
class Toolkit(BaseModel):
|
17
|
+
"""A base class where subclass can declare a collection
|
18
|
+
of tools related to a specific task."""
|
19
|
+
|
20
|
+
name: str
|
21
|
+
|
22
|
+
functions: Dict[str, FunctionTool] = Field(default_factory=dict)
|
23
|
+
openai_tools_file: str = ""
|
24
|
+
|
25
|
+
def __init__(self, name: str = "toolkit", openai_tools_file: str = ""):
|
26
|
+
"""Initialize a new Toolkit.
|
27
|
+
|
28
|
+
Args:
|
29
|
+
name:
|
30
|
+
A descriptive name for the toolkit
|
31
|
+
openai_tools_file:
|
32
|
+
Optional JSON containing the function definition
|
33
|
+
per OpenAI Responses API function tool format
|
34
|
+
"""
|
35
|
+
super().__init__(name=name, functions={}, openai_tools_file=openai_tools_file)
|
36
|
+
|
37
|
+
# Load OpenAI tool definitions if specified
|
38
|
+
openai_tools_json = {}
|
39
|
+
if openai_tools_file != "":
|
40
|
+
try:
|
41
|
+
with open(openai_tools_file, "r", encoding="utf-8") as f:
|
42
|
+
openai_tools_json = json.load(f)
|
43
|
+
|
44
|
+
# check it's a JSON object that contains a "tools" key
|
45
|
+
if "tools" not in openai_tools_json:
|
46
|
+
raise ValueError("OpenAI tools file must contain a 'tools' key")
|
47
|
+
|
48
|
+
# check the "tools" key is a list
|
49
|
+
if not isinstance(openai_tools_json["tools"], list):
|
50
|
+
raise ValueError(
|
51
|
+
"OpenAI tools file must contain a 'tools' key that is a list"
|
52
|
+
)
|
53
|
+
|
54
|
+
# check each item in the list is a JSON object that contains key "type"
|
55
|
+
for tool in openai_tools_json["tools"]:
|
56
|
+
if "type" not in tool:
|
57
|
+
raise ValueError(
|
58
|
+
"OpenAI tools file must contain a 'type' key for each tool"
|
59
|
+
)
|
60
|
+
|
61
|
+
# check the "type" key is "function"
|
62
|
+
if tool["type"] != "function":
|
63
|
+
raise ValueError(
|
64
|
+
"OpenAI tools file must contain a 'type' key "
|
65
|
+
"for each tool that is 'function'"
|
66
|
+
)
|
67
|
+
|
68
|
+
# get the number of tools
|
69
|
+
num_tools = len(openai_tools_json["tools"])
|
70
|
+
logger.debug(
|
71
|
+
f"[green]Success:[/green] Loaded {num_tools} "
|
72
|
+
f"OpenAI tools from {openai_tools_file}"
|
73
|
+
)
|
74
|
+
except Exception as e:
|
75
|
+
logger.debug(
|
76
|
+
f"[yellow]Warning:[/yellow] Failed to load OpenAI tools "
|
77
|
+
f"from {openai_tools_file}: {e}"
|
78
|
+
)
|
79
|
+
|
80
|
+
# Auto-register methods marked with @tool decorator
|
81
|
+
for attr_name in dir(self):
|
82
|
+
# skip private methods
|
83
|
+
if attr_name.startswith("__"):
|
84
|
+
continue
|
85
|
+
|
86
|
+
if attr_name.startswith("model_"):
|
87
|
+
continue
|
88
|
+
|
89
|
+
attr = getattr(self, attr_name)
|
90
|
+
|
91
|
+
# skip non-callable attributes
|
92
|
+
if not callable(attr):
|
93
|
+
continue
|
94
|
+
|
95
|
+
# skip non-tool attributes
|
96
|
+
if not getattr(attr, "_is_tool", False):
|
97
|
+
continue
|
98
|
+
|
99
|
+
# skip not method attributes
|
100
|
+
if not isinstance(attr, MethodType):
|
101
|
+
continue
|
102
|
+
|
103
|
+
# Ensure method first argument is self
|
104
|
+
original_func = attr.__func__
|
105
|
+
sig = inspect.signature(original_func)
|
106
|
+
params = list(sig.parameters.values())
|
107
|
+
if len(params) == 0 or params[0].name != "self":
|
108
|
+
raise ValueError(
|
109
|
+
f"@Tool decorated method {attr_name} of {self.__class__.__name__} "
|
110
|
+
"must have a first argument of self"
|
111
|
+
)
|
112
|
+
|
113
|
+
matching_openai_tool = None
|
114
|
+
if openai_tools_json:
|
115
|
+
# Find the matching OpenAI tool def with the same name as the method
|
116
|
+
openai_tool_list = openai_tools_json["tools"]
|
117
|
+
matching_openai_tool = next(
|
118
|
+
(
|
119
|
+
tool
|
120
|
+
for tool in openai_tool_list
|
121
|
+
if tool.get("name") == attr_name and tool.get("type") == "function"
|
122
|
+
),
|
123
|
+
None,
|
124
|
+
)
|
125
|
+
|
126
|
+
if matching_openai_tool:
|
127
|
+
# Create FunctionTool from OpenAI definition
|
128
|
+
self._add_function_tool_from_openai(attr, matching_openai_tool)
|
129
|
+
else:
|
130
|
+
# Create FunctionTool from method decoration
|
131
|
+
self._add_function_tool(attr)
|
132
|
+
|
133
|
+
def get_registered_tools(self) -> List[FunctionTool]:
|
134
|
+
"""Return a list of all registered tools in the toolkit."""
|
135
|
+
return list(self.functions.values())
|
136
|
+
|
137
|
+
def print_arguments_received(self) -> None:
|
138
|
+
"""Print the arguments received by the tool."""
|
139
|
+
# Get the frame of the calling function
|
140
|
+
caller_frame = inspect.currentframe()
|
141
|
+
if caller_frame is None:
|
142
|
+
logger.info("Could not get caller frame")
|
143
|
+
return
|
144
|
+
|
145
|
+
caller_frame = caller_frame.f_back
|
146
|
+
if caller_frame is None:
|
147
|
+
logger.info("Could not get caller's parent frame")
|
148
|
+
return
|
149
|
+
|
150
|
+
# Get all arguments of the calling function
|
151
|
+
args_info = inspect.getargvalues(caller_frame)
|
152
|
+
# Create a dictionary of arguments (excluding 'self')
|
153
|
+
args = {arg: args_info.locals[arg] for arg in args_info.args if arg != "self"}
|
154
|
+
logger.info(
|
155
|
+
f"Executing mock function implementation with received arguments: {args}"
|
156
|
+
)
|
157
|
+
|
158
|
+
def _add_function_tool(self, callable: Callable[..., Any]) -> None:
|
159
|
+
"""Internal method to add a function as a tool to the toolkit.
|
160
|
+
|
161
|
+
Args:
|
162
|
+
callable: The callable to add as a tool
|
163
|
+
"""
|
164
|
+
try:
|
165
|
+
f = FunctionTool.from_callable(callable)
|
166
|
+
self.functions[f.name] = f
|
167
|
+
except Exception as e:
|
168
|
+
raise e
|
169
|
+
|
170
|
+
def _add_function_tool_from_openai(
|
171
|
+
self, callable: Callable[..., Any], openai_tool: Dict[str, Any]
|
172
|
+
) -> None:
|
173
|
+
"""Internal method to add a function as a tool using OpenAI tool definition.
|
174
|
+
|
175
|
+
Args:
|
176
|
+
callable: The callable to add as a tool
|
177
|
+
openai_tool: The OpenAI tool definition
|
178
|
+
"""
|
179
|
+
try:
|
180
|
+
f = FunctionTool.from_callable_openai_tool(callable, openai_tool)
|
181
|
+
self.functions[f.name] = f
|
182
|
+
except Exception as e:
|
183
|
+
raise e
|
184
|
+
|
185
|
+
def __repr__(self):
|
186
|
+
return f"<{self.__class__.__name__} name={self.name} functions={list(self.functions.keys())}>" # noqa: E501
|
187
|
+
|
188
|
+
def __str__(self):
|
189
|
+
return self.__repr__()
|
@@ -0,0 +1,120 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved.
|
3
|
+
# This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license.
|
4
|
+
|
5
|
+
from typing import Dict, Any, List, TypeVar
|
6
|
+
|
7
|
+
from oci.addons.adk.tool.function_tool import FunctionTool
|
8
|
+
from oci.addons.adk.tool.prebuilt.agentic_rag_tool import AgenticRagTool
|
9
|
+
from oci.addons.adk.logger import default_logger as logger
|
10
|
+
from oci.addons.adk.util import build_custom_function_params
|
11
|
+
|
12
|
+
|
13
|
+
def diff_local_and_remote_tool(
|
14
|
+
local_tool: FunctionTool | AgenticRagTool,
|
15
|
+
remote_tool: Dict[str, Any],
|
16
|
+
) -> bool:
|
17
|
+
"""
|
18
|
+
Return true if the local tool and the remote tool are different.
|
19
|
+
|
20
|
+
Args:
|
21
|
+
local_tool: The local tool
|
22
|
+
remote_tool: The remote tool
|
23
|
+
|
24
|
+
Returns:
|
25
|
+
True if the local tool and the remote tool are different, False otherwise
|
26
|
+
"""
|
27
|
+
local_tool_json_spec: Dict[str, Any] = {}
|
28
|
+
remote_tool_json_spec: Dict[str, Any] = {}
|
29
|
+
|
30
|
+
if isinstance(local_tool, FunctionTool):
|
31
|
+
local_tool_json_spec = {
|
32
|
+
"tool_name": local_tool.name,
|
33
|
+
"tool_description": local_tool.description,
|
34
|
+
"name": local_tool.name,
|
35
|
+
"description": local_tool.description,
|
36
|
+
"parameters": build_custom_function_params(local_tool.parameters),
|
37
|
+
}
|
38
|
+
|
39
|
+
remote_tool_json_spec = {
|
40
|
+
"tool_name": remote_tool.get("display_name", ""),
|
41
|
+
"tool_description": remote_tool.get("description", ""),
|
42
|
+
**remote_tool["tool_config"]["function"],
|
43
|
+
}
|
44
|
+
|
45
|
+
elif isinstance(local_tool, AgenticRagTool):
|
46
|
+
local_tool_json_spec = {
|
47
|
+
"name": local_tool.name,
|
48
|
+
"description": local_tool.description,
|
49
|
+
"knowledge_base_ids": sorted(local_tool.knowledge_base_ids),
|
50
|
+
}
|
51
|
+
remote_tool_json_spec = {
|
52
|
+
"name": remote_tool.get("display_name", ""),
|
53
|
+
"description": remote_tool.get("description", ""),
|
54
|
+
"knowledge_base_ids": sorted(
|
55
|
+
[
|
56
|
+
kb_config.get("knowledge_base_id")
|
57
|
+
for kb_config in remote_tool.get("tool_config", {}).get(
|
58
|
+
"knowledge_base_configs", []
|
59
|
+
)
|
60
|
+
]
|
61
|
+
)
|
62
|
+
}
|
63
|
+
|
64
|
+
logger.debug(f"Local tool JSON spec: {local_tool_json_spec}")
|
65
|
+
logger.debug(f"Remote tool JSON spec: {remote_tool_json_spec}")
|
66
|
+
|
67
|
+
return local_tool_json_spec != remote_tool_json_spec
|
68
|
+
|
69
|
+
|
70
|
+
def compare_local_and_remote_tools(
|
71
|
+
local_tools: List[FunctionTool] | List[AgenticRagTool],
|
72
|
+
remote_tools: List[Dict[str, Any]],
|
73
|
+
) -> bool:
|
74
|
+
"""
|
75
|
+
Return true if the local tools and the remote tools are the same.
|
76
|
+
|
77
|
+
Args:
|
78
|
+
local_tools: The local tools
|
79
|
+
remote_tools: The remote tools
|
80
|
+
|
81
|
+
Returns:
|
82
|
+
True if the all local tools and the remote tools are the same, False otherwise
|
83
|
+
"""
|
84
|
+
same_list: List[bool] = []
|
85
|
+
# different number of tools
|
86
|
+
if len(local_tools) != len(remote_tools):
|
87
|
+
return False
|
88
|
+
for local_tool in local_tools:
|
89
|
+
# any remote tool is the same with local tool
|
90
|
+
same_list.append(
|
91
|
+
any(
|
92
|
+
not diff_local_and_remote_tool(local_tool, remote_tool)
|
93
|
+
for remote_tool in remote_tools
|
94
|
+
)
|
95
|
+
)
|
96
|
+
# all local tools are the same with remote tools
|
97
|
+
return all(same_list)
|
98
|
+
|
99
|
+
|
100
|
+
T = TypeVar('T')
|
101
|
+
|
102
|
+
|
103
|
+
def dedupe_tools_list(
|
104
|
+
tools_list: List[T],
|
105
|
+
) -> List[T]:
|
106
|
+
"""
|
107
|
+
Return a list of unique tools.
|
108
|
+
|
109
|
+
Args:
|
110
|
+
tools_list: The tools list of any type
|
111
|
+
|
112
|
+
Returns:
|
113
|
+
A list of unique tools of the same type as input
|
114
|
+
"""
|
115
|
+
result_tools_list: List[T] = []
|
116
|
+
for tool in tools_list:
|
117
|
+
if any(tool == exist_tool for exist_tool in result_tools_list):
|
118
|
+
continue
|
119
|
+
result_tools_list.append(tool)
|
120
|
+
return result_tools_list
|
oci/addons/adk/util.py
ADDED
@@ -0,0 +1,325 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# Copyright (c) 2016, 2025, Oracle and/or its affiliates. All rights reserved.
|
3
|
+
# This software is dual-licensed to you under the Universal Permissive License (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl or Apache License 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose either license.
|
4
|
+
|
5
|
+
import inspect
|
6
|
+
import json
|
7
|
+
from types import NoneType
|
8
|
+
from typing import Any, Callable, Dict, Optional, Tuple, Union, get_args, get_origin
|
9
|
+
|
10
|
+
from docstring_parser import parse
|
11
|
+
from oci import regions
|
12
|
+
|
13
|
+
|
14
|
+
class DocstringParser:
|
15
|
+
"""Utility class for parsing and extracting information from docstrings."""
|
16
|
+
|
17
|
+
@staticmethod
|
18
|
+
def get_callable_description(callable_func: Callable) -> str:
|
19
|
+
"""
|
20
|
+
Extract a description from a callable's docstring.
|
21
|
+
|
22
|
+
Args:
|
23
|
+
callable_func: The function or method to extract description from
|
24
|
+
|
25
|
+
Returns:
|
26
|
+
A string containing the combined short and long descriptions
|
27
|
+
"""
|
28
|
+
doc = inspect.getdoc(callable_func)
|
29
|
+
if not doc:
|
30
|
+
return ""
|
31
|
+
|
32
|
+
parsed = parse(doc)
|
33
|
+
|
34
|
+
# Combine short and long descriptions
|
35
|
+
result = ""
|
36
|
+
if parsed.short_description:
|
37
|
+
result = parsed.short_description
|
38
|
+
if parsed.long_description:
|
39
|
+
# Preserve the double newline between short and long descriptions
|
40
|
+
if result:
|
41
|
+
result += "\n\n"
|
42
|
+
result += parsed.long_description
|
43
|
+
|
44
|
+
return result
|
45
|
+
|
46
|
+
|
47
|
+
class JsonSchemaGenerator:
|
48
|
+
"""Utility class for generating JSON schemas from Python type annotations."""
|
49
|
+
|
50
|
+
# Constants for type mapping
|
51
|
+
JSON_TYPE_MAPPING = {
|
52
|
+
"int": "number",
|
53
|
+
"float": "number",
|
54
|
+
"complex": "number",
|
55
|
+
"Decimal": "number",
|
56
|
+
"str": "string",
|
57
|
+
"string": "string",
|
58
|
+
"bool": "boolean",
|
59
|
+
"boolean": "boolean",
|
60
|
+
"NoneType": "null",
|
61
|
+
"None": "null",
|
62
|
+
"list": "array",
|
63
|
+
"tuple": "array",
|
64
|
+
"set": "array",
|
65
|
+
"frozenset": "array",
|
66
|
+
"dict": "object",
|
67
|
+
"mapping": "object",
|
68
|
+
}
|
69
|
+
|
70
|
+
# Collection types that should be treated as arrays
|
71
|
+
ARRAY_TYPES = (list, tuple, set, frozenset)
|
72
|
+
|
73
|
+
@classmethod
|
74
|
+
def get_json_type_for_py_type(cls, arg_type: str) -> str:
|
75
|
+
"""
|
76
|
+
Get the JSON schema type for a given Python type.
|
77
|
+
|
78
|
+
Args:
|
79
|
+
arg_type: The Python type name to convert
|
80
|
+
|
81
|
+
Returns:
|
82
|
+
The corresponding JSON schema type
|
83
|
+
"""
|
84
|
+
return cls.JSON_TYPE_MAPPING.get(arg_type, "object")
|
85
|
+
|
86
|
+
@classmethod
|
87
|
+
def get_json_schema_for_arg(cls, t: Any) -> Optional[Dict[str, Any]]:
|
88
|
+
"""
|
89
|
+
Generate a JSON schema for a given type annotation.
|
90
|
+
|
91
|
+
Args:
|
92
|
+
t: The type annotation to convert to JSON schema
|
93
|
+
|
94
|
+
Returns:
|
95
|
+
A dictionary representing the JSON schema for the type
|
96
|
+
"""
|
97
|
+
type_args = get_args(t)
|
98
|
+
type_origin = get_origin(t)
|
99
|
+
|
100
|
+
if type_origin is not None:
|
101
|
+
if type_origin in cls.ARRAY_TYPES:
|
102
|
+
return cls._handle_array_type(type_args)
|
103
|
+
elif type_origin is dict:
|
104
|
+
return cls._handle_dict_type(type_args)
|
105
|
+
elif type_origin is Union:
|
106
|
+
return cls._handle_union_type(type_args)
|
107
|
+
|
108
|
+
return {"type": cls.get_json_type_for_py_type(t.__name__)}
|
109
|
+
|
110
|
+
@classmethod
|
111
|
+
def _handle_array_type(cls, type_args: Tuple) -> Dict[str, Any]:
|
112
|
+
"""Helper method to handle array-like types"""
|
113
|
+
json_schema_for_items = (
|
114
|
+
cls.get_json_schema_for_arg(type_args[0])
|
115
|
+
if type_args
|
116
|
+
else {"type": "string"}
|
117
|
+
)
|
118
|
+
return {"type": "array", "items": json_schema_for_items}
|
119
|
+
|
120
|
+
@classmethod
|
121
|
+
def _handle_dict_type(cls, type_args: Tuple) -> Dict[str, Any]:
|
122
|
+
"""Helper method to handle dictionary types"""
|
123
|
+
key_schema = (
|
124
|
+
cls.get_json_schema_for_arg(type_args[0])
|
125
|
+
if type_args
|
126
|
+
else {"type": "string"}
|
127
|
+
)
|
128
|
+
value_schema = (
|
129
|
+
cls.get_json_schema_for_arg(type_args[1])
|
130
|
+
if len(type_args) > 1
|
131
|
+
else {"type": "string"}
|
132
|
+
)
|
133
|
+
return {
|
134
|
+
"type": "object",
|
135
|
+
"propertyNames": key_schema,
|
136
|
+
"additionalProperties": value_schema,
|
137
|
+
}
|
138
|
+
|
139
|
+
@classmethod
|
140
|
+
def _handle_union_type(cls, type_args: Tuple) -> Optional[Dict[str, Any]]:
|
141
|
+
"""Helper method to handle Union types"""
|
142
|
+
types = []
|
143
|
+
for arg in type_args:
|
144
|
+
if arg is not NoneType:
|
145
|
+
try:
|
146
|
+
schema = cls.get_json_schema_for_arg(arg)
|
147
|
+
if schema:
|
148
|
+
types.append(schema)
|
149
|
+
except Exception:
|
150
|
+
continue
|
151
|
+
return {"anyOf": types} if types else None
|
152
|
+
|
153
|
+
@staticmethod
|
154
|
+
def is_optional_type(v: Any) -> Tuple[bool, Any]:
|
155
|
+
"""
|
156
|
+
Check if a type is Optional (Union with NoneType) and extract the actual type.
|
157
|
+
|
158
|
+
Args:
|
159
|
+
v: The type to check
|
160
|
+
|
161
|
+
Returns:
|
162
|
+
A tuple of (is_optional, actual_type)
|
163
|
+
"""
|
164
|
+
type_origin = get_origin(v)
|
165
|
+
type_args = get_args(v)
|
166
|
+
is_optional = (
|
167
|
+
type_origin is Union and
|
168
|
+
len(type_args) == 2 and
|
169
|
+
any(arg is NoneType for arg in type_args)
|
170
|
+
)
|
171
|
+
|
172
|
+
if is_optional:
|
173
|
+
actual_type = next(arg for arg in type_args if arg is not NoneType)
|
174
|
+
return True, actual_type
|
175
|
+
|
176
|
+
return False, v
|
177
|
+
|
178
|
+
@classmethod
|
179
|
+
def get_json_schema(
|
180
|
+
cls,
|
181
|
+
type_hints: Dict[str, Any],
|
182
|
+
param_descriptions: Optional[Dict[str, str]] = None,
|
183
|
+
strict: bool = False,
|
184
|
+
) -> Dict[str, Any]:
|
185
|
+
"""
|
186
|
+
Generate a JSON schema from type hints and parameter descriptions.
|
187
|
+
|
188
|
+
Args:
|
189
|
+
type_hints: Dictionary of parameter names to their type annotations
|
190
|
+
param_descriptions: Optional dictionary of parameter descriptions
|
191
|
+
strict: Whether to disallow additional properties
|
192
|
+
|
193
|
+
Returns:
|
194
|
+
A JSON schema object
|
195
|
+
"""
|
196
|
+
json_schema: Dict[str, Any] = {
|
197
|
+
"type": "object",
|
198
|
+
"properties": {},
|
199
|
+
}
|
200
|
+
if strict:
|
201
|
+
json_schema["additionalProperties"] = False
|
202
|
+
|
203
|
+
for k, v in type_hints.items():
|
204
|
+
if k == "return":
|
205
|
+
continue
|
206
|
+
|
207
|
+
try:
|
208
|
+
is_optional, actual_type = cls.is_optional_type(v)
|
209
|
+
|
210
|
+
# Handle cases with no type hint
|
211
|
+
if actual_type:
|
212
|
+
arg_json_schema = cls.get_json_schema_for_arg(actual_type)
|
213
|
+
else:
|
214
|
+
arg_json_schema = {}
|
215
|
+
|
216
|
+
if arg_json_schema is not None:
|
217
|
+
if is_optional:
|
218
|
+
# Handle null type for optional fields
|
219
|
+
if isinstance(arg_json_schema.get("type"), list):
|
220
|
+
arg_json_schema["type"].append("null")
|
221
|
+
else:
|
222
|
+
arg_json_schema["type"] = [arg_json_schema["type"], "null"]
|
223
|
+
|
224
|
+
# Add description
|
225
|
+
if (
|
226
|
+
param_descriptions and
|
227
|
+
k in param_descriptions and
|
228
|
+
param_descriptions[k]
|
229
|
+
):
|
230
|
+
arg_json_schema["description"] = param_descriptions[k]
|
231
|
+
|
232
|
+
json_schema["properties"][k] = arg_json_schema
|
233
|
+
except Exception:
|
234
|
+
continue
|
235
|
+
|
236
|
+
return json_schema
|
237
|
+
|
238
|
+
|
239
|
+
# Maintain backward compatibility with the original function names
|
240
|
+
def get_callable_description(callable_func: Callable) -> str:
|
241
|
+
return DocstringParser.get_callable_description(callable_func)
|
242
|
+
|
243
|
+
|
244
|
+
def get_json_type_for_py_type(arg_type: str) -> str:
|
245
|
+
return JsonSchemaGenerator.get_json_type_for_py_type(arg_type)
|
246
|
+
|
247
|
+
|
248
|
+
def get_json_schema_for_arg(t: Any) -> Optional[Dict[str, Any]]:
|
249
|
+
return JsonSchemaGenerator.get_json_schema_for_arg(t)
|
250
|
+
|
251
|
+
|
252
|
+
def get_json_schema(
|
253
|
+
type_hints: Dict[str, Any],
|
254
|
+
param_descriptions: Optional[Dict[str, str]] = None,
|
255
|
+
strict: bool = False,
|
256
|
+
) -> Dict[str, Any]:
|
257
|
+
return JsonSchemaGenerator.get_json_schema(type_hints, param_descriptions, strict)
|
258
|
+
|
259
|
+
|
260
|
+
def build_custom_function_params(func_params: Dict[str, Any]) -> Dict[str, str]:
|
261
|
+
"""
|
262
|
+
Build a dictionary of function parameters for customizing a function.
|
263
|
+
This function ensures that all values are json serialized
|
264
|
+
which is required for current OCI Agent function calls API.
|
265
|
+
|
266
|
+
Args:
|
267
|
+
func_params: Dictionary of function parameters to customize
|
268
|
+
|
269
|
+
Returns:
|
270
|
+
A dictionary of parameters with string values
|
271
|
+
"""
|
272
|
+
new_func_params = {}
|
273
|
+
for k, v in func_params.items():
|
274
|
+
if isinstance(v, str):
|
275
|
+
new_func_params[k] = v
|
276
|
+
elif isinstance(v, dict):
|
277
|
+
new_func_params[k] = json.dumps(v)
|
278
|
+
elif isinstance(v, list):
|
279
|
+
new_func_params[k] = json.dumps(v)
|
280
|
+
else:
|
281
|
+
new_func_params[k] = str(v)
|
282
|
+
return new_func_params
|
283
|
+
|
284
|
+
|
285
|
+
def read_custom_function_params(func_params: Dict[str, str]) -> Dict[str, Any]:
|
286
|
+
"""
|
287
|
+
Read a dictionary of function parameters from a dictionary of string values.
|
288
|
+
|
289
|
+
Args:
|
290
|
+
func_params: Dictionary of function parameters with string values
|
291
|
+
|
292
|
+
Returns:
|
293
|
+
A dictionary of parameters with their original types
|
294
|
+
"""
|
295
|
+
new_func_params = {}
|
296
|
+
for k, v in func_params.items():
|
297
|
+
if isinstance(v, dict):
|
298
|
+
new_func_params[k] = json.loads(v)
|
299
|
+
else:
|
300
|
+
new_func_params[k] = v
|
301
|
+
return new_func_params
|
302
|
+
|
303
|
+
|
304
|
+
def get_region_endpoint(
|
305
|
+
region: str, endpoint: str, service: str = "generativeai"
|
306
|
+
) -> str:
|
307
|
+
"""
|
308
|
+
Get the endpoint for a given region and service.
|
309
|
+
|
310
|
+
Args:
|
311
|
+
region: The region to use, e.g. "FRA" or "us-chicago-1"
|
312
|
+
endpoint: The endpoint to use, e.g. "agent" or "agent-runtime"
|
313
|
+
service: The service to use, default "generativeai"
|
314
|
+
|
315
|
+
Returns:
|
316
|
+
The endpoint for the given region and service
|
317
|
+
"""
|
318
|
+
service_endpoint_template = (
|
319
|
+
f"https://{endpoint}.{service}" + ".{region}.oci.{secondLevelDomain}"
|
320
|
+
)
|
321
|
+
return regions.endpoint_for(
|
322
|
+
service=service,
|
323
|
+
region=region,
|
324
|
+
service_endpoint_template=service_endpoint_template,
|
325
|
+
)
|