重构 改为标准化输出
This commit is contained in:
+17
-8
@@ -29,6 +29,7 @@ class ProviderConfig:
|
||||
# Chat Completions uses the legacy flat ``reasoning_effort`` parameter.
|
||||
# Keep it provider-scoped because compatibility varies by endpoint/model.
|
||||
reasoning_effort: str = ""
|
||||
api_style: str = "chat_completions"
|
||||
|
||||
@property
|
||||
def configured(self) -> bool:
|
||||
@@ -43,6 +44,14 @@ class ProviderConfig:
|
||||
return {"reasoning_effort": self.reasoning_effort}
|
||||
return {}
|
||||
|
||||
@property
|
||||
def request_options(self) -> dict[str, object]:
|
||||
if not self.reasoning_effort:
|
||||
return {}
|
||||
if self.api_style == "responses":
|
||||
return {"reasoning": {"effort": self.reasoning_effort}}
|
||||
return {"reasoning_effort": self.reasoning_effort}
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class Settings:
|
||||
@@ -59,14 +68,10 @@ class Settings:
|
||||
review_provider_id: str = ""
|
||||
review_model_id: str = ""
|
||||
agent_tool_calls_per_cycle: int = 12
|
||||
agent_candidate_attempts_per_head: int = 3
|
||||
agent_consecutive_no_progress_limit: int = 6
|
||||
agent_format_error_repeat_limit: int = 3
|
||||
agent_max_features_per_fragment: int = 6
|
||||
agent_context_char_limit: int = 14000
|
||||
agent_render_cache: bool = True
|
||||
modeling_plan_enabled: bool = True
|
||||
modeling_plan_max_revisions: int = 2
|
||||
autonomous_generation: bool = True
|
||||
resume_running_tasks_on_startup: bool = True
|
||||
|
||||
@@ -130,6 +135,13 @@ def _reasoning_effort(value: str) -> str:
|
||||
return effort
|
||||
|
||||
|
||||
def _api_style(value: str) -> str:
|
||||
style = value.strip().lower() or "chat_completions"
|
||||
if style not in {"chat_completions", "responses"}:
|
||||
raise ValueError("CDSL_*_API_STYLE must be 'chat_completions' or 'responses'")
|
||||
return style
|
||||
|
||||
|
||||
def _env_flag(name: str, default: bool) -> bool:
|
||||
value = os.getenv(name)
|
||||
if value is None or not value.strip():
|
||||
@@ -167,6 +179,7 @@ def _provider(prefix: str, provider_id: str, label: str, default_base_url: str,
|
||||
api_key=api_key,
|
||||
models=_models(model_list, vision_models),
|
||||
reasoning_effort=_reasoning_effort(os.getenv(f"CDSL_{prefix}_REASONING_EFFORT", "")),
|
||||
api_style=_api_style(os.getenv(f"CDSL_{prefix}_API_STYLE", "responses" if provider_id == "openai" else "chat_completions")),
|
||||
)
|
||||
|
||||
|
||||
@@ -195,14 +208,10 @@ def get_settings() -> Settings:
|
||||
review_provider_id=os.getenv("CDSL_REVIEW_PROVIDER", "").strip().lower(),
|
||||
review_model_id=os.getenv("CDSL_REVIEW_MODEL", "").strip(),
|
||||
agent_tool_calls_per_cycle=max(1, int(os.getenv("CDSL_AGENT_TOOL_CALLS_PER_CYCLE", "12"))),
|
||||
agent_candidate_attempts_per_head=max(1, int(os.getenv("CDSL_AGENT_CANDIDATE_ATTEMPTS_PER_HEAD", "3"))),
|
||||
agent_consecutive_no_progress_limit=max(1, int(os.getenv("CDSL_AGENT_CONSECUTIVE_NO_PROGRESS_LIMIT", "6"))),
|
||||
agent_format_error_repeat_limit=max(1, int(os.getenv("CDSL_AGENT_FORMAT_ERROR_REPEAT_LIMIT", "3"))),
|
||||
agent_max_features_per_fragment=max(1, min(6, int(os.getenv("CDSL_AGENT_MAX_FEATURES_PER_FRAGMENT", "6")))),
|
||||
agent_context_char_limit=max(4000, int(os.getenv("CDSL_AGENT_CONTEXT_CHAR_LIMIT", "14000"))),
|
||||
agent_render_cache=_env_flag("CDSL_AGENT_RENDER_CACHE", True),
|
||||
modeling_plan_enabled=_env_flag("CDSL_MODELING_PLAN_ENABLED", True),
|
||||
modeling_plan_max_revisions=max(1, int(os.getenv("CDSL_MODELING_PLAN_MAX_REVISIONS", "2"))),
|
||||
autonomous_generation=True,
|
||||
# Production instances recover durable runs by default. Test workers
|
||||
# can disable this before startup to guarantee they touch only tasks
|
||||
|
||||
Reference in New Issue
Block a user