@@ -10,7 +10,8 @@ public partial class FileInstructService
1010 public async Task < string > ReadImages ( string text , IEnumerable < InstructFileModel > images , InstructOptions ? options = null )
1111 {
1212 var innerAgentId = options ? . AgentId ?? Guid . Empty . ToString ( ) ;
13- var instruction = await GetAgentTemplate ( innerAgentId , options ? . TemplateName ) ;
13+ var instruction = await RenderAgentTemplate ( innerAgentId , options ? . TemplateName , options ? . Data ) ;
14+ text = RenderText ( text , options ? . Data ) ;
1415
1516 var completion = CompletionProvider . GetChatCompletion ( _services , provider : options ? . Provider ?? "openai" , model : options ? . Model ?? "gpt-4o" , multiModal : true ) ;
1617 var message = await completion . GetChatCompletions ( new Agent ( )
@@ -48,7 +49,8 @@ await hook.OnResponseGenerated(new InstructResponseModel
4849 public async Task < RoleDialogModel > GenerateImage ( string text , InstructOptions ? options = null )
4950 {
5051 var innerAgentId = options ? . AgentId ?? Guid . Empty . ToString ( ) ;
51- var instruction = await GetAgentTemplate ( innerAgentId , options ? . TemplateName ) ;
52+ var instruction = await RenderAgentTemplate ( innerAgentId , options ? . TemplateName , options ? . Data ) ;
53+ text = RenderText ( text , options ? . Data ) ;
5254
5355 var textContent = text . IfNullOrEmptyAs ( instruction ) . IfNullOrEmptyAs ( string . Empty ) ;
5456 var completion = CompletionProvider . GetImageCompletion ( _services , provider : options ? . Provider ?? "openai" , model : options ? . Model ?? "gpt-image-1-mini" ) ;
@@ -124,7 +126,8 @@ public async Task<RoleDialogModel> EditImage(string text, InstructFileModel imag
124126 }
125127
126128 var innerAgentId = options ? . AgentId ?? Guid . Empty . ToString ( ) ;
127- var instruction = await GetAgentTemplate ( innerAgentId , options ? . TemplateName ) ;
129+ var instruction = await RenderAgentTemplate ( innerAgentId , options ? . TemplateName , options ? . Data ) ;
130+ text = RenderText ( text , options ? . Data ) ;
128131
129132 var completion = CompletionProvider . GetImageCompletion ( _services , provider : options ? . Provider ?? "openai" , model : options ? . Model ?? "gpt-image-1-mini" ) ;
130133 var binary = await DownloadFile ( image ) ;
@@ -173,7 +176,8 @@ public async Task<RoleDialogModel> EditImage(string text, InstructFileModel imag
173176 }
174177
175178 var innerAgentId = options ? . AgentId ?? Guid . Empty . ToString ( ) ;
176- var instruction = await GetAgentTemplate ( innerAgentId , options ? . TemplateName ) ;
179+ var instruction = await RenderAgentTemplate ( innerAgentId , options ? . TemplateName , options ? . Data ) ;
180+ text = RenderText ( text , options ? . Data ) ;
177181
178182 var completion = CompletionProvider . GetImageCompletion ( _services , provider : options ? . Provider ?? "openai" , model : options ? . Model ?? "gpt-image-1-mini" ) ;
179183 var imageBinary = await DownloadFile ( image ) ;
@@ -225,7 +229,8 @@ await hook.OnResponseGenerated(new InstructResponseModel
225229 public async Task < RoleDialogModel > ComposeImages ( string text , InstructFileModel [ ] images , InstructOptions ? options = null )
226230 {
227231 var innerAgentId = options ? . AgentId ?? Guid . Empty . ToString ( ) ;
228- var instruction = await GetAgentTemplate ( innerAgentId , options ? . TemplateName ) ;
232+ var instruction = await RenderAgentTemplate ( innerAgentId , options ? . TemplateName , options ? . Data ) ;
233+ text = RenderText ( text , options ? . Data ) ;
229234
230235 var completion = CompletionProvider . GetImageCompletion ( _services , provider : options ? . Provider ?? "openai" , model : options ? . Model ?? "gpt-image-1-mini" ) ;
231236
0 commit comments