File tree Expand file tree Collapse file tree 6 files changed +27
-25
lines changed Expand file tree Collapse file tree 6 files changed +27
-25
lines changed Original file line number Diff line number Diff line change @@ -10,16 +10,16 @@ class InferenceParameters:
10
10
11
11
model_id : str
12
12
"""ID of the model, required."""
13
- rag : bool = False
14
- """Use Retrieval-Augmented Generation during inference ."""
15
- raw_text : bool = False
16
- """Extract the entire text from the document as strings, and fill the ``raw_text`` attribute."""
17
- polygon : bool = False
18
- """Calculate bounding box polygons for values , and fill the ``locations`` attribute of fields """
19
- confidence : bool = False
13
+ rag : Optional [ bool ] = None
14
+ """Enhance extraction accuracy with Retrieval-Augmented Generation."""
15
+ raw_text : Optional [ bool ] = None
16
+ """Extract the full text content from the document as strings, and fill the ``raw_text`` attribute."""
17
+ polygon : Optional [ bool ] = None
18
+ """Calculate bounding box polygons for all fields , and fill their ``locations`` attribute. """
19
+ confidence : Optional [ bool ] = None
20
20
"""
21
- Calculate confidence scores for values, and fill the ``confidence`` attribute of fields .
22
- Useful for automation .
21
+ Boost the precision and accuracy of all extractions .
22
+ Calculate confidence scores for all fields, and fill their ``confidence`` attribute .
23
23
"""
24
24
alias : Optional [str ] = None
25
25
"""Use an alias to link the file to your own DB. If empty, no alias will be used."""
Original file line number Diff line number Diff line change @@ -82,14 +82,14 @@ def req_post_inference_enqueue(
82
82
data = {"model_id" : params .model_id }
83
83
url = f"{ self .url_root } /inferences/enqueue"
84
84
85
- if params .rag :
86
- data ["rag" ] = "true"
87
- if params .raw_text :
88
- data ["raw_text" ] = "true"
89
- if params .confidence :
90
- data ["confidence" ] = "true"
91
- if params .polygon :
92
- data ["polygon" ] = "true"
85
+ if params .rag is not None :
86
+ data ["rag" ] = str ( params . rag ). lower ()
87
+ if params .raw_text is not None :
88
+ data ["raw_text" ] = str ( params . raw_text ). lower ()
89
+ if params .confidence is not None :
90
+ data ["confidence" ] = str ( params . confidence ). lower ()
91
+ if params .polygon is not None :
92
+ data ["polygon" ] = str ( params . polygon ). lower ()
93
93
if params .webhook_ids and len (params .webhook_ids ) > 0 :
94
94
data ["webhook_ids" ] = "," .join (params .webhook_ids )
95
95
if params .alias and len (params .alias ):
Original file line number Diff line number Diff line change @@ -8,10 +8,16 @@ class RawText:
8
8
"""Raw text extracted from the document."""
9
9
10
10
pages : List [RawTextPage ]
11
- """Page the raw text was found on ."""
11
+ """Pages of raw text content ."""
12
12
13
13
def __init__ (self , raw_response : StringDict ):
14
14
self .pages = [RawTextPage (page ) for page in raw_response .get ("pages" , [])]
15
15
16
16
def __str__ (self ) -> str :
17
- return "\n \n " .join ([page .content for page in self .pages ])
17
+ """
18
+ Text content of all pages.
19
+
20
+ Each page is separated by 2 newline characters.
21
+ """
22
+ page_contents = "\n \n " .join ([page .content for page in self .pages ])
23
+ return page_contents + "\n "
Original file line number Diff line number Diff line change @@ -86,10 +86,6 @@ def test_parse_file_filled_single_page_must_succeed(
86
86
input_source = PathInput (input_path )
87
87
params = InferenceParameters (
88
88
model_id = findoc_model_id ,
89
- rag = False ,
90
- raw_text = False ,
91
- polygon = False ,
92
- confidence = False ,
93
89
webhook_ids = [],
94
90
alias = "py_integration_filled_single" ,
95
91
)
Original file line number Diff line number Diff line change @@ -186,7 +186,7 @@ def test_standard_field_simple_list():
186
186
187
187
@pytest .mark .v2
188
188
def test_raw_texts ():
189
- json_sample , rst_sample = _get_inference_samples ("raw_texts" )
189
+ json_sample , _ = _get_inference_samples ("raw_texts" )
190
190
inference_result = InferenceResponse (json_sample )
191
191
assert isinstance (inference_result .inference , Inference )
192
192
You can’t perform that action at this time.
0 commit comments