| 
 | 1 | +=========  | 
 | 2 | +AI agents  | 
 | 3 | +=========  | 
 | 4 | + | 
 | 5 | +An AI agent is a smart assistant in Odoo that can understand natural language, perform tasks, and  | 
 | 6 | +assist users by interacting with Odoo tools. Agents are a core component of the AI structure in  | 
 | 7 | +Odoo. Each agent has a defined purpose, prompt, and a set of topics and tools that guide its  | 
 | 8 | +behavior.  | 
 | 9 | + | 
 | 10 | +Agents are formed of two main components, *Topics* and *Sources*.  | 
 | 11 | + | 
 | 12 | + - *Topics* are the instructions and roles that inform the agent of what tasks they need to  | 
 | 13 | +   complete. *Tools* are assigned to topics, and are the actual functions the agent can utilize to  | 
 | 14 | +   perform tasks.  | 
 | 15 | + - *Sources* provide the agent with the information they need to complete their tasks.  | 
 | 16 | + | 
 | 17 | +.. important::  | 
 | 18 | +   While many AI features can be used in Odoo without the *AI* application, creating and customizing  | 
 | 19 | +   agents requires that the *AI* application is installed.  | 
 | 20 | + | 
 | 21 | +AI prompts in Odoo  | 
 | 22 | +==================  | 
 | 23 | + | 
 | 24 | +Before working with AI agents, it is important to understand some basics concepts regarding AI  | 
 | 25 | +prompts.  | 
 | 26 | + | 
 | 27 | +An AI prompt is a set of written instructions or context given to an AI model that tells it how to  | 
 | 28 | +respond to a request, or what role to take. Prompts can define:  | 
 | 29 | + | 
 | 30 | +- the tone, style, and persona of the AI model  | 
 | 31 | +- the scope of what the model can do  | 
 | 32 | +- the type of output expected from the request  | 
 | 33 | + | 
 | 34 | +In Odoo, each AI agent is assigned a :guilabel:`System Prompt`, which defines the agent's overall  | 
 | 35 | +role, purpose, and behavior. It acts as the core mission statement of the agent, and drives all  | 
 | 36 | +interactions.  | 
 | 37 | + | 
 | 38 | +Each :ref:`Topic <ai/topics>` also includes its own prompt-like component, called  | 
 | 39 | +:guilabel:`Instructions`. Instructions are topic-specific guidelines that refine how the agent  | 
 | 40 | +behaves within a certain context or workflow, and how it interacts within the Odoo framework.  | 
 | 41 | + | 
 | 42 | +Instructions often include:  | 
 | 43 | + | 
 | 44 | +- A purpose, or what the topic covers  | 
 | 45 | +- Rules or constraints for the agent to follow when assigned this topic  | 
 | 46 | +- Step-by-step workflows for how to complete a specfic action  | 
 | 47 | +- Technical details needed to complete any actions  | 
 | 48 | + | 
 | 49 | +Agent structure  | 
 | 50 | +===============  | 
 | 51 | + | 
 | 52 | +.. _ai/topics:  | 
 | 53 | + | 
 | 54 | +Topics  | 
 | 55 | +------  | 
 | 56 | + | 
 | 57 | +*Topics* are a collection of instructions and :ref:`tools <ai/tools>` that define how an agent  | 
 | 58 | +behaves within a specific context. Essentially, the topics define what an agent can do within the  | 
 | 59 | +database.  | 
 | 60 | + | 
 | 61 | +.. important::  | 
 | 62 | +   If an agent is not assigned any Topics, it is only able to provide information, not complete  | 
 | 63 | +   tasks or make changes to the database.  | 
 | 64 | + | 
 | 65 | +Topics guide conversations, telling the agent what it can do, how it can do it, and when it should  | 
 | 66 | +do it. Within each topic includes a detailed prompt, which provides the agent with more in-depth  | 
 | 67 | +instructions on how to perform the  | 
 | 68 | + | 
 | 69 | +The following topics are preconfigured in the *AI* app:  | 
 | 70 | + | 
 | 71 | +- :guilabel:`Natural Language Search`: supports the interpretation of a user query to open the  | 
 | 72 | +  appropriate Odoo view with a set of tools necessary to perform the search.  | 
 | 73 | +- :guilabel:`Information retrieval`: a collection of tools to retrieve information about the models.  | 
 | 74 | +- :guilabel:`Create Leads`: a collection of tools to support automated lead creation. This topic is  | 
 | 75 | +  **only** available if the *CRM* app is installed.  | 
 | 76 | + | 
 | 77 | +Within each topic is a set of :guilabel:`Instructions`, which act as a prompt and provide guidance  | 
 | 78 | +for the structure of the interaction, and one or more :ref:`AI Tools <ai/tools>`, which indicate the  | 
 | 79 | +functions the agent can perform.  | 
 | 80 | + | 
 | 81 | +.. _ai/tools:  | 
 | 82 | + | 
 | 83 | +Tools  | 
 | 84 | +~~~~~  | 
 | 85 | + | 
 | 86 | +*Tools* are the functions the agent can perform in Odoo. These include actions like creating a lead  | 
 | 87 | +or opening a view. Tools extend the purpose of the agent beyond conversations, they enable real  | 
 | 88 | +actions. The available tools in a database vary based on the applications installed. Multiple  | 
 | 89 | +:guilabel:`AI Tools` can be assigned to a single topic.  | 
 | 90 | + | 
 | 91 | +Sources  | 
 | 92 | +-------  | 
 | 93 | + | 
 | 94 | +Sources are the data the agent can refer to when generating responses or completing tasks. Sources  | 
 | 95 | +are indexed so the agent can retrieve relevant information when a user asks a question.  | 
 | 96 | + | 
 | 97 | +.. example::  | 
 | 98 | +    An agent designed to answer customer support questions has *Knowledge* articles included as  | 
 | 99 | +    sources, which include frequently asked questions.  | 
 | 100 | + | 
 | 101 | +Sources can be in the following formats:  | 
 | 102 | + | 
 | 103 | + - PDFs  | 
 | 104 | + - Weblinks  | 
 | 105 | + - Documents (uploaded in the *Documents* application)  | 
 | 106 | + - *Knowledge* app articles  | 
 | 107 | + | 
 | 108 | +.. important::  | 
 | 109 | +   If the :guilabel:`Restrict to Sources` option is enabled on an agent, the agent can **only**  | 
 | 110 | +   utilize information from the uploaded and active sources.  | 
 | 111 | + | 
 | 112 | +Create a new agent  | 
 | 113 | +==================  | 
 | 114 | + | 
 | 115 | +To create a new AI agent, navigate to the :menuselection:`AI app --> New`. Enter an :guilabel:`Agent  | 
 | 116 | +Name`, then add a short description, if desired.  | 
 | 117 | + | 
 | 118 | +.. tip::  | 
 | 119 | +   Before creating a new agent, it is recommended to have a clear use case in mind. This helps when  | 
 | 120 | +   writing out the :guilabel:`System Prompt`, and assigning the :guilabel:`Topics` and :guilabel:`AI  | 
 | 121 | +   Tools`.  | 
 | 122 | + | 
 | 123 | +Select an :guilabel:`LLM Model` from the drop-down menu.  | 
 | 124 | + | 
 | 125 | +.. important::  | 
 | 126 | +   Odoo supports multiple versions of both ChatGPT and Gemini.  | 
 | 127 | + | 
 | 128 | +Next, select a :guilabel:`Response Style`. This manages the overall tone the agent uses when  | 
 | 129 | +responding to an inquiry. Choose from one of the following options:  | 
 | 130 | + | 
 | 131 | + - :guilabel:`Analytical`: more mathematical, this option is more likely to give the same answer to  | 
 | 132 | +   the same question. This option is recommended for situations where accuracy is more important  | 
 | 133 | +   than diplomacy.  | 
 | 134 | + - :guilabel:`Balanced`: a mix of both *Analytical* and *Creative*. This is an excellent option for  | 
 | 135 | +   situations with outside customers who would benefit from **both** accuracy and diplomacy.  | 
 | 136 | + - :guilabel:`Creative`: approaches questions in a more human way, changes answers every time to  | 
 | 137 | +   react to the conversation. This option works best for times when the solutions often vary based  | 
 | 138 | +   on the situation.  | 
 | 139 | + | 
 | 140 | +Tick the :guilabel:`Restrict to Sources` checkbox to limit the agent to **only** respond based on  | 
 | 141 | +the provided resources.  | 
 | 142 | + | 
 | 143 | +Next, select one or more :guilabel:`Topics` for the agent. As explained above, :ref:`Topics  | 
 | 144 | +<ai/topics>` include both instructions and tools that guide the agent in helping users complete a  | 
 | 145 | +task.  | 
 | 146 | + | 
 | 147 | +Enter a :guilabel:`System Prompt` with detailed instructions for the agent as to their role and  | 
 | 148 | +responsibilities.  | 
 | 149 | + | 
 | 150 | +.. tip::  | 
 | 151 | +   The specificity and length of the :guilabel:`System Prompt` can vary, depending on the use case  | 
 | 152 | +   for the agent. Use the preconfigured agents as an example of the possible information.  | 
 | 153 | + | 
 | 154 | +.. image:: agents/new-agent.png  | 
 | 155 | +   :alt: A new agent form with the required information.  | 
 | 156 | + | 
 | 157 | +If *Sources* are needed for the agent, scroll to the :guilabel:`Sources` tab, then click  | 
 | 158 | +:guilabel:`Add a source`.  | 
 | 159 | + | 
 | 160 | +Select a format:  | 
 | 161 | + | 
 | 162 | + - PDFs: Select the appropriate file from the explorer window, and click :guilabel:`Open`  | 
 | 163 | + - Weblinks: paste the URL. Multiple links can be added at once, paste one link per line. Click  | 
 | 164 | +   :guilabel:`Save`.  | 
 | 165 | + - Documents (uploaded in the *Documents* application): Tick the checkbox next to one or more  | 
 | 166 | +   documents, then click :guilabel:`Select`.  | 
 | 167 | + - *Knowledge* app articles: Tick the checkbox next to one or more articles, then click  | 
 | 168 | +   :guilabel:`Select`.  | 
 | 169 | + | 
 | 170 | +Once a source is added, the :guilabel:`Status` field updates to reflect its current status. The  | 
 | 171 | +source is ready when the status changes from *Processing* to *Indexed*. Slide the :guilabel:`Active`  | 
 | 172 | +toggle to activate the source.  | 
 | 173 | + | 
 | 174 | +.. image:: agents/sources.png  | 
 | 175 | +   :alt: A list of sources for an agent, each denoted with their format.  | 
 | 176 | + | 
 | 177 | +.. important::  | 
 | 178 | +   If a source fails to upload, it could be the result of a conflict with the selected LLM model.  | 
 | 179 | + | 
 | 180 | +Click the :guilabel:`Test` button to open a conversation window and test the new agent.  | 
0 commit comments