Skip to content

Commit

Permalink
Add BasicPlanner
Browse files Browse the repository at this point in the history
  • Loading branch information
dluc committed Apr 24, 2023
1 parent 87bd0b4 commit 0534138
Show file tree
Hide file tree
Showing 36 changed files with 541 additions and 70 deletions.
7 changes: 7 additions & 0 deletions dotnet/SK-dotnet.sln
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SemanticKernel.MetaPackage"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ImportDocument", "..\samples\apps\copilot-chat-app\importdocument\ImportDocument.csproj", "{94E14913-D600-4448-A5C5-A268C23B2C3B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Skills.Planning", "src\Skills\Skills.Planning\Skills.Planning.csproj", "{994BEF0B-E277-4D10-BB13-FE670D26620D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -177,6 +179,10 @@ Global
{94E14913-D600-4448-A5C5-A268C23B2C3B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{94E14913-D600-4448-A5C5-A268C23B2C3B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{94E14913-D600-4448-A5C5-A268C23B2C3B}.Release|Any CPU.Build.0 = Release|Any CPU
{994BEF0B-E277-4D10-BB13-FE670D26620D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{994BEF0B-E277-4D10-BB13-FE670D26620D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{994BEF0B-E277-4D10-BB13-FE670D26620D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{994BEF0B-E277-4D10-BB13-FE670D26620D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -209,6 +215,7 @@ Global
{627742DB-1E52-468A-99BD-6FF1A542D25B} = {831DDCA2-7D2C-4C31-80DB-6BDB3E1F7AE0}
{E3299033-EB81-4C4C-BCD9-E8DC40937969} = {831DDCA2-7D2C-4C31-80DB-6BDB3E1F7AE0}
{94E14913-D600-4448-A5C5-A268C23B2C3B} = {FA3720F1-C99A-49B2-9577-A940257098BF}
{994BEF0B-E277-4D10-BB13-FE670D26620D} = {9ECD1AA0-75B3-4E25-B0B5-9F0945B64974}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {FBDC56A3-86AD-4323-AA0F-201E59123B83}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
using System.Buffers;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
Expand Down Expand Up @@ -100,9 +98,7 @@ public static List<int> Encode(string text)
// for every 1 UTF8 byte. If we can reasonably stack-allocate the space, we do, otherwise
// we temporarily rent a pooled array.
char[]? arrayPoolArray = null;
Span<char> chars = maxUtf8Length <= 256 ?
stackalloc char[maxUtf8Length] :
(arrayPoolArray = ArrayPool<char>.Shared.Rent(maxUtf8Length));
Span<char> chars = maxUtf8Length <= 256 ? stackalloc char[maxUtf8Length] : (arrayPoolArray = ArrayPool<char>.Shared.Rent(maxUtf8Length));

// Rather than using separate space for the UTF8 bytes, we just reinterpret the Span<char>
// as a Span<byte>. Since our mapping is 1:1, the space required for the bytes will always
Expand Down Expand Up @@ -156,24 +152,23 @@ static unsafe int EncodingUtf8GetByteCount(ReadOnlySpan<char> chars)
static unsafe int EncodingUtf8GetBytes(ReadOnlySpan<char> chars, Span<byte> bytes)
{
fixed (char* charPtr = chars)
fixed (byte* bytesPtr = bytes)
{
return Encoding.UTF8.GetBytes(charPtr, chars.Length, bytesPtr, bytes.Length);
fixed (byte* bytesPtr = bytes)
{
return Encoding.UTF8.GetBytes(charPtr, chars.Length, bytesPtr, bytes.Length);
}
}
}
}

public static List<int> Encode(StringBuilder? stringBuilder) =>
stringBuilder is not null ? Encode(stringBuilder.ToString()) :
new List<int>();
stringBuilder is not null ? Encode(stringBuilder.ToString()) : new List<int>();

public static List<int> Encode(char[]? chars) =>
chars is not null ? Encode(new string(chars)) :
new List<int>();
chars is not null ? Encode(new string(chars)) : new List<int>();

public static List<int> Encode(IEnumerable<char>? chars) =>
chars is not null ? Encode(string.Concat(chars)) :
new List<int>();
chars is not null ? Encode(string.Concat(chars)) : new List<int>();

private static List<string> BytePairEncoding(string token)
{
Expand Down Expand Up @@ -237,6 +232,7 @@ private static List<string> BytePairEncoding(string token)
{
break;
}

i = j;

if (i < (word.Count - 1) &&
Expand Down
1 change: 1 addition & 0 deletions dotnet/src/IntegrationTests/IntegrationTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

<ItemGroup>
<ProjectReference Include="..\Connectors\Connectors.AI.OpenAI\Connectors.AI.OpenAI.csproj" />
<ProjectReference Include="..\Skills\Skills.Planning\Skills.Planning.csproj" />
<ProjectReference Include="..\Skills\Skills.Web\Skills.Web.csproj" />
<ProjectReference Include="..\SemanticKernel\SemanticKernel.csproj" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

using Microsoft.Extensions.Configuration;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Planning;
using Microsoft.SemanticKernel.Skills.Planning.SequentialPlanner;
using SemanticKernel.IntegrationTests.Fakes;
using SemanticKernel.IntegrationTests.TestSettings;
using Xunit;
using Xunit.Abstractions;

namespace SemanticKernel.IntegrationTests.Planning;
namespace SemanticKernel.IntegrationTests.Planning.SequentialPlanner;

public class SequentialPlanParserTests
{
Expand Down Expand Up @@ -57,7 +57,10 @@ public void CanCallToPlanFromXml()
</plan>";

// Act
// TODO - a test should not rely on the code under test, e.g. if there's a bug in ToPlanFromXml
// it'll result in false positives/negatives
var plan = planString.ToPlanFromXml(kernel.CreateNewContext());
// Microsoft.SemanticKernel.Skills.Planning.SequentialPlanner.SequentialPlanParser.

// Assert
Assert.NotNull(plan);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Memory;
using Microsoft.SemanticKernel.Planning.Planners;
using Microsoft.SemanticKernel.Skills.Planning.SequentialPlanner;
using SemanticKernel.IntegrationTests.Fakes;
using SemanticKernel.IntegrationTests.TestSettings;
using Xunit;
using Xunit.Abstractions;

namespace SemanticKernel.IntegrationTests.Planning;
namespace SemanticKernel.IntegrationTests.Planning.SequentialPlanner;

public sealed class SequentialPlannerTests : IDisposable
{
Expand All @@ -39,7 +39,7 @@ public async Task CreatePlanFunctionFlowAsync(string prompt, string expectedFunc
IKernel kernel = this.InitializeKernel();
TestHelpers.GetSkill("FunSkill", kernel);

var planner = new SequentialPlanner(kernel);
var planner = new Microsoft.SemanticKernel.Skills.Planning.SequentialPlanner.SequentialPlanner(kernel);

// Act
var plan = await planner.CreatePlanAsync(prompt);
Expand All @@ -61,7 +61,7 @@ public async Task CreatePlanGoalRelevantAsync(string prompt, string expectedFunc
// Import all sample skills available for demonstration purposes.
TestHelpers.ImportSampleSkills(kernel);

var planner = new SequentialPlanner(kernel, new PlannerConfig() { RelevancyThreshold = 0.70, MaxRelevantFunctions = 20 });
var planner = new Microsoft.SemanticKernel.Skills.Planning.SequentialPlanner.SequentialPlanner(kernel, new PlannerConfig() { RelevancyThreshold = 0.70, MaxRelevantFunctions = 20 });

// Act
var plan = await planner.CreatePlanAsync(prompt);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System;
using Microsoft.SemanticKernel.Diagnostics;

namespace Microsoft.SemanticKernel.Planning;
namespace Microsoft.SemanticKernel.Orchestration;

/// <summary>
/// Planning exception.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
<_Parameter1>Microsoft.SemanticKernel.Connectors.AI.OpenAI</_Parameter1>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
<_Parameter1>Microsoft.SemanticKernel.Skills.Planning</_Parameter1>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
<_Parameter1>Microsoft.SemanticKernel.Skills.OpenAPI</_Parameter1>
</AssemblyAttribute>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ Empowers app owners to integrate cutting-edge LLM technology quickly and easily
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\SemanticKernel\SemanticKernel.csproj" />
<ProjectReference Include="..\Connectors\Connectors.AI.OpenAI\Connectors.AI.OpenAI.csproj" PrivateAssets="none"/>
<ProjectReference Include="..\SemanticKernel\SemanticKernel.csproj" PrivateAssets="none" />
<ProjectReference Include="..\Connectors\Connectors.AI.OpenAI\Connectors.AI.OpenAI.csproj" PrivateAssets="none" />
<ProjectReference Include="..\Skills\Skills.Planning\Skills.Planning.csproj" PrivateAssets="none" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public sealed class PromptTemplateEngineTests
public PromptTemplateEngineTests(ITestOutputHelper testOutputHelper)
{
this._logger = testOutputHelper;
this._target = new PromptTemplateEngine(ConsoleLogger.Log);
this._target = new PromptTemplateEngine(TestConsoleLogger.Log);
this._variables = new ContextVariables(Guid.NewGuid().ToString("X"));
this._skills = new Mock<IReadOnlySkillCollection>();
}
Expand Down Expand Up @@ -219,7 +219,7 @@ private SKContext MockContext()
this._variables,
NullMemory.Instance,
this._skills.Object,
ConsoleLogger.Log);
TestConsoleLogger.Log);
}
}
#pragma warning restore VSTHRD103
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace SemanticKernel.UnitTests.XunitHelpers;
/// <summary>
/// Basic logger printing to console
/// </summary>
internal static class ConsoleLogger
internal static class TestConsoleLogger
{
internal static ILogger Log => LogFactory.CreateLogger<object>();

Expand Down
3 changes: 3 additions & 0 deletions dotnet/src/SemanticKernel/SemanticKernel.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ Install this package manually only if you are selecting individual Semantic Kern
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
<_Parameter1>Microsoft.SemanticKernel.Connectors.OpenAI</_Parameter1>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
<_Parameter1>Microsoft.SemanticKernel.Skills.Planning</_Parameter1>
</AssemblyAttribute>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleTo">
<_Parameter1>Microsoft.SemanticKernel.Skills.OpenAPI</_Parameter1>
</AssemblyAttribute>
Expand Down
104 changes: 104 additions & 0 deletions dotnet/src/Skills/Skills.Planning/BasicPlanner/BasicPlanner.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
// Copyright (c) Microsoft. All rights reserved.

using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using Microsoft.SemanticKernel.Diagnostics;
using Microsoft.SemanticKernel.Orchestration;
using Microsoft.SemanticKernel.SkillDefinition;

namespace Microsoft.SemanticKernel.Skills.Planning.BasicPlanner;

public class BasicPlanner

Check warning on line 14 in dotnet/src/Skills/Skills.Planning/BasicPlanner/BasicPlanner.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, Release)

The type name BasicPlanner conflicts in whole or in part with the namespace name 'Microsoft.SemanticKernel.Skills.Planning.BasicPlanner'. Change either name to eliminate the conflict.

Check warning on line 14 in dotnet/src/Skills/Skills.Planning/BasicPlanner/BasicPlanner.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, Release)

The type name BasicPlanner conflicts in whole or in part with the namespace name 'Microsoft.SemanticKernel.Skills.Planning.BasicPlanner'. Change either name to eliminate the conflict.

Check warning on line 14 in dotnet/src/Skills/Skills.Planning/BasicPlanner/BasicPlanner.cs

View workflow job for this annotation

GitHub Actions / check-format

The type name BasicPlanner conflicts in whole or in part with the namespace name 'Microsoft.SemanticKernel.Skills.Planning.BasicPlanner'. Change either name to eliminate the conflict.

Check warning on line 14 in dotnet/src/Skills/Skills.Planning/BasicPlanner/BasicPlanner.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, Debug)

The type name BasicPlanner conflicts in whole or in part with the namespace name 'Microsoft.SemanticKernel.Skills.Planning.BasicPlanner'. Change either name to eliminate the conflict.

Check warning on line 14 in dotnet/src/Skills/Skills.Planning/BasicPlanner/BasicPlanner.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, Debug)

The type name BasicPlanner conflicts in whole or in part with the namespace name 'Microsoft.SemanticKernel.Skills.Planning.BasicPlanner'. Change either name to eliminate the conflict.
{
private const string SKPrompt = "BasicPlanner/skprompt.txt";
private const string StopSequence = "#END-OF-PLAN";
private const string SkillName = "basicPlanner";

private readonly ISKFunction _plannerFunction;

/// <summary>
/// Initialize a new instance of the <see cref="BasicPlanner"/> class.
/// </summary>
/// <param name="kernel">The semantic kernel instance.</param>
/// <param name="prompt">Optional prompt override</param>
public BasicPlanner(
IKernel kernel,
string? prompt = null)
{
Verify.NotNull(kernel, "The planner requires a non-null kernel instance");

string promptTemplate = prompt ?? File.ReadAllText(SKPrompt);

this._plannerFunction = kernel.CreateSemanticFunction(
promptTemplate: promptTemplate,
maxTokens: 1024,
stopSequences: new[] { StopSequence });

kernel.ImportSkill(this, skillName: SkillName);
}

public async Task<Plan> CreatePlanAsync(string goal, SKContext context)
{
SKContext result = await this._plannerFunction.InvokeAsync(context);

Check failure on line 45 in dotnet/src/Skills/Skills.Planning/BasicPlanner/BasicPlanner.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, Release)

Add .ConfigureAwait(bool) to your await expression

Check failure on line 45 in dotnet/src/Skills/Skills.Planning/BasicPlanner/BasicPlanner.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, Release)

Consider calling ConfigureAwait on the awaited task

Check failure on line 45 in dotnet/src/Skills/Skills.Planning/BasicPlanner/BasicPlanner.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, Release)

Add .ConfigureAwait(bool) to your await expression

Check failure on line 45 in dotnet/src/Skills/Skills.Planning/BasicPlanner/BasicPlanner.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, Release)

Consider calling ConfigureAwait on the awaited task

Check failure on line 45 in dotnet/src/Skills/Skills.Planning/BasicPlanner/BasicPlanner.cs

View workflow job for this annotation

GitHub Actions / check-format

Consider calling ConfigureAwait on the awaited task

Check failure on line 45 in dotnet/src/Skills/Skills.Planning/BasicPlanner/BasicPlanner.cs

View workflow job for this annotation

GitHub Actions / check-format

Add .ConfigureAwait(bool) to your await expression

Check failure on line 45 in dotnet/src/Skills/Skills.Planning/BasicPlanner/BasicPlanner.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, Debug)

Add .ConfigureAwait(bool) to your await expression

Check failure on line 45 in dotnet/src/Skills/Skills.Planning/BasicPlanner/BasicPlanner.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, Debug)

