# AI Assistant Vvveb plugin

Add an AI assistant toolbar button to the content editor (TinyMCE) on post and product edit pages and to the visual editor (VvvebJS) site editor.

## AI providers

The assistant talks to modern chat APIs. Selected from the plugin settings page (`provider` option):

| Provider | Id | Default model | Api |
|---|---|---|---|
| OpenAI | `openai` | gpt-4o-mini | chat completions |
| Anthropic Claude | `anthropic` | claude-sonnet-4-20250514 | messages |
| Google Gemini | `google` | gemini-2.0-flash | generateContent |
| DeepSeek | `deepseek` | deepseek-chat (reasoning via deepseek-reasoner) | openai compatible |
| Groq | `groq` | llama-3.3-70b-versatile | openai compatible |
| Mistral | `mistral` | mistral-large-latest | openai compatible |
| xAI Grok | `xai` | grok-3-latest | openai compatible |
| OpenRouter | `openrouter` | openai/gpt-4o-mini | openai compatible |
| OpenCode Zen | `opencode` | qwen3-coder | openai compatible |
| NVIDIA NIM | `nim` | meta/llama-3.3-70b-instruct | openai compatible |

Each provider adapter translates a single internal message format to the native API:

- system prompt (configurable in settings)
- multi-part content: text, images, PDFs/documents, audio
- streaming responses rendered incrementally
- "thinking"/reasoning blocks shown collapsed
- function/tool calls surfaced via the `vvveb-ai-tool-calls` event so plugins can execute them and send results back with `VvvebAi.continueWithToolResults()`

### Api mode - direct or proxy

- **direct** - the browser calls the provider API directly using the saved api key.
- **proxy** - requests are relayed through your own site (`admin/controller/proxy.php`) which injects the api key server side, so keys are never exposed to the browser.

Per-provider keys can be set for every provider (`openai_key`, `anthropic_key`, `google_key`, `deepseek_key`, `groq_key`, `mistral_key`, `xai_key`, `openrouter_key`, `opencode_key`, `nim_key`) with the generic `key` as fallback.

### Tool calls from other plugins

```js
// register handlers
document.addEventListener("vvveb-ai-tool-calls", async (event) => {
	const {calls} = event.detail;
	// ... execute tools ...
});
window.aiAssistantToolHandlers = {
	get_weather: async (args) => ({temp: "22C"}),
};
// or trigger execution + follow-up turn manually
const result = await aiAssistantRunToolCalls(window.aiAssistantLastPayload._lastToolCalls);
```

## Install

Upload plugin zip to your Vvveb dashboard `admin / plugins` page or unzip to plugins folder.

## License

Copyright (c) [Vvveb](https://www.vvveb.com)

Released under the [GPL 3](https://github.com/Vvveb/ai-assistant/blob/main/LICENSE) license.
