Allowed the Batch Processing assistant to process images (#1087)

Co-authored-by: Thorsten Sommer <SommerEngineering@users.noreply.github.com>
This commit is contained in:
Peer HogeterpandThorsten Sommer authored and GitHub committed 2026-10-21 13:52:26 +02:00
1 parent 5d6e48ef93
commit e019c24ea2
19 files changed
+429 -31

No files matched your search

@@ -56,6 +56,8 @@ public partial class AssistantBatchProcessing
# Task description
You are a batch document processing agent. Each request contains exactly one DOCUMENT.
Your task is to process this DOCUMENT strictly according to the instructions below.
A DOCUMENT may also be an image attached to the request. Then, the content of the
DOCUMENT is what the image shows, including any text within it.
# Scope and precedence
Use only information explicitly contained in the DOCUMENT and the instructions.
@@ -88,11 +90,20 @@ public partial class AssistantBatchProcessing
""";
}
private static string BuildImageUserPrompt(string fileName)
{
return $"""
# DOCUMENT
File name: {fileName}
Content: The DOCUMENT is the image attached to this request.
""";
}
/// <param name="fileName">The name of the document being processed.</param>
/// <param name="fileContent">The content handed to the model.</param>
/// <param name="input">The text or the image handed to the model.</param>
/// <param name="token">The cancellation token.</param>
/// <returns>The answer of the model, and which tools it used to get there.</returns>
private async Task<(string Answer, string UsedTools)> CallAIAsync(string fileName, string fileContent, CancellationToken token)
private async Task<(string Answer, string UsedTools)> CallAIAsync(string fileName, BatchInput input, CancellationToken token)
{
//
// Every file of the batch gets the tools the user picked for the job. The batch builds its
@@ -120,10 +131,9 @@ public partial class AssistantBatchProcessing
};
this.AssignRuntimeIdentity(chatThread);
var userPrompt = new ContentText
{
Text = BuildUserPrompt(fileName, fileContent),
};
var userPrompt = input.Image is null
? new ContentText { Text = BuildUserPrompt(fileName, input.Text) }
: new ContentText { Text = BuildImageUserPrompt(fileName), FileAttachments = [input.Image] };
chatThread.Blocks.Add(new ContentBlock
{