Consider calling ConfigureAwait on the awaited task

Check failure on line 45 in dotnet/src/Skills/Skills.Planning/BasicPlanner/BasicPlanner.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, Debug)

Add .ConfigureAwait(bool) to your await expression

Check failure on line 45 in dotnet/src/Skills/Skills.Planning/BasicPlanner/BasicPlanner.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, Debug)

Consider calling ConfigureAwait on the awaited task

// extract and parse JSON
// build and return plan

throw new NotImplementedException("work in progress");
}

/// <summary>
/// Native function returning a list of all the functions in the current context,
/// excluding functions in the planner itself.
/// </summary>
/// <param name="goal">Currently unused. Will be used to handle long lists of functions.</param>
/// <param name="context">Function execution context</param>
/// <returns>List of functions, formatted accordingly to the prompt</returns>
[SKFunction("List all functions available in the kernel")]
[SKFunctionName("ListOfFunctions")]
[SKFunctionInput(Description = "The current goal processed by the planner", DefaultValue = "")]
public string ListOfFunctions(string goal, SKContext context)
{
Verify.NotNull(context.Skills, "The planner requires a non-null skill collection");
var functionsAvailable = context.Skills.GetFunctionsView();

// Prepare list using the format used by skprompt.txt
var list = new StringBuilder();
this.PopulateList(list, functionsAvailable.NativeFunctions);
this.PopulateList(list, functionsAvailable.SemanticFunctions);

return list.ToString();
}

