/ src / modules / AdvancedPaste / AdvancedPaste / Helpers / AIServiceFormatEvent.cs
AIServiceFormatEvent.cs
 1  // Copyright (c) Microsoft Corporation
 2  // The Microsoft Corporation licenses this file to you under the MIT license.
 3  // See the LICENSE file in the project root for more information.
 4  
 5  using System.Text.Json;
 6  using AdvancedPaste.Models.KernelQueryCache;
 7  using AdvancedPaste.SerializationContext;
 8  using AdvancedPaste.Telemetry;
 9  
10  namespace AdvancedPaste.Helpers
11  {
12      public class AIServiceFormatEvent
13      {
14          public AIServiceFormatEvent(AdvancedPasteSemanticKernelFormatEvent semanticKernelFormatEvent)
15          {
16              CacheUsed = semanticKernelFormatEvent.CacheUsed;
17              IsSavedQuery = semanticKernelFormatEvent.IsSavedQuery;
18              PromptTokens = semanticKernelFormatEvent.PromptTokens;
19              CompletionTokens = semanticKernelFormatEvent.CompletionTokens;
20              ModelName = semanticKernelFormatEvent.ModelName;
21              ProviderType = semanticKernelFormatEvent.ProviderType;
22              ActionChain = semanticKernelFormatEvent.ActionChain;
23          }
24  
25          public AIServiceFormatEvent(AdvancedPasteGenerateCustomFormatEvent generateCustomFormatEvent)
26          {
27              PromptTokens = generateCustomFormatEvent.PromptTokens;
28              CompletionTokens = generateCustomFormatEvent.CompletionTokens;
29              ModelName = generateCustomFormatEvent.ModelName;
30          }
31  
32          public bool IsSavedQuery { get; set; }
33  
34          public bool CacheUsed { get; set; }
35  
36          public int PromptTokens { get; set; }
37  
38          public int CompletionTokens { get; set; }
39  
40          public string ModelName { get; set; }
41  
42          public string ProviderType { get; set; }
43  
44          public string ActionChain { get; set; }
45  
46          public string ToJsonString() => JsonSerializer.Serialize(this, SourceGenerationContext.Default.AIServiceFormatEvent);
47      }
48  }