This commit is contained in:
Andrew Nicols 2025-03-05 14:55:33 +08:00
commit 0865f0e996
No known key found for this signature in database
GPG Key ID: 6D1E3157C8CFBF14
3 changed files with 9 additions and 8 deletions

View File

@ -24,6 +24,7 @@ use core_reportbuilder\local\filters\text;
use core_reportbuilder\local\helpers\format;
use core_reportbuilder\local\report\column;
use core_reportbuilder\local\report\filter;
use core\output\help_icon;
use lang_string;
/**
@ -145,6 +146,7 @@ class ai_action_register extends base {
->set_type(column::TYPE_INTEGER)
->add_field("COALESCE({$generatetextalias}.prompttokens, {$summarisetextalias}.prompttokens)", 'prompttokens')
->set_is_sortable(true)
->set_help_icon(new help_icon('prompttokens', 'core_ai'))
->add_callback(static function(?int $value): string {
return $value ?? get_string('unknownvalue', 'core_ai');
});
@ -168,6 +170,7 @@ class ai_action_register extends base {
->set_type(column::TYPE_INTEGER)
->add_field("COALESCE({$generatetextalias}.completiontoken, {$summarisetextalias}.completiontoken)", 'completiontokens')
->set_is_sortable(true)
->set_help_icon(new help_icon('completiontokens', 'core_ai'))
->add_callback(static function(?int $value): string {
return $value ?? get_string('unknownvalue', 'core_ai');
});

View File

@ -77,7 +77,7 @@ class usage extends system_report {
* unique identifier.
*/
public function add_columns(): void {
$columns = [
$this->add_columns_from_entities([
'ai_action_register:provider',
'ai_action_register:actionname',
'ai_action_register:timecreated',
@ -86,9 +86,7 @@ class usage extends system_report {
'ai_action_register:success',
'context:name',
'user:fullnamewithlink',
];
$this->add_columns_from_entities($columns);
]);
$this->get_column('ai_action_register:provider')
->add_callback(static function(string $output): string {
@ -111,7 +109,7 @@ class usage extends system_report {
* unique identifier.
*/
protected function add_filters(): void {
$filters = [
$this->add_filters_from_entities([
'ai_action_register:actionname',
'ai_action_register:provider',
'ai_action_register:timecreated',
@ -120,8 +118,6 @@ class usage extends system_report {
'ai_action_register:success',
'context:level',
'user:fullname',
];
$this->add_filters_from_entities($filters);
]);
}
}

View File

@ -80,6 +80,7 @@ You can manage the actions for each provider in their settings.';
$string['btninstancecreate'] = 'Create instance';
$string['btninstanceupdate'] = 'Update instance';
$string['completiontokens'] = 'Completion tokens';
$string['completiontokens_help'] = 'Completion tokens are the text units generated by the AI model as a response to your input. Longer responses use more tokens, which typically increases the cost.';
$string['configureprovider'] = 'Configure provider instance';
$string['contentwatermark'] = 'Generated by AI';
$string['createnewprovider'] = 'Create a new provider instance';
@ -142,6 +143,7 @@ $string['privacy:metadata:ai_policy_register:contextid'] = 'The ID of the contex
$string['privacy:metadata:ai_policy_register:timeaccepted'] = 'The time the user accepted the AI policy.';
$string['privacy:metadata:ai_policy_register:userid'] = 'The ID of the user whose data was saved.';
$string['prompttokens'] = 'Prompt tokens';
$string['prompttokens_help'] = 'Prompt tokens are the individual text units that make up the input you send to an AI model. Longer inputs use more tokens, which often leads to higher costs.';
$string['provider'] = 'Provider';
$string['provideractionsettings'] = 'Actions';
$string['provideractionsettings_desc'] = 'Choose and configure the actions that the {$a} can perform on your site.';