myLogger = \Config\Services::mylogger(); // $this->client = new Google_Client(); // $this->client->setAuthConfig(ROOTPATH . 'nhance-app-google-drive.json'); // App credentials // // putenv('GOOGLE_APPLICATION_CREDENTIALS=' . ROOTPATH . 'nhance-app-google-drive.json'); // $this->client->useApplicationDefaultCredentials(); // $this->client->addScope(Google_Service_Drive::DRIVE); // Full access to Google Drive } public function check() { try { // Initialize the Gemini client $client = new Client($apiKey); // Send a prompt to the Gemini Pro model $response = $client->generativeModel(ModelName::GEMINI_PRO)->generateContent( new TextPart('Write a short, creative story about a knight and a dragon.') ); // Display the generated text $data['gemini_response'] = $response->text(); } catch (\Exception $e) { // Handle any errors that occur during the API call $data['gemini_response'] = 'An error occurred: ' . $e->getMessage(); } } }