Skip to content

Commit d52fa05

Browse files
test: test AI confidence score (box/box-codegen#919) (#1312)
1 parent 9db7a80 commit d52fa05

3 files changed

Lines changed: 16 additions & 3 deletions

File tree

.codegen.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{ "engineHash": "f9e2519", "specHash": "ccdb456", "version": "10.3.0" }
1+
{ "engineHash": "b181eba", "specHash": "ccdb456", "version": "10.3.0" }

docs/ai.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ client.ai.create_ai_extract_structured(
246246
],
247247
),
248248
],
249+
include_confidence_score=True,
249250
ai_agent=ai_extract_structured_agent_basic_text_config,
250251
)
251252
```

test/ai.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,12 @@ def testAIExtractStructuredWithFields():
252252
parent=UploadFileAttributesParentField(id='0'),
253253
),
254254
string_to_byte_stream(
255-
'My name is John Doe. I was born in 4th July 1990. I am 34 years old. My hobby is guitar.'
255+
''.join(
256+
[
257+
'My name is John Doe. I was born in 4th July 1990. I am 34 years old. My hobby is guitar. My UUID is ',
258+
get_uuid(),
259+
]
260+
)
256261
),
257262
)
258263
file: FileFull = uploaded_files.entries[0]
@@ -300,8 +305,10 @@ def testAIExtractStructuredWithFields():
300305
],
301306
),
302307
],
308+
include_confidence_score=True,
303309
ai_agent=ai_extract_structured_agent_basic_text_config,
304310
)
311+
assert not response.confidence_score == None
305312
assert to_string(response.answer.get('hobby')) == to_string(['guitar'])
306313
assert to_string(response.answer.get('firstName')) == 'John'
307314
assert to_string(response.answer.get('lastName')) == 'Doe'
@@ -318,7 +325,12 @@ def testAIExtractStructuredWithMetadataTemplate():
318325
parent=UploadFileAttributesParentField(id='0'),
319326
),
320327
string_to_byte_stream(
321-
'My name is John Doe. I was born in 4th July 1990. I am 34 years old. My hobby is guitar.'
328+
''.join(
329+
[
330+
'My name is John Doe. I was born in 4th July 1990. I am 34 years old. My hobby is guitar. My UUID is ',
331+
get_uuid(),
332+
]
333+
)
322334
),
323335
)
324336
file: FileFull = uploaded_files.entries[0]

0 commit comments

Comments
 (0)