Skip to content

Commit

Permalink
Pascal case constants
Browse files Browse the repository at this point in the history
  • Loading branch information
teresaqhoang committed Aug 8, 2023
1 parent dc2f5f3 commit 2db5a5c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions webapi/Skills/ChatSkills/CopilotChatPlanner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,21 @@ public class CopilotChatPlanner
/// Flag to indicate that a variable is unknown and needs to be filled in by the user.
/// This is used to flag any inputs that had dependencies from removed steps.
/// </summary>
private const string UNKNOWN_VARIABLE_FLAG = "$???";
private const string UnknownVariableFlag = "$???";

/// <summary>
/// Regex to match variable names from plan parameters.
/// Valid variable names can contain letters, numbers, underscores, and dashes but can't start with a number.
/// Matches: $variableName, $variable_name, $variable-name, $some_variable_Name, $variableName123, $variableName_123, $variableName-123
/// Does not match: $123variableName, $100 $200
/// </summary>
private const string VARIABLE_REGEX = @"\$([A-Za-z]+[_-]*[\w]+)";
private const string VariableRegex = @"\$([A-Za-z]+[_-]*[\w]+)";

/// <summary>
/// Supplemental text to add to the plan goal if PlannerOptions.Type is set to Stepwise.
/// Helps the planner know when to bail out to request additional user input.
/// </summary>
private const string STEPWISE_PLANNER_SUPPLEMENT = "If you need more information to fulfill this request, return with a request for additional user input.";
private const string StepwisePlannerSupplement = "If you need more information to fulfill this request, return with a request for additional user input.";

/// <summary>
/// Initializes a new instance of the <see cref="CopilotChatPlanner"/> class.
Expand Down Expand Up @@ -127,7 +127,7 @@ public async Task<SKContext> RunStepwisePlannerAsync(string goal, SKContext cont
var plan = new StepwisePlanner(
this.Kernel,
config
).CreatePlan(string.Join("\n", goal, STEPWISE_PLANNER_SUPPLEMENT));
).CreatePlan(string.Join("\n", goal, StepwisePlannerSupplement));
var result = await plan.InvokeAsync(context);

sw.Stop();
Expand Down Expand Up @@ -164,7 +164,7 @@ private Plan SanitizePlan(Plan plan, FunctionsView availableFunctions, ILogger l
availableOutputs.AddRange(step.Outputs);

// Regex to match variable names
Regex variableRegEx = new(VARIABLE_REGEX, RegexOptions.Singleline);
Regex variableRegEx = new(VariableRegex, RegexOptions.Singleline);

// Check for any inputs that may have dependencies from removed steps
foreach (var input in step.Parameters)
Expand All @@ -185,7 +185,7 @@ private Plan SanitizePlan(Plan plan, FunctionsView availableFunctions, ILogger l
&& inputVariableMatch.Groups[1].Captures.Count == 1
&& !unavailableOutputs.Any(output => string.Equals(output, inputVariableValue, StringComparison.OrdinalIgnoreCase))
? "$PLAN.RESULT" // TODO: [Issue #2256] Extract constants from Plan class, requires change on kernel team
: UNKNOWN_VARIABLE_FLAG;
: UnknownVariableFlag;
step.Parameters.Set(input.Key, Regex.Replace(input.Value, variableRegEx.ToString(), overrideValue));
}
}
Expand Down

0 comments on commit 2db5a5c

Please sign in to comment.