From dabfefedf68c25ba50e7f4843971bcf5714e89a0 Mon Sep 17 00:00:00 2001 From: nir-schleyen Date: Tue, 8 Aug 2023 16:06:14 -0700 Subject: [PATCH] undo --- .../Planning.StepwisePlanner/StepwisePlanner.cs | 2 -- .../ChatStepwisePlanner.cs | 14 ++++++-------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/dotnet/src/Extensions/Planning.StepwisePlanner/StepwisePlanner.cs b/dotnet/src/Extensions/Planning.StepwisePlanner/StepwisePlanner.cs index c66ef98b7ca0..a6ac4b14213f 100644 --- a/dotnet/src/Extensions/Planning.StepwisePlanner/StepwisePlanner.cs +++ b/dotnet/src/Extensions/Planning.StepwisePlanner/StepwisePlanner.cs @@ -120,7 +120,6 @@ public async Task ExecutePlanAsync( string actionText = llmResponse.Result.Trim(); this._logger?.LogTrace("Response: {ActionText}", actionText); - await Console.Out.WriteLineAsync(actionText).ConfigureAwait(false); var nextStep = this.ParseResult(actionText); stepsTaken.Add(nextStep); @@ -168,7 +167,6 @@ public async Task ExecutePlanAsync( } this._logger?.LogTrace("Observation: {Observation}", nextStep.Observation); - await Console.Out.WriteLineAsync("[OBSERVATION]: " + nextStep.Observation).ConfigureAwait(false); } else { diff --git a/dotnet/src/PF-Extensions/Planning.ChatStepwisePlanner/ChatStepwisePlanner.cs b/dotnet/src/PF-Extensions/Planning.ChatStepwisePlanner/ChatStepwisePlanner.cs index ec59481063c3..8386f3d1166d 100644 --- a/dotnet/src/PF-Extensions/Planning.ChatStepwisePlanner/ChatStepwisePlanner.cs +++ b/dotnet/src/PF-Extensions/Planning.ChatStepwisePlanner/ChatStepwisePlanner.cs @@ -11,6 +11,7 @@ using System.Threading.Tasks; using Microsoft.Extensions.Logging; using Microsoft.SemanticKernel.AI.ChatCompletion; +using Microsoft.SemanticKernel.Diagnostics; using Microsoft.SemanticKernel.Orchestration; using Microsoft.SemanticKernel.Planning.ChatStepwise; using Microsoft.SemanticKernel.Planning.Stepwise; @@ -114,7 +115,7 @@ public async Task ExecutePlanAsync( string currentTime = DateTimeOffset.UtcNow.ToString("f", DateTimeFormatInfo.InvariantInfo); ChatHistory history = this._chatCompletion.CreateNewChat(systemPromptTemplate.Replace("{{$functionDescriptions}}", functionDescriptions).Replace("{{time.UtcNow}}", currentTime)); foreach (FewShotExample example in fewShotExamplesTemplate) - { + { switch (example.Role) { case Role.User: @@ -130,8 +131,7 @@ public async Task ExecutePlanAsync( } } - string gameMetadata = "The name is the game is 'My Awesome Game'. It's a 'Shooting' game created at 2021/3/3\n"; - history.AddUserMessage(gameMetadata + question); + history.AddUserMessage(question); for (int i = 0; i < this.Config.MaxIterations; i++) { @@ -139,10 +139,11 @@ public async Task ExecutePlanAsync( //this._logger?.LogDebug("Scratchpad: {ScratchPad}", scratchPad); //context.Variables.Set("agentScratchPad", scratchPad); + // TODO request settings and cancellation token var llmResponse = (await this._chatCompletion.GetChatCompletionsAsync(history).ConfigureAwait(false)); var llmResult = llmResponse.Single(); // TODO, is there a case where we get multiple messages? var responseMessage = await llmResult.GetChatMessageAsync().ConfigureAwait(false); - + /*if (response.ErrorOccurred) { var exception = new PlanningException(PlanningException.ErrorCodes.UnknownError, $"Error occurred while executing stepwise plan: {llmResponse.LastErrorDescription}", llmResponse.LastException); @@ -152,8 +153,7 @@ public async Task ExecutePlanAsync( string actionText = responseMessage.Content.Trim(); history.AddAssistantMessage(actionText); - this._logger?.LogInformation("Response : {ActionText}", actionText); - await Console.Out.WriteLineAsync(actionText).ConfigureAwait(false); + this._logger?.LogDebug("Response : {ActionText}", actionText); var nextStep = this.ParseResult(actionText); stepsTaken.Add(nextStep); @@ -197,8 +197,6 @@ public async Task ExecutePlanAsync( } this._logger?.LogInformation("Observation: {Observation}", nextStep.Observation); - await Console.Out.WriteLineAsync("[OBSERVATION]: " + nextStep.Observation).ConfigureAwait(false); - history.AddAssistantMessage("[OBSERVATION] " + nextStep.Observation); } else