"""Default runtime profiles for protected AI functions.""" from __future__ import annotations from typing import Any AI_FUNCTION_RUNTIME_PROFILE_INTEGRATION_TYPE = "ai_function_runtime_profiles" DEFAULT_AI_FUNCTION_RUNTIME_PROFILES: dict[str, dict[str, Any]] = { "pmflow_launch_draft_v1": { "function_name": "pmflow_launch_draft_v1", "label": "项目启动草案生成", "scene_key": "project_launch", "prompt_key": "PROMPT_PMFLOW_LAUNCH_DRAFT", "required_slot": "structured", "response_contract": "structured", "max_tokens": 10000, "max_tokens_min": 3000, "max_tokens_max": 10000, "recommended_min_tokens": 6500, "repair_max_tokens": 3600, "temperature": 0.0, "foreground_wait_seconds": 10, "provider_timeout_seconds": 90, "job_timeout_seconds": 180, "max_retries": 1, "large_input_policy": "preprocess_then_generate", "response_mode": "fast", "response_format": "json_object", "retry_policy": { "on_length": "model_repair_then_fail", "on_json_invalid": "model_repair_then_fail", "max_attempts": 2, }, "health_policy": { "window_hours": 24, "consecutive_failure_threshold": 3, "smoke_required_for_publish": True, }, "cost_policy": { "budget_class": "medium", "estimated_cost_ceiling_cny": 0.02, "show_cost_warning_above_tokens": 8000, }, }, "pmflow_change_review_extraction_v1": { "function_name": "pmflow_change_review_extraction_v1", "label": "项目主链变更抽取", "scene_key": "change_review", "prompt_key": "PROMPT_PMFLOW_CHANGE_REVIEW_EXTRACTION", "required_slot": "structured", "response_contract": "structured", "max_tokens": 10000, "max_tokens_min": 1800, "max_tokens_max": 10000, "recommended_min_tokens": 4200, "repair_max_tokens": 2400, "temperature": 0.0, "foreground_wait_seconds": 8, "provider_timeout_seconds": 90, "job_timeout_seconds": 180, "max_retries": 1, "large_input_policy": "preprocess_then_generate", "response_mode": "fast", "response_format": "json_object", "retry_policy": { "on_length": "model_repair_then_fail", "on_json_invalid": "model_repair_then_fail", "max_attempts": 2, }, "health_policy": { "window_hours": 24, "consecutive_failure_threshold": 3, "smoke_required_for_publish": True, }, "cost_policy": { "budget_class": "medium", "estimated_cost_ceiling_cny": 0.015, "show_cost_warning_above_tokens": 6500, }, }, "customer_answer_composer": { "function_name": "customer_answer_composer", "label": "客户答案表达生成", "scene_key": "pmflow_ai_answer_presentation", "prompt_key": "PROMPT_CUSTOMER_ANSWER_COMPOSER", "required_slot": "low", "response_contract": "text", "max_tokens": 10000, "max_tokens_min": 700, "max_tokens_max": 10000, "recommended_min_tokens": 1400, "repair_max_tokens": 1000, "temperature": 0.2, "foreground_wait_seconds": 8, "provider_timeout_seconds": 120, "job_timeout_seconds": 240, "max_retries": 1, "large_input_policy": "direct_generate", "response_mode": "fast", "response_format": "text", "retry_policy": { "on_length": "retry_with_larger_budget_then_fallback", "max_attempts": 2, }, "health_policy": { "window_hours": 24, "consecutive_failure_threshold": 3, "smoke_required_for_publish": False, }, "cost_policy": { "budget_class": "medium", "estimated_cost_ceiling_cny": 0.02, "show_cost_warning_above_tokens": 8000, }, }, "space_ai_interaction_option_planner": { "function_name": "space_ai_interaction_option_planner", "label": "Space AI 追问选项规划", "scene_key": "pmflow_ai_answer_presentation", "prompt_key": "PROMPT_SPACE_AI_INTERACTION_OPTION_PLANNER", "required_slot": "low", "response_contract": "json", "max_tokens": 4000, "max_tokens_min": 700, "max_tokens_max": 6000, "recommended_min_tokens": 1600, "repair_max_tokens": 800, "temperature": 0.1, "foreground_wait_seconds": 5, "provider_timeout_seconds": 60, "job_timeout_seconds": 120, "max_retries": 1, "large_input_policy": "direct_generate", "response_mode": "fast", "response_format": "json_object", "retry_policy": { "on_json_invalid": "fallback_to_generic_options", "max_attempts": 1, }, "health_policy": { "window_hours": 24, "consecutive_failure_threshold": 3, "smoke_required_for_publish": False, }, "cost_policy": { "budget_class": "low", "estimated_cost_ceiling_cny": 0.01, "show_cost_warning_above_tokens": 5000, }, }, "customer_answer_verifier": { "function_name": "customer_answer_verifier", "label": "客户答案安全质检", "scene_key": "pmflow_ai_answer_presentation", "prompt_key": "PROMPT_CUSTOMER_ANSWER_VERIFIER", "required_slot": "low", "response_contract": "json", "max_tokens": 10000, "max_tokens_min": 300, "max_tokens_max": 10000, "recommended_min_tokens": 300, "repair_max_tokens": 300, "temperature": 0.0, "foreground_wait_seconds": 5, "provider_timeout_seconds": 60, "job_timeout_seconds": 120, "max_retries": 1, "large_input_policy": "direct_generate", "response_mode": "fast", "response_format": "json_object", "retry_policy": { "on_json_invalid": "deterministic_guard_fallback", "max_attempts": 1, }, "health_policy": { "window_hours": 24, "consecutive_failure_threshold": 3, "smoke_required_for_publish": False, }, "cost_policy": { "budget_class": "low", "estimated_cost_ceiling_cny": 0.01, "show_cost_warning_above_tokens": 8000, }, }, "pmflow_ai_operating_mission": { "function_name": "pmflow_ai_operating_mission", "label": "Space AI Operating Mission 生成", "scene_key": "space_pmflow_ai_operating_runtime", "prompt_key": "PROMPT_PMFLOW_AI_OPERATING_MISSION", "required_slot": "low", "response_contract": "json", "max_tokens": 1600, "max_tokens_min": 600, "max_tokens_max": 4000, "recommended_min_tokens": 1600, "repair_max_tokens": 600, "temperature": 0.0, "foreground_wait_seconds": 6, "provider_timeout_seconds": 60, "job_timeout_seconds": 90, "max_retries": 0, "large_input_policy": "direct_generate", "response_mode": "fast", "response_format": "json_object", "retry_policy": { "on_timeout": "deterministic_mission_fallback", "on_json_invalid": "deterministic_mission_fallback", "max_attempts": 1, }, "health_policy": { "window_hours": 24, "consecutive_failure_threshold": 3, "smoke_required_for_publish": False, }, "cost_policy": { "budget_class": "low", "estimated_cost_ceiling_cny": 0.01, "show_cost_warning_above_tokens": 5000, }, }, "external_query_dashscope_responses": { "function_name": "external_query_dashscope_responses", "label": "DashScope Responses 外部搜索", "scene_key": "external_query", "prompt_key": "", "required_slot": "external_query", "response_contract": "external_evidence", "max_tokens": 1000, "max_tokens_min": 1, "max_tokens_max": 4000, "recommended_min_tokens": 1, "repair_max_tokens": 180, "temperature": 0.0, "foreground_wait_seconds": 8, "provider_timeout_seconds": 120, "job_timeout_seconds": 180, "max_retries": 0, "large_input_policy": "direct_generate", "response_mode": "tool", "response_format": "external_evidence", "retry_policy": { "on_timeout": "try_next_external_adapter", "max_attempts": 1, }, "health_policy": { "window_hours": 24, "consecutive_failure_threshold": 3, "smoke_required_for_publish": False, }, "cost_policy": { "budget_class": "external_query", "estimated_cost_ceiling_cny": 0.05, "show_cost_warning_above_tokens": 30000, }, }, } def default_runtime_profile_bundle() -> dict[str, Any]: return { "version": "profile-default-v1", "active_version": "profile-default-v1", "draft_version": "draft", "active": { "profiles": DEFAULT_AI_FUNCTION_RUNTIME_PROFILES, "published_at": None, "published_by": None, }, "draft": { "profiles": DEFAULT_AI_FUNCTION_RUNTIME_PROFILES, "updated_at": None, "updated_by": None, "last_smoke": {}, }, "history": [], } __all__ = [ "AI_FUNCTION_RUNTIME_PROFILE_INTEGRATION_TYPE", "DEFAULT_AI_FUNCTION_RUNTIME_PROFILES", "default_runtime_profile_bundle", ]