Skip to content

Commit 9719d5a

Browse files
committed
docs
1 parent 3092d6e commit 9719d5a

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

getting-started/CONCEPTS/FUNCTION-CALLS.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,21 @@ To use function calling with the Chat Completions API:
4646
4747
```
4848

49+
### C#
50+
51+
```cs
52+
ActionPlannerOptions<TurnState> options = new ActionPlannerOptions<TurnState>()
53+
{
54+
Model = model,
55+
Prompts = prompts,
56+
async (context, state, planner) =>
57+
{
58+
return await Task.FromResult(prompts.GetPrompt("Tools"));
59+
}
60+
}
61+
ActionPlanner<TurnState> planner = new ActionPlanner(options)
62+
```
63+
4964
2. Specify "tools" in your `config.json`.
5065

5166
```diff
@@ -101,7 +116,24 @@ To use function calling with the Chat Completions API:
101116
ensure_list_exists(state, context.data["list"])
102117
# Continues exectuion of next command in the plan.
103118
return ""
104-
````
119+
```
120+
121+
### C#
122+
123+
```cs
124+
[Action("CreateList")]
125+
public string CreateList([ActionTurnState] ListState turnState, [ActionParameters] Dictionary<string, object> parameters)
126+
{
127+
ArgumentNullException.ThrowIfNull(turnState);
128+
ArgumentNullException.ThrowIfNull(parameters);
129+
130+
string listName = GetParameterString(parameters, "list");
131+
132+
EnsureListExists(turnState, listName);
133+
134+
return "list created. think about your next action";
135+
}
136+
```
105137

106138

107139
If the model requests to invoke any function(s), these are internally mapped to `DO` commands within a `Plan`, which are then invoked in our AI class' `run` function. These outputs are then returned to the model.

0 commit comments

Comments
 (0)