Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
unstructured-3486139
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
unstructured-3486139
Commits
9a02171c
Commit
9a02171c
authored
8 months ago
by
Marcus Johansson
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3442743
by Marcus_Johansson: Add bypass for three combinations
parent
9353fd9e
No related branches found
Branches containing commit
Tags
1.0.0-beta2
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
modules/ai_interpolator_unstructured/src/FileToTextBase.php
+19
-0
19 additions, 0 deletions
modules/ai_interpolator_unstructured/src/FileToTextBase.php
with
19 additions
and
0 deletions
modules/ai_interpolator_unstructured/src/FileToTextBase.php
+
19
−
0
View file @
9a02171c
...
...
@@ -162,6 +162,12 @@ class FileToTextBase extends AiInterpolatorFieldRule implements AiInterpolatorFi
'#default_value'
=>
$fieldDefinition
->
getConfig
(
$entity
->
bundle
())
->
getThirdPartySetting
(
'ai_interpolator'
,
'interpolator_unstructured_images'
,
TRUE
),
];
$form
[
'interpolator_unstructured_bypass_unstructured'
]
=
[
'#type'
=>
'checkbox'
,
'#title'
=>
'Bypass on perfect match'
,
'#description'
=>
$this
->
t
(
'This will bypass an API call if the input file is a text and the output is text, input file is md and the output is markdown or input file is html and the output is html.'
),
'#default_value'
=>
$fieldDefinition
->
getConfig
(
$entity
->
bundle
())
->
getThirdPartySetting
(
'ai_interpolator'
,
'interpolator_unstructured_bypass_unstructured'
,
TRUE
),
];
return
$form
;
}
...
...
@@ -175,6 +181,19 @@ class FileToTextBase extends AiInterpolatorFieldRule implements AiInterpolatorFi
foreach
(
$entity
->
{
$interpolatorConfig
[
'base_field'
]}
as
$entityWrapper
)
{
if
(
$entityWrapper
->
entity
)
{
$fileEntity
=
$entityWrapper
->
entity
;
// Check if bypass is on.
if
(
$interpolatorConfig
[
'unstructured_bypass_unstructured'
])
{
$fileType
=
$fileEntity
->
getMimeType
();
$outputType
=
$interpolatorConfig
[
'unstructured_output_format'
];
if
(
(
$fileType
===
'text/plain'
&&
$outputType
===
'text'
)
||
(
$fileType
===
'text/markdown'
&&
$outputType
===
'markdown'
)
||
(
$fileType
===
'text/html'
&&
$outputType
===
'html'
)
)
{
$values
[]
=
file_get_contents
(
$fileEntity
->
getFileUri
());
continue
;
}
}
$extract
=
[];
if
(
$interpolatorConfig
[
'unstructured_images'
])
{
$extract
=
[
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment