Add Summarizer class that calls Model Gateway Inference gRPC endpoint to produce query-relevant summaries of web page content. Includes parallel summarization, configurable max length, and graceful degradation (falls back to truncated raw content if gateway unavailable). 13 tests covering success, params, truncation, degradation, parallel, concurrency limits, empty list, and prompt template verification. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1.8 KiB
1.8 KiB
Implementation Plan — Issue #48: Implement summarization step via Model Gateway
Metadata
| Field | Value |
|---|---|
| Issue | #48 |
| Title | Implement summarization step via Model Gateway |
| Milestone | Phase 6: Search Service |
| Labels | — |
| Status | COMPLETED |
| Language | Python |
| Related Plans | issue-047.md, issue-042.md |
| Blocked by | #47 |
Acceptance Criteria
- gRPC client to Model Gateway
Inference - Summarization prompt that focuses on query relevance
- Concise summary output (configurable max length)
- Parallel summarization for multiple results
- Graceful degradation: return raw extract if gateway unavailable
Implementation Steps
1. Create summarizer.py module
Summarizer class:
__init__(channel, max_summary_length, task_complexity)async summarize(query, content, session_context) -> strasync summarize_many(query, contents, session_context) -> list[str]
Uses ModelGatewayServiceStub from proto stubs to call Inference endpoint.
2. Summarization prompt
Template that instructs the model to produce a concise, query-relevant summary:
Summarize the following web page content in relation to the query: "{query}"
Focus on information directly relevant to the query. Be concise.
Content:
{content}
3. Graceful degradation
If Model Gateway is unavailable, truncate the raw content as fallback.
4. Tests with mock gRPC server
Files to Create/Modify
| File | Action | Purpose |
|---|---|---|
services/search/src/search_service/summarizer.py |
Create | Model Gateway client for summarization |
services/search/tests/test_summarizer.py |
Create | Tests with mock gRPC |
Deviation Log
| Deviation | Reason |
|---|