Skip to content

Commit

Permalink
Bug-fix on first post content
Browse files Browse the repository at this point in the history
  • Loading branch information
muhammedsaidckr committed Jul 7, 2024
1 parent 6a27646 commit 1484636
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 20 deletions.
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@
},
"config": {
"allow-plugins": {
"php-http/discovery": true
}
}
}
2 changes: 2 additions & 0 deletions extend.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
use Flarum\Discussion\Event\Started;
use Flarum\Extend;
use Msc\Gemini\Listener\ReplyToPost;
use Msc\Gemini\BindingsProvider;
use Msc\Gemini\ClientProvider;

return [
(new Extend\Frontend('forum'))
Expand Down
23 changes: 5 additions & 18 deletions src/Agent.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@

use Flarum\Discussion\Discussion;
use Flarum\Post\CommentPost;
use Flarum\Post\Post;
use Flarum\Settings\SettingsRepositoryInterface;
use Flarum\User\User;
use Illuminate\Support\Arr;
use Gemini;
use Gemini\Client;

class Agent
Expand All @@ -17,24 +13,15 @@ class Agent

public function __construct(
public readonly User $user,
protected ?Client $client = null,
) {
protected ?Client $client = null,
)
{
}

// public function operational(): bool
// {
// return $this->client !== null;
// }
//
// public
// function is(User $someone): bool
// {
// return $this->user->is($someone);
// }

public function repliesTo(Discussion $discussion): void
{
$content = $discussion->firstPost->content;
$content = $discussion->posts()->first()->content;
$title = $discussion->title;

$response = $this->client->geminiPro()->generateContent($content);

Expand Down
2 changes: 1 addition & 1 deletion src/Listener/ReplyToPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ public function __construct(
public function handle(Started $event): void
{
// See https://docs.flarum.org/extend/backend-events.html for more information.
$this->queue->push(new ReplyJob($event->discussion), null, 'flarum');
$this->queue->push(new ReplyJob($event->discussion));
}
}

0 comments on commit 1484636

Please sign in to comment.