Skip to content

Commit

Permalink
🔧 Rename PlannerOptions.SkipMissingFunctionsError to PlannerOptions.S…
Browse files Browse the repository at this point in the history
…kipOnMissingFunctionsError + Update PlanStepInput.tsx to use a more specific regex for matching interpolated variables.
  • Loading branch information
teresaqhoang committed Aug 2, 2023
1 parent c504ff1 commit fa83129
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion webapi/CopilotChat/Options/PlannerOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class PlannerOptions
// If set to true, the plan will be created with missing functions as no-op steps that are filtered from the final proposed plan.
// If this is set to false, the plan creation will fail if any functions are missing.
// </summary>
public bool SkipMissingFunctionsError { get; set; } = true;
public bool SkipOnMissingFunctionsError { get; set; } = true;

// <summary>
// Whether to retry plan creation if LLM returned response that doesn't contain valid plan (e.g., invalid XML or JSON, contains missing function, etc.).
Expand Down
4 changes: 2 additions & 2 deletions webapi/CopilotChat/Skills/ChatSkills/CopilotChatPlanner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ public async Task<Plan> CreatePlanAsync(string goal, ILogger logger)
{
RelevancyThreshold = this._plannerOptions?.RelevancyThreshold,
// Allow plan to be created with missing functions
AllowMissingFunctions = this._plannerOptions!.SkipMissingFunctionsError
AllowMissingFunctions = this._plannerOptions!.SkipOnMissingFunctionsError
}
).CreatePlanAsync(goal)
: await new ActionPlanner(this.Kernel).CreatePlanAsync(goal);

return this._plannerOptions!.SkipMissingFunctionsError ? this.SanitizePlan(plan, plannerFunctionsView, logger) : plan;
return this._plannerOptions!.SkipOnMissingFunctionsError ? this.SanitizePlan(plan, plannerFunctionsView, logger) : plan;
}

#region Private
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public async Task<string> AcquireExternalInformationAsync(
/// <summary>
/// Retry on plan creation error if:
/// 1. PlannerOptions.AllowRetriesOnInvalidPlan is true and exception contains error code InvalidPlan.
/// 2. PlannerOptions.SkipMissingFunctionsError is true and exception contains error code FunctionNotAvailable.
/// 2. PlannerOptions.SkipOnMissingFunctionsError is true and exception contains error code FunctionNotAvailable.
/// </summary>
private bool IsRetriableError(Exception e)
{
Expand All @@ -182,7 +182,7 @@ private bool IsRetriableError(Exception e)

var retryOnMissingFunctionError = e is KernelException
&& (e as KernelException)!.ErrorCode == KernelException.ErrorCodes.FunctionNotAvailable
&& this._planner.PlannerOptions!.SkipMissingFunctionsError;
&& this._planner.PlannerOptions!.SkipOnMissingFunctionsError;

return this._planner.PlannerOptions!.AllowRetriesOnInvalidPlan
&& (retryOnMissingFunctionError || retryOnInvalidPlanError);
Expand Down
2 changes: 1 addition & 1 deletion webapi/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
// Whether to allow missing functions in the plan on creation then sanitize output. Functions are considered missing if they're not available in the planner's kernel's context.
// If set to true, the plan will be created with missing functions as no-op steps that are filtered from the final proposed plan.
// If this is set to false, the plan creation will fail if any functions are missing.
"SkipMissingFunctionsError": "true",
"SkipOnMissingFunctionsError": "true",
// Whether to retry plan creation if LLM returned response with invalid plan.
"AllowRetriesOnInvalidPlan": "true"
},
Expand Down
6 changes: 3 additions & 3 deletions webapp/src/components/chat/plan-viewer/PlanStepInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ const useClasses = makeStyles({

// Regex to match interpolated variables in the form of $VARIABLE_NAME or $VARIABLE2_NAME.
// Variables that are not interpolated will fail to match.
// \$([A-Z0-9]+_*)+ matches the variable name
// \$([A-Z]+[_-]*)+ matches the variable name
// (?=[\sa-z[\].]+) is a positive lookahead matching the end of static string
// (?:.+\s*) is a noncapturing group that matches the start of static string
const INTERPOLATED_VARIABLE_REGEX = /((\$([A-Z0-9]+_*)+)(?=[\sa-z[\].]+))|((?:.+\s*)(\$([A-Z0-9]+_*)+))/g;
const INTERPOLATED_VARIABLE_REGEX = /((\$([A-Z]+[_-]*)+)(?=[\sa-z[\].]+))|((?:.+\s*)(\$([A-Z]+[_-]*)+))/g;

interface PlanStepInputProps {
input: IPlanInput;
Expand Down Expand Up @@ -112,7 +112,7 @@ export const PlanStepInput: React.FC<PlanStepInputProps> = ({

return (
<Badge
color={requiresEdits(input.Value) ? 'danger' : 'informative'}
color={editsRequired ? 'danger' : 'informative'}
shape="rounded"
appearance="tint"
className={classes.root}
Expand Down

0 comments on commit fa83129

Please sign in to comment.