Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding HandlebarsPlanCreationException #4973

Merged
merged 6 commits into from
Feb 23, 2024

Conversation

teresaqhoang
Copy link
Contributor

@teresaqhoang teresaqhoang commented Feb 12, 2024

Motivation and Context

Resolves #4440

This PR adds a more detailed HandlebarsPlanCreationException type, which allows users to inspect the prompt and model results, if available.

Als includes a minor update to sample to add clarifying comments.

Description

Users can catch HandlebarsPlanCreationException to inspect the prompt, proposed plan, and exception details on error. All exceptions will be bubbled up to the caller.

var planner = new HandlebarsPlanner();

try
{
     var plan = await planner.CreatePlanAsync(kernel, intent, cancellationToken);
}
catch (HandlebarsPlanCreationException ex)
{
     Console.WriteLine(ex.Message);
     Console.WriteLine(ex.InnerException?.Message);
     Console.WriteLine($"CreatePlan Prompt: {ex.CreatePlanPrompt}");
     Console.WriteLine($"Proposed plan (model output): {ex.ModelResults.Content}");
     throw ex;
}

Contribution Checklist

@teresaqhoang teresaqhoang self-assigned this Feb 12, 2024
@teresaqhoang teresaqhoang requested a review from a team as a code owner February 12, 2024 20:31
@shawncal shawncal added the .NET Issue or Pull requests regarding .NET code label Feb 12, 2024
@github-actions github-actions bot changed the title [Handlebars Planner] Option to return error details in HB Plan object instead of throwing .Net: [Handlebars Planner] Option to return error details in HB Plan object instead of throwing Feb 12, 2024
@Krzysztof318
Copy link
Contributor

But isn't this a return to how kernel errors were once handled? ADR 0004 describes a departure from such solution in favor of throwing exceptions.

@teresaqhoang teresaqhoang changed the title .Net: [Handlebars Planner] Option to return error details in HB Plan object instead of throwing Adding HandlebarsPlanCreationException Feb 15, 2024
@teresaqhoang
Copy link
Contributor Author

But isn't this a return to how kernel errors were once handled? ADR 0004 describes a departure from such solution in favor of throwing exceptions.

Great callout @Krzysztof318, that slipped my mind. Pivoted to creating a narrower exception type containing these details.

@teresaqhoang teresaqhoang added this pull request to the merge queue Feb 23, 2024
Merged via the queue into microsoft:main with commit 8858733 Feb 23, 2024
18 checks passed
@teresaqhoang teresaqhoang deleted the hb-planner-error-handling branch February 23, 2024 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
.NET Issue or Pull requests regarding .NET code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

.Net: Exceptions thrown from the HandlebarsPlanner should be specific and should contain Exception-Data.
6 participants