mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-11-05 05:47:21 +00:00
Allowed the Batch Processing assistant to process images (#1087)
Co-authored-by: Thorsten Sommer <SommerEngineering@users.noreply.github.com>
This commit is contained in:
1 parent
5d6e48ef93
commit
e019c24ea2
19 files changed
+429
-31
No files matched your search
+16
-6
@@ -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
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user