-
Notifications
You must be signed in to change notification settings - Fork 3
/
extend.php
47 lines (37 loc) · 1.54 KB
/
extend.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
/*
* This file is part of datlechin/flarum-chatgpt.
*
* Copyright (c) 2023 Ngo Quoc Dat.
*
* For the full copyright and license information, please view the LICENSE.md
* file that was distributed with this source code.
*/
namespace Datlechin\FlarumChatGPT;
use Datlechin\FlarumChatGPT\Access\DiscussionPolicy;
use Datlechin\FlarumChatGPT\Listener\PostChatGPTAnswer;
use Flarum\Discussion\Discussion;
use Flarum\Discussion\Event\Started;
use Flarum\Extend;
return [
(new Extend\Frontend('forum'))
->js(__DIR__.'/js/dist/forum.js')
->css(__DIR__.'/less/forum.less'),
(new Extend\Frontend('admin'))
->js(__DIR__.'/js/dist/admin.js')
->css(__DIR__.'/less/admin.less'),
(new Extend\Routes('api'))
->get('/datlechin-chatgpt/models', 'datlechin-chatgpt.models', Api\Controller\ShowOpenAiModelsController::class),
new Extend\Locales(__DIR__.'/locale'),
(new Extend\Settings())
->default('datlechin-chatgpt.model', 'text-davinci-003')
->default('datlechin-chatgpt.enable_on_discussion_started', true)
->default('datlechin-chatgpt.max_tokens', 100)
->default('datlechin-chatgpt.user_prompt_badge_text', 'Assistant')
->serializeToForum('chatGptUserPromptId', 'datlechin-chatgpt.user_prompt')
->serializeToForum('chatGptBadgeText', 'datlechin-chatgpt.user_prompt_badge_text'),
(new Extend\Event())
->listen(Started::class, PostChatGPTAnswer::class),
(new Extend\Policy())
->modelPolicy(Discussion::class, DiscussionPolicy::class),
];