Skip to content

Commit c2c66fc

Browse files
committed
Added original question to question rewriter
1 parent d79948e commit c2c66fc

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/KernelMemory.Extensions.FunctionalTests/QueryPipeline/UserQuestionConversationTests.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,17 @@ public void Can_continue_conversation_with_unanswered_question()
6868
Assert.False(question.Answered);
6969
}
7070

71+
[Fact]
72+
public void Original_question_is_saved_when_rewriting_question()
73+
{
74+
var sut = GenerateSut("What is water");
75+
76+
sut.RewriteQuestion("What is the color of the sky");
77+
78+
Assert.Equal("What is water", sut.OriginalQuestion);
79+
Assert.Equal("What is the color of the sky", sut.Question);
80+
}
81+
7182
[Fact]
7283
public void Can_add_saved_conversation_to_userQuestion()
7384
{

src/KernelMemory.Extensions/QueryPipeline/UserQuestion.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ internal void AddReRanker(IReRanker reRanker)
3333

3434
public string Question { get; private set; }
3535

36+
/// <summary>
37+
/// if the question was rewritten, this stores the original question made by the user.
38+
/// </summary>
39+
public string OriginalQuestion { get; private set; }
40+
3641
/// <summary>
3742
/// Optional list of filter to perform the query.
3843
/// </summary>
@@ -193,6 +198,7 @@ public void SetConversation(Conversation conversation)
193198

194199
public void RewriteQuestion(string newQuestion)
195200
{
201+
OriginalQuestion = Question;
196202
Question = newQuestion;
197203
}
198204

0 commit comments

Comments
 (0)