Skip to content

Commit c4d1d42

Browse files
committed
introduced context in query
1 parent 477c591 commit c4d1d42

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/KernelMemory.Extensions.ConsoleTest/Samples/CustomSearchPipelineBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ private static IKernelMemoryBuilder CreateBasicKernelMemoryBuilder(
316316
services.AddSingleton<HyDeQueryHandler>();
317317
var hydeConfig = new HiDeQueryHandlerConfiguration()
318318
{
319-
Prompt = "Given a question, generate a paragraph of text that answers the question in the context of computer security and IT security"
319+
Prompt = "Given a question, generate a paragraph of text that answers the question"
320320
};
321321
services.AddSingleton(hydeConfig);
322322
services.AddSingleton<KeywordSearchQueryHandler>();

src/KernelMemory.Extensions/QueryPipeline/HyDeQueryHandler.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ protected override async Task OnHandleAsync(UserQuestion userQuestion, Cancellat
4747
// Perform a vector search in default memory
4848
StringBuilder prompt = new StringBuilder(_configuration.Prompt.Length + userQuestion.Question.Length + "Question: ".Length + "Paragraph: ".Length + 20);
4949
prompt.AppendLine(_configuration.Prompt);
50+
if (!string.IsNullOrEmpty(userQuestion.Context))
51+
{
52+
prompt.AppendLine("The context of the question is: " + userQuestion.Context);
53+
}
54+
5055
prompt.AppendLine("Question: " + userQuestion.Question);
5156
prompt.AppendLine("Paragraph: ");
5257

0 commit comments

Comments
 (0)