Skip to content
This repository has been archived by the owner on Aug 21, 2023. It is now read-only.

Commit

Permalink
undo
Browse files Browse the repository at this point in the history
  • Loading branch information
nir-schleyen committed Aug 8, 2023
1 parent 1bd1c8b commit dabfefe
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ public async Task<SKContext> 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);
Expand Down Expand Up @@ -168,7 +167,6 @@ public async Task<SKContext> ExecutePlanAsync(
}

this._logger?.LogTrace("Observation: {Observation}", nextStep.Observation);
await Console.Out.WriteLineAsync("[OBSERVATION]: " + nextStep.Observation).ConfigureAwait(false);
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -114,7 +115,7 @@ public async Task<SKContext> 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:
Expand All @@ -130,19 +131,19 @@ public async Task<SKContext> 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++)
{
//var scratchPad = this.CreateScratchPad(question, stepsTaken);
//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);
Expand All @@ -152,8 +153,7 @@ public async Task<SKContext> 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);
Expand Down Expand Up @@ -197,8 +197,6 @@ public async Task<SKContext> ExecutePlanAsync(
}

this._logger?.LogInformation("Observation: {Observation}", nextStep.Observation);
await Console.Out.WriteLineAsync("[OBSERVATION]: " + nextStep.Observation).ConfigureAwait(false);

history.AddAssistantMessage("[OBSERVATION] " + nextStep.Observation);
}
else
Expand Down

0 comments on commit dabfefe

Please sign in to comment.