You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/pages/semantic_sdk/io_mapper.md
+296-44
Original file line number
Diff line number
Diff line change
@@ -31,6 +31,8 @@ The IO mapper Agent can be fed the schema definitions of inputs and outputs as d
31
31
To get a local copy up and running follow these simple steps.
32
32
33
33
### Prerequisites
34
+
-[Poetry](https://python-poetry.org/)
35
+
-[cmake](https://cmake.org/)
34
36
35
37
### Installation
36
38
@@ -60,42 +62,13 @@ This project supports specifying model interations using [LangGraph](https://lan
60
62
61
63
## How to use the Agent IO mapping
62
64
:warning:<b> For each example, the detailed process of creating agents and configuring the respective multi-agent software is omitted. Instead, only the essential steps for configuring and integrating the IO mapper agent are presented.</b>
63
-
### LangGraph Example 1
64
-
65
-
This example involves a multi-agent software system designed to process a create engagement campaign and share within an organization. It interacts with an agent specialized in creating campaigns, another agent specialized in identifying suitable users. The information is then relayed to an IO mapper, which converts the list of users and the campaign details to present statistics about the campaign.
The above instruction directs the IO mapper agent to utilize the `selected_users` and `name` from the `campaign_details` field and map them to the `stats.status`. No further information is needed since the type information can be derived from the input data which is a pydantic model.
65
+
## LangGraph
66
+
We support usages with both LangGraph state defined with TypedDict or as a Pydantic object
78
67
79
-
:information_source: <i>Both input_fields and output_fields can also be sourced with a list composed of str and/or instances of FieldMetadata as the bellow example shows</i>:
80
-
81
-
```python
82
-
metadata = IOMappingAgentMetadata(
83
-
input_fields=[
84
-
FieldMetadata(
85
-
json_path="selected_users", description="A list of users to be targeted"
86
-
),
87
-
FieldMetadata(
88
-
json_path="campaign_details.name",
89
-
description="The name that can be used by the campaign",
90
-
examples=["Campaign A"]
91
-
),
92
-
],
93
-
output_fields=["stats"],
94
-
)
95
-
```
68
+
### Entities
96
69
97
70
<details>
98
-
<summary><h4>Expand to better understand the IOMappingAgentMetadata Interface</h4></summary>
<summary>Expand for explanation of interface for IOMappingAgent model</summary>
138
+
<summary><h4>IOMappingAgent</h4></summary>
172
139
173
140
## IOMappingAgent model
174
141
<table>
@@ -222,6 +189,48 @@ IOMappingAgentMetadata(
222
189
</table>
223
190
</details>
224
191
192
+
### LangGraph Example 1
193
+
194
+
This example involves a multi-agent software system designed to process a create engagement campaign and share within an organization. It interacts with an agent specialized in creating campaigns, another agent specialized in identifying suitable users. The information is then relayed to an IO mapper, which converts the list of users and the campaign details to present statistics about the campaign.
The above instruction directs the IO mapper agent to utilize the `selected_users` and `name` from the `campaign_details` field and map them to the `stats.status`. No further information is needed since the type information can be derived from the input data which is a pydantic model.
207
+
208
+
:information_source: <i>Both input_fields and output_fields can also be sourced with a list composed of str and/or instances of FieldMetadata as the bellow example shows</i>:
209
+
210
+
```python
211
+
metadata = IOMappingAgentMetadata(
212
+
input_fields=[
213
+
FieldMetadata(
214
+
json_path="selected_users", description="A list of users to be targeted"
215
+
),
216
+
FieldMetadata(
217
+
json_path="campaign_details.name",
218
+
description="The name that can be used by the campaign",
#define an instance of config with must have an llm instance
467
+
config = LLamaIndexIOMapperConfig(llm=llm)
468
+
469
+
# Finally return define and return the IOMappingInputEvent
470
+
io_mapping_input_event = IOMappingInputEvent(
471
+
metadata=metadata,
472
+
config=config,
473
+
data=OverallState(
474
+
campaign_details=campaign_details,
475
+
selected_users=ev.list_users,
476
+
),
477
+
)
478
+
return io_mapping_input_event
479
+
```
480
+
481
+
#### Add The IO mapper step
482
+
483
+
```python
484
+
w = CampaignWorkflow()
485
+
486
+
IOMappingAgent.as_worfklow_step(workflow=w)
487
+
```
488
+
489
+
### Example of usage in a LlamaIndex AgentWorkflow
490
+
491
+
In this example we recreate the recipe workflow using [LlamaIndex workflow]([https://docs.llamaindex.ai/en/stable/module_guides/workflow/](https://docs.llamaindex.ai/en/stable/examples/agent/agent_workflow_multi/))
492
+
493
+
#### Import the necessary objects
494
+
```python
495
+
from agntcy_iomapper import FieldMetadata, IOMappingAgent, IOMappingAgentMetadata
496
+
```
497
+
498
+
#### Define an instance of the IOMappingAgentMetadata
499
+
500
+
```python
501
+
mapping_metadata = IOMappingAgentMetadata(
502
+
input_fields=["documents.0.text"],
503
+
output_fields=[
504
+
FieldMetadata(
505
+
json_path="recipe",
506
+
description="this is a recipe for the ingredients you've provided",
0 commit comments