Skip to content

Commit

Permalink
[AIDAPP-377]: Introduce the ability to store credentials for AI power…
Browse files Browse the repository at this point in the history
…ed features in Global Settings > Product Integrations (#350)

* Setting up Ai module

* Add manage ai form and other changes

* chore: fix enforcement of copyright on all files

* Change default to null and remove unuse file

---------

Co-authored-by: amit-canyon <[email protected]>
  • Loading branch information
amit-canyon and amit-canyon authored Dec 11, 2024
1 parent 9fa5b19 commit 6fd1137
Show file tree
Hide file tree
Showing 14 changed files with 488 additions and 2 deletions.
26 changes: 26 additions & 0 deletions app-modules/ai/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "canyon-gbs/aiding-app-ai",
"description": "",
"type": "library",
"version": "1.0",
"license": "proprietary",
"require": {
"filament/filament": "^3.2"
},
"autoload": {
"psr-4": {
"AidingApp\\Ai\\": "src/",
"AidingApp\\Ai\\Tests\\": "tests/",
"AidingApp\\Ai\\Database\\Factories\\": "database/factories/",
"AidingApp\\Ai\\Database\\Seeders\\": "database/seeders/"
}
},
"minimum-stability": "stable",
"extra": {
"laravel": {
"providers": [
"AidingApp\\Ai\\Providers\\AiServiceProvider"
]
}
}
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

/*
<COPYRIGHT>
Copyright © 2016-2024, Canyon GBS LLC. All rights reserved.
Aiding App™ is licensed under the Elastic License 2.0. For more details,
see <https://github.com/canyongbs/aidingapp/blob/main/LICENSE.>
Notice:
- You may not provide the software to third parties as a hosted or managed
service, where the service provides users with access to any substantial set of
the features or functionality of the software.
- You may not move, change, disable, or circumvent the license key functionality
in the software, and you may not remove or obscure any functionality in the
software that is protected by the license key.
- You may not alter, remove, or obscure any licensing, copyright, or other notices
of the licensor in the software. Any use of the licensor’s trademarks is subject
to applicable law.
- Canyon GBS LLC respects the intellectual property rights of others and expects the
same in return. Canyon GBS™ and Aiding App™ are registered trademarks of
Canyon GBS LLC, and we are committed to enforcing and protecting our trademarks
vigorously.
- The software solution, including services, infrastructure, and code, is offered as a
Software as a Service (SaaS) by Canyon GBS LLC.
- Use of this software implies agreement to the license terms and conditions as stated
in the Elastic License 2.0.
For more information or inquiries please visit our website at
<https://www.canyongbs.com> or contact us via email at [email protected].
</COPYRIGHT>
*/

use Spatie\LaravelSettings\Migrations\SettingsMigration;

return new class () extends SettingsMigration {
public function up(): void
{
$this->migrator->add('ai.url', null, encrypted: true);
$this->migrator->add('ai.key', null, encrypted: true);
$this->migrator->add('ai.api_version', null, encrypted: true);
$this->migrator->add('ai.model', null, encrypted: true);
}

public function down(): void
{
$this->migrator->delete('ai.url');
$this->migrator->delete('ai.key');
$this->migrator->delete('ai.api_version');
$this->migrator->delete('ai.model');
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

/*
<COPYRIGHT>
Copyright © 2016-2024, Canyon GBS LLC. All rights reserved.
Aiding App™ is licensed under the Elastic License 2.0. For more details,
see <https://github.com/canyongbs/aidingapp/blob/main/LICENSE.>
Notice:
- You may not provide the software to third parties as a hosted or managed
service, where the service provides users with access to any substantial set of
the features or functionality of the software.
- You may not move, change, disable, or circumvent the license key functionality
in the software, and you may not remove or obscure any functionality in the
software that is protected by the license key.
- You may not alter, remove, or obscure any licensing, copyright, or other notices
of the licensor in the software. Any use of the licensor’s trademarks is subject
to applicable law.
- Canyon GBS LLC respects the intellectual property rights of others and expects the
same in return. Canyon GBS™ and Aiding App™ are registered trademarks of
Canyon GBS LLC, and we are committed to enforcing and protecting our trademarks
vigorously.
- The software solution, including services, infrastructure, and code, is offered as a
Software as a Service (SaaS) by Canyon GBS LLC.
- Use of this software implies agreement to the license terms and conditions as stated
in the Elastic License 2.0.
For more information or inquiries please visit our website at
<https://www.canyongbs.com> or contact us via email at [email protected].
</COPYRIGHT>
*/

use App\Features\AiSettingsFeature;
use Illuminate\Database\Migrations\Migration;

return new class () extends Migration {
public function up(): void
{
AiSettingsFeature::activate();
}

public function down(): void
{
AiSettingsFeature::deactivate();
}
};
Empty file.
58 changes: 58 additions & 0 deletions app-modules/ai/src/AiPlugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

/*
<COPYRIGHT>
Copyright © 2016-2024, Canyon GBS LLC. All rights reserved.
Aiding App™ is licensed under the Elastic License 2.0. For more details,
see <https://github.com/canyongbs/aidingapp/blob/main/LICENSE.>
Notice:
- You may not provide the software to third parties as a hosted or managed
service, where the service provides users with access to any substantial set of
the features or functionality of the software.
- You may not move, change, disable, or circumvent the license key functionality
in the software, and you may not remove or obscure any functionality in the
software that is protected by the license key.
- You may not alter, remove, or obscure any licensing, copyright, or other notices
of the licensor in the software. Any use of the licensor’s trademarks is subject
to applicable law.
- Canyon GBS LLC respects the intellectual property rights of others and expects the
same in return. Canyon GBS™ and Aiding App™ are registered trademarks of
Canyon GBS LLC, and we are committed to enforcing and protecting our trademarks
vigorously.
- The software solution, including services, infrastructure, and code, is offered as a
Software as a Service (SaaS) by Canyon GBS LLC.
- Use of this software implies agreement to the license terms and conditions as stated
in the Elastic License 2.0.
For more information or inquiries please visit our website at
<https://www.canyongbs.com> or contact us via email at [email protected].
</COPYRIGHT>
*/

namespace AidingApp\Ai;

use Filament\Panel;
use Filament\Contracts\Plugin;

class AiPlugin implements Plugin
{
public function getId(): string
{
return 'ai';
}

public function register(Panel $panel): void
{
$panel->discoverPages(
in: __DIR__ . '/Filament/Pages',
for: 'AidingApp\\Ai\\Filament\\Pages'
);
}

public function boot(Panel $panel): void {}
}
94 changes: 94 additions & 0 deletions app-modules/ai/src/Filament/Pages/ManageAiSettings.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?php

/*
<COPYRIGHT>
Copyright © 2016-2024, Canyon GBS LLC. All rights reserved.
Aiding App™ is licensed under the Elastic License 2.0. For more details,
see <https://github.com/canyongbs/aidingapp/blob/main/LICENSE.>
Notice:
- You may not provide the software to third parties as a hosted or managed
service, where the service provides users with access to any substantial set of
the features or functionality of the software.
- You may not move, change, disable, or circumvent the license key functionality
in the software, and you may not remove or obscure any functionality in the
software that is protected by the license key.
- You may not alter, remove, or obscure any licensing, copyright, or other notices
of the licensor in the software. Any use of the licensor’s trademarks is subject
to applicable law.
- Canyon GBS LLC respects the intellectual property rights of others and expects the
same in return. Canyon GBS™ and Aiding App™ are registered trademarks of
Canyon GBS LLC, and we are committed to enforcing and protecting our trademarks
vigorously.
- The software solution, including services, infrastructure, and code, is offered as a
Software as a Service (SaaS) by Canyon GBS LLC.
- Use of this software implies agreement to the license terms and conditions as stated
in the Elastic License 2.0.
For more information or inquiries please visit our website at
<https://www.canyongbs.com> or contact us via email at [email protected].
</COPYRIGHT>
*/

namespace AidingApp\Ai\Filament\Pages;

use App\Models\User;
use Filament\Forms\Form;
use App\Models\Authenticatable;
use Filament\Pages\SettingsPage;
use App\Features\AiSettingsFeature;
use AidingApp\Ai\Settings\AiSettings;
use Filament\Forms\Components\Section;
use Filament\Forms\Components\TextInput;
use App\Filament\Clusters\ProductIntegrations;

class ManageAiSettings extends SettingsPage
{
protected static ?string $navigationIcon = 'heroicon-o-cog-6-tooth';

protected static string $settings = AiSettings::class;

protected static ?string $title = 'Cognitive Services Settings';

protected static ?string $navigationLabel = 'Cognitive Services';

protected static ?int $navigationSort = 100;

protected static ?string $cluster = ProductIntegrations::class;

public static function canAccess(): bool
{
/** @var User $user */
$user = auth()->user();

return AiSettingsFeature::active() && $user->hasRole(Authenticatable::SUPER_ADMIN_ROLE);
}

public function form(Form $form): Form
{
return $form
->columns(1)
->schema([
Section::make()
->schema([
TextInput::make('url')
->label('URL')
->string()
->url(),
TextInput::make('key')
->string()
->password()
->revealable(),
TextInput::make('api_version')
->label('API Version')
->string(),
TextInput::make('model')
->string(),
]),
]);
}
}
Empty file.
55 changes: 55 additions & 0 deletions app-modules/ai/src/Providers/AiServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

/*
<COPYRIGHT>
Copyright © 2016-2024, Canyon GBS LLC. All rights reserved.
Aiding App™ is licensed under the Elastic License 2.0. For more details,
see <https://github.com/canyongbs/aidingapp/blob/main/LICENSE.>
Notice:
- You may not provide the software to third parties as a hosted or managed
service, where the service provides users with access to any substantial set of
the features or functionality of the software.
- You may not move, change, disable, or circumvent the license key functionality
in the software, and you may not remove or obscure any functionality in the
software that is protected by the license key.
- You may not alter, remove, or obscure any licensing, copyright, or other notices
of the licensor in the software. Any use of the licensor’s trademarks is subject
to applicable law.
- Canyon GBS LLC respects the intellectual property rights of others and expects the
same in return. Canyon GBS™ and Aiding App™ are registered trademarks of
Canyon GBS LLC, and we are committed to enforcing and protecting our trademarks
vigorously.
- The software solution, including services, infrastructure, and code, is offered as a
Software as a Service (SaaS) by Canyon GBS LLC.
- Use of this software implies agreement to the license terms and conditions as stated
in the Elastic License 2.0.
For more information or inquiries please visit our website at
<https://www.canyongbs.com> or contact us via email at [email protected].
</COPYRIGHT>
*/

namespace AidingApp\Ai\Providers;

use Filament\Panel;
use AidingApp\Ai\AiPlugin;
use Illuminate\Support\ServiceProvider;
use Illuminate\Database\Eloquent\Relations\Relation;

class AiServiceProvider extends ServiceProvider
{
public function register()
{
Panel::configureUsing(fn (Panel $panel) => $panel->getId() !== 'admin' || $panel->plugin(new AiPlugin()));
}

public function boot()
{
Relation::morphMap([]);
}
}
Loading

0 comments on commit 6fd1137

Please sign in to comment.