Skip to content

Re-ordered plug-in result to be included _after_ chat-history #182

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 18, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions webapi/Skills/ChatSkills/ChatSkill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -383,9 +383,10 @@ private async Task<ChatMessage> GetChatResponseAsync(string chatId, string userI
var documentMemories = tasks[1];

// Fill in the chat history if there is any token budget left
var chatContextComponents = new List<string>() { chatMemories, documentMemories, planResult };
var chatContextComponents = new List<string>() { chatMemories, documentMemories };
var chatContextText = string.Join("\n\n", chatContextComponents.Where(c => !string.IsNullOrEmpty(c)));
var chatHistoryTokenLimit = remainingToken - TokenUtilities.TokenCount(chatContextText);
var chatHistoryTokenLimit = remainingToken - TokenUtilities.TokenCount(chatContextText) - TokenUtilities.TokenCount(planResult);

string chatHistory = string.Empty;
if (chatHistoryTokenLimit > 0)
{
Expand All @@ -395,6 +396,11 @@ private async Task<ChatMessage> GetChatResponseAsync(string chatId, string userI
chatContextText = $"{chatContextText}\n{chatHistory}";
}

if (!string.IsNullOrWhiteSpace(planResult))
{
chatContextText = $"{chatContextText}\n{planResult}";
}

// Set variables needed in prompt
chatContext.Variables.Set("audience", audience);
chatContext.Variables.Set("userIntent", userIntent);
Expand Down