Skip to content

Developer Documentation

Krishnakanth Alagiri edited this page May 13, 2024 · 8 revisions

Project Architecture

Meeseeks is designed with a multi-agent architecture to efficiently handle complex user queries. It leverages multiple Large Language Models (LLMs) to break down tasks and utilizes semantic caching to minimize LLM calls.

Core Modules

  • core/task_master.py:
    • generate_action_plan(user_query: str, model_name: str = None) -> List[dict]:
      • Takes a user query as input and generates an action plan, a list of dictionaries representing individual tasks.
      • Leverages LangChain for prompt engineering, LLM interaction, and output parsing.
      • Utilizes core.classes.TaskQueue to structure the action plan.
    • run_action_plan(task_queue: TaskQueue) -> TaskQueue:
      • Executes the generated action plan.
      • Calls appropriate tools based on the action_consumer specified in each action step.
      • Updates the task_queue with the results from each tool.
  • core/classes.py:
    • ActionStep (BaseModel):
      • Represents a single step in the action plan.
      • Fields: action_consumer, action_type, action_argument, result.
      • Validates the fields to ensure correctness.
    • TaskQueue (BaseModel):
      • Represents the overall action plan.
      • Fields: human_message, action_steps.
      • Validates the action_steps to ensure they are compatible with available tools.
    • AbstractTool (ABC):
      • Abstract base class for all tools.
      • Defines common methods for tools, like set_state, get_state, and run.
      • Provides basic functionality like caching and Langfuse integration.
  • core/common.py:
    • Provides utility functions like get_logger, num_tokens_from_string, get_unique_timestamp, get_system_prompt, and ha_render_system_prompt.
  • tools/integration/homeassistant.py:
    • HomeAssistant (AbstractTool):
      • Tool to interact with Home Assistant.
      • Inherits from AbstractTool and implements set_state and get_state.
      • Manages a cache of Home Assistant entities and services.
      • Uses LangChain to translate natural language commands into Home Assistant API calls.
  • tools/core/talk_to_user.py:
    • TalkToUser (AbstractTool):
      • Simple tool to communicate directly with the user.
      • Primarily used for conveying messages or asking for input.

Optional Modules

Chat Interface

  • meeseeks-chat/chat_master.py:
    • Implements the Streamlit-based chat interface.
    • Handles user input, generates and runs the action plan, and displays the results.
    • Utilizes streamlit components for interactive chat features.

Understanding the Flow

  1. User Input: The user interacts with the chat interface, providing a query in natural language.
  2. Action Plan Generation: The core.task_master.generate_action_plan function processes the user's query and creates an TaskQueue with a series of ActionStep instances.
  3. Action Plan Execution: The core.task_master.run_action_plan function iterates through the ActionStep instances in the TaskQueue, utilizing the appropriate AbstractTool to fulfill each step.
  4. Response Generation: The results from each tool are collected and compiled into a comprehensive response for the user.
  5. User Interaction: The response is presented to the user via the chat interface, completing the interaction cycle.

Contributing

This documentation provides a high-level overview of the Meeseeks project architecture. For detailed information on specific functions and classes, please refer to the inline comments within the code.

Contributions to enhance this documentation or any other aspect of the project are highly encouraged.