Closed MikeYeager closed 2 weeks ago
what's your SK version and exact error? Also did you try right click on the prompty file and generate SK code from there?
@wayliums
<PackageReference Include="Microsoft.SemanticKernel" Version="1.18.0-rc" />
<PackageReference Include="Microsoft.SemanticKernel.Abstractions" Version="1.18.0-rc" />
<PackageReference Include="Microsoft.SemanticKernel.Prompty" Version="1.18.0-alpha" />
The exact error message is the title of this issue:
Invalid prompty template. Header and content could not be parsed.
The stack trace is:
at Microsoft.SemanticKernel.Prompty.KernelFunctionPrompty.ToPromptTemplateConfig(String promptyTemplate)
at Microsoft.SemanticKernel.PromptyKernelExtensions.CreateFunctionFromPrompty(Kernel kernel, String promptyTemplate, IPromptTemplateFactory promptTemplateFactory)
at SKLasVegas.Program.<Prompty>d__7.MoveNext() in C:\Users\MYeager\Dropbox\AI\SK DevIntersections Las Vegas 2024\SampleCode\SKVegas\Program.cs:line 149
at SKLasVegas.Program.<Main>d__3.MoveNext() in C:\Users\MYeager\Dropbox\AI\SK DevIntersections Las Vegas 2024\SampleCode\SKVegas\Program.cs:line 32
The code generated by the VS Code extension is very similar to the code I'm using and produces the same result.
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Connectors.OpenAI;
var deployment = "";
var endpoint = "";
var key = "aoai_key";
var kernel = Kernel.CreateBuilder()
.AddAzureOpenAIChatCompletion(deployment, endpoint, key)
.Build();
// update the input below to match your prompty
KernelArguments kernelArguments = new()
{
{ "question", "what's my question?" },
};
var prompty = kernel.CreateFunctionFromPromptyFile("joke.prompty");
var result = await prompty.InvokeAsync<string>(kernel, kernelArguments);
Console.WriteLine(result);
Hmmm - it looks like an implementation problem in SK. In general it should pull all the relevant params and pass it into the API call.
Thanks @sethjuarez. I wonder if it's related to this: https://github.com/microsoft/semantic-kernel/issues/8154 I guess I'll wait for a new release of SK and see if it's fixed. If not, I will re-post in the SK repo.
I created a simple prompty template in VS Code and ran it with no problem. When I try to load the same template file into Semantic Kernel in VS2022, I get this exception: "Invalid prompty template. Header and content could not be parsed."
Here is my template:
And here is my SK code:
It blows up on kernel.CreateFunctionFromPrompty()
Any ideas? Thanks in advance.