private void PopulateList(StringBuilder list, IDictionary<string, List<FunctionView>> functions)
{
foreach (KeyValuePair<string, List<FunctionView>> skill in functions)
{
// Skill the BasicPlanner skill (ie. this class)
if (string.Compare(skill.Key, SkillName, StringComparison.OrdinalIgnoreCase) == 0) { continue; }

Check warning on line 81 in dotnet/src/Skills/Skills.Planning/BasicPlanner/BasicPlanner.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, Release)

Use 'string.Equals' instead of comparing the result of 'string.Compare' to 0

Check warning on line 81 in dotnet/src/Skills/Skills.Planning/BasicPlanner/BasicPlanner.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, Release)

Use 'string.Equals' instead of comparing the result of 'string.Compare' to 0

Check warning on line 81 in dotnet/src/Skills/Skills.Planning/BasicPlanner/BasicPlanner.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, Debug)

Use 'string.Equals' instead of comparing the result of 'string.Compare' to 0

Check warning on line 81 in dotnet/src/Skills/Skills.Planning/BasicPlanner/BasicPlanner.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, Debug)

Use 'string.Equals' instead of comparing the result of 'string.Compare' to 0

foreach (FunctionView func in skill.Value)
{
// Function description
list.AppendLine($"// {AddPeriod(func.Description)}");

// Function name
list.AppendLine($"{func.SkillName}.{func.Name}");

// Function parameters
foreach (var p in func.Parameters)
{
list.AppendLine($"Parameter \"{p.Name}\": {AddPeriod(p.Description)}");
}
}
}
}

