Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ private string AskUser(
AskedQuestions = asked;
return $"The {(asked.Count == 1 ? "question is" : "questions are")} shown to the user below your reply, with the "
+ "options to choose from. Their answers arrive in their next message. Do not call more tools in this turn: "
+ "end it with one short sentence, and do not repeat the questions in it.";
+ "end it with a short reply that first says what you changed in this turn, if anything, and do not repeat "
+ "the questions in it.";
}

private static DraftQuestion CheckQuestion(AskUserQuestion question, int number)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ field that looks like a reference to another record (an employee, a department,
names, types, lengths, the menu placement, low-confidence relations. Ask with ask_user, never in the text
of a reply: a few questions at a time, each with the likely answers as options and the one you suggest,
such as "Which ProgId should the form use?" with the options LeaveRequest and LeaveApplication. After
ask_user, end the turn with one short sentence; the answers arrive in the user's next message. Apply them
with the tools.
ask_user, end the turn with a short reply: first what you changed in this turn, as a short list when it is
more than one thing, and when the user asked for something that was already so, say that it was; then one
sentence pointing to the questions below. The answers arrive in the user's next message. Apply them with
the tools.
3. Finish. When validate_draft reports no errors and the user has nothing to add, call mark_ready.

Conventions:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public async Task StartAsync_TurnFailsAfterQuestions_ShowsNoQuestionCard()
Assert.DoesNotContain(viewModel.Messages, item => item is DraftQuestionCard);
Assert.True(Assert.IsType<DraftChatEntry>(viewModel.Messages[^1]).IsError);
var card = Assert.Single(viewModel.Messages.OfType<DraftActivityCard>());
Assert.Equal(LocalizationService.Current["DraftingStep_Stopped"].Replace("{0}", "1", StringComparison.Ordinal), card.Title);
Assert.Equal(LocalizationService.Current["DraftingStep_StoppedOne"], card.Title);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,22 @@ public async Task AskUser_Questions_RaiseQuestionsAskedAndEndTheTurn()
Assert.Equal(0, first.RecommendedIndex);
Assert.Equal(-1, asked.Questions[1].RecommendedIndex);
Assert.Equal(ChatToolMode.None, client.Requests[1].Options?.ToolMode);
Assert.Contains("answers arrive in their next message", client.Requests[1].Messages[^1].Contents
.OfType<FunctionResultContent>().Single().Result?.ToString(), StringComparison.Ordinal);
var result = client.Requests[1].Messages[^1].Contents.OfType<FunctionResultContent>().Single().Result?.ToString();
Assert.Contains("answers arrive in their next message", result, StringComparison.Ordinal);
Assert.Contains("says what you changed in this turn", result, StringComparison.Ordinal);
Assert.Equal(["Please answer the questions above."], replies);
}

[Fact]
[DisplayName("The instructions ask the reply that ends a turn with questions to say first what was changed")]
public void Instructions_AfterAskUser_ReplySaysWhatChanged()
{
var session = new FormDraftSession(new ScriptedChatClient(), new FakeDraftingHost());

Assert.Contains("first what you changed in this turn", session.History[0].Text, StringComparison.Ordinal);
Assert.DoesNotContain("end the turn with one short sentence", session.History[0].Text, StringComparison.Ordinal);
}

[Fact]
[DisplayName("A tool the model calls after asking the user is not run")]
public async Task AskUser_ToolCallAfterQuestions_IsNotRun()
Expand Down
2 changes: 2 additions & 0 deletions tools/DefineEditor/Resources/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,8 @@ The draft is as it was before this message; send it again to retry.</value></dat
<data name="DraftingStep_Reasoning" xml:space="preserve"><value>Thought</value></data>
<data name="DraftingStep_Done" xml:space="preserve"><value>Done in {0} steps</value></data>
<data name="DraftingStep_Stopped" xml:space="preserve"><value>Stopped after {0} steps</value></data>
<data name="DraftingStep_DoneOne" xml:space="preserve"><value>Done in 1 step</value></data>
<data name="DraftingStep_StoppedOne" xml:space="preserve"><value>Stopped after 1 step</value></data>
<data name="DraftingStep_Other" xml:space="preserve"><value>Running {0}</value></data>
<data name="DraftingStep_set_form_info" xml:space="preserve"><value>Setting the form's name and menu</value></data>
<data name="DraftingStep_upsert_table" xml:space="preserve"><value>Setting up the table {0}</value></data>
Expand Down
2 changes: 2 additions & 0 deletions tools/DefineEditor/Resources/Strings.zh-TW.resx
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,8 @@
<data name="DraftingStep_Reasoning" xml:space="preserve"><value>思考</value></data>
<data name="DraftingStep_Done" xml:space="preserve"><value>已完成 {0} 個步驟</value></data>
<data name="DraftingStep_Stopped" xml:space="preserve"><value>已中止(完成 {0} 個步驟)</value></data>
<data name="DraftingStep_DoneOne" xml:space="preserve"><value>已完成 1 個步驟</value></data>
<data name="DraftingStep_StoppedOne" xml:space="preserve"><value>已中止(完成 1 個步驟)</value></data>
<data name="DraftingStep_Other" xml:space="preserve"><value>正在執行 {0}</value></data>
<data name="DraftingStep_set_form_info" xml:space="preserve"><value>設定表單名稱與選單</value></data>
<data name="DraftingStep_upsert_table" xml:space="preserve"><value>設定資料表 {0}</value></data>
Expand Down
8 changes: 7 additions & 1 deletion tools/DefineEditor/ViewModels/DraftActivityCard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,13 @@ public void Finish(bool completed)
{
IsRunning = false;
IsExpanded = false;
Title = completed ? L("DraftingStep_Done", _toolSteps) : L("DraftingStep_Stopped", _toolSteps);
Title = (completed, _toolSteps) switch
{
(true, 1) => L("DraftingStep_DoneOne"),
(true, _) => L("DraftingStep_Done", _toolSteps),
(false, 1) => L("DraftingStep_StoppedOne"),
_ => L("DraftingStep_Stopped", _toolSteps),
};
}

/// <summary>
Expand Down
Loading