### Install MkDocs Source: https://github.com/project/ai_agents/blob/1.3.x/README.md Install MkDocs and the Material theme for building local documentation. ```bash pip install mkdocs mkdocs-material ``` -------------------------------- ### Serve MkDocs Documentation Source: https://github.com/project/ai_agents/blob/1.3.x/README.md Run the MkDocs development server to view local documentation. ```bash mkdocs serve ``` -------------------------------- ### Configure and Set Up an AI Agent Source: https://github.com/project/ai_agents/blob/1.3.x/docs/developers/using_ai_agent_in_custom_code.md Configure the loaded AI Agent with its task, AI provider, model name, and any specific AI configurations. This prepares the agent for execution. ```php // Create the task you require the AI Agent to perform. $task = new Task('Description of the task for the AI Agent to complete'); $task->setComments(['Context description' => 'Additional context that the AI may require to carry out the task.']); // Set up the AI agent. $yourAgent->setTask($task); $yourAgent->setAiProvider($yourLoadedProvider); $yourAgent->setModelName('The Provider model for the AI Agent to use'); $yourAgent->setAiConfiguration(['An array of any additional provider settings.']); // Instruct some AI Agents whether to create any entities they can // immediately, or to delay any direct action so additional steps can be // carried out. $yourAgent->setCreateDirectly(TRUE); ``` -------------------------------- ### Load a Specific AI Agent Instance Source: https://github.com/project/ai_agents/blob/1.3.x/docs/developers/using_ai_agent_in_custom_code.md Load a specific AI Agent instance using its unique plugin ID. This requires obtaining the plugin definition and then creating the instance via the Plugin Manager service. ```php $plugin_id = 'YOUR CHOSEN AI AGENT PLUGIN ID'; $definition = \Drupal::service('plugin.manager.ai_agents')->getDefinition($plugin_id); $aiAgent = \Drupal::service('plugin.manager.ai_agents')->createInstance($plugin_id, $definition); ``` -------------------------------- ### Discover Available AI Agent Plugin IDs Source: https://github.com/project/ai_agents/blob/1.3.x/docs/developers/using_ai_agent_in_custom_code.md Use the AI Agents Plugin Manager service to retrieve a list of all available AI Agent plugin IDs. This is the first step to identifying which agent to load. ```php $pluginIds = \Drupal::service('plugin.manager.ai_agents')->getDefinitions(); ``` -------------------------------- ### Handle Different AI Agent Task Responses Source: https://github.com/project/ai_agents/blob/1.3.x/docs/developers/using_ai_agent_in_custom_code.md Use a switch statement based on the `determineSolvability()` result to call the appropriate AI Agent method for handling the task, such as asking a question, answering, informing, or solving. ```php switch ($solution_type) { case AiAgentInterface::JOB_NEEDS_ANSWERS: $response = $yourAgent->askQuestion(); break; case AiAgentInterface::JOB_SHOULD_ANSWER_QUESTION: $response = $yourAgent->answerQuestion(); break; case AiAgentInterface::JOB_INFORMS: $response = $yourAgent->inform(); break; case AiAgentInterface::JOB_SOLVABLE: $response = $yourAgent->solve(); break; case AiAgentInterface::JOB_NOT_SOLVABLE: $response = NULL; break; } ``` -------------------------------- ### Set User Interface Identifiers for AI Agent Calls Source: https://github.com/project/ai_agents/blob/1.3.x/docs/developers/using_ai_agent_in_custom_code.md Optionally, set user interface identifiers for AI Agent calls. This helps in tracking and identifying specific API calls made by your module. ```php $yourAgent->setUserInterface('YOUR_MODULE_NAME', ['tags to identify the AI API call']); ``` -------------------------------- ### Determine AI Agent Task Solvability Source: https://github.com/project/ai_agents/blob/1.3.x/docs/developers/using_ai_agent_in_custom_code.md Call the `determineSolvability()` method on the AI Agent to identify the type of task it is expected to perform. This returns a constant indicating how to proceed. ```php $solution_type = $yourAgent->determineSolvability(); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.