helion: deepseek-first, on-demand CrewAI, local subagent profiles, concise post-synthesis
This commit is contained in:
@@ -1412,6 +1412,17 @@ async def agent_infer(agent_id: str, request: InferRequest):
|
||||
if isinstance(row, dict):
|
||||
logger.info(json.dumps(row, ensure_ascii=False))
|
||||
logger.info(f"✅ CrewAI success for {agent_id}: {latency:.2f}s")
|
||||
final_response_text = crew_result["result"]
|
||||
# Helion: keep first-touch answers short by default, even after CrewAI.
|
||||
if (
|
||||
agent_id == "helion"
|
||||
and isinstance(final_response_text, str)
|
||||
and effective_metadata.get("force_concise")
|
||||
and not effective_metadata.get("force_detailed")
|
||||
):
|
||||
parts = re.split(r"(?<=[.!?])\s+", final_response_text.strip())
|
||||
if len(parts) > 3:
|
||||
final_response_text = " ".join(parts[:3]).strip()
|
||||
|
||||
# Store interaction in memory
|
||||
if MEMORY_RETRIEVAL_AVAILABLE and memory_retrieval and chat_id and user_id:
|
||||
@@ -1423,13 +1434,13 @@ async def agent_infer(agent_id: str, request: InferRequest):
|
||||
agent_id=request_agent_id,
|
||||
username=username,
|
||||
user_message=request.prompt,
|
||||
assistant_response=crew_result["result"]
|
||||
assistant_response=final_response_text
|
||||
)
|
||||
except Exception as e:
|
||||
logger.warning(f"⚠️ Memory storage failed: {e}")
|
||||
|
||||
return InferResponse(
|
||||
response=crew_result["result"],
|
||||
response=final_response_text,
|
||||
model="crewai-" + agent_id,
|
||||
backend="crewai",
|
||||
tokens_used=0
|
||||
|
||||
Reference in New Issue
Block a user