Skip to content

Commit b6a33f4

Browse files
authored
Merge pull request game-by-virtuals#69 from stevensf1998/feat/allow-selection-of-gameEngine
Feat/allow selection of game engine
2 parents 2b4ed81 + 140279b commit b6a33f4

File tree

3 files changed

+44
-18
lines changed

3 files changed

+44
-18
lines changed

src/game_sdk/hosted_game/README.md

Lines changed: 25 additions & 6 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,12 +17,14 @@ 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
@@ -35,7 +38,8 @@ agent = Agent(
3538
world_info="Virtual crypto trading environment where 1 DOGE = 1 DOGE"
3639
)
3740
```
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.
41+
42+
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.
3943

4044
```python
4145
agent = Agent(api_key=VIRTUALS_API_KEY)
@@ -54,9 +58,15 @@ agent.set_world_info("Virtual crypto trading environment where 1 DOGE = 1 DOGE")
5458
agent.get_goal()
5559
agent.get_description()
5660
agent.get_world_info()
61+
62+
# set game engine model
63+
# Available models: llama_3_1_405b, deepseek_r1, llama_3_3_70b_instruct, qwen2p5_72b_instruct, deepseek_v3
64+
agent.set_game_engine_model("llama_3_1_405b")
65+
5766
```
5867

5968
### Functions
69+
6070
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.
6171

6272
```python
@@ -67,6 +77,7 @@ agent.use_default_twitter_functions(["wait", "reply_tweet"])
6777
```
6878

6979
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:
80+
7081
```python
7182

7283
search_function = game.Function(
@@ -93,12 +104,14 @@ agent.add_custom_function(search_function)
93104
```
94105

95106
### Evaluate with Simulate, Deploy
107+
96108
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/).
97109

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

104117
```python
@@ -118,13 +131,15 @@ response = agent.react(
118131
```
119132

120133
Once you are happy, `deploy_twitter` will push your agent configurations to production and run your agent on Twitter/X autonomously.
134+
121135
```python
122136
# deploy agent! (NOTE: supported for Twitter/X only now)
123137
agent.deploy_twitter()
124138
```
125139

126140
## 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.
141+
142+
`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.
128143

129144
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.
130145

@@ -150,19 +165,23 @@ response = agent.react(
150165
## Arguments Definition
151166

152167
### 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.
168+
169+
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.
154170

155171
### Platform Tag
172+
156173
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.
157174

158175
### Task Description
176+
159177
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:
178+
160179
- User message
161180
- Conversation history
162181
- Instructions
163182

164-
165183
## Importing Functions and Sharing Functions
184+
166185
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!
167186

168187
```python

src/game_sdk/hosted_game/agent.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,6 @@ class ContentLLMTemplate:
164164
top_p: float = 0.7
165165
repetition_penalty: float = 1.0
166166
type: str = None
167-
taskDescription: str = None
168167
isSandbox: bool = False
169168

170169
def _validate_fields(self):
@@ -190,11 +189,7 @@ def _validate_fields(self):
190189
self.type = self.template_type
191190
self.isSandbox = False
192191
self.userPrompt = self.user_prompt or ""
193-
194-
# Additional settings for REPLY only
195-
if self.template_type == "REPLY":
196-
self.taskDescription = self.taskDescription or "Process incoming tweet. Ignore if it is boring or unimportant. Ignore if the conversation has gone too long."
197-
192+
198193
elif self.template_type in ["TWITTER_START_SYSTEM_PROMPT", "TWITTER_END_SYSTEM_PROMPT", "SHARED"]:
199194
if not self.system_prompt:
200195
raise ValueError("system_prompt is required")
@@ -259,7 +254,8 @@ def __init__(
259254
world_info: str = "",
260255
main_heartbeat: int = 15,
261256
reaction_heartbeat: int = 5,
262-
task_description: str = ""
257+
task_description: str = "",
258+
game_engine_model: str = "llama_3_1_405b"
263259
):
264260
self.game_sdk = sdk.GameSDK(api_key)
265261
self.goal = goal
@@ -272,7 +268,7 @@ def __init__(
272268
self.templates: List[ContentLLMTemplate] = []
273269
self.tweet_usernames: List[str] = []
274270
self.task_description: str = task_description
275-
271+
self.game_engine_model: str = game_engine_model
276272

277273
def set_goal(self, goal: str):
278274
self.goal = goal
@@ -298,8 +294,16 @@ def set_task_description(self, task_description: str):
298294
self.task_description = task_description
299295
return True
300296

297+
def set_game_engine_model(self, game_engine_model: str):
298+
# Available models: llama_3_1_405b, deepseek_r1, llama_3_3_70b_instruct, qwen2p5_72b_instruct, deepseek_v3
299+
self.game_engine_model = game_engine_model
300+
return True
301+
301302
def get_task_description(self) -> str:
302303
return self.task_description
304+
305+
def get_game_engine_model(self) -> str:
306+
return self.game_engine_model
303307

304308
def get_goal(self) -> str:
305309
return self.goal
@@ -378,7 +382,10 @@ def deploy_twitter(self):
378382
self.enabled_functions,
379383
self.custom_functions,
380384
self.main_heartbeat,
381-
self.reaction_heartbeat
385+
self.reaction_heartbeat,
386+
self.tweet_usernames,
387+
self.templates,
388+
self.game_engine_model
382389
)
383390

384391
def export(self) -> str:

src/game_sdk/hosted_game/sdk.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def react(self, session_id: str, platform: str, goal: str,
9090

9191
return response.json()["data"]
9292

93-
def deploy(self, goal: str, description: str, world_info: str, functions: list, custom_functions: list, main_heartbeat: int, reaction_heartbeat: int, tweet_usernames: list = None, templates: list = None, task_description: str = None):
93+
def deploy(self, goal: str, description: str, world_info: str, functions: list, custom_functions: list, main_heartbeat: int, reaction_heartbeat: int, tweet_usernames: list = None, templates: list = None, game_engine_model: str = "llama_3_1_405b"):
9494
"""
9595
Simulate the agent configuration
9696
"""
@@ -104,9 +104,9 @@ def deploy(self, goal: str, description: str, world_info: str, functions: list,
104104
"mainHeartbeat": main_heartbeat,
105105
"reactionHeartbeat": reaction_heartbeat,
106106
},
107-
"taskDescription": task_description
107+
"gameEngineModel": game_engine_model
108108
}
109-
109+
110110
if tweet_usernames is not None:
111111
payload["tweetUsernames"] = tweet_usernames
112112

0 commit comments

Comments
 (0)