ScavioScavio
ProductoPreciosDocumentación
Iniciar sesionComenzar
  1. Inicio
  2. Tutoriales
  3. Cómo agregar búsqueda web a un agente DeerFlow
Tutorial

Cómo agregar búsqueda web a un agente DeerFlow

Agregue búsqueda web en vivo a un agente de investigación de DeerFlow utilizando la API de Scavio. Ejemplo de Python con registro de herramientas, nodo de búsqueda y análisis de resultados.

Obtener clave API gratisDocumentacion API

Agregar búsqueda web a un agente de DeerFlow le brinda acceso a datos en vivo para tareas de investigación en lugar de depender de conocimientos de capacitación estáticos. DeerFlow es un marco de investigación profundo que organiza flujos de trabajo de investigación de varios pasos, pero necesita una herramienta de búsqueda lista para usar para recopilar evidencia externa. Este tutorial registra una herramienta de búsqueda Scavio en un agente DeerFlow, la conecta al flujo de investigación y analiza los datos SERP estructurados en el formato de contexto del agente.

Requisitos previos

  • Python 3.10+
  • DeerFlow instalado (pip install deerflow)
  • Clave API de Scavio de scavio.dev
  • Comprensión básica del registro de herramientas de agentes

Guia paso a paso

Paso 1: Crear la función de herramienta de búsqueda

Defina una función de búsqueda que llame a la API de Scavio y devuelva resultados en el formato que espera DeerFlow.

Python
import os, requests

H = {'x-api-key': os.environ['SCAVIO_API_KEY'], 'Content-Type': 'application/json'}

def web_search(query: str, num_results: int = 5) -> list[dict]:
    '''Search the web and return structured results.'''
    data = requests.post('https://api.scavio.dev/api/v1/search',
        headers=H, json={'query': query, 'country_code': 'us'}).json()
    results = []
    for r in data.get('organic_results', [])[:num_results]:
        results.append({
            'title': r.get('title', ''),
            'url': r.get('link', ''),
            'content': r.get('snippet', ''),
        })
    return results

Paso 2: Registre la herramienta con DeerFlow

Registre la función de búsqueda como herramienta en la configuración del agente DeerFlow para poder llamarla durante los flujos de investigación.

Python
from deerflow import DeerFlowAgent, Tool

search_tool = Tool(
    name='web_search',
    description='Search the web for current information. Use for fact-checking, finding recent data, and research.',
    function=web_search,
    parameters={
        'query': {'type': 'string', 'description': 'The search query', 'required': True},
        'num_results': {'type': 'integer', 'description': 'Number of results to return', 'default': 5},
    }
)

agent = DeerFlowAgent(
    name='research_agent',
    tools=[search_tool],
    model='gpt-4o',
    system_prompt='You are a research agent. Use web_search to find current information before answering.',
)

Paso 3: Agregar capacidad de búsqueda multiplataforma

Amplíe la herramienta para realizar búsquedas en Google, Reddit y YouTube para obtener una cobertura de investigación completa.

Python
def multi_search(query: str, platforms: list[str] = None) -> dict:
    '''Search across multiple platforms for comprehensive research.'''
    if platforms is None:
        platforms = ['google', 'reddit']
    all_results = {}
    for platform in platforms:
        params = {'query': query, 'country_code': 'us'}
        if platform != 'google':
            params['platform'] = platform
        data = requests.post('https://api.scavio.dev/api/v1/search',
            headers=H, json=params).json()
        all_results[platform] = [{
            'title': r.get('title', ''),
            'url': r.get('link', ''),
            'content': r.get('snippet', ''),
        } for r in data.get('organic_results', [])[:3]]
    return all_results

multi_search_tool = Tool(
    name='multi_search',
    description='Search multiple platforms (google, reddit, youtube) for research.',
    function=multi_search,
    parameters={
        'query': {'type': 'string', 'required': True},
        'platforms': {'type': 'array', 'items': {'type': 'string'}, 'default': ['google', 'reddit']},
    }
)

Paso 4: Ejecutar una tarea de investigación

Ejecute una consulta de investigación y observe al agente utilizando herramientas de búsqueda para recopilar evidencia antes de sintetizar una respuesta.

Python
async def run_research():
    agent = DeerFlowAgent(
        name='research_agent',
        tools=[search_tool, multi_search_tool],
        model='gpt-4o',
        system_prompt='You are a research agent. Always search before answering. Cite sources.',
    )
    result = await agent.run(
        'What are the top 3 LLM agent frameworks in 2026 and how do they compare?'
    )
    print(result.answer)
    print(f'\nTools called: {len(result.tool_calls)}')
    for call in result.tool_calls:
        print(f'  - {call.tool_name}({call.arguments.get("query", "")})')

import asyncio
asyncio.run(run_research())

Ejemplo en Python

Python
import os, requests, asyncio
from deerflow import DeerFlowAgent, Tool

H = {'x-api-key': os.environ['SCAVIO_API_KEY'], 'Content-Type': 'application/json'}

def web_search(query: str, num_results: int = 5) -> list[dict]:
    data = requests.post('https://api.scavio.dev/api/v1/search',
        headers=H, json={'query': query, 'country_code': 'us'}).json()
    return [{'title': r.get('title', ''), 'url': r.get('link', ''),
             'content': r.get('snippet', '')}
            for r in data.get('organic_results', [])[:num_results]]

