Skip to content

Commit 45a6dcf

Browse files
committed
StopWatch only arount AiCommunication
1 parent 530f79b commit 45a6dcf

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

FetchXmlBuilder/DockControls/AiChatControl.cs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -241,17 +241,16 @@ private string GetMetadataForUnknownEntity([Description("The name/description of
241241
{
242242
var entities = fxb.EntitiesToAi();
243243
var json = System.Text.Json.JsonSerializer.Serialize(entities, new System.Text.Json.JsonSerializerOptions());
244-
var sw = Stopwatch.StartNew();
245244

246245
chatHistory.Add(ChatRole.User, $"The tool GetMetadataForUnknownAttribute was called: retrieve a table that matches the description '{tableDescription}'", true);
247246

247+
var sw = Stopwatch.StartNew();
248248
var result = AiCommunication.SamplingAI(PromptEntityMeta.Replace("{metadata}", json),
249249
$"Please find entries that match the description {tableDescription}", supplier.Name, model.Name, fxb.settings.AiSettings.ApiKey);
250-
251-
chatHistory.Add(result, true);
252-
253250
sw.Stop();
254251
fxb.LogUse($"{logname}-Meta-Entity-{tableDescription}", count: entities.Count, duration: sw.ElapsedMilliseconds, ai2: true, ai1: false);
252+
253+
chatHistory.Add(result, true);
255254
return result.Text;
256255
}
257256

@@ -280,17 +279,17 @@ private string GetMetadataForUnknownAttribute([Description("The logical name of
280279
}
281280
var attributes = metaAttributes[entityName];
282281
var json = System.Text.Json.JsonSerializer.Serialize(attributes, new System.Text.Json.JsonSerializerOptions());
283-
var sw = Stopwatch.StartNew();
284282

285283
chatHistory.Add(ChatRole.User, $"The tool GetMetadataForUnknownAttribute was called: retrieve attributes for table '{entityName}' that matches the description '{attributeDescription}'", true);
286284

285+
var sw = Stopwatch.StartNew();
287286
var result = AiCommunication.SamplingAI(PromptAttributeMeta.Replace("{metadata}", json),
288287
$"Please find attributes that match the description {attributeDescription}", supplier.Name, model.Name, fxb.settings.AiSettings.ApiKey);
288+
sw.Stop();
289+
fxb.LogUse($"{logname}-Meta-Attribute-{entityName}", count: attributes.Count, duration: sw.ElapsedMilliseconds, ai2: true, ai1: false);
289290

290291
chatHistory.Add(result, true);
291292

292-
sw.Stop();
293-
fxb.LogUse($"{logname}-Meta-Attribute-{entityName}", count: attributes.Count, duration: sw.ElapsedMilliseconds, ai2: true, ai1: false);
294293
return result.Text;
295294
}
296295

0 commit comments

Comments
 (0)