37 lines
1.0 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""Claude 适配器薄接缝:只消费 FrameworkExecutionRequest,不跑生产。"""
from __future__ import annotations
from dataclasses import dataclass
from framework.primitives.execution import FrameworkExecutionRequest
class ClaudeAdapterError(RuntimeError):
"""Claude 适配器未作为生产默认开放。"""
@dataclass(frozen=True)
class ClaudeExecutionPolicy:
provider: str
model: str
claude_bin: str = "claude"
def __post_init__(self) -> None:
if not self.provider.strip() or not self.model.strip():
raise ValueError("provider 与 model 必须显式传入")
def build_claude_argv(request: FrameworkExecutionRequest, policy: ClaudeExecutionPolicy) -> list[str]:
if not request.system_prompt or not request.user_content:
raise ClaudeAdapterError("请求缺少 system_prompt 或 user_content")
return [
policy.claude_bin,
"--print",
"--model",
policy.model,
"--system-prompt",
request.system_prompt,
request.user_content,
]