mirror of
https://github.com/moodle/moodle.git
synced 2025-08-07 09:56:38 +02:00
MDL-84394 ai: ensure provider instance config correctly encoded.
This commit is contained in:
parent
07881a5772
commit
750077f3cd
2 changed files with 1 additions and 3 deletions
|
@ -380,7 +380,7 @@ class manager {
|
||||||
$provider = new $classname(
|
$provider = new $classname(
|
||||||
enabled: $enabled,
|
enabled: $enabled,
|
||||||
name: $name,
|
name: $name,
|
||||||
config: $config ? json_encode($config) : '',
|
config: json_encode($config ?? []),
|
||||||
);
|
);
|
||||||
|
|
||||||
$id = $this->db->insert_record('ai_providers', $provider->to_record());
|
$id = $this->db->insert_record('ai_providers', $provider->to_record());
|
||||||
|
|
|
@ -41,11 +41,9 @@ final class provider_test extends \advanced_testcase {
|
||||||
|
|
||||||
// Create the provider instance.
|
// Create the provider instance.
|
||||||
$this->manager = \core\di::get(\core_ai\manager::class);
|
$this->manager = \core\di::get(\core_ai\manager::class);
|
||||||
$config = ['data' => 'goeshere'];
|
|
||||||
$this->provider = $this->manager->create_provider_instance(
|
$this->provider = $this->manager->create_provider_instance(
|
||||||
classname: '\aiprovider_openai\provider',
|
classname: '\aiprovider_openai\provider',
|
||||||
name: 'dummy',
|
name: 'dummy',
|
||||||
config: $config,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue