Skip to content

Commit

Permalink
New checkbox setting to ask for json_format
Browse files Browse the repository at this point in the history
  • Loading branch information
marcusgreen committed Jun 6, 2024
1 parent f984b59 commit b1bbed7
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
6 changes: 4 additions & 2 deletions classes/ai/ai.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,15 @@ public function prompt_completion($prompttext) {
*/
private function get_prompt_data(string $prompttext): array {
$data = [
'response_format' => ['type' => 'json_object'],
'model' => $this->model,
'temperature' => $this->temperature,
'messages' => [
['role' => 'system', 'content' => 'You: ' . $prompttext],
['role' => 'system', 'content' => 'You ' . $prompttext],
],
];
if (get_config('tool_aiconntect', 'json_format')) {
$data['response_format'] = ['type' => 'json_object'];
}
return $data;
}
/**
Expand Down
2 changes: 1 addition & 1 deletion classes/event/make_request.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ protected function init() {
* @return \lang_string|string
*/
public static function get_name() {
return get_string('log_requests', 'tool_aiconnect');
return get_string('make_request', 'tool_aiconnect');
}

/**
Expand Down
3 changes: 3 additions & 0 deletions lang/en/tool_aiconnect.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@
$string['endpointerror'] = 'Endpoint error';
$string['frequency_penalty'] = 'Frequency penalty';
$string['frequency_penalty_desc'] = 'Reduces repetition of words that have already been generated. It counts how many times the word was already used.';
$string['json_format'] = 'Json format response';
$string['json_format_text'] = 'Ask remote system to respond in json format, may not work with all models';
$string['log_requests'] = 'Log requests';
$string['log_requests_text'] = 'Log the messages part of all requests to the remote AI system. Debug must also be set to Developer. It adds a lot of text to the logging gsystem.';

$string['make_request'] = 'Make request';
$string['misssingmodelerror'] = 'No model has been provided for the call';
$string['model'] = 'Model';
Expand Down
5 changes: 5 additions & 0 deletions settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@
get_string('log_requests', 'tool_aiconnect'),
get_string('log_requests_text', 'tool_aiconnect') , 0));

$settings->add(new admin_setting_configcheckbox(
'tool_aiconnect/log_requests',
get_string('json_format', 'tool_aiconnect'),
get_string('json_format_text', 'tool_aiconnect') , 0));

$settings->add(new admin_setting_configtext(
'tool_aiconnect/top_p',
get_string('top_p', 'tool_aiconnect'),
Expand Down
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
defined('MOODLE_INTERNAL') || die();

$plugin->component = 'tool_aiconnect';
$plugin->version = 2024032001;
$plugin->version = 2024032003;
$plugin->requires = 2022112800;
$plugin->release = '4.1.1';

0 comments on commit b1bbed7

Please sign in to comment.