-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathInferenceActiveOptions.php
More file actions
75 lines (66 loc) · 2.54 KB
/
InferenceActiveOptions.php
File metadata and controls
75 lines (66 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<?php
namespace Mindee\Parsing\V2;
use Mindee\Parsing\Common\SummaryHelper;
/**
* Options which were activated during the inference.
*
* Options can be activated or deactivated:
* - By setting their default values on the Platform UI
* - By explicitly setting them in the inference request
*/
class InferenceActiveOptions
{
/**
* @var boolean Whether the Retrieval-Augmented Generation feature was activated.
* When this feature is activated, the RAG pipeline is used to increase result accuracy.
*/
public bool $rag;
/**
* @var boolean Whether the Raw Text feature was activated.
*/
public bool $rawText;
/**
* @var boolean Whether the Raw Text feature was activated.
* When this feature is activated, the raw text extracted from the document is returned in the result.
*/
public bool $polygon;
/**
* @var boolean Whether the confidence feature was activated.
* When this feature is activated, a confidence score for each field is returned in the result.
*/
public bool $confidence;
/**
* @var boolean Whether the text context feature was activated.
* When this feature is activated, the provided context is used to improve the accuracy of the inference.
*/
public bool $textContext;
/**
* @var DataSchemaActiveOption Data schema options provided for the inference.
*/
public DataSchemaActiveOption $dataSchema;
/**
* @param array $serverResponse Raw server response array.
*/
public function __construct(array $serverResponse)
{
$this->rag = $serverResponse['rag'];
$this->rawText = $serverResponse['raw_text'];
$this->polygon = $serverResponse['polygon'];
$this->confidence = $serverResponse['confidence'];
$this->textContext = $serverResponse['text_context'];
$this->dataSchema = new DataSchemaActiveOption($serverResponse['data_schema']);
}
/**
* @return string String representation.
*/
public function __toString(): string
{
return "Active Options\n==============\n"
. ':Raw Text: ' . SummaryHelper::formatForDisplay($this->rawText) . "\n"
. ':Polygon: ' . SummaryHelper::formatForDisplay($this->polygon) . "\n"
. ':Confidence: ' . SummaryHelper::formatForDisplay($this->confidence) . "\n"
. ':RAG: ' . SummaryHelper::formatForDisplay($this->rag) . "\n"
. ':Text Context: ' . SummaryHelper::formatForDisplay($this->textContext) . "\n\n"
. $this->dataSchema . "\n";
}
}