def multi_search(query: str, platforms: list[str] = None) -> dict:
    platforms = platforms or ['google', 'reddit']
    results = {}
    for p in platforms:
        params = {'query': query, 'country_code': 'us'}
        if p != 'google': params['platform'] = p
        data = requests.post('https://api.scavio.dev/api/v1/search',
            headers=H, json=params).json()
        results[p] = [{'title': r.get('title',''), 'url': r.get('link',''),
            'content': r.get('snippet','')} for r in data.get('organic_results',[])[:3]]
    return results

async def main():
    agent = DeerFlowAgent(
        name='researcher',
        tools=[
            Tool(name='web_search', description='Search the web', function=web_search,
                 parameters={'query': {'type':'string','required':True}}),
            Tool(name='multi_search', description='Multi-platform search', function=multi_search,
                 parameters={'query': {'type':'string','required':True},
                             'platforms': {'type':'array','default':['google','reddit']}}),
        ],
        model='gpt-4o',
        system_prompt='Research agent. Search before answering. Cite sources.',
    )
    result = await agent.run('Compare LangGraph vs CrewAI vs AutoGen in 2026')
    print(result.answer)

asyncio.run(main())

Ejemplo en JavaScript

JavaScript
const H = {'x-api-key': process.env.SCAVIO_API_KEY, 'Content-Type': 'application/json'};

async function webSearch(query, numResults = 5) {
  const data = await fetch('https://api.scavio.dev/api/v1/search', {
    method: 'POST', headers: H,
    body: JSON.stringify({query, country_code: 'us'})
  }).then(r => r.json());
  return (data.organic_results || []).slice(0, numResults).map(r => ({
    title: r.title || '', url: r.link || '', content: r.snippet || ''
  }));
}

async function multiSearch(query, platforms = ['google', 'reddit']) {
  const results = {};
  for (const p of platforms) {
    const params = {query, country_code: 'us'};
    if (p !== 'google') params.platform = p;
    const data = await fetch('https://api.scavio.dev/api/v1/search', {
      method: 'POST', headers: H, body: JSON.stringify(params)
    }).then(r => r.json());
    results[p] = (data.organic_results || []).slice(0, 3).map(r => ({
      title: r.title, url: r.link, content: r.snippet
    }));
  }
  return results;
}

// Register with DeerFlow (JS SDK)
// const agent = new DeerFlowAgent({tools: [{name: 'web_search', fn: webSearch}]});
console.log('DeerFlow search tools ready');
webSearch('LangGraph vs CrewAI 2026').then(r => console.log(\`\${r.length} results\`));

Salida esperada

JSON
Research agent output:
- LangGraph: Best for stateful, cyclic agent workflows. Most GitHub stars in 2026.
- CrewAI: Best for multi-agent orchestration with role-based agents.
- AutoGen: Best for conversational multi-agent patterns.

Tools called: 3
  - web_search(LLM agent frameworks comparison 2026)
  - multi_search(LangGraph vs CrewAI vs AutoGen)
  - web_search(agent framework github stars 2026)

Tutoriales relacionados

  • Cómo agregar búsqueda a un agente de investigación LangGraph
  • Cómo crear una búsqueda seleccionada para agentes de IA
  • Cómo fundamentar un LLM local con búsqueda estructurada

Preguntas frecuentes

La mayoria de los desarrolladores completan este tutorial en 15 a 30 minutos. Necesitaras una clave API de Scavio (el plan gratuito funciona) y un entorno de Python o JavaScript.

Python 3.10+. DeerFlow instalado (pip install deerflow). Clave API de Scavio de scavio.dev. Comprensión básica del registro de herramientas de agentes. Una clave API de Scavio te da 50 creditos gratuitos al registrarte.

Si. El plan gratuito incluye 50 creditos al registrarte, mas que suficiente para completar este tutorial y crear un prototipo funcional.

Scavio tiene un paquete nativo de LangChain (langchain-scavio), un servidor MCP y una API REST simple que funciona con cualquier cliente HTTP. Este tutorial usa the raw REST API, pero puedes adaptarlo al framework que prefieras.

Recursos relacionados

Use Case

Acceso web de IA de código abierto 2026

Read more
Comparison

Parallel Web Systems vs Scavio

Read more
Best Of

Mejor proveedor de búsqueda de DeerFlow en 2026

Read more
Solution

Fundamenta Agentes de Investigación DeerFlow con Búsqueda Scavio

Read more
Use Case

Recuperación de búsqueda web local LLM 2026

Read more
Best Of

Las mejores alternativas a SerpAPI en 2026

Read more

Empieza a construir

Agregue búsqueda web en vivo a un agente de investigación de DeerFlow utilizando la API de Scavio. Ejemplo de Python con registro de herramientas, nodo de búsqueda y análisis de resultados.

Obtener clave API gratuitaLeer la documentacion
ScavioScavio

API de busqueda en tiempo real para agentes de IA. Busca en todas las plataformas, no solo en Google.

Producto

  • Funciones
  • Precios
  • Panel
  • Afiliados

Desarrolladores

  • Documentacion
  • Referencia de API
  • Inicio rapido
  • Integracion MCP
  • Python SDK

Alternativas

  • Alternativa a Tavily
  • Alternativa a SerpAPI
  • Alternativa a Firecrawl
  • Alternativa a Exa

Herramientas

  • Formateador JSON
  • cURL a codigo
  • Contador de tokens
  • Todas las herramientas

© 2026 Scavio. Todos los derechos reservados.

Featured on TAAFT
Terminos de servicioPolitica de privacidad