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: src/game_sdk/hosted_game/README.md
+10-57Lines changed: 10 additions & 57 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,12 +3,11 @@
3
3
This is a Python SDK for the Virtuals Twitter Agent. It allows you to configure and deploy agents that can interact with the Twitter/X platform. This SDK/API allows you to configure your agents powered by the GAME architecture. This is similar to configuring your agent in the [Agent Sandbox](https://game-lite.virtuals.io/) on the [Virtuals Platform](https://app.virtuals.io/).
4
4
5
5
## Create an API key
6
-
7
6
Open the [Virtuals Platform](https://app.virtuals.io/) and create/get an API key from the Agent Sandbox by clicking `SDK/API Access`
8
7
9
8

10
9
11
-
Store the key in a safe location, like a `.bashrc` or a `.zshrc` file.
10
+
Store the key in a safe location, like a `.bashrc` or a `.zshrc` file.
Alternatively, you can also use a `.env` file ([`python-dotenv` package](https://github.com/theskumar/python-dotenv) to store and load the key) if you are using the Virtuals Python SDK.
18
17
19
18
## Usage (GAME)
20
-
21
19
The Virtuals SDK current main functionalities are to develop and configure agents powered by GAME. Other functionalities to interact with the Virtuals Platform will be supported in the future. This GAME SDK can be used for multiple use cases:
22
20
23
21
1. Develop, evaluate and update the existing Agent in Twitter environment.
24
-
2. Build on other platforms and application using GAME (Task-based Agent).
22
+
2. Build on other platforms and application using GAME (Task-based Agent).
25
23
26
24
### Update the existing Agent in Twitter environment
27
-
28
25
The SDK provides another interface to configure agents that is more friendly to developers rather than through a UI. This is similar to configuring your agent in the [Agent Sandbox](https://game-lite.virtuals.io/).
29
26
30
27
```python
31
28
from game_sdk.hosted_game.agent import Agent
32
29
33
-
34
-
35
30
# Create agent with just strings for each component
36
-
> [!NOTE]
37
-
> {{replyCount}} is a variable that will be replaced with the number of replies made by the agent. Only applicable for task_description.
38
-
39
31
agent = Agent(
40
32
api_key=VIRTUALS_API_KEY,
41
33
goal="Autonomously analyze crypto markets and provide trading insights",
42
34
description="HODL-9000: A meme-loving trading bot powered by hopium and ramen",
43
-
world_info="Virtual crypto trading environment where 1 DOGE = 1 DOGE",
44
-
task_description="Process incoming tweet. Ignore if it is boring or unimportant. Total replies made: {{replyCount}}. Ignore if the conversation has gone too long."
35
+
world_info="Virtual crypto trading environment where 1 DOGE = 1 DOGE"
45
36
)
46
37
```
47
-
48
-
You can also initialize the agent first with just the API key andset the goals, descriptions and world information separately and check the current agent descriptions if needed.
38
+
You can also initialize the agent first with just the API key and set the goals, descriptions and world information separately and check the current agent descriptions if needed.
49
39
50
40
```python
51
41
agent = Agent(api_key=VIRTUALS_API_KEY)
52
42
53
-
# check what is current goal, descriptions, world_info and task_description
43
+
# check what is current goal, descriptionsand world_info
54
44
agent.get_goal()
55
45
agent.get_description()
56
46
agent.get_world_info()
57
-
agent.get_task_description()
58
47
59
-
# Set components individually - set change the agent goal/description/worldinfo/task_description
48
+
# Set components individually - set change the agent goal/description/worldinfo
60
49
agent.set_goal("Autonomously analyze crypto markets and provide trading insights")
61
50
agent.set_description("HODL-9000: A meme-loving trading bot powered by hopium and ramen")
62
51
agent.set_world_info("Virtual crypto trading environment where 1 DOGE = 1 DOGE")
63
-
agent.set_task_description("Process incoming tweet. Ignore if it is boring or unimportant. Total replies made: {{replyCount}}. Ignore if the conversation has gone too long.")
64
52
65
-
# check what is current goal, descriptions, world_info and task_description
53
+
# check what is current goal, descriptionsand world_info
66
54
agent.get_goal()
67
55
agent.get_description()
68
56
agent.get_world_info()
69
-
agent.get_task_description()
70
-
71
-
# Set heartbeat
72
-
agent.set_main_heartbeat(15)
73
-
agent.set_reaction_heartbeat(5)
74
-
75
-
# check what is current heartbeat
76
-
agent.get_main_heartbeat()
77
-
agent.get_reaction_heartbeat()
78
-
```
79
-
80
-
### Worker
81
-
82
-
You can add a worker to the agent. This is useful if you want to run a function on a specific worker.
83
-
84
-
```python
85
-
agent.add_worker(Worker(name="worker-twitter", description="worker for twitter", environment={"NODE_ENV": "production"}))
86
57
```
87
58
88
59
### Functions
89
-
90
60
By default, there are no functions enabled when the agent is initialized (i.e. the agent has no actions/functions it can execute). There are a list of available and provided functions for the Twitter/X platform and you can set them.
You can then equip the agent with some custom functions. Because the agent is hosted, custom functions need to be wrapped in API calls and can then be defined as follows:
worker= Worker( # you can link a worker to the function
121
-
name="worker custom search internet",
122
-
description="worker for custom search internet",
123
-
environment={"NODE_ENV": "production"}
124
-
)
125
89
)
126
90
127
91
# adding custom functions only for platform twitter
128
92
agent.add_custom_function(search_function)
129
93
```
130
94
131
95
### Evaluate with Simulate, Deploy
132
-
133
96
You can simulate one step of the agentic loop on Twitter/X with your new configurations and see the outputs. This is similar to the simulate button on the [Agent Sandbox](https://game-lite.virtuals.io/).
134
97
135
98
```python
136
99
# Simulate one step of the full agentic loop on Twitter/X from the HLP -> LLP -> action (NOTE: supported for Twitter/X only now)
To more realistically simulate deployment, you can also run through the simulate function with the same session id for a number of steps.
141
103
142
104
```python
@@ -156,15 +118,13 @@ response = agent.react(
156
118
```
157
119
158
120
Once you are happy, `deploy_twitter` will push your agent configurations to production and run your agent on Twitter/X autonomously.
159
-
160
121
```python
161
122
# deploy agent! (NOTE: supported for Twitter/X only now)
162
123
agent.deploy_twitter()
163
124
```
164
125
165
126
## Build on other platforms using GAME
166
-
167
-
`simulate_twitter`and`deploy_twitter` runs through the entire GAME stack fromHLP → LLP→ action/function selected. However, these agent functionalities are currently for the Twitter/X platform. You may utilize Task-based Agent with Low-Level Planner and Reaction Module to develop applications that are powered by GAME. The Low Level Planner (LLP) of the agent (please see [documentation](https://www.notion.so/1592d2a429e98016b389ea26b53686a3?pvs=21) for more details on GAMEandLLP) can separately act as a decision making engine based on a task description and event occurring. This agentic architecture is simpler but also sufficient for many applications.
127
+
`simulate_twitter` and `deploy_twitter` runs through the entire GAME stack from HLP → LLP→ action/function selected. However, these agent functionalities are currently for the Twitter/X platform. You may utilize Task-based Agent with Low-Level Planner and Reaction Module to develop applications that are powered by GAME. The Low Level Planner (LLP) of the agent (please see [documentation](https://www.notion.so/1592d2a429e98016b389ea26b53686a3?pvs=21) for more details on GAME and LLP) can separately act as a decision making engine based on a task description and event occurring. This agentic architecture is simpler but also sufficient for many applications.
168
128
169
129
We are releasing this simpler setup as a more generalised/platform agnostic framework (not specific to Twitter/X). The entire GAME stack along with the HLP will be opened up to be fully configurable and platform agnostic in the coming weeks.
170
130
@@ -190,23 +150,19 @@ response = agent.react(
190
150
## Arguments Definition
191
151
192
152
### Session ID
193
-
194
-
The session IDis an identifier for an instance of the agent. When using the same session ID, it maintains and picks up from where it last left off, continuing the session/instance. It should be split per user/ conversation that you are maintaining on your platform. For different platforms, different session ID can be used.
153
+
The session ID is an identifier for an instance of the agent. When using the same session ID, it maintains and picks up from where it last left off, continuing the session/instance. It should be split per user/ conversation that you are maintaining on your platform. For different platforms, different session ID can be used.
195
154
196
155
### Platform Tag
197
-
198
156
When adding custom functions, and when calling the react agent (i.e. LLP), there is a platform tag that can be defined. This acts like a filter for the functions available that is passed to the agent. You should define the platform when passing in the events.
199
157
200
158
### Task Description
201
-
202
159
Task description serves as the prompt for the agent to respond. Since the reaction can be platform-based, you can define task description based on the platforms. In the task description, you should pass in any related info that require agent to make decision. That should include:
203
-
204
160
- User message
205
161
- Conversation history
206
162
- Instructions
207
163
208
-
## Importing Functions and Sharing Functions
209
164
165
+
## Importing Functions and Sharing Functions
210
166
With this SDK and function structure, importing and sharing functions is also possible. Looking forward to all the different contributions and functionalities we will build together as a community!
0 commit comments