Skip to content

Commit 0ffce72

Browse files
committed
Consolidate system sender messages into single message.
1 parent f077e45 commit 0ffce72

File tree

1 file changed

+9
-21
lines changed

1 file changed

+9
-21
lines changed

classes/local/question_generator.php

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -74,20 +74,7 @@ public function generate_question(stdClass $dataobject, bool $sendexistingquesti
7474

7575
$provider = get_config('qbank_questiongen', 'provider');
7676
if ($provider === 'local_ai_manager') {
77-
$messages = [
78-
[
79-
'sender' => 'system',
80-
'message' => $primer,
81-
],
82-
[
83-
'sender' => 'system',
84-
'message' => $instructions,
85-
],
86-
[
87-
'sender' => 'system',
88-
'message' => $example,
89-
],
90-
];
77+
$systemprompt = $primer . " " . $instructions . " " . $example;
9178

9279
if ($sendexistingquestionsascontext) {
9380
$questionidsincategory = question_bank::get_finder()->get_questions_from_categories([$dataobject->category], null);
@@ -106,11 +93,7 @@ public function generate_question(stdClass $dataobject, bool $sendexistingquesti
10693
$questiontextsinqbankprompt = 'The question that will be generated by you has to be different '
10794
. 'from all of the following questions in this JSON string: "'
10895
. json_encode($questiontextsinqbankcat) . '"';
109-
$messages[] =
110-
[
111-
'sender' => 'system',
112-
'message' => $questiontextsinqbankprompt,
113-
];
96+
$systemprompt = $systemprompt . " " . $questiontextsinqbankprompt;
11497
}
11598
}
11699

@@ -128,11 +111,16 @@ public function generate_question(stdClass $dataobject, bool $sendexistingquesti
128111
break;
129112
}
130113

131-
$messages[] =
114+
$messages = [
115+
[
116+
'sender' => 'system',
117+
'message' => $systemprompt,
118+
],
132119
[
133120
'sender' => 'user',
134121
'message' => $storyprompt,
135-
];
122+
],
123+
];
136124

137125
[
138126
'generatedquestiontext' => $generatedquestiontext,

0 commit comments

Comments
 (0)