private static string AddPeriod(string x)
{
return x.EndsWith(".") ? x : $"{x}.";

Check warning on line 102 in dotnet/src/Skills/Skills.Planning/BasicPlanner/BasicPlanner.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, Release)

The behavior of 'string.EndsWith(string)' could vary based on the current user's locale settings. Replace this call in 'Microsoft.SemanticKernel.Skills.Planning.BasicPlanner.BasicPlanner.AddPeriod(string)' with a call to 'string.EndsWith(string, System.StringComparison)'.

Check warning on line 102 in dotnet/src/Skills/Skills.Planning/BasicPlanner/BasicPlanner.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, Release)

The behavior of 'string.EndsWith(string)' could vary based on the current user's locale settings. Replace this call in 'Microsoft.SemanticKernel.Skills.Planning.BasicPlanner.BasicPlanner.AddPeriod(string)' with a call to 'string.EndsWith(string, System.StringComparison)'.

Check warning on line 102 in dotnet/src/Skills/Skills.Planning/BasicPlanner/BasicPlanner.cs

View workflow job for this annotation

GitHub Actions / check-format

The behavior of 'string.EndsWith(string)' could vary based on the current user's locale settings. Replace this call in 'Microsoft.SemanticKernel.Skills.Planning.BasicPlanner.BasicPlanner.AddPeriod(string)' with a call to 'string.EndsWith(string, System.StringComparison)'.

