Skip to content

Commit 0d67cf6

Browse files
committed
Update read me
1 parent 2530336 commit 0d67cf6

1 file changed

Lines changed: 57 additions & 10 deletions

File tree

src/game_sdk/hosted_game/README.md

Lines changed: 57 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
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/).
44

55
## Create an API key
6+
67
Open the [Virtuals Platform](https://app.virtuals.io/) and create/get an API key from the Agent Sandbox by clicking `SDK/API Access`
78

89
![getGAMEApi](./../../../docs/imgs/accesskey.jpg)
910

10-
Store the key in a safe location, like a `.bashrc` or a `.zshrc` file.
11+
Store the key in a safe location, like a `.bashrc` or a `.zshrc` file.
1112

1213
```bash
1314
export VIRTUALS_API_KEY="your_virtuals_api_key"
@@ -16,47 +17,76 @@ export VIRTUALS_API_KEY="your_virtuals_api_key"
1617
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.
1718

1819
## Usage (GAME)
20+
1921
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:
2022

2123
1. Develop, evaluate and update the existing Agent in Twitter environment.
22-
2. Build on other platforms and application using GAME (Task-based Agent).
24+
2. Build on other platforms and application using GAME (Task-based Agent).
2325

2426
### Update the existing Agent in Twitter environment
27+
2528
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/).
2629

2730
```python
2831
from game_sdk.hosted_game.agent import Agent
2932

33+
34+
3035
# 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+
3139
agent = Agent(
3240
api_key=VIRTUALS_API_KEY,
3341
goal="Autonomously analyze crypto markets and provide trading insights",
3442
description="HODL-9000: A meme-loving trading bot powered by hopium and ramen",
35-
world_info="Virtual crypto trading environment where 1 DOGE = 1 DOGE"
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."
3645
)
3746
```
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.
47+
48+
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.
3949

4050
```python
4151
agent = Agent(api_key=VIRTUALS_API_KEY)
4252

43-
# check what is current goal, descriptions and world_info
53+
# check what is current goal, descriptions, world_info and task_description
4454
agent.get_goal()
4555
agent.get_description()
4656
agent.get_world_info()
57+
agent.get_task_description()
4758

48-
# Set components individually - set change the agent goal/description/worldinfo
59+
# Set components individually - set change the agent goal/description/worldinfo/task_description
4960
agent.set_goal("Autonomously analyze crypto markets and provide trading insights")
5061
agent.set_description("HODL-9000: A meme-loving trading bot powered by hopium and ramen")
5162
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.")
5264

53-
# check what is current goal, descriptions and world_info
65+
# check what is current goal, descriptions, world_info and task_description
5466
agent.get_goal()
5567
agent.get_description()
5668
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"}))
5786
```
5887

5988
### Functions
89+
6090
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.
6191

6292
```python
@@ -67,6 +97,7 @@ agent.use_default_twitter_functions(["wait", "reply_tweet"])
6797
```
6898

6999
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:
100+
70101
```python
71102

72103
search_function = game.Function(
@@ -86,19 +117,26 @@ search_function = game.Function(
86117
success_feedback="I found the best songs",
87118
error_feedback="I couldn't find the best songs",
88119
)
120+
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+
)
89125
)
90126

91127
# adding custom functions only for platform twitter
92128
agent.add_custom_function(search_function)
93129
```
94130

95131
### Evaluate with Simulate, Deploy
132+
96133
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/).
97134

98135
```python
99136
# Simulate one step of the full agentic loop on Twitter/X from the HLP -> LLP -> action (NOTE: supported for Twitter/X only now)
100137
response = agent.simulate_twitter(session_id="123")
101138
```
139+
102140
To more realistically simulate deployment, you can also run through the simulate function with the same session id for a number of steps.
103141

104142
```python
@@ -118,13 +156,15 @@ response = agent.react(
118156
```
119157

120158
Once you are happy, `deploy_twitter` will push your agent configurations to production and run your agent on Twitter/X autonomously.
159+
121160
```python
122161
# deploy agent! (NOTE: supported for Twitter/X only now)
123162
agent.deploy_twitter()
124163
```
125164

126165
## Build on other platforms using GAME
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.
166+
167+
`simulate_twitter` and `deploy_twitter` runs through the entire GAME stack from HLPLLP→ 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.
128168

129169
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.
130170

@@ -150,19 +190,23 @@ response = agent.react(
150190
## Arguments Definition
151191

152192
### Session ID
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.
193+
194+
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.
154195

155196
### Platform Tag
197+
156198
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.
157199

158200
### Task Description
201+
159202
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+
160204
- User message
161205
- Conversation history
162206
- Instructions
163207

164-
165208
## Importing Functions and Sharing Functions
209+
166210
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!
167211

168212
```python
@@ -186,4 +230,7 @@ pin_message_fn("xxxxxxxx", "xx", "True")
186230
agent.add_custom_function(reply_message_fn)
187231
agent.add_custom_function(create_poll_fn)
188232
agent.add_custom_function(pin_message_fn)
233+
234+
# reset memory
235+
agent.reset_memory()
189236
```

0 commit comments

Comments
 (0)