Skip to content
Snippets Groups Projects

Resolve #3522896 "Add event for"

Merged Marcus Johansson requested to merge issue/ai_agents-3522896:3522896-add-event-for into 1.1.x
All threads resolved!
Files
2
+ 163
0
<?php
namespace Drupal\ai_agents\Event;
use Drupal\Component\EventDispatcher\Event;
use Drupal\ai_agents\AiAgentInterface;
/**
* This can be used to log the responses for each loop.
*/
class AgentResponseEvent extends Event {
// The event name.
const EVENT_NAME = 'ai_agents.response';
/**
* The agent.
*
* @var \Drupal\ai_agents\AiAgentInterface
*/
protected $agent;
/**
* The system prompt.
*
* @var string
*/
protected $systemPrompt;
/**
* The agent id.
*
* @var string
*/
protected $agentId;
/**
* The instructions.
*
* @var string
*/
protected $instructions;
/**
* The chat history.
*
* @var array
*/
protected $chatHistory;
/**
* The response.
*
* @var string
*/
protected $response;
/**
* The loop count.
*
* @var int
*/
protected $loopCount;
/**
* Constructs the object.
*
* @param \Drupal\ai_agents\AiAgentInterface $agent
* The agent.
* @param string $system_prompt
* The system prompt.
* @param string $agent_id
* The agent id.
* @param string $instructions
* The instructions.
* @param array $chat_history
* The chat messages.
* @param string $response
* The response.
* @param int $loop_count
* The loop count.
*/
public function __construct(AiAgentInterface $agent, string $system_prompt, string $agent_id, string $instructions, array $chat_history, string $response, int $loop_count) {
$this->agent = $agent;
$this->systemPrompt = $system_prompt;
$this->agentId = $agent_id;
$this->instructions = $instructions;
$this->chatHistory = $chat_history;
$this->response = $response;
$this->loopCount = $loop_count;
}
/**
* Gets the agent.
*
* @return \Drupal\ai_agents\AiAgentInterface
* The agent.
*/
public function getAgent(): AiAgentInterface {
return $this->agent;
}
/**
* Gets the system prompt.
*
* @return string
* The system prompt.
*/
public function getSystemPrompt(): string {
return $this->systemPrompt;
}
/**
* Gets the agent id.
*
* @return string
* The agent id.
*/
public function getAgentId(): string {
return $this->agentId;
}
/**
* Gets the instructions.
*
* @return string
* The instructions.
*/
public function getInstructions(): string {
return $this->instructions;
}
/**
* Gets the chat history.
*
* @return array
* The chat history.
*/
public function getChatHistory(): array {
return $this->chatHistory;
}
/**
* Gets the response.
*
* @return string
* The response.
*/
public function getResponse(): string {
return $this->response;
}
/**
* Gets the loop count.
*
* @return int
* The loop count.
*/
public function getLoopCount(): int {
return $this->loopCount;
}
}
Loading