feat(aggregation): Implement sub-agent summarization pass
This commit is contained in:
@@ -2450,3 +2450,52 @@ def get_history_bleed_stats(md_content: Optional[str] = None) -> dict[str, Any]:
|
||||
"percentage": 0,
|
||||
})
|
||||
|
||||
def run_subagent_summarization(file_path: str, content: str, is_code: bool, outline: str) -> str:
|
||||
"""Performs a stateless summarization request using a sub-agent prompt."""
|
||||
prompt_tmpl = mma_prompts.TIER4_SUMMARIZE_CODE_PROMPT if is_code else mma_prompts.TIER4_SUMMARIZE_TEXT_PROMPT
|
||||
prompt = prompt_tmpl.format(file_path=file_path, outline=outline, content=content)
|
||||
if _provider == "gemini":
|
||||
_ensure_gemini_client()
|
||||
if _gemini_client:
|
||||
resp = _gemini_client.models.generate_content(
|
||||
model=_model,
|
||||
contents=prompt,
|
||||
config=types.GenerateContentConfig(
|
||||
temperature=0.0,
|
||||
max_output_tokens=1024,
|
||||
)
|
||||
)
|
||||
return resp.text or ""
|
||||
elif _provider == "anthropic":
|
||||
_ensure_anthropic_client()
|
||||
if _anthropic_client:
|
||||
resp = _anthropic_client.messages.create(
|
||||
model=_model,
|
||||
max_tokens=1024,
|
||||
messages=[{"role": "user", "content": prompt}]
|
||||
)
|
||||
return "".join([b.text for b in resp.content if hasattr(b, "text") and b.text])
|
||||
elif _provider == "deepseek":
|
||||
creds = _load_credentials()
|
||||
api_key = creds.get("deepseek", {}).get("api_key")
|
||||
if not api_key: return "ERROR: DeepSeek API key missing"
|
||||
headers = {"Authorization": f"Bearer {api_key}", "Content-Type": "application/json"}
|
||||
payload = {
|
||||
"model": _model,
|
||||
"messages": [{"role": "user", "content": prompt}],
|
||||
"temperature": 0.0,
|
||||
}
|
||||
try:
|
||||
r = requests.post("https://api.deepseek.com/chat/completions", headers=headers, json=payload, timeout=60)
|
||||
r.raise_for_status()
|
||||
return r.json()["choices"][0]["message"]["content"]
|
||||
except Exception as e:
|
||||
return f"ERROR: DeepSeek summarization failed: {e}"
|
||||
elif _provider == "gemini_cli":
|
||||
# Using the adapter for a one-off call
|
||||
from src.gemini_cli_adapter import GeminiCliAdapter
|
||||
adapter = GeminiCliAdapter(binary_path="gemini")
|
||||
resp_data = adapter.send(prompt, model=_model)
|
||||
return resp_data.get("text", "")
|
||||
return "ERROR: Unsupported provider for sub-agent summarization"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user