Check warning on line 102 in dotnet/src/Skills/Skills.Planning/BasicPlanner/BasicPlanner.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, Debug)

The behavior of 'string.EndsWith(string)' could vary based on the current user's locale settings. Replace this call in 'Microsoft.SemanticKernel.Skills.Planning.BasicPlanner.BasicPlanner.AddPeriod(string)' with a call to 'string.EndsWith(string, System.StringComparison)'.

Check warning on line 102 in dotnet/src/Skills/Skills.Planning/BasicPlanner/BasicPlanner.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest, Debug)

The behavior of 'string.EndsWith(string)' could vary based on the current user's locale settings. Replace this call in 'Microsoft.SemanticKernel.Skills.Planning.BasicPlanner.BasicPlanner.AddPeriod(string)' with a call to 'string.EndsWith(string, System.StringComparison)'.
}
}
60 changes: 60 additions & 0 deletions dotnet/src/Skills/Skills.Planning/BasicPlanner/skprompt.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
A planner takes a list of functions, a goal, and chooses which function to use.
For each function the list includes details about the input parameters.
[EXAMPLE 1]
- List of functions:
// Read a file.
FileIOSkill.ReadAsync
Parameter "path": Source file.
// Write a file.
FileIOSkill.WriteAsync
Parameter "path": Destination file.
Parameter "content": File content.
// Get the current time.
TimeSkill.Time
No parameters.
// Makes a POST request to a uri.
HttpSkill.PostAsync
Parameter "body": The body of the request.
- End list of functions.
Goal: create a file called "something.txt".
#PLAN:
{
"rationale": "the list contains a function that allows to create files",
"function": "FileIOSkill.WriteAsync",
"parameters": {
"path": "something.txt",
"content": ""
}
}
#END-OF-PLAN
[EXAMPLE 2]
- List of functions:
// Get the current time.
TimeSkill.Time
No parameters.
// Write a file.
FileIOSkill.WriteAsync
Parameter "path": Destination file.
Parameter "content": File content.
// Makes a POST request to a uri.
HttpSkill.PostAsync
Parameter "body": The body of the request.
// Read a file.
FileIOSkill.ReadAsync
Parameter "path": Source file.
- End list of functions.
Goal: tell me a joke.
#PLAN:
{
"rationale": "the list does not contain functions to tell jokes or something funny",
"function": "",
"parameters": {}
}
#END-OF-PLAN
[END OF EXAMPLES]
[REAL SCENARIO STARTS HERE]
- List of functions:
{{basicPlanner.ListOfFunctions}}
- End list of functions.
Goal: {{ $input }}
#PLAN:

0 comments on commit 0534138

Please sign in to comment.