Skip to content

Commit d20552a

Browse files
committed
Change aimanger instantiation to use di
1 parent 8678406 commit d20552a

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

question.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,17 +166,13 @@ public function perform_request(string $prompt, string $purpose = 'feedback'): s
166166
}
167167
return $llmresponse->get_content();
168168
} else if ($backend == 'core_ai_subsystem') {
169-
global $USER,$CFG, $DB;
170-
if(str_starts_with($CFG->release, '5')) {
171-
$manager = new \core_ai\manager($DB);
172-
} else {
173-
$manager = new \core_ai\manager();
174-
}
169+
global $USER;
175170
$action = new \core_ai\aiactions\generate_text(
176171
contextid: $this->contextid,
177172
userid: $USER->id,
178173
prompttext: $prompt
179174
);
175+
$manager = \core\di::get(\core_ai\manager::class);
180176
$llmresponse = $manager->process_action($action);
181177
$responsedata = $llmresponse->get_response_data();
182178
return $responsedata['generatedcontent'];

0 commit comments

Comments
 (0)