|
dolibarr 24.0.0-beta
|
Library files with common functions for Ai. More...
Go to the source code of this file.
Functions | |
| getListOfAIFeatures () | |
| Prepare admin pages header. | |
| getListOfAIServices () | |
| Get list of available ai services. | |
| testAIConnection (string $service, string $key, string $url) | |
| Tests the connection to an AI service using its API key and URL by sending message "Hello". | |
| ai_log_request ($db, $user, $query, array $response, $provider, float $time, float $confidence, $status, $error='', $rawReq='', $rawRes='') | |
| Log AI Request with Raw Payloads. | |
| getListForAISummarize () | |
| Get list for AI summarize. | |
| getListForAIRephraseStyle () | |
| Get list for AI style of writing. | |
| aiAdminPrepareHead () | |
| Prepare admin pages header. | |
| getAiAssistantProviderLabel () | |
| Resolve the AI provider/service currently configured for the AI Assistant (e.g. | |
| getAiChatAssistantConfig () | |
| Build the configuration array consumed by the AI Assistant chat frontend (ai/js/ai_assistant.js). | |
| getAiChatAssistantHtml ($mode='page') | |
| Build the HTML of the AI Assistant chat interface. | |
Library files with common functions for Ai.
Definition in file ai.lib.php.
| ai_log_request | ( | $db, | |
| $user, | |||
| $query, | |||
| array | $response, | ||
| $provider, | |||
| float | $time, | ||
| float | $confidence, | ||
| $status, | |||
| $error = '', | |||
| $rawReq = '', | |||
| $rawRes = '' ) |
Log AI Request with Raw Payloads.
| DoliDB | $db | Database object |
| User | $user | User object |
| string | $query | The query sent to the AI |
| array<string,mixed> | $response The full response from the AI | |
| string | $provider | The AI provider (e.g., 'OpenAI', 'Anthropic') |
| float | $time | Execution time in seconds |
| float | $confidence | Confidence score from the AI (if any) |
| string | $status | Status of the request (e.g., 'success', 'error') |
| string | $error | Error message, if any |
| string | $rawReq | Raw request payload |
| string | $rawRes | Raw response payload |
Definition at line 319 of file ai.lib.php.
References $conf, $db, dol_now(), dol_print_error(), dol_strlen(), dol_substr(), getDolGlobalInt(), and string.
Referenced by mcp_log_request().
| aiAdminPrepareHead | ( | ) |
Prepare admin pages header.
Definition at line 407 of file ai.lib.php.
References $conf, complete_head_from_modules(), dol_buildpath(), and getDolGlobalString().
| getAiAssistantProviderLabel | ( | ) |
Resolve the AI provider/service currently configured for the AI Assistant (e.g.
"ChatGPT (OpenAI)", "Google Gemini", "Anthropic (Claude)"), so it can be displayed in the chat header. The precise model name is intentionally not shown here, only which AI is in use.
Definition at line 477 of file ai.lib.php.
References getDolGlobalString(), getListOfAIServices(), and string.
Referenced by getAiChatAssistantHtml().
| getAiChatAssistantConfig | ( | ) |
Build the configuration array consumed by the AI Assistant chat frontend (ai/js/ai_assistant.js).
It is serialized as JSON into the data-ai-config attribute of the chat container.
Definition at line 495 of file ai.lib.php.
References dol_buildpath(), dol_strtoupper(), dol_substr(), and getDolGlobalString().
Referenced by getAiChatAssistantHtml().
| getAiChatAssistantHtml | ( | $mode = 'page' | ) |
Build the HTML of the AI Assistant chat interface.
Shared by the standalone page (ai/assistant/index.php) and the topbar popover fragment (ai/assistant/popover.php) so both render the exact same chat.
| string | $mode | 'page' for the standalone full page, 'popover' for the topbar popover fragment |
Definition at line 617 of file ai.lib.php.
References dol_escape_htmltag(), getAiAssistantProviderLabel(), getAiChatAssistantConfig(), and img_picto().
| getListForAIRephraseStyle | ( | ) |
Get list for AI style of writing.
Definition at line 391 of file ai.lib.php.
Referenced by FormAI\getSectionForAIEnhancement().
| getListForAISummarize | ( | ) |
Get list for AI summarize.
Definition at line 369 of file ai.lib.php.
Referenced by FormAI\getSectionForAIEnhancement().
| getListOfAIFeatures | ( | ) |
Prepare admin pages header.
Definition at line 36 of file ai.lib.php.
| getListOfAIServices | ( | ) |
Get list of available ai services.
Definition at line 68 of file ai.lib.php.
Referenced by Ai\generateContent(), getAiAssistantProviderLabel(), and testAIConnection().
Tests the connection to an AI service using its API key and URL by sending message "Hello".
This function supports multiple AI providers (Google Gemini, Anthropic Claude, and OpenAI-compatible APIs like Mistral, Groq, and DeepSeek). It constructs a minimal, provider-specific request payload and sends it to the given endpoint to verify that the API key is valid and the service is reachable.
| string | $service | The identifier of the AI service (e.g., 'google', 'anthropic', 'openai', 'mistral'). |
| string | $key | The API key for the service. |
| string | $url | The base URL of the AI service's API endpoint. |
Definition at line 212 of file ai.lib.php.
References getDolGlobalString(), and getListOfAIServices().