Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
ai
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
ai
Commits
c5460672
Commit
c5460672
authored
2 months ago
by
Marcus Johansson
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3489690
: Add an event that triggers on chat iterator consumption
parent
325baac2
No related branches found
No related tags found
1 merge request
!295
Resolve #3489690 "Add an event"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/OperationType/Chat/StreamedChatMessageIterator.php
+4
-1
4 additions, 1 deletion
src/OperationType/Chat/StreamedChatMessageIterator.php
src/Traits/OperationType/EventDispatcherTrait.php
+21
-0
21 additions, 0 deletions
src/Traits/OperationType/EventDispatcherTrait.php
with
25 additions
and
1 deletion
src/OperationType/Chat/StreamedChatMessageIterator.php
+
4
−
1
View file @
c5460672
...
...
@@ -3,12 +3,15 @@
namespace
Drupal\ai\OperationType\Chat
;
use
Drupal\ai\Event\PostStreamingResponseEvent
;
use
Drupal\ai\Traits\OperationType\EventDispatcherTrait
;
/**
* Streamed chat message iterator interface.
*/
abstract
class
StreamedChatMessageIterator
implements
StreamedChatMessageIteratorInterface
{
use
EventDispatcherTrait
;
/**
* The iterator.
*
...
...
@@ -60,7 +63,7 @@ abstract class StreamedChatMessageIterator implements StreamedChatMessageIterato
// Dispatch the event.
$event
=
new
PostStreamingResponseEvent
(
$this
->
eventId
,
$message
,
[]);
\Drupal
::
service
(
'e
vent
_d
ispatcher
'
)
->
dispatch
(
$event
,
PostStreamingResponseEvent
::
EVENT_NAME
);
$this
->
getE
vent
D
ispatcher
(
)
->
dispatch
(
$event
,
PostStreamingResponseEvent
::
EVENT_NAME
);
}
/**
...
...
This diff is collapsed.
Click to expand it.
src/Traits/OperationType/EventDispatcherTrait.php
0 → 100644
+
21
−
0
View file @
c5460672
<?php
namespace
Drupal\ai\Traits\OperationType
;
use
Symfony\Component\EventDispatcher\EventDispatcherInterface
;
/**
* Event dispatcher trait for operation types.
*
* @package Drupal\ai\Traits\OperationType
*/
trait
EventDispatcherTrait
{
/**
* {@inheritdoc}
*/
public
function
getEventDispatcher
():
EventDispatcherInterface
{
return
\Drupal
::
service
(
'event_dispatcher'
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment