Agent
Represents an AI agent within a LaravelNeuro Corporation.
An Agent encapsulates settings for connecting to an AI service, including model, API endpoint, prompt, pipeline class, and role. This class provides methods for configuring these properties, initializing an agent from the database, and installing the agent into the system.
Table of Contents
Properties
- $apiType : APItype
- The API type, as defined by the APItype enum.
- $driver : Driver
- The driver used for making API requests.
- $id : int
- The agent's database ID.
- $name : string
- The agent's name.
- $outputModel : mixed
- The output model configuration (if any).
- $pipelineClass : string
- The fully-qualified pipeline class name.
- $promptClass : string
- The fully-qualified prompt class name.
- $role : string
- The role of the agent.
- $unit : int
- The associated unit ID.
- $validateOutput : bool
- Flag indicating whether output should be validated.
- $api : mixed
- The API endpoint for the agent.
- $model : mixed
- The model identifier for the agent.
- $prompt : mixed
- The prompt data for the agent.
Methods
- getApi() : mixed
- Retrieves the API endpoint for the agent.
- getModel() : mixed
- Retrieves the agent's model identifier.
- getName() : string
- Retrieves the agent's name.
- getPrompt() : mixed
- Retrieves the prompt data for the agent.
- getRole() : string
- Retrieves the agent's role.
- init() : object
- Initializes an agent instance from the database.
- install() : array<string|int, mixed>
- Installs the agent into the system.
- setApi() : self
- Sets the API endpoint for the agent.
- setApiType() : self
- Sets the API type for the agent.
- setModel() : self
- Sets the model identifier for the agent.
- setName() : self
- Sets the name of the agent.
- setOutputModel() : self
- Sets the output model configuration for the agent.
- setPipelineClass() : self
- Sets the pipeline class for the agent.
- setPrompt() : self
- Sets the prompt for the agent.
- setPromptClass() : self
- Sets the prompt class for the agent.
- setRole() : self
- Sets the role for the agent.
- validateOutput() : self
- Sets whether the agent should validate output.
Properties
$apiType
The API type, as defined by the APItype enum.
public
APItype
$apiType
$driver
The driver used for making API requests.
public
Driver
$driver
$id
The agent's database ID.
public
int
$id
$name
The agent's name.
public
string
$name
$outputModel
The output model configuration (if any).
public
mixed
$outputModel
= false
$pipelineClass
The fully-qualified pipeline class name.
public
string
$pipelineClass
$promptClass
The fully-qualified prompt class name.
public
string
$promptClass
$role
The role of the agent.
public
string
$role
$unit
The associated unit ID.
public
int
$unit
$validateOutput
Flag indicating whether output should be validated.
public
bool
$validateOutput
= false
$api
The API endpoint for the agent.
protected
mixed
$api
$model
The model identifier for the agent.
protected
mixed
$model
$prompt
The prompt data for the agent.
protected
mixed
$prompt
Methods
getApi()
Retrieves the API endpoint for the agent.
public
getApi() : mixed
Return values
mixed —The API endpoint.
getModel()
Retrieves the agent's model identifier.
public
getModel() : mixed
Return values
mixed —The model identifier.
getName()
Retrieves the agent's name.
public
getName() : string
Return values
string —The agent's name.
getPrompt()
Retrieves the prompt data for the agent.
public
getPrompt() : mixed
Return values
mixed —The prompt.
getRole()
Retrieves the agent's role.
public
getRole() : string
Return values
string —The agent's role.
init()
Initializes an agent instance from the database.
public
init(int $agentId) : object
Loads the agent record with the given ID from the NetworkAgent model, retrieves the associated unit, creates an instance of the agent's pipeline (using the stored pipeline class), and returns an object containing various properties of the agent.
Parameters
- $agentId : int
-
The ID of the agent to initialize.
Return values
object —An object containing agent properties: id, apiType, role, prompt, promptClass, name, unit_id, unitName, outputModel, validateOutput, and the pipeline instance.
install()
Installs the agent into the system.
public
install(int $unitId) : array<string|int, mixed>
Creates a new NetworkAgent record using the agent's configuration, including model, API, pipeline class, role, prompt, output model, and validation settings, and saves it to the database. Returns an array with the agent's ID, name, and role.
Parameters
- $unitId : int
-
The ID of the unit to which the agent belongs.
Return values
array<string|int, mixed> —An array containing: agentId, agentName, and agentRole.
setApi()
Sets the API endpoint for the agent.
public
setApi(mixed $api) : self
Parameters
- $api : mixed
-
The API endpoint.
Return values
self —Returns the current instance for method chaining.
setApiType()
Sets the API type for the agent.
public
setApiType(APItype $set) : self
Parameters
- $set : APItype
-
The API type (as an APItype enum instance).
Return values
self —Returns the current instance for method chaining.
setModel()
Sets the model identifier for the agent.
public
setModel(mixed $model) : self
Parameters
- $model : mixed
-
The model identifier.
Return values
self —Returns the current instance for method chaining.
setName()
Sets the name of the agent.
public
setName(string $set) : self
Parameters
- $set : string
-
The agent's name.
Return values
self —Returns the current instance for method chaining.
setOutputModel()
Sets the output model configuration for the agent.
public
setOutputModel(string $set) : self
Parameters
- $set : string
-
The output model identifier.
Return values
self —Returns the current instance for method chaining.
setPipelineClass()
Sets the pipeline class for the agent.
public
setPipelineClass(string $set) : self
Parameters
- $set : string
-
The fully-qualified pipeline class name.
Return values
self —Returns the current instance for method chaining.
setPrompt()
Sets the prompt for the agent.
public
setPrompt(mixed $prompt) : self
Parameters
- $prompt : mixed
-
The prompt data.
Return values
self —Returns the current instance for method chaining.
setPromptClass()
Sets the prompt class for the agent.
public
setPromptClass(string $set) : self
Parameters
- $set : string
-
The fully-qualified prompt class name.
Return values
self —Returns the current instance for method chaining.
setRole()
Sets the role for the agent.
public
setRole(string $set) : self
Parameters
- $set : string
-
The role to assign.
Return values
self —Returns the current instance for method chaining.
validateOutput()
Sets whether the agent should validate output.
public
validateOutput(bool $set) : self
Parameters
- $set : bool
-
True to enable output validation, false otherwise.
Return values
self —Returns the current instance for method chaining.