@@ -2306,6 +2306,58 @@ await ValidateStream(
23062306 ) ;
23072307 }
23082308
2309+ [ RecordedTest ]
2310+ [ TestCase ( true , "adani" ) ]
2311+ //TODO: The Image URI is not supported, uncomment this text when the ICM 686545924 will be resolved.
2312+ //[TestCase(false, "trail")]
2313+ public async Task TestImageAsInput ( bool useUploaded , string expectedWord )
2314+ {
2315+ PersistentAgentsClient client = GetClient ( ) ;
2316+ PersistentAgent agent = await GetAgent (
2317+ client : client ,
2318+ model : "gpt-4o" ,
2319+ instruction : "Analyze images from internally uploaded files."
2320+ ) ;
2321+ PersistentAgentThread thread = client . Threads . CreateThread ( ) ;
2322+ var contentBlocks = new List < MessageInputContentBlock >
2323+ {
2324+ new MessageInputTextBlock ( "Here is an uploaded file. Please describe it:" ) ,
2325+ } ;
2326+ if ( useUploaded )
2327+ {
2328+ // Note: To get the Image ID, please upload it using sample "Sample_PersistentAgents_ImageFileInputs."
2329+ contentBlocks . Add ( new MessageInputImageFileBlock ( new MessageImageFileParam ( TestEnvironment . UPLOADED_IMAGE_ID ) ) ) ;
2330+ }
2331+ else
2332+ {
2333+ string uri = "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg" ;
2334+ contentBlocks . Add ( new MessageInputImageUriBlock ( new MessageImageUriParam ( uri ) ) ) ;
2335+ }
2336+
2337+ PersistentThreadMessage imageMessage = client . Messages . CreateMessage (
2338+ threadId : thread . Id ,
2339+ role : MessageRole . User ,
2340+ contentBlocks : contentBlocks
2341+ ) ;
2342+ ThreadRun run = client . Runs . CreateRun (
2343+ threadId : thread . Id ,
2344+ assistantId : agent . Id
2345+ ) ;
2346+ run = await WaitForRun ( client , run ) ;
2347+ List < PersistentThreadMessage > messages = await client . Messages . GetMessagesAsync ( threadId : run . ThreadId ) . ToListAsync ( ) ;
2348+ Assert . Greater ( messages . Count , 0 ) ;
2349+ StringBuilder sbResponse = new ( ) ;
2350+ foreach ( PersistentThreadMessage msg in messages )
2351+ {
2352+ if ( msg . Role == MessageRole . Agent )
2353+ {
2354+ msg . ContentItems . Where ( x => x is MessageTextContent ) . Select ( x => ( ( MessageTextContent ) x ) . Text ) . Aggregate ( sbResponse , ( sbResponse , next ) => sbResponse . Append ( next ) ) ;
2355+ }
2356+ }
2357+ string response = sbResponse . ToString ( ) . ToLower ( ) ;
2358+ Assert . That ( response . Contains ( expectedWord ) , $ "The word { expectedWord } was not found in the response: { response } ") ;
2359+ }
2360+
23092361 #region Helpers
23102362 private static async Task ValidateStream (
23112363 PersistentAgentsClient client ,
0 commit comments