Skip to content

Commit 09d850b

Browse files
Python: Prevents LLMs from stripping complex function names (#4366)
### Motivation and Context When using the `StepwisePlanner` planner along with core skills, for example `TextMemorySkill`, the LLMs tend to plans with function names stripped down to the name without the skill name. This makes the plan fail with an exception like: `Error invoking action recall: (<ErrorCodes.UnknownError: -1>, "The function 'recall' was not found.", None)` This error is because the completion returned by the planner prompt does not include the fully structured skill function name. Ex.: instead of returning `_GLOBAL_FUNCTIONS_.recall` it returns `recall` or `GLOBAL_FUNCTIONS.recall`. This is somehow relates #3237 ### Description This change instructs the LLM to keep the skill function name unchanged in its response by adding an example that includes `_` in the name. This approach mimics how the `SequentialPlanner` solves this same issue. ### Contribution Checklist - [X] The code builds clean without any errors or warnings - [X] The PR follows the [SK Contribution Guidelines](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md) and the [pre-submission formatting script](https://github.com/microsoft/semantic-kernel/blob/main/CONTRIBUTING.md#development-scripts) raises no violations - [X] All unit tests pass, and I have added new tests where possible - [X] I didn't break anyone 😄
1 parent 21038a2 commit 09d850b

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

  • python/semantic_kernel/planning/stepwise_planner/Skills/StepwiseStep

‎python/semantic_kernel/planning/stepwise_planner/Skills/StepwiseStep/skprompt.txt‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,20 @@ Here is an example of a valid $JSON_BLOB:
2424
"action": "functionName",
2525
"action_variables": {"parameterName": "some value", ...}
2626
}
27+
28+
Here is another example of a valid $JSON_BLOB:
29+
{
30+
"action": "_Function_.Name",
31+
"action_variables": {"parameterName": "some value", ...}
32+
}
33+
34+
Here is another example of a valid $JSON_BLOB:
35+
{
36+
"action": "FunctionName2",
37+
"action_variables": {"parameterName": "some value", ...}
38+
}
39+
40+
The $JSON_BLOB must contain an "action_variables" key, with the {"parameterName": "some value", ...} value in the response.
2741
[END USAGE INSTRUCTIONS]
2842
[END INSTRUCTION]
2943

0 commit comments

Comments
 (0)