odoo/enterprise#82290

Created by Dylan Proovost (DPRO)
Merged at c920a794c96ad43356aa60284229b10f4dbe85cc

Statuses:

Linked pull requests
label
odoo-dev:master-ai
head
cda5624b667c82f2b5d795c919df565a26e6a215
merged
6 months ago by iAP, Louis Baudoux (lba)
odoo/odoo odoo/enterprise
master #204523 #82290

[ADD] ai: implementation of AI agents

This commit introduces a new ai module as well as a bridge module ai_calendar.

This module allows for the creation of AI agents designed for retrieval-augmented generation (RAG), using context extracted from uploaded documents and web pages. Aside from answering questions, the agents can also perform actions on the database. Currently, they can create calendar events with users through integration with the calendar module.

This module also introduces one new dependency: markdown2.
- markdown2 is used for converting the response of the LLM APIs from markdown to html for rendering in the chat messages.

As for the technical features of the module:
- Creation of AI agents that use models from various providers. The agents can be fine-tuned for specific tasks by specifying system prompts, and providing relevant documents.
- Indexation and chunking of documents (e.g. PDF, ppt, docs, etc.) and web pages for easy retrieval when creating the RAG.
- Integration with server actions to allow agents to perform operations directly within Odoo database.

Choices:
- Markdown library: two libraries were considered during development for the conversion of markdown to html: markdown, and markdown2. For this choice, we considered the performances and the features proposed by the two libraries. In terms of performance, markdown we conducted a benchmark that consisted in the conversion of a big markdown file (~2.3MB) from which markdown came out on top. However, when considering the features, markdown2 proposes more features "out-of-the-box" and is also more robust for standard markdown, specifically for the use case of nested lists. Which is why we decided to work with markdown2

Limitations:
- The agents' backend currently only support two OpenAI models (GPT 3.5, and GPT 4).
- The AI actions are limited to scheduling of calendar events.
- Embedding generation is currently fixed to use the OpenAI API, requiring an OpenAI key, and the database column size for storing embeddings is predefined.

task-4526285

Co-authored-by: deimort <dpro@odoo.com>
Co-authored-by: abdelrahmanfawzy <abdh@odoo.com>
Co-authored-by: abdelrahmankhaledg <akha@odoo.com>
Co-authored-by: lobaudoux <lba@odoo.com>