Google I/O 2026 a modifié la structure des résultats de recherche avec le Mode IA atteignant plus d'1 milliard d'utilisateurs, Gemini 3.5 Flash, et une barre de recherche repensée. Les pipelines RAG qui ancrent les réponses dans les données de recherche doivent s'adapter à ces changements. Ce tutoriel met à jour votre ancrage RAG pour gérer les nouveaux formats de résultats, les citations AI Overview et les réponses de l'Agent Information.
Prérequis
- Python 3.8+
- bibliothèque requests
- Une clé API Scavio depuis scavio.dev
- Pipeline RAG existant à mettre à jour
Parcours
Étape 1: Détecter le nouveau format de résultat de recherche
Identifier quels types de résultats post-I/O vos requêtes renvoient.
import os, requests, json
from datetime import datetime
API_KEY = os.environ['SCAVIO_API_KEY']
SH = {'x-api-key': API_KEY, 'Content-Type': 'application/json'}
def detect_result_format(query):
data = requests.post('https://api.scavio.dev/api/v1/search',
headers=SH, json={'query': query, 'country_code': 'us'}, timeout=10).json()
format_info = {
'query': query,
'has_ai_overview': bool(data.get('ai_overview', data.get('answer_box'))),
'has_featured_snippet': bool(data.get('featured_snippet')),
'has_knowledge_graph': bool(data.get('knowledge_graph')),
'has_paa': len(data.get('people_also_ask', [])) > 0,
'paa_count': len(data.get('people_also_ask', [])),
'organic_count': len(data.get('organic_results', [])),
'ai_overview_data': data.get('ai_overview', data.get('answer_box', {})),
}
return format_info, data
TEST_QUERIES = [
'what is model context protocol',
'best search api for ai agents 2026',
'how to build rag pipeline python',
]
print('Post-I/O 2026 Result Format Detection:\n')
for q in TEST_QUERIES:
fmt, _ = detect_result_format(q)
ai = 'AI' if fmt['has_ai_overview'] else '--'
fs = 'FS' if fmt['has_featured_snippet'] else '--'
kg = 'KG' if fmt['has_knowledge_graph'] else '--'
print(f' {q[:40]:40} | {ai} {fs} {kg} | PAA: {fmt["paa_count"]} | Org: {fmt["organic_count"]}')
print(f'\nCost: ${len(TEST_QUERIES) * 0.005:.3f}')Étape 2: Construire une extraction d'ancrage adaptative
Extraire des données d'ancrage qui fonctionnent avec les anciens et nouveaux formats de résultats.
def extract_grounding(query):
"""Extract grounding data adaptive to post-I/O 2026 result formats."""
data = requests.post('https://api.scavio.dev/api/v1/search',
headers=SH, json={'query': query, 'country_code': 'us'}, timeout=10).json()
grounding = {
'query': query,
'sources': [],
'direct_answer': '',
'related_questions': [],
'confidence': 'low',
}
# Priority 1: AI Overview (post-I/O, most authoritative)
ai = data.get('ai_overview', data.get('answer_box', {}))
if ai:
answer = ai.get('snippet', ai.get('answer', ai.get('description', '')))
if answer:
grounding['direct_answer'] = answer[:500]
grounding['confidence'] = 'high'
# Priority 2: Featured Snippet
featured = data.get('featured_snippet', {})
if not grounding['direct_answer'] and featured:
grounding['direct_answer'] = featured.get('snippet', '')[:500]
grounding['confidence'] = 'medium'
# Priority 3: Organic results (always available)
for r in data.get('organic_results', [])[:5]:
grounding['sources'].append({
'title': r.get('title', ''),
'url': r.get('link', ''),
'text': r.get('snippet', ''),
'domain': r.get('displayed_link', '').split('/')[0],
})
if not grounding['direct_answer'] and grounding['sources']:
grounding['direct_answer'] = grounding['sources'][0]['text']
grounding['confidence'] = 'low'
# Related questions for follow-up
grounding['related_questions'] = [q.get('question', '') for q in data.get('people_also_ask', [])[:3]]
return grounding
print('\n=== Adaptive Grounding Extraction ===')
for q in TEST_QUERIES:
g = extract_grounding(q)
print(f'\n Query: {q[:40]}')
print(f' Confidence: {g["confidence"]}')
print(f' Answer: {g["direct_answer"][:80]}...' if g['direct_answer'] else ' No direct answer')
print(f' Sources: {len(g["sources"])} | Related Qs: {len(g["related_questions"])}')Étape 3: Intégrer avec le pipeline RAG
Remplacer votre ancrage de recherche existant par l'extracteur adaptatif.
def grounded_rag_response(question):
"""Generate a grounded response using adaptive post-I/O search data."""
print(f'\n Question: {question}')
# Step 1: Get grounding data
grounding = extract_grounding(question)
print(f' Grounding confidence: {grounding["confidence"]}')
print(f' Sources: {len(grounding["sources"])}')
# Step 2: Build context for LLM
context_parts = []
if grounding['direct_answer']:
context_parts.append(f'Direct answer: {grounding["direct_answer"]}')
for s in grounding['sources'][:3]:
context_parts.append(f'Source ({s["domain"]}): {s["text"]}')
context = '\n'.join(context_parts)
# Step 3: Format response with citations
print(f'\n Grounded Context ({len(context)} chars):')
for s in grounding['sources'][:3]:
print(f' [{s["domain"]:20}] {s["title"][:45]}')
# Step 4: Follow-up grounding
if grounding['related_questions']:
print(f'\n Available follow-ups:')
for q in grounding['related_questions']:
print(f' - {q[:55]}')
return {
'context': context,
'sources': grounding['sources'],
'confidence': grounding['confidence'],
}
print('=== Post-I/O 2026 Grounded RAG ===')
for q in ['what is MCP protocol', 'best search api for rag 2026']:
grounded_rag_response(q)
print(f'\n Grounding cost: $0.005/query')
print(f' Adapts to AI Mode, Featured Snippets, and organic results')
print(f' Works with Gemini 3.5 Flash and new search box format')Exemple Python
import os, requests
SH = {'x-api-key': os.environ['SCAVIO_API_KEY'], 'Content-Type': 'application/json'}
def ground(query):
data = requests.post('https://api.scavio.dev/api/v1/search',
headers=SH, json={'query': query, 'country_code': 'us'}, timeout=10).json()
ai = data.get('ai_overview', data.get('answer_box', {}))
answer = ai.get('snippet', '') if ai else data.get('organic_results', [{}])[0].get('snippet', '')
sources = [r.get('link', '') for r in data.get('organic_results', [])[:3]]
print(f'Answer: {answer[:80]}')
print(f'Sources: {len(sources)}')
ground('what is MCP protocol')Exemple JavaScript
const SH = { 'x-api-key': process.env.SCAVIO_API_KEY, 'Content-Type': 'application/json' };
const data = await fetch('https://api.scavio.dev/api/v1/search', {
method: 'POST', headers: SH,
body: JSON.stringify({ query: 'what is MCP protocol', country_code: 'us' })
}).then(r => r.json());
const ai = data.ai_overview || data.answer_box || {};
const answer = ai.snippet || (data.organic_results?.[0]?.snippet || '');
console.log(`Grounded answer: ${answer.slice(0, 80)}`);
console.log(`Sources: ${(data.organic_results || []).length}`);Sortie attendue
Post-I/O 2026 Result Format Detection:
what is model context protocol | AI FS -- | PAA: 4 | Org: 10
best search api for ai agents 2026 | AI -- -- | PAA: 3 | Org: 10
how to build rag pipeline python | -- FS -- | PAA: 4 | Org: 10
=== Adaptive Grounding Extraction ===
Query: what is model context protocol
Confidence: high
Answer: Model Context Protocol (MCP) is an open standard for connecting...
Sources: 5 | Related Qs: 3
=== Post-I/O 2026 Grounded RAG ===
Question: what is MCP protocol
Grounding confidence: high
Sources: 5
Grounding cost: $0.005/query
Adapts to AI Mode, Featured Snippets, and organic results