Transformers documentation

tiny-agents

You are viewing main version, which requires installation from source. If you'd like regular pip install, checkout the latest stable version (v5.22.2).
Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

tiny-agents

tiny-agents ofrece un patrón minimalista para crear agentes que utilizan herramientas. Un pequeño bucle en Python conecta un cliente MCP con herramientas de servidores MCP. Los Hugging Face Spaces funcionan como servidores MCP. Encuentra más Spaces compatibles en el Hub.

Crea un archivo de configuración que apunte a tu modelo local y al servidor de la herramienta. Este ejemplo utiliza un Space de generación de imágenes.

{
    "model": "Menlo/Jan-nano",
    "endpointUrl": "http://localhost:8000",
    "servers": [
        {
            "type": "sse",
            "url": "https://huggingface.co/proxy/evalstate-flux1-schnell.hf.space/gradio_api/mcp/sse"
        }
    ]
}

Ejecuta el agente con tu configuración.

tiny-agents run path/to/your/config.json

Asegúrate de que transformers serve se esté ejecutando en segundo plano. El agente usará tu modelo local para ejecutar la herramienta de generación de imágenes.

Agent loaded with 1 tools:
 • flux1_schnell_infer
»  Generate an image of a cat on the moon
<Tool req_0_tool_call>flux1_schnell_infer {"prompt": "a cat on the moon", "seed": 42, "randomize_seed": true, "width": 1024, "height": 1024, "num_inference_steps": 4}

Tool req_0_tool_call
[Binary Content: Image image/webp, 57732 bytes]
The task is complete and the content accessible to the User
Image URL: https://huggingface.co/proxy/evalstate-flux1-schnell.hf.space/gradio_api/file=/tmp/gradio/3dbddc0e53b5a865ed56a4e3dbdd30f3f61cf3b8aabf1b456f43e5241bd968b8/image.webp
380576952

I have generated an image of a cat on the moon using the Flux 1 Schnell Image Generator. The image is 1024x1024 pixels and was created with 4 inference steps. Let me know if you would like to make any changes or need further assistance!
Update on GitHub