111 lines
3.5 KiB
Python
111 lines
3.5 KiB
Python
"""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": 7200,
|
|
"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": 5600,
|
|
"max_tokens_min": 1800,
|
|
"max_tokens_max": 8000,
|
|
"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,
|
|
},
|
|
},
|
|
}
|
|
|
|
|
|
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",
|
|
]
|