Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
dynamo
Commits
f49df565
"lib/bindings/python/vscode:/vscode.git/clone" did not exist on "cf83794ae0f236c590a8797abcebf227ca5812c2"
Unverified
Commit
f49df565
authored
Apr 08, 2026
by
KrishnanPrash
Committed by
GitHub
Apr 08, 2026
Browse files
perf: avoid cloning content parts in gather_multi_modal_data (#8009)
parent
9b3e9249
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
24 deletions
+28
-24
lib/llm/src/preprocessor.rs
lib/llm/src/preprocessor.rs
+28
-24
No files found.
lib/llm/src/preprocessor.rs
View file @
f49df565
...
@@ -413,12 +413,14 @@ impl OpenAIPreprocessor {
...
@@ -413,12 +413,14 @@ impl OpenAIPreprocessor {
formatted_prompt
:
Option
<
String
>
,
formatted_prompt
:
Option
<
String
>
,
)
->
Result
<
()
>
{
)
->
Result
<
()
>
{
let
mut
media_map
:
MultimodalDataMap
=
HashMap
::
new
();
let
mut
media_map
:
MultimodalDataMap
=
HashMap
::
new
();
let
mut
fetch_tasks
:
Vec
<
(
String
,
ChatCompletionRequestUserMessageContentPart
)
>
=
let
mut
fetch_tasks
:
Vec
<
(
String
,
&
ChatCompletionRequestUserMessageContentPart
)
>
=
Vec
::
new
();
Vec
::
new
();
let
Some
(
messages
)
=
request
.typed_messages
()
else
{
let
Some
(
messages
)
=
request
.typed_messages
()
else
{
return
Ok
(());
return
Ok
(());
};
};
let
has_media_loader
=
self
.media_loader
.is_some
();
for
message
in
messages
.iter
()
{
for
message
in
messages
.iter
()
{
let
content_parts
=
match
message
{
let
content_parts
=
match
message
{
ChatCompletionRequestMessage
::
User
(
u
)
=>
match
&
u
.content
{
ChatCompletionRequestMessage
::
User
(
u
)
=>
match
&
u
.content
{
...
@@ -427,33 +429,35 @@ impl OpenAIPreprocessor {
...
@@ -427,33 +429,35 @@ impl OpenAIPreprocessor {
},
},
_
=>
continue
,
_
=>
continue
,
};
};
// Iterate over content parts
for
content_part
in
content_parts
.iter
()
{
for
content_part
in
content_parts
.iter
()
{
if
has_media_loader
{
let
type_str
=
match
content_part
{
ChatCompletionRequestUserMessageContentPart
::
ImageUrl
(
_
)
=>
"image_url"
,
ChatCompletionRequestUserMessageContentPart
::
VideoUrl
(
_
)
=>
"video_url"
,
ChatCompletionRequestUserMessageContentPart
::
AudioUrl
(
_
)
=>
"audio_url"
,
_
=>
continue
,
};
fetch_tasks
.push
((
type_str
.to_string
(),
content_part
));
}
else
{
let
(
type_str
,
url
)
=
match
content_part
{
let
(
type_str
,
url
)
=
match
content_part
{
ChatCompletionRequestUserMessageContentPart
::
ImageUrl
(
image_part
)
=>
{
ChatCompletionRequestUserMessageContentPart
::
ImageUrl
(
p
)
=>
{
(
"image_url"
.to_string
(),
image_part
.image_url.url
.clone
())
(
"image_url"
,
p
.image_url.url
.clone
())
}
}
ChatCompletionRequestUserMessageContentPart
::
VideoUrl
(
video_part
)
=>
{
ChatCompletionRequestUserMessageContentPart
::
VideoUrl
(
p
)
=>
{
(
"video_url"
.to_string
(),
video_part
.video_url.url
.clone
())
(
"video_url"
,
p
.video_url.url
.clone
())
}
}
ChatCompletionRequestUserMessageContentPart
::
AudioUrl
(
audio_part
)
=>
{
ChatCompletionRequestUserMessageContentPart
::
AudioUrl
(
p
)
=>
{
(
"audio_url"
.to_string
(),
audio_part
.audio_url.url
.clone
())
(
"audio_url"
,
p
.audio_url.url
.clone
())
}
}
_
=>
continue
,
_
=>
continue
,
};
};
if
self
.media_loader
.is_some
()
{
fetch_tasks
.push
((
type_str
,
content_part
.clone
()));
continue
;
}
//Fallback: ust pass the URL through
media_map
media_map
.entry
(
type_str
)
.entry
(
type_str
.to_string
()
)
.or_default
()
.or_default
()
.push
(
MultimodalData
::
Url
(
url
));
.push
(
MultimodalData
::
Url
(
url
));
}
}
}
}
}
// Execute all fetch tasks
// Execute all fetch tasks
if
!
fetch_tasks
.is_empty
()
{
if
!
fetch_tasks
.is_empty
()
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment