@@ -869,6 +869,20 @@ pub async fn get_suggested_queries(
869869 Ok ( HttpResponse :: Ok ( ) . json ( SuggestedQueriesResponse { queries } ) )
870870}
871871
872+ #[ derive( Deserialize , Serialize , Debug , ToSchema , Clone ) ]
873+ /// Enum allowing for a single URL or a list of URLs
874+ #[ schema( example = "https://example.com/jacket.jpg" ) ]
875+ pub enum StringOrVec {
876+ /// A single URL of an image
877+ #[ serde( rename = "string" ) ]
878+ #[ schema( title = "string" ) ]
879+ String ( String ) ,
880+ /// A list of URLs of images
881+ #[ serde( rename = "string[]" ) ]
882+ #[ schema( title = "string[]" ) ]
883+ Vec ( Vec < String > ) ,
884+ }
885+
872886#[ derive( Deserialize , Serialize , Debug , ToSchema ) ]
873887/// Type of a given parameter for a LLM tool call
874888pub enum ToolFunctionParameterType {
@@ -947,7 +961,7 @@ pub struct GetToolFunctionParamsReqPayload {
947961 /// Text of the user's message to the assistant which will be used to generate the parameters for the tool function.
948962 pub user_message_text : Option < String > ,
949963 /// Image URL to attach to the message to generate the parameters for the tool function.
950- pub image_url : Option < String > ,
964+ pub image_url : Option < StringOrVec > ,
951965 /// The base64 encoded audio input of the user message to attach to the topic and then generate an assistant message in response to.
952966 pub audio_input : Option < String > ,
953967 /// Function to get the parameters for.
@@ -1038,17 +1052,35 @@ pub async fn get_tool_function_params(
10381052 r#type: "text" . to_string( ) ,
10391053 text: message_content. clone( ) ,
10401054 } ) ] ;
1041- if let Some ( image_url) = data. image_url . clone ( ) {
1042- message_content_parts. insert (
1043- 0 ,
1044- ChatMessageContentPart :: Image ( ChatMessageImageContentPart {
1045- r#type : "image_url" . to_string ( ) ,
1046- image_url : ImageUrlType {
1047- url : image_url,
1048- detail : None ,
1049- } ,
1050- } ) ,
1051- ) ;
1055+ if let Some ( image_url_or_uls) = data. image_url . clone ( ) {
1056+ match image_url_or_uls {
1057+ StringOrVec :: String ( image_url) => {
1058+ message_content_parts. insert (
1059+ 0 ,
1060+ ChatMessageContentPart :: Image ( ChatMessageImageContentPart {
1061+ r#type : "image_url" . to_string ( ) ,
1062+ image_url : ImageUrlType {
1063+ url : image_url,
1064+ detail : None ,
1065+ } ,
1066+ } ) ,
1067+ ) ;
1068+ }
1069+ StringOrVec :: Vec ( image_urls) => {
1070+ for image_url in image_urls. iter ( ) {
1071+ message_content_parts. insert (
1072+ 0 ,
1073+ ChatMessageContentPart :: Image ( ChatMessageImageContentPart {
1074+ r#type : "image_url" . to_string ( ) ,
1075+ image_url : ImageUrlType {
1076+ url : image_url. clone ( ) ,
1077+ detail : None ,
1078+ } ,
1079+ } ) ,
1080+ ) ;
1081+ }
1082+ }
1083+ }
10521084 }
10531085
10541086 let client = Client {
0 commit comments