diff options
| author | Roy Ben Shabat <roy.mail.net@gmail.com> | 2025-09-07 01:40:46 +0300 |
|---|---|---|
| committer | Roy Ben Shabat <roy.mail.net@gmail.com> | 2025-09-07 01:40:46 +0300 |
| commit | 7ef8abb4e24ca338df631b45ae9c3e47ea8745f8 (patch) | |
| tree | a9465591a3c1b132e440e735427492e4ebeb86a2 /Software/Visual_Studio_22/Tango.Portal.Chat.Web/Services | |
| parent | 404cff82fe27cc8e00b5eee4d41f825c4ba3a569 (diff) | |
| download | Tango-7ef8abb4e24ca338df631b45ae9c3e47ea8745f8.tar.gz Tango-7ef8abb4e24ca338df631b45ae9c3e47ea8745f8.zip | |
Improved vagure questions response and conversation history length and uniqueness.
Diffstat (limited to 'Software/Visual_Studio_22/Tango.Portal.Chat.Web/Services')
| -rw-r--r-- | Software/Visual_Studio_22/Tango.Portal.Chat.Web/Services/LlmClient.cs | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/Software/Visual_Studio_22/Tango.Portal.Chat.Web/Services/LlmClient.cs b/Software/Visual_Studio_22/Tango.Portal.Chat.Web/Services/LlmClient.cs index fb34c183b..fb742d455 100644 --- a/Software/Visual_Studio_22/Tango.Portal.Chat.Web/Services/LlmClient.cs +++ b/Software/Visual_Studio_22/Tango.Portal.Chat.Web/Services/LlmClient.cs @@ -10,6 +10,7 @@ namespace Tango.Portal.Chat.Web.Services { public sealed class LlmClient { + private static int MAX_HISTORY = 10; private readonly HttpClient _http; private readonly LlmOptions _opt; @@ -52,7 +53,9 @@ namespace Tango.Portal.Chat.Web.Services if (history != null) { - foreach (var m in history.TakeLast(6)) + history = history.DistinctBy(x => x.Content); + + foreach (var m in history.TakeLast(MAX_HISTORY)) messages.Add(new { role = m.Role, content = CapString(m.Content, 1000), usedKql = m.UsedKql }); } @@ -94,11 +97,14 @@ namespace Tango.Portal.Chat.Web.Services if (history != null) { - foreach (var m in history.TakeLast(6)) + history = history.DistinctBy(x => x.Content); + + foreach (var m in history.TakeLast(MAX_HISTORY)) { - messages.Add(new { - role = m.Role == "assistant" ? "assistant" : "user", - content = CapString(m.Content, 1000) + messages.Add(new + { + role = m.Role == "assistant" ? "assistant" : "user", + content = CapString(m.Content, 1000) }); } } @@ -321,12 +327,12 @@ namespace Tango.Portal.Chat.Web.Services } public async Task<AssistantRunResult> AnswerWithAssistantAsync( - AssistantType assistant, - string question, - string factsJson, - string kql, - string? threadId, - CancellationToken ct = default) + AssistantType assistant, + string question, + string factsJson, + string kql, + string? threadId, + CancellationToken ct = default) { // 1) Use existing thread or create a new one if (string.IsNullOrEmpty(threadId)) |
