Skip to main content
You are viewing: Quick Reference - Common mixin usage patternsSee also: 17 Detailed Mixin Specifications (under Specifications → Tool Mixins)
Import: from gaia.agents.chat.tools.file_tools import FileToolsMixin

Purpose: Reusable tool sets that can be mixed into your agents. Available Mixins: For complete API specifications of all 17 mixins, see Specifications → Tool Mixins

9.1 File Operations Mixin

Detailed Spec: FileToolsMixin
from gaia.agents.base.agent import Agent
from gaia.agents.chat.tools.file_tools import FileToolsMixin

class MyAgent(Agent, FileToolsMixin):
    """Agent with file operation tools."""

    def _register_tools(self):
        # FileToolsMixin provides these tools automatically:
        # - read_file(file_path: str) -> dict
        # - write_file(file_path: str, content: str) -> dict
        # - append_to_file(file_path: str, content: str) -> dict
        # - list_directory(directory_path: str) -> dict
        pass

# Usage
agent = MyAgent()
result = agent.process_query("Read the config.json file")
# Agent uses read_file tool automatically

9.2 RAG Tools Mixin

Import: from gaia.agents.chat.tools.rag_tools import RAGToolsMixin Detailed Spec: RAGToolsMixin
from gaia.agents.base.agent import Agent
from gaia.agents.chat.tools.rag_tools import RAGToolsMixin

class MyAgent(Agent, RAGToolsMixin):
    """Agent with document Q&A tools."""

    def __init__(self, documents_path: str = "./docs", **kwargs):
        self.documents_path = documents_path
        super().__init__(**kwargs)

    def _register_tools(self):
        # RAGToolsMixin provides:
        # - index_documents(path: str) -> dict
        # - search_documents(query: str) -> dict
        # - list_indexed_documents() -> dict
        pass

# Usage
agent = MyAgent(documents_path="./manuals")
result = agent.process_query("What does the manual say about installation?")
# Agent searches indexed documents automatically

9.3 Shell Commands Mixin

Import: from gaia.agents.chat.tools.shell_tools import ShellToolsMixin Detailed Spec: ShellToolsMixin
from gaia.agents.base.agent import Agent
from gaia.agents.chat.tools.shell_tools import ShellToolsMixin

class MyAgent(Agent, ShellToolsMixin):
    """Agent that can execute shell commands."""

    def _register_tools(self):
        # ShellToolsMixin provides:
        # - execute_shell_command(command: str) -> dict
        pass

# Usage
agent = MyAgent()
result = agent.process_query("List files in the current directory")
# Agent uses execute_shell_command("ls") automatically

9.4 File Search Mixin

Import: from gaia.agents.tools.file_tools import FileSearchToolsMixin Detailed Spec: FileSearchToolsMixin
from gaia.agents.base.agent import Agent
from gaia.agents.tools.file_tools import FileSearchToolsMixin

class MyAgent(Agent, FileSearchToolsMixin):
    """Agent with file search capabilities."""

    def _register_tools(self):
        # FileSearchToolsMixin provides:
        # - search_files(pattern: str, directory: str) -> dict
        # - find_file(filename: str) -> dict
        pass

9.5 Stable Diffusion Mixin

Import: from gaia.sd import SDToolsMixin Detailed Guide: Image Generation Guide Source: src/gaia/sd/mixin.py
from gaia.agents.base.agent import Agent
from gaia.sd import SDToolsMixin

class MyImageAgent(Agent, SDToolsMixin):
    """Agent with image generation tools."""

    def __init__(self):
        super().__init__(
            model_id="Qwen3-8B-GGUF",  # LLM for orchestration
            min_context_size=8192,  # 8K sufficient for SD
        )

        # Initialize SD tools (auto-registers generate_image, list_sd_models, etc.)
        self.init_sd(
            output_dir=".gaia/cache/sd/images",
            default_model="SDXL-Turbo",  # Fast, good quality
        )

    def _register_tools(self):
        pass  # Tools already registered by init_sd()

    def _get_system_prompt(self):
        return "You generate images. Use generate_image with enhanced prompts."

# Usage
agent = MyImageAgent()
result = agent.process_query("create a sunset over mountains")
# Agent enhances prompt and calls generate_image automatically
Available Tools:
  • generate_image(prompt, model, size, steps, cfg_scale, seed) - Generate images with SD
  • list_sd_models() - Show available models
  • get_generation_history(limit) - See generated images from session
Supported Models:
  • SDXL-Turbo (default) - Fast, 512x512, ~17s
  • SD-Turbo - Faster, 512x512, ~13s
  • SDXL-Base-1.0 - Photorealistic, 1024x1024, ~9min
  • SD-1.5 - Legacy, 512x512, ~88s

9.6 Vision Language Model Mixin

Import: from gaia.vlm import VLMToolsMixin Source: src/gaia/vlm/mixin.py
from gaia.agents.base.agent import Agent
from gaia.vlm import VLMToolsMixin

class MyVisionAgent(Agent, VLMToolsMixin):
    """Agent with vision analysis tools."""

    def __init__(self):
        super().__init__(min_context_size=8192)

        # Initialize VLM tools (auto-registers analyze_image, create_story_from_image, etc.)
        self.init_vlm(model="Qwen3-VL-4B-Instruct-GGUF")

    def _register_tools(self):
        pass  # Tools already registered by init_vlm()

    def _get_system_prompt(self):
        return "You analyze images. Use VLM tools for descriptions, stories, and Q&A."

# Usage
agent = MyVisionAgent()
result = agent.process_query("analyze this image: photo.jpg")
# Agent calls analyze_image automatically
Available Tools:
  • analyze_image(image_path, focus) - Get detailed image description
  • create_story_from_image(image_path, story_style) - Generate creative narrative
  • answer_question_about_image(image_path, question) - Answer specific questions
Focus Options: composition, colors, mood, details, all (default) Story Styles: whimsical, dramatic, educational, adventure, any (default)