Path in the Gestor bibliotecas/ia.php
It is the AI inside the editors: the component where the user picks server, model, prompt and mode, and the call that sends the text to the API. It is used by the HTML editor (html-editor.php) and by the dashboard Live Editor.
Concepts
| Table | What it is |
|---|---|
servidores_ia |
An (encrypted) API key with a name; padrao sets the first one in the list. Registered in admin-ia |
prompts_ia |
Ready-made texts per target and language, such as "generate a pricing section" |
modos_ia |
System instructions per target (how the AI should answer); the one with padrao comes preselected |
The target is the context where the component shows up (for example, paginas in the page editor). Prompts and modes are resources: they are born from modules (ai_prompts, ai_modes, ai_prompts_targets) and can be created in the editor itself (resources).
Rendering the component
ia_renderizar_prompt(['alvo' => 'paginas', 'prompt_controls' => $html]) returns the HTML of the ia-prompt component:
-
it lists the target's servers, prompts and modes, and the Gemini models, with the default selected;
-
it includes the library JS, CodeMirror and the
ia-prompt-modaismodals; -
it exposes
gestor.ai.activatedandgestor.ia(target and messages) to JavaScript; -
with no active server, it returns the
ia-sem-servidorcomponent andgestor.ai.activated = false.
ia_editor_dados($target) returns the same data as JSON, for the Live Editor to build the screen by itself.
Available filters (hooks): ia.prompts.load.where (WHERE of the prompt list), ia.prompt.option (HTML of each option), ia.models.available (models) and ia.config (extra data for the JS).
Sending the prompt
$r = ia_enviar_prompt(['servidor_id' => 3, 'modelo' => 'models/gemini-3-flash-preview', 'prompt' => $text]);
if ($r['status'] === 'success') {
$text = $r['data']['texto_gerado']; // + modelo_usado, tokens_entrada/saida/total, resposta_completa
}-
Without
modelo, it uses thedefaultModelfromadmin-ia.json(currentlymodels/gemini-3-flash-preview). The model name carries themodels/prefix; the hard-coded fallback,gemini-1.5-flash, lacks the prefix and would not work in the URL. -
It decrypts the server key and calls the Gemini API
generateContent(120 s timeout). -
It returns
['status' => 'success', 'data' => …]or['status' => 'error', 'message' => …]; on an HTTP error, the message includes the API response body. -
There is no conversation history: each call sends a single text.
-
ia_processar_retorno(['dados_retorno' => $r['data'], 'formato' => 'texto'|'html'|'json'])formats the result (htmlapplieshtmlspecialchars+nl2br). It has no callers.
Editor AJAX
ia_ajax_interface() dispatches, by ajax-opcao: ia-prompts → ia_ajax_prompts() and ia-modos → ia_ajax_modos() (text of a prompt/mode), ia-prompt-edit → ia_ajax_prompt_edit(), ia-prompt-new → ia_ajax_prompt_novo() and ia-prompt-del → ia_ajax_prompt_del().
Functions
Generated from gestor/bibliotecas/ia.php · 10 functions
ia_renderizar_prompt
view source · line 22 ↗ia_renderizar_prompt(array $params = false)Renderizar Prompt.
Parameters
$paramsarray- Parâmetros da função.
ia_enviar_prompt
view source · line 266 ↗ia_enviar_prompt($params = false)Enviar Prompt.
Parameters
$params
ia_processar_retorno
view source · line 438 ↗ia_processar_retorno(array $params = false)Processar Retorno.
Parameters
$paramsarray- Parâmetros da função.
ia_editor_dados
view source · line 507 ↗ia_editor_dados(string $alvo): arrayDados do assistente de IA para UI vanilla (Live Editor — BATCH-080).
Parameters
$alvostring- Alvo do prompt/modo (ex.: 'paginas').
Returns
{status, data|message}.ia_ajax_interface
view source · line 577 ↗ia_ajax_interface($params = false)Parameters
$params
ia_ajax_prompts
view source · line 598 ↗ia_ajax_prompts(array $params = false)AJAX Prompts.
Parameters
$paramsarray- Parâmetros da função.
ia_ajax_modos
view source · line 659 ↗ia_ajax_modos(array $params = false)AJAX Modos.
Parameters
$paramsarray- Parâmetros da função.
ia_ajax_prompt_edit
view source · line 723 ↗ia_ajax_prompt_edit(array $params = false)AJAX Prompt Edit.
Parameters
$paramsarray- Parâmetros da função.
ia_ajax_prompt_novo
view source · line 773 ↗ia_ajax_prompt_novo(array $params = false)AJAX Prompt Novo.
Parameters
$paramsarray- Parâmetros da função.
ia_ajax_prompt_del
view source · line 854 ↗ia_ajax_prompt_del(array $params = false)AJAX Prompt Delete.
Parameters
$paramsarray- Parâmetros da função.