AI 서버 액션¶
AI 서버 액션을 통해 Odoo의 자동화 프레임워크 범위를 확장할 수 있습니다. 업무 프로세스에서 필요한 다양한 의사결정에 인공지능을 활용할 수 있습니다.
이 기능은 주어진 조건만으로는 복잡한 로직을 모두 표현할 수 없는 상황에서도, 표준 서버 액션을 통해 실행 관리를 해야 하는 경우를 위해 제작되었습니다.
AI 서버 액션이 작동하는 방식¶
Odoo에서 AI 기반 워크플로우는 AI 서버 액션(또는 관리자)과 그 도구(또는 작업자) 간의 명확한 책임 분리를 전제로 구축되어 있습니다.
AI 서버 액션: 관리자¶
AI 서버 액션은 의사결정권자, 즉 관리자의 역할을 수행합니다. 레코드와 그 컨텍스트를 읽고 파악하며, AI 프롬프트를 해석하며, 어떤 도구를 호출하고 어떤 인수를 적용할지 판단합니다.
서버 액션에서는 비즈니스 규칙에 대한 강제 적용, 레코드에 대한 직접 수정 및 작업의 정확성이 보장되지 않습니다. 서버 액션은 의사결정을 하는 역할로만 한정되어 있습니다.
AI 도구: 작업자¶
도구는 표준 서버 액션의 하나로 사용 탭에서 AI에서 사용하기 옵션을 활성화하면 실행할 수 있습니다. 도구에는 모든 실행 로직이 포함되어 있으며 레코드 업데이트, 이동, 작성 작업을 수행합니다. 도구는 반드시 파이썬 코드를 통해 명시적으로 비즈니스 규칙을 구현하고 실행해야 합니다.
AI 서버 액션에서 도구를 호출할 경우, 코드 자체에서 실행이 제한되는 경우를 제외하고는 도구가 무조건 실행됩니다.
AI 서버 액션 워크플로우¶
AI 서버 액션은 다음과 같은 순서로 진행됩니다:
레코드에서 AI 서버 액션이 트리거됩니다.
AI 프롬프트에 대한 평가가 진행되며, 레코드가 컨텍스트가 됩니다.
AI 가 사용 가능한 도구 중 하나를 선택합니다.
AI 가 도구에 필요한 인수를 제공합니다.
선택된 도구가 파이썬 코드를 실행합니다.
중요
Odoo에서 이미 존재하는 기본 동작(예: 문서를 폴더로 이동하기)의 경우에는 로직을 사용자 지정하지 않고도 AI 서버 액션을 작동할 수 있습니다. 이 경우 AI 에서 매개변수를 선택하면 Odoo에서 액션이 실행됩니다.
단계별 사례 보기¶
받은 편지함 문서 자동 분류하기 예시를 통해 전체적인 AI 서버 액션의 패턴을 확인할 수 있습니다. 을 통해 서버 액션 메뉴로 이동합니다.
참고
This server action is designed to review documents for their content, and add tags. The action itself does not move documents or add tags, it only decides which tool should be used, based on the documents’ content.
The Model for the action is listed as Document, and the Type is AI.
The prompt for this action provides context about the document, as well as intent of the action.
The Tool field includes several actions that may be taken based on this prompt, including moving a document, adding tags, or creating invoices or bills.
참고
AI: Add Tags, AI: Move to Folder, and AI: Rename Document are all Execute Code server actions, meaning they trigger python code.
For example, if the action determines, based on the content of the document, that the most appropriate tool is AI: Move to Folder, the Python code performs the following operation:
ai['result'] = record._ai_action_move_in_folder(folder_id)
This code, executes unconditionally when called and performs the move using an existing method.
참고
The AI does not infer arguments from the Python code or from the method signature. Instead, arguments passed to a tool are determined entirely by the tool’s configuration.
For the AI: Move to Folder tool, the Python code expects a variable named folder_id. The AI
knows to provide folder_id because it is explicitly declared as an argument in the
configuration. This can be found on the Usage tab of the server action, in the AI
Schema field. The Name column under AI Schema must match the variable name used in
the Python code exactly.
The AI uses the argument description to understand what the parameter represents, what type of value is expected, and when it is appropriate to supply it.
If an argument is not defined in the Usage tab, the AI cannot provide it, even if the Python code references it.
Creating custom AI tools¶
The same pattern in the Auto-sort documents in Inbox example above can be implemented using standard Odoo logic. For example, to create an action that can update a task description, an Execute Code action could be created with the following code:
record.write({'description': content})
To function correctly, content must be defined as an argument in tool’s Usage tab.
더 보기:
일반적인 문제점¶
Why is the Tools field empty?¶
Confirm that at least one server action has Use in AI enabled.
Confirm that at least one tool is assigned to the same model Model as the server action.
Why did the tool run but nothing happened?¶
The Python code exited without changes.
Required arguments were missing or empty.
Business conditions were not implemented in the tool logic.
Why did the AI choose an unexpected tool?¶
The prompt lacked sufficient context.
Multiple tools matched the same intent.
No constraints were enforced at the tool level.