Add independent thinking-mode controls
This commit is contained in:
@@ -16,6 +16,7 @@ class LLMClientConfig:
|
||||
base_url: str = "https://api.openai.com/v1"
|
||||
api_style: str = "responses"
|
||||
timeout_seconds: int = 240
|
||||
enable_thinking: bool | None = None
|
||||
|
||||
@classmethod
|
||||
def from_env(cls, role: str) -> "LLMClientConfig":
|
||||
@@ -25,6 +26,7 @@ class LLMClientConfig:
|
||||
base_url = os.getenv(f"{prefix}_BASE_URL", "").strip()
|
||||
api_style = os.getenv(f"{prefix}_API_STYLE", "").strip() or "responses"
|
||||
timeout_text = os.getenv(f"{prefix}_TIMEOUT_SECONDS", "").strip()
|
||||
thinking_text = os.getenv(f"{prefix}_ENABLE_THINKING", "").strip().lower()
|
||||
if not model:
|
||||
raise ValueError(f"{prefix}_MODEL is required")
|
||||
if not api_key:
|
||||
@@ -36,12 +38,16 @@ class LLMClientConfig:
|
||||
timeout_seconds = int(timeout_text) if timeout_text else 240
|
||||
if timeout_seconds < 1:
|
||||
raise ValueError(f"{prefix}_TIMEOUT_SECONDS must be positive")
|
||||
if thinking_text not in {"", "true", "false"}:
|
||||
raise ValueError(f"{prefix}_ENABLE_THINKING must be true or false")
|
||||
enable_thinking = None if not thinking_text else thinking_text == "true"
|
||||
return cls(
|
||||
model=model,
|
||||
api_key=api_key,
|
||||
base_url=base_url.rstrip("/"),
|
||||
api_style=api_style,
|
||||
timeout_seconds=timeout_seconds,
|
||||
enable_thinking=enable_thinking,
|
||||
)
|
||||
|
||||
|
||||
@@ -92,6 +98,9 @@ class LLMClient:
|
||||
"max_tokens": 2500,
|
||||
}
|
||||
|
||||
if self.config.enable_thinking is not None:
|
||||
body["enable_thinking"] = self.config.enable_thinking
|
||||
|
||||
text = self._post(path, body)
|
||||
try:
|
||||
result = json.loads(text)
|
||||
@@ -122,6 +131,8 @@ class LLMClient:
|
||||
],
|
||||
"max_tokens": 512,
|
||||
}
|
||||
if self.config.enable_thinking is not None:
|
||||
body["enable_thinking"] = self.config.enable_thinking
|
||||
return self._post(path, body)
|
||||
|
||||
def _post(self, path: str, body: dict[str, Any]) -> str:
|
||||
|
||||
@@ -56,7 +56,8 @@ def render_skeleton(client: JsonModel, skeleton: BehaviorSkeleton) -> str:
|
||||
"trigger probabilities, intermediate flags, exact query probability, or answer. Make clear that "
|
||||
"all trials use one unchanged system and that the question asks which final outcome is more likely, "
|
||||
"not for an exact probability. Present repeated histories in a compact table rather than verbose "
|
||||
"paragraphs. End by requiring exactly one supplied answer label."
|
||||
"paragraphs. State the supplied answer labels, but do not impose a response format or forbid an "
|
||||
"explanation; the evaluator supplies its own output protocol to the solver."
|
||||
),
|
||||
user=f"Render this intermediate representation:\n{prompt}",
|
||||
schema_name="rendered_problem",
|
||||
|
||||
Reference in New Issue
Block a user