Image extends Engine implements IEngine
Abstract class Image engine
This abstract class represents an AI engine for image processing. It implements the IEngine and IQueue interfaces.
Table of Contents
Interfaces
Methods
- __construct() : mixed
- checkLimits() : bool
- Returns true if current Engine must use limits.
- completionsInQueue() : void
- Makes request to AI Engine throw the queue.
- getAgreement() : Agreement|null
- Returns Agreement if current Engine has it, null otherwise.
- getAnalyticData() : array<string|int, mixed>|array<string|int, string>
- Get analytic data
- getCategory() : string
- Returns Engine's category.
- getCode() : string
- Returns Engine's code.
- getConsumptionId() : string
- Returns id consumption from bass
- getContext() : Context
- Returns current context.
- getContextLimit() : int
- Returns context limit in tokens.
- getHistoryGroupId() : int
- Get ID of history group -1 - no grouped, 0 - first item of group
- getImageFormats() : array<string|int, mixed>
- Get the supported image formats.
- getMessages() : array<string|int, Message>
- Returns array of messages, that represents as Context of current request.
- getName() : string
- Returns Engine's name.
- getParameters() : array<string|int, mixed>
- Returns all current default and custom parameters.
- getPayload() : IPayload|null
- Returns stored payload.
- getResponseJsonMode() : bool
- Get response json mode.
- hasQuality() : bool
- Returns true, if Engine has required Quality.
- inTariff() : bool
- Checks that current Engine is available in the current tariff.
- isCache() : bool
- Return cache state
- isExpired() : bool
- Returns true if Engine is expired (in REST Application case for example).
- isPreferredForQuality() : bool
- Check if Engine recommended to use for Quality
- isThirdParty() : bool
- Returns true if current Engine is third party application.
- onError() : void
- Sets callback, that will be called on any error occurred.
- onResponseError() : void
- On post response error.
- onResponseSuccess() : void
- On response success.
- onSuccess() : void
- Sets callback, that will be called on successful request.
- setAnalyticData() : void
- Extension of setAnalyticData(), set same data for analytic,
- setCache() : void
- Set cache state for request
- setConsumptionId() : void
- Set id consumption from bass
- setHistoryGroupId() : void
- Set ID of history group -1 - no grouped, 0 - first item of group
- setHistoryState() : void
- Write or not history, in depend on $state.
- setParameters() : void
- Sets additional parameters for future request to Engine.
- setPayload() : void
- Stores payload for future request.
- setResponseJsonMode() : void
- Set response json mode.
- setUserParameters() : void
- Extension of setParameters(), forbids setting by user important engine params, such as allowed query cost (for example).
- shouldSkipAgreement() : bool
- shouldWriteHistory() : bool
- Returns true, if history will be written in current request.
- skipAgreement() : self
- Skips User Agreement (in fact just accept agreement by current Context's user).
- writeErrorInHistory() : void
- Writes error response in history, must depend on isWriteHistory.
- writeHistory() : void
- Writes history, must depend on isWriteHistory.
Methods
__construct()
public
__construct(Context $context[, mixed $data = null ]) : mixed
Parameters
- $context : Context
- $data : mixed = null
checkLimits()
Returns true if current Engine must use limits.
public
checkLimits() : bool
Return values
boolcompletionsInQueue()
Makes request to AI Engine throw the queue.
public
completionsInQueue() : void
getAgreement()
Returns Agreement if current Engine has it, null otherwise.
public
getAgreement() : Agreement|null
Return values
Agreement|nullgetAnalyticData()
Get analytic data
public
getAnalyticData() : array<string|int, mixed>|array<string|int, string>
Return values
array<string|int, mixed>|array<string|int, string>getCategory()
Returns Engine's category.
public
getCategory() : string
Return values
stringgetCode()
Returns Engine's code.
public
getCode() : string
Return values
stringgetConsumptionId()
Returns id consumption from bass
public
getConsumptionId() : string
Return values
stringgetContext()
Returns current context.
public
getContext() : Context
Return values
ContextgetContextLimit()
Returns context limit in tokens.
public
getContextLimit() : int
Return values
intgetHistoryGroupId()
Get ID of history group -1 - no grouped, 0 - first item of group
public
getHistoryGroupId() : int
Return values
intgetImageFormats()
Get the supported image formats.
public
getImageFormats() : array<string|int, mixed>
Return values
array<string|int, mixed> —The supported image formats with their respective dimensions.
getMessages()
Returns array of messages, that represents as Context of current request.
public
getMessages() : array<string|int, Message>
Each item must contain at least one key content
.
Return values
array<string|int, Message>getName()
Returns Engine's name.
public
getName() : string
Return values
stringgetParameters()
Returns all current default and custom parameters.
public
getParameters() : array<string|int, mixed>
Return values
array<string|int, mixed>getPayload()
Returns stored payload.
public
getPayload() : IPayload|null
Return values
IPayload|nullgetResponseJsonMode()
Get response json mode.
public
getResponseJsonMode() : bool
Return values
boolhasQuality()
Returns true, if Engine has required Quality.
public
hasQuality(Quality $quality) : bool
Parameters
- $quality : Quality
Return values
boolinTariff()
Checks that current Engine is available in the current tariff.
public
inTariff() : bool
Return values
boolisCache()
Return cache state
public
isCache() : bool
Return values
boolisExpired()
Returns true if Engine is expired (in REST Application case for example).
public
isExpired() : bool
Return values
boolisPreferredForQuality()
Check if Engine recommended to use for Quality
public
isPreferredForQuality([Quality|null $quality = null ]) : bool
Parameters
- $quality : Quality|null = null
Return values
boolisThirdParty()
Returns true if current Engine is third party application.
public
isThirdParty() : bool
Return values
boolonError()
Sets callback, that will be called on any error occurred.
public
onError(callable $callback) : void
This callback will receive Error object as input parameter.
Parameters
- $callback : callable
-
Function will be called.
Tags
onResponseError()
On post response error.
public
onResponseError(string $message, string $status) : void
Parameters
- $message : string
- $status : string
onResponseSuccess()
On response success.
public
onResponseSuccess(mixed $response, EngineResultCache $cacheManager[, bool $cached = false ]) : void
Parameters
- $response : mixed
- $cacheManager : EngineResultCache
- $cached : bool = false
onSuccess()
Sets callback, that will be called on successful request.
public
onSuccess(callable $callback) : void
This callback will receive Result object as input parameter.
Parameters
- $callback : callable
-
Function will be called.
Tags
setAnalyticData()
Extension of setAnalyticData(), set same data for analytic,
public
setAnalyticData(array<string|int, string> $analyticData) : void
Parameters
- $analyticData : array<string|int, string>
Tags
setCache()
Set cache state for request
public
setCache(bool $cache) : void
Parameters
- $cache : bool
setConsumptionId()
Set id consumption from bass
public
setConsumptionId(string $consumptionId) : void
Parameters
- $consumptionId : string
setHistoryGroupId()
Set ID of history group -1 - no grouped, 0 - first item of group
public
setHistoryGroupId(int $groupId) : void
Parameters
- $groupId : int
setHistoryState()
Write or not history, in depend on $state.
public
setHistoryState(bool $state) : void
Parameters
- $state : bool
-
True to write, false otherwise.
setParameters()
Sets additional parameters for future request to Engine.
public
setParameters(array<string|int, mixed> $params) : void
Method replace old parameters, if they were set.
Parameters
- $params : array<string|int, mixed>
-
Array of parameters (linear array key to value).
setPayload()
Stores payload for future request.
public
setPayload(IPayload $payload) : void
Parameters
- $payload : IPayload
-
Payload.
setResponseJsonMode()
Set response json mode.
public
setResponseJsonMode(bool $enable) : void
Parameters
- $enable : bool
setUserParameters()
Extension of setParameters(), forbids setting by user important engine params, such as allowed query cost (for example).
public
setUserParameters(array<string|int, mixed> $params) : void
Parameters
- $params : array<string|int, mixed>
Tags
shouldSkipAgreement()
public
shouldSkipAgreement() : bool
Return values
boolshouldWriteHistory()
Returns true, if history will be written in current request.
public
final shouldWriteHistory() : bool
Return values
boolskipAgreement()
Skips User Agreement (in fact just accept agreement by current Context's user).
public
skipAgreement() : self
Return values
selfwriteErrorInHistory()
Writes error response in history, must depend on isWriteHistory.
public
writeErrorInHistory(Error $error) : void
Parameters
- $error : Error
-
Error instance.
writeHistory()
Writes history, must depend on isWriteHistory.
public
writeHistory(Result $result) : void
Parameters
- $result : Result
-
Engine's work result.