@luceos Does the Ai user have to exist before the extension can be activated?
Here's my extend.php
(the php syntax should be valid):
<?php
/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/
use Flarum\Extend;
return [
// Register extenders here to customize your forum!
(new \Flarum\Ai\Extend\Ai(
// unique identifier
key: 'gandalf',
// username or user Id of User to represent
represents: 'gandalf',
// Chat GPT Model to use. Either \Flarum\Ai\Agent\Model::gpt_3_5_turbo or \Flarum\Ai\Agent\Model::gpt_4
model: \Flarum\Ai\Agent\Model::gpt_3_5_turbo,
// Discussion Id of discussion that contains the instructions
instructions: 31
))
// Chain the call to assign authorizations/permissions
->authorize()
// The tag slug where this authorization applies
->in('*')
// What the Ai can do, full list is in the documentation/readme.
->can(
replyToPosts: false,
respondToMentions: true
)
// Conclude this autorization
->activate()
// Chain another authorization after activate() that applies to this Ai
->authorize()
// The tag slug where this authorization applies
->in('auto-gandalf')
// What the Ai can do, full list is in the documentation/readme.
->can(
replyToPosts: true,
respondToMentions: true
)
// Conclude this autorization
->activate(),
];
Now "gandalf" replies to every post (ignoring ->in
...) if I create the user first.
Dashboard:
Flarum 1.8.5
PHP 8.2.20
MySQL 11.4.2-MariaDB