Skip to content

Commit bb59b75

Browse files
authored
Merge pull request #772 from iceljc/features/add-agent-utility-doc
add json
2 parents 6e5e390 + eae6d88 commit bb59b75

File tree

1 file changed

+60
-26
lines changed

1 file changed

+60
-26
lines changed

docs/agent-utility/intro.md

Lines changed: 60 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,17 @@ The agent utility is a unique feature that can be integrated into agent to enhan
88

99
<div id="agent-utility-example">
1010
<img src="assets/agent-utility-example.png" style="display: block; margin: auto;" />
11-
<div style="text-align: center;">Fig 2.1.1 Agent utility example.</div>
1211
</div>
1312
<br />
1413

1514
## Agent Utility Setup
1615
In this section, we outline the steps to set up a custom agent utility. We start with the basic code structure and then add essential utility data, such as prompts and functions. The utility hooks are used to incorporate the utility into the agent. Finally, we give a brief overview of the utility implementation.
1716

1817
### Basic Code Structure
19-
The basic code structure of a typical agent utility includes prompt/function data, hooks, and function implementation. We can add specific utility prompts and functions in different projects. Note that the agent “6745151e-6d46-4a02-8de4-1c4f21c7da95” is considered as a dedicated utility assistant, and every prompt and function can be optionally used as a utility. [Fig 3.1.1](#agent-utility-code-structure) presents the prompt, function, hooks, and implementation of an http utility.
18+
The basic code structure of a typical agent utility includes prompt/function data, hooks, and function implementation. We can add specific utility prompts and functions in different projects. Note that the agent “6745151e-6d46-4a02-8de4-1c4f21c7da95” is considered as a dedicated utility assistant, and every prompt and function can be optionally used as a utility. [Fig 3.1.1](#agent-utility-code-structure) presents the structure of prompt, function, hooks, and implementation of an http utility.
2019

2120
<div id="agent-utility-code-structure">
2221
<img src="assets/agent-utility-code-structure.png" style="display: block; margin: auto;" />
23-
<div style="text-align: center;">Fig 3.1.1 Basic code structure of an agent utility</div>
2422
</div>
2523
<br />
2624

@@ -323,33 +321,73 @@ public class HandleHttpRequestFn : IFunctionCallback
323321
### Utility Inheritance
324322
Here we introduce a new feature: utility inheritance. As we are using the routing-based multi-agent architecture, different agents may come into the call stack while we are handling user requests. With the utility inheritance, the agent can not only use the utilities added to itself but also inherit the utilities from the entry agent, which is the first agent that comes into the call stack, such as a router agent. [Fig 3.5.1](#routing-architecture) illustrates a typical example of routing-based multi-agent architecture, where “Pizza Bot” is the router and "Order Inquery", "Ordering", "Payment" are task agents. When the user starts chatting, “Pizza Bot” first comes into the call stack, with "Order Inquery", "Ordering", or "Payment" joining next depending on what the user actually requests. For example, if we allow "Order Inquery" to inherit utilities, all the utilities from itself as well as “Pizza Bot” will be invoked once the "Order Inquery" agent is in action.
325323

326-
<div id="routing-architecture">
324+
<div id="routing-architecture">
327325
<img src="assets/routing-arch.png" style="display: block; margin: auto;" />
328-
<div style="text-align: center;">Fig 3.5.1 An example of routing-based multi-agent architecture.</div>
329326
</div>
330327
<br />
331328

332329
### Agent Setup
333-
Here we introduce the agent setup with utilities and inheritance. As we introduced in [Section 3.3](#utility-hooks), each utility of an agent is structured with utility name, functions, and prompts. [Fig 3.6.1](#router-utility) and [Fig 3.6.2](#task-agent-utility) presents the utility configuration and utility inheritance of “Pizza Bot” and “Order Inquery”, respectively. As is displayed, we can apply the utility configuration and inheritance via agent files or agent detail ui. Note that we can uncheck the box to disable a utility ([Fig 3.6.1](#router-utility) right).
334-
335-
<div id="router-utility">
336-
<div style="display: flex; justify-content: center;">
337-
<div><img src="assets/router-utility.png" /></div>
338-
<div><img src="assets/router-utility-ui.png" /></div>
339-
</div>
340-
<div style="text-align: center;">Fig 3.6.1 Router utility setup of "Pizza Bot".</div>
341-
<div style="text-align: center;">(left: agent file, right: agent detail ui)</div>
330+
Here we introduce the agent setup with utilities and inheritance. As we introduced in [Section 3.3](#utility-hooks), each utility of an agent is structured with utility name, functions, and prompts. [Fig 3.6.1](#router-utility-ui) and [Fig 3.6.2](#task-agent-utility-ui) presents the utility configuration and utility inheritance of “Pizza Bot” and “Order Inquery”, respectively. As is displayed, we can apply the utility configuration and inheritance via agent files or agent detail ui. Note that we can uncheck the box to disable a utility ([Fig 3.6.2](#router-utility-ui)).
331+
332+
```json
333+
{
334+
"id": "8970b1e5-d260-4e2c-90b1-f1415a257c18",
335+
"name": "Pizza Bot",
336+
"description": "AI assistant that can help customer place pizza order.",
337+
"type": "routing",
338+
"inheritAgentId": "01fcc3e5-9af7-49e6-ad7a-a760bd12dc4a",
339+
"createdDateTime": "2023-08-18T10:39:32.2349685Z",
340+
"updatedDateTime": "2023-08-18T14:39:32.2349686Z",
341+
"iconUrl": "https://cdn-icons-png.flaticon.com/512/6978/6978255.png",
342+
"disabled": false,
343+
"isPublic": true,
344+
"profiles": [ "pizza" ],
345+
"utilities": [
346+
{
347+
"name": "http_handler",
348+
"functions": [
349+
{ "name": "handle_http_request" }
350+
],
351+
"templates": [
352+
{ "name": "handle_http_request.fn" }
353+
]
354+
}
355+
],
356+
"routingRules": [
357+
{
358+
"type": "reasoner",
359+
"field": "NaiveReasoner"
360+
}
361+
]
362+
}
363+
```
364+
<br />
365+
366+
367+
<div id="router-utility-ui">
368+
<img src="assets/router-utility-ui.png" style="display: block; margin: auto;" />
342369
</div>
343370
<br />
344371
<br />
372+
<br />
373+
374+
```json
375+
{
376+
"name": "Order Inquiry",
377+
"description": "Check the order status like payment, delivery or baking.",
378+
"createdDateTime": "2023-08-18T14:39:32.2349685Z",
379+
"updatedDateTime": "2023-08-18T14:39:32.2349686Z",
380+
"id": "b284db86-e9c2-4c25-a59e-4649797dd130",
381+
"disabled": false,
382+
"isPublic": true,
383+
"mergeUtility": true,
384+
"profiles": [ "pizza" ]
385+
}
386+
```
387+
<br />
345388

346-
<div style="text-align: center;" id="task-agent-utility">
347-
<div style="display: flex; justify-content: center;">
348-
<div><img src="assets/task-agent-utility.png" /></div>
349-
<div><img src="assets/task-agent-utility-ui.png" /></div>
350-
</div>
351-
<div style="text-align: center;">Fig 3.6.2 Utility inheritance of "Order Inquery" agent.</div>
352-
<div style="text-align: center;">(left: agent file, right: agent detail ui)</div>
389+
<div id="task-agent-utility-ui">
390+
<img src="assets/task-agent-utility-ui.png" style="display: block; margin: auto;" />
353391
</div>
354392
<br />
355393

@@ -381,11 +419,10 @@ public class HttpHandlerPlugin : IBotSharpPlugin
381419
}
382420
```
383421

384-
[Fig 4.1.2](#register-assembly) shows the utility assembly registration in “appsettings.json”. It is important to note that we are required to add the project reference to the Startup project, e.g., WebStarter. Moreover, we are required to add any new custom agent utility in the “Plugin” folder instead of the “BotSharp” folder.
422+
[Fig 4.1.2](#register-assembly) demonstrates the utility assembly registration in “appsettings.json”. It is important to note that we are required to add the project reference to the Startup project, e.g., WebStarter. Moreover, we are required to add any new custom agent utility in the “Plugin” folder instead of the “BotSharp” folder.
385423

386424
<div style="text-align: center;" id="register-assembly">
387425
<img src="assets/register-assembly.png" />
388-
<div>Fig 4.1.2 Register assembly.</div>
389426
</div>
390427
<br />
391428

@@ -395,23 +432,20 @@ In this section, we demonstrate an http utility. After we set up and integrate t
395432

396433
<div style="text-align: center;" id="add-utility">
397434
<img src="assets/add-utility.png" />
398-
<div>Fig 5.1.1 Add http utility in Chatbot.</div>
399435
</div>
400436
<br />
401437

402438
Once we add the utility, we can initialize a conversation by clicking the bot icon at the top left corner. [Fig 5.1.2](#chat-window-demo) shows the conversation window, where we can find the number of utilities at the left panel. We can also click the agent name to go back to the agent page.
403439

404440
<div style="text-align: center;" id="chat-window-demo">
405441
<img src="assets/chat-window-demo.png" />
406-
<div>Fig 5.1.2 Chat window with Chatbot and http utility.</div>
407442
</div>
408443
<br />
409444

410445
Here we use dummy rest APIs (source: https://dummy.restapiexample.com/) for the demo purpose. [Fig 5.1.3](#dummy-http) displays the various http requests sent in the conversation with “Chatbot”. We can see that the “Http Handler” utility has successfully extends the agent to send http request and receive response.
411446

412447
<div style="text-align: center;" id="dummy-http">
413448
<img src="assets/dummy-http.png" />
414-
<div>Fig 5.1.3 Send dummy http requests.</div>
415449
</div>
416450
<br />
417451

0 commit comments

Comments
 (0)