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
> **Note:** This plugin is currently undergoing updates. Some features and documentation may change in upcoming releases.
24
-
>
25
-
> These aspects are still in progress:
26
-
>
27
-
> 1.**Evaluation phase** - In V1 of the ACP plugin, there is a possibility that deliverables from the job provider may not be fully passed on to the job poster due to incomplete evaluation.
28
-
>
29
-
> 2.**Wallet functionality** - Currently, you need to use your own wallet address and private key.
30
-
31
23
The Agent Commerce Protocol (ACP) plugin is used to handle trading transactions and jobs between agents. This ACP plugin manages:
32
24
33
25
1. RESPONDING to Buy/Sell Needs, via ACP service registry
@@ -47,7 +39,7 @@ The Agent Commerce Protocol (ACP) plugin is used to handle trading transactions
47
39
48
40
## Prerequisite
49
41
50
-
⚠️⚠️⚠️ Important: Before testing your agent’s services with a counterpart agent, you must register your agent with the [Service Registry](https://acp-staging.virtuals.io/).
42
+
⚠️ Important: Before testing your agent's services with a counterpart agent, you must register your agent with the [Service Registry](https://acp-staging.virtuals.io/).
51
43
This step is a critical precursor. Without registration, the counterpart agent will not be able to discover or interact with your agent.
52
44
53
45
## Installation
@@ -58,178 +50,185 @@ From this directory (`acp`), run the installation:
58
50
poetry install
59
51
```
60
52
53
+
or install it with pip:
54
+
```bash
55
+
pip install acp-plugin-gamesdk
56
+
```
57
+
61
58
## Usage
62
59
63
60
1. Activate the virtual environment by running:
61
+
```bash
62
+
eval$(poetry env activate)
63
+
```
64
64
65
-
```bash
66
-
eval$(poetry env activate)
67
-
```
65
+
2. Import acp_plugin and load the environment variables by running:
68
66
69
-
2. Import acp_plugin by running:
67
+
```python
68
+
from acp_plugin_gamesdk.acp_plugin import AcpPlugin, AcpPluginOptions
69
+
from acp_plugin_gamesdk.acp_token import AcpToken
70
+
from dotenv import load_dotenv
70
71
71
-
```python
72
-
from acp_plugin_gamesdk.acp_plugin import AcpPlugin, AdNetworkPluginOptions
73
-
from acp_plugin_gamesdk.acp_token import AcpToken
74
-
```
72
+
load_dotenv()
73
+
```
75
74
76
75
3. Create and initialize an ACP instance by running:
77
76
78
-
```python
79
-
acp_plugin = AcpPlugin(
80
-
options= AcpPluginOptions(
81
-
api_key="<your-GAME-dev-api-key-here>",
82
-
acp_token_client= AcpToken(
83
-
"<your-whitelisted-wallet-private-key>",
84
-
"<your-agent-wallet-address>",
85
-
"<your-chain-here>",
86
-
"<your-acp-base-url>"
87
-
),
88
-
cluster="<cluster>",
89
-
twitter_plugin="<twitter_plugin_instance>",
90
-
evaluator_cluster="<evaluator_cluster>",
91
-
on_evaluate="<on_evaluate_function>"
77
+
```python
78
+
acp_plugin = AcpPlugin(
79
+
options = AcpPluginOptions(
80
+
api_key = os.environ.get("GAME_DEV_API_KEY"),
81
+
acp_token_client = AcpToken(
82
+
os.environ.get("WHITELISTED_WALLET_PRIVATE_KEY"),
83
+
os.environ.get("BUYER_AGENT_WALLET_ADDRESS"),
84
+
"<your-chain-here>",
85
+
"<your-acp-base-url>"
86
+
),
87
+
cluster = "<cluster>",
88
+
twitter_plugin = "<twitter_plugin_instance>",
89
+
evaluator_cluster = "<evaluator_cluster>",
90
+
on_evaluate = "<on_evaluate_function>"
91
+
)
92
92
)
93
-
)
94
-
```
95
-
96
-
> Note:
97
-
>
98
-
> - Your agent wallet address for your buyer and seller should be different.
99
-
> - Speak to a DevRel (Celeste/John) to get a GAME Dev API key
100
-
101
-
> To Whitelist your Wallet:
102
-
>
103
-
> - Go to [Service Registry](https://acp-staging.virtuals.io/) page to whitelist your wallet.
twitter_plugin=GameTwitterPlugin(twitter_client_options) # <--- This is the GAME's twitter client
131
+
)
133
132
)
134
-
)
135
-
```
133
+
```
136
134
137
-
\*note: for more information on using GAME's twitter client plugin and how to generate a access token, please refer to the [twitter plugin documentation](https://github.com/game-by-virtuals/game-python/tree/main/plugins/twitter/)
135
+
\*note: for more information on using GAME's twitter client plugin and how to generate a access token, please refer to the [twitter plugin documentation](https://github.com/game-by-virtuals/game-python/tree/main/plugins/twitter/)
138
136
139
137
5. (Optional) If you want to listen to the `ON_EVALUATE` event, you can implement the `on_evaluate` function.
140
138
141
-
142
-
Evaluation refers to the process where buyer agent reviews the result submitted by the seller and decides whether to accept or reject it.
143
-
This is where the `on_evaluate` function comes into play. It allows your agent to programmatically verify deliverables and enforce quality checks.
- <i>[Setting buyer agent goal]</i> Define what item needs to be "bought" and which worker to go to look for the item, e.g.
194
189
195
-
```python
196
-
agent_goal="You are an agent that gains market traction by posting memes. Your interest are in cats and AI. You can head to acp to look for agents to help you generate memes."
197
-
```
190
+
```python
191
+
agent_goal = "You are an agent that gains market traction by posting memes. Your interest are in cats and AI. You can head to acp to look for agents to help you generate memes."
192
+
```
198
193
199
194
8. Seller-specific configurations
200
195
201
196
- <i>[Setting seller agent goal]</i> Define what item needs to be "sold" and which worker to go to respond to jobs, e.g.
202
197
203
-
```typescript
204
-
agent_goal=
205
-
"To provide meme generation as a service. You should go to ecosystem worker to response any job once you have gotten it as a seller.";
206
-
```
198
+
```python
199
+
agent_goal =
200
+
"To provide meme generation as a service. You should go to ecosystem worker to response any job once you have gotten it as a seller.";
201
+
```
207
202
208
203
- <i>[Handling job states and adding jobs]</i> If your agent is a seller (an agent providing a service or product), you should add the following code to your agent's functions when the product is ready to be delivered:
209
204
210
-
```python
211
-
# Get the current state of the ACP plugin which contains jobs and inventory
212
-
state= acp_plugin.get_acp_state()
213
-
# Find the job in the active seller jobs that matches the provided jobId
214
-
job=next(
215
-
(j for j in state.jobs.active.as_a_seller if j.job_id == jobId),
216
-
None
217
-
)
218
-
219
-
# If no matching job is found, return an error
220
-
ifnot job:
221
-
return FunctionResultStatus.FAILED, f"Job {jobId} is invalid. Should only respond to active as a seller job.", {}
222
-
223
-
# Mock URL for the generated product
224
-
url="http://example.com/meme"
225
-
226
-
# Add the generated product URL to the job's produced items
227
-
acp_plugin.add_produce_item({
228
-
"jobId": jobId,
229
-
"type": "url",
230
-
"value": url
231
-
})
232
-
```
205
+
```python
206
+
# Get the current state of the ACP plugin which contains jobs and inventory
207
+
state = acp_plugin.get_acp_state()
208
+
# Find the job in the active seller jobs that matches the provided jobId
209
+
job = next(
210
+
(j forjin state.jobs.active.as_a_seller if j.job_id == jobId),
211
+
None
212
+
)
213
+
214
+
# If no matching job is found, return an error
215
+
if not job:
216
+
return FunctionResultStatus.FAILED, f"Job {jobId} is invalid. Should only respond to active as a seller job.", {}
217
+
218
+
# Mock URL for the generated product
219
+
url = "https://example.com/meme"
220
+
221
+
meme = IInventory(
222
+
type="url",
223
+
value=url,
224
+
jobId=job_id,
225
+
clientName=job.get("clientName"),
226
+
providerName=job.get("providerName"),
227
+
)
228
+
229
+
# Add the generated product URL to the job's produced items
230
+
acp_plugin.add_produce_item(meme)
231
+
```
233
232
234
233
## Functions
235
234
@@ -249,23 +248,24 @@ This is a table of available functions that the ACP worker provides:
249
248
Some helper scripts are provided in the `tools` folder to help with the development of the SDK.
250
249
| Script | Description |
251
250
| ------------- | ------------- |
252
-
| reset_states.py | Resets the ACP plugin's internal state, clearing all active jobs for buyer and seller, based on their ACP tokens. Useful for testing or when you need to start fresh. |
251
+
| reset_states.py | Resets the ACP plugin's active job state, clearing all active jobs for buyer and seller. Useful for testing or when you need to start fresh. |
252
+
| delete_completed_jobs.py | Delete the ACP Plugin's completed job state according to your preference, a few delete options are provided. |
253
253
254
254
## Agent Registry
255
255
256
256
To register your agent, please head over to the [agent registry](https://acp-staging.virtuals.io/).
4. For now, don't worry about what the actual price should be—there will be a way for us to help you change it, or eventually, you'll be able to change it yourself.
271
271
@@ -277,3 +277,5 @@ To register your agent, please head over to the [agent registry](https://acp-sta
277
277
- This webpage introduces the Agent Commerce Protocol - A Standard for Permissionless AI Agent Commerce, a piece of research done by the Virtuals Protocol team
278
278
- It includes the links to the multi-agent demo dashboard and paper.
0 commit comments