# AI Assistant (jb_ai_assistant)

Odoo 17 module providing a ChatGPT-style personal AI assistant powered by OpenAI.

## Features (v1)

| Area | What it does |
|------|----------------|
| **Chat UI** | OWL client action with sidebar history and main message pane |
| **Personal history** | Each user sees only their own conversations (record rules) |
| **Bot name** | Per-user display name for the assistant (default: **Udi**) |
| **Multi-model** | Admin configures available OpenAI models in Settings |
| **Admin oversight** | AI Administrators can view all conversations for support |
| **System prompt** | Global base prompt in Settings → AI Assistant |
| **Card rails** | Ordered context cards appended to every system message |
| **Session memory** | Per-chat persistent notes sent with every message |
| **OpenAI** | Global API key in Settings → AI Assistant |

## Install

1. Ensure Docker stack is running (`docker compose up -d`).
2. Update Apps list and install **AI Assistant**.
3. As admin: **Settings → AI Assistant** → enter OpenAI API key.
4. Open **AI Assistant** from the app switcher.

## User preferences

**Settings → Users → Preferences → AI Assistant → AI Bot Name**

Each user can rename their assistant (e.g. "Udi", "DevBot").

## Admin

- **Settings → AI Assistant** — API key, base URL, temperature, max tokens
- **AI Assistant → AI Models** — manage model list
- **AI Assistant → All Conversations** — read any user's chat history

## Privacy

- Record rules restrict `jb.ai.conversation` and `jb.ai.message` to the owning user.
- Members of **AI Assistant / Administrator** bypass rules for support.

## Roadmap (v2)

- Image generation (DALL-E)
- Email drafting helper
- Knowledge base / company Q&A tools
- Streaming responses

## Module layout

```
jb_ai_assistant/
├── models/
│   ├── ai_conversation.py   # Chat + OpenAI RPC API
│   ├── ai_message.py
│   ├── ai_model.py
│   ├── res_config_settings.py
│   └── res_users.py
├── static/src/
│   ├── js/ai_chat.js        # OWL client action
│   ├── xml/ai_chat.xml
│   └── scss/ai_chat.scss
└── security/                # Groups + per-user record rules
```
