api_key_env); if (!$apikey) { $this->markTestSkipped('API key environment not set'); } $providerName = ucfirst($this->provider); $providerConf = strtolower($this->provider); $conf['plugin']['aichat']['chatmodel'] = $providerName . ' ' . $this->chat_model; $conf['plugin']['aichat']['rephrasemodel'] = $providerName . ' ' . $this->chat_model; $conf['plugin']['aichat']['embeddingmodel'] = $providerName . ' ' . $this->embedding_model; $conf['plugin']['aichat'][$providerConf . '_apikey'] = $apikey; } public function testChat() { global $conf; $prompt = 'This is a test. Please reply with "Hello World"'; /** @var \helper_plugin_aichat $helper */ $helper = plugin_load('helper', 'aichat'); $model = $helper->getChatModel(); $reply = $model->getAnswer([ ['role' => 'user', 'content' => $prompt] ]); $this->assertStringContainsString('hello world', strtolower($reply)); } public function testEmbedding() { $text = 'This is a test for embeddings.'; /** @var \helper_plugin_aichat $helper */ $helper = plugin_load('helper', 'aichat'); $model = $helper->getEmbeddingModel(); $embedding = $model->getEmbedding($text); $this->assertIsArray($embedding); $this->assertNotEmpty($embedding, 'Embedding should not be empty'); $this->assertIsFloat($embedding[0], 'Embedding should be an array of floats'); } }