Add MCP server for council integration
- Add mcp_server package with 7 tools proxying to FastAPI: - council_query (full 3-stage process) - council_stage1_collect, stage2_rank, stage3_synthesize - council_conversation_create, list, get - Add individual stage endpoints to FastAPI (/api/council/stage1, stage2, stage3) - Update council models to use valid OpenRouter identifiers - Add mcp>=1.0.0 dependency
This commit is contained in:
@@ -194,6 +194,65 @@ async def send_message_stream(conversation_id: str, request: SendMessageRequest)
|
||||
)
|
||||
|
||||
|
||||
# ============================================================================
|
||||
# INDIVIDUAL STAGE ENDPOINTS (for MCP granular control)
|
||||
# ============================================================================
|
||||
|
||||
class Stage1Request(BaseModel):
|
||||
"""Request for Stage 1."""
|
||||
query: str
|
||||
|
||||
|
||||
class Stage2Request(BaseModel):
|
||||
"""Request for Stage 2."""
|
||||
query: str
|
||||
stage1_results: List[Dict[str, Any]]
|
||||
|
||||
|
||||
class Stage3Request(BaseModel):
|
||||
"""Request for Stage 3."""
|
||||
query: str
|
||||
stage1_results: List[Dict[str, Any]]
|
||||
stage2_results: List[Dict[str, Any]]
|
||||
|
||||
|
||||
@app.post("/api/council/stage1")
|
||||
async def run_stage1(request: Stage1Request):
|
||||
"""
|
||||
Run Stage 1 independently - collect individual responses from all council models.
|
||||
"""
|
||||
results = await stage1_collect_responses(request.query)
|
||||
return results
|
||||
|
||||
|
||||
@app.post("/api/council/stage2")
|
||||
async def run_stage2(request: Stage2Request):
|
||||
"""
|
||||
Run Stage 2 independently - collect rankings with anonymization.
|
||||
"""
|
||||
stage2_results, label_to_model = await stage2_collect_rankings(
|
||||
request.query, request.stage1_results
|
||||
)
|
||||
aggregate_rankings = calculate_aggregate_rankings(stage2_results, label_to_model)
|
||||
|
||||
return {
|
||||
"rankings": stage2_results,
|
||||
"label_to_model": label_to_model,
|
||||
"aggregate_rankings": aggregate_rankings
|
||||
}
|
||||
|
||||
|
||||
@app.post("/api/council/stage3")
|
||||
async def run_stage3(request: Stage3Request):
|
||||
"""
|
||||
Run Stage 3 independently - chairman synthesis.
|
||||
"""
|
||||
result = await stage3_synthesize_final(
|
||||
request.query, request.stage1_results, request.stage2_results
|
||||
)
|
||||
return result
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import uvicorn
|
||||
uvicorn.run(app, host="0.0.0.0", port=8001)
|
||||
|
||||
Reference in New Issue
Block a user