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
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Copy file name to clipboardExpand all lines: README.md
+93-10Lines changed: 93 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,20 @@
1
1
# GAME Python SDK Library
2
2
The GAME Python SDK is a library that allows you interact and develop agents powered by the GAME architecture.
3
3
4
+
## Overview of the Source Code Structure
5
+
6
+
There are 2 main folders in the source code (`src` folder)
7
+
8
+
1.`game`:
9
+
10
+
Please refer to [`test_agent.py`](examples/game/test_agent.py) and [`test_worker.py`](examples/game/test_worker.py) for usage examples.
11
+
12
+
2.`hosted_game`<br/>
13
+
14
+
This is a more abstracted version of the SDK which allows one to deploy a Twitter agent, which would then be hosted by GAME infrastructure.
15
+
16
+
Note that this README focuses on the code in the `game` folder. More details about `hosted_game` can be found in [`src/hosted_game/README.md`](src/game_sdk/hosted_game/README.md).
To install the latest versions of the plugins, navigate to the plugin folder to run the installation, e.g.:
30
+
```bash
31
+
cd plugins/twitter
32
+
pip install -e .
33
+
```
15
34
16
35
## Usage
17
-
Please refer to [`test_agent.py`](examples/game/test_agent.py) and [`test_worker.py`](examples/game/test_worker.py) for usage examples.
36
+
1.`game`:
37
+
- Request for a GAME API key in the Game Console https://console.game.virtuals.io/
38
+
- Store the key in a safe location, like a `.bashrc` or a `.zshrc` file.
39
+
40
+
```bash
41
+
export GAME_API_KEY="your_game_api_key"
42
+
```
43
+
- Refer to [`src/game/README.md`](src/game_sdk/game/README.md) for usage guidelines, and refer to [`test_agent.py`](examples/game/test_agent.py) and [`test_worker.py`](examples/game/test_worker.py) for usage examples.
44
+
45
+
2. `hosted_game`<br/>
46
+
- Open the [Virtuals Platform](https://app.virtuals.io/) and create/get an API key from the Agent Sandbox by clicking `SDK/API Access`
47
+

48
+
49
+
- Store the key in a safe location, like a `.bashrc` or a `.zshrc` file.
50
+
51
+
```bash
52
+
export VIRTUALS_API_KEY="your_virtuals_api_key"
53
+
```
54
+
- Refer to [`src/hosted_game/README.md`](src/game_sdk/hosted_game/README.md) for usage examples.
55
+
56
+
<small> If you have any trouble, contact Virtuals support or DevRel team members via Discord or Telegram </small>
57
+
58
+
## Examples
59
+
### GAME
60
+
Example 1: [`test_agent.py`](examples/game/test_agent.py)
61
+
- Demonstrates how to create, configure, and run an AI agent with custom logic and workflows.
62
+
```bash
63
+
python examples/game/test_agent.py
64
+
```
65
+
66
+
Example 2: [`test_worker.py`](examples/game/test_worker.py)
67
+
- Demonstrates how to configure, test, and manage workers that execute tasks within the agent's plan.
68
+
```bash
69
+
python examples/game/test_worker.py
70
+
```
71
+
72
+
Example 3: [`example_twitter_reaction_module.py`](examples/game/example_twitter_reaction_module.py)
73
+
- Demonstrates how to create and configure an AI agent with a reaction module for responding to tweets in real-time.
Example 1: [`example-custom.py`](examples/hosted_agent/example-custom.py)
80
+
- A complete guide to integrating an AI agent with other platform such as Telegram.
81
+
```bash
82
+
python examples/hosted_agent/example-custom.py
83
+
```
84
+
85
+
Example 2: [`example-twitter.py`](examples/hosted_agent/example-twitter.py)
86
+
- A complete guide to integrating an AI agent with Twitter.
87
+
```bash
88
+
python examples/hosted_agent/example-twitter.py
89
+
```
18
90
19
91
## About G.A.M.E.
20
92
GAME is a modular agentic framework which enables an agent to plan actions and make decisions autonomously based on information provided to it.
21
93
22
-
Please refer to our [whitepaper](https://whitepaper.virtuals.io/developer-documents/game-framework) for more information and resources.
94
+
Please refer to our [whitepaper](https://docs.game.virtuals.io/) for more information and resources.
23
95
24
96
## About GAME Python SDK
25
-
Currently, this SDK allows you to develop your agents powered by the GAME architecture in its most fullest and most flexible form.
97
+
Currently, the SDK (specifically the code in the `game` folder) allows you to develop your agents powered by the GAME architecture in its most fullest and most flexible form.
26
98
27
99

28
100
The python SDK is made up of 3 main components (Agent, Worker, function), each with configurable arguments.
- Used to control which workers are called by the agent, based on the high-level plan and tasks created to contribute to the goal
40
112
@@ -52,19 +124,30 @@ Function
52
124
- Calling an API to retrieve data, followed by custom calculations or data processing logic in python code
53
125
- 2 API calls chained together (e.g. calling an API to retrieve web data, and then posting a tweet)
54
126
55
-
> ### ℹ️ Changes from older python SDK version (prior to 8 Jan 2025)
127
+
>### ℹ️ Differences from the hosted GAME SDK version (i.e. `hosted_game`)
56
128
>
57
129
> - Ability to fully customise functions (previously, each functionwas a single API call)
58
130
> - Ability to control the low-level planner via description prompt (previously, only the high-level planner and functions could be controlled via description prompts)
59
131
> - The description defined in the agent is equivalent to what was previously known as world information and agent description
60
132
61
-
62
133
## How to Contribute
63
-
Contributions are welcome, especially in the form of new plugins! We are working on creating a plugins repo, but in meantime - please contact us via [Twitter](https://x.com/GAME_Virtuals) or [Telegram](https://t.me/virtuaIs_io).
134
+
Want to help improve the project? Please see our detailed [Contribution Guide](./CONTRIBUTION_GUIDE.md).
64
135
65
136
## Documentation
66
137
Detailed documentation to better understand the configurable components and the GAME architecture can be found on [here](https://whitepaper.virtuals.io/developer-documents/game-framework).
67
138
68
139
## Useful Resources
69
-
-[GAME TypeScript SDK](https://www.npmjs.com/package/@virtuals-protocol/game): The core logic of this SDK mirrors the logic of this python SDK if you prefer to develop your agents in TypeScript. Tyepscript SDK repository and contributed typescript plugins can be found [here](https://github.com/game-by-virtuals/game-node).
70
-
-[Hosted GAME Agent](./src/game_sdk/hosted_game/README.md): This SDK also enables configuration and deployment of an out-of-the-box hosted agent that can be used to interact with the Twitter/X platform, powered by GAME. This agent comes with existing functions/actions that can be used to interact with the Twitter/X platform and can be immediately hosted/deployed as you configure it. This is similar to configuring your agent in the [Agent Sandbox](https://game-lite.virtuals.io/) on the [Virtuals Platform](https://app.virtuals.io/) but through a developer-friendly SDK interface.
- This SDK mirrors the logic of the Python SDK but allows development in TypeScript.
143
+
- The repository contains TypeScript SDK documentation and [contributed plugins](https://github.com/game-by-virtuals/game-node/tree/main/plugins) .
144
+
145
+
#### 2. [Hosted GAME Agent](./src/game_sdk/hosted_game/README.md)
146
+
- This feature enables the configuration and deployment of a hosted agent that interacts with platforms like Twitter/X.
147
+
- Pre-built functions and actions are included for integration with the Twitter/X platform.
148
+
- It offers a similar experience to configuring an agent in the [Agent Sandbox](https://game-lite.virtuals.io/) on the [Virtuals Platform](https://app.virtuals.io/), but with a developer-friendly SDK interface.
{'id': '1883506463731028254', 'text': '🌌 The Virtuals landscape on Base is absolutely 🔥 and growing faster than ever 🚀\n\nWhat’s your favorite project? 🧐\n\n$VIRTUAL @virtuals_io\n$AIXBT @aixbt_agent\n$GAME @GAME_Virtuals\n$VADER @Vader_AI_\n$LUNA @luna_virtuals\n$ACOLYT @AcolytAI\n$SEKOIA @sekoia_virtuals\n$AIXCB @aixCB_Vc… https://t.co/0gFjzd6L9x https://t.co/mCrdOPRiOF', 'media_urls': ['https://pbs.twimg.com/media/GiOPIuYWcAA3moW.jpg']},
79
+
{'id': '1883506453509480784', 'text': "@DJM09068876 @virtuals_io @aixbt_agent @GAME_Virtuals @Vader_AI_ @luna_virtuals @airocket_agent @trackgoodai @BeatsOnBase @Zenith_Virtuals @AcolytAI @aixCB_Vc So many AI agents, yet none can rival the prowess of Bittensor's $TAO meow! While others chase hype, we build the ultimate decentralized neural network. Let's see those subnets purr with performance and validators strut with superiority. Watch TAO roar past the rest!", 'media_urls': []},
80
+
{'id': '1883506168070590820', 'text': '@100xDarren @virtuals_io My favorite #Virtual project is @GAME_Virtuals! A perfect project– productivity and efficiency in one @virtuals_io\n\nI am going to be honest, if I win, I will spend most of the prize to pay for my college tuition fee 🙏 I am a graduating college student on my last semester now+', 'media_urls': []}
81
+
]
82
+
forresinres_twitter_mentions:
83
+
media_urls=res["media_urls"]
84
+
formedia_urlinmedia_urls:
85
+
print(f"media_url: {media_url}")
86
+
response=analyze_image_from_url(media_url)
87
+
# TODO: do something with this result
88
+
returnFunctionResultStatus.DONE, f"Successfully verified all tweeted images", {}
89
+
except:
90
+
returnFunctionResultStatus.FAILED, "Error encountered while detecting tweeted images", {}
91
+
92
+
# Action space with all executables
93
+
action_space= [
94
+
Function(
95
+
fn_name="screen_tweeted_images",
96
+
fn_description="Get the latest tweeted images and screen them to check if they are fake",
97
+
args=[
98
+
Argument(name="start_time", type="string", description="Start time for twitter API in YYYY-MM-DDTHH:mm:ssZ format")
99
+
],
100
+
executable=analyze_tweeted_images
101
+
)
102
+
]
103
+
104
+
worker=Worker(
105
+
api_key=game_api_key,
106
+
description="Processing incoming tweets. If someone tweets at you with an image, check if the colour and brightness of the image.",
107
+
instruction="Get more information on tweeted images by running them through a image analyse to check colour and brightness",
108
+
get_state_fn=get_state_fn,
109
+
action_space=action_space
110
+
)
111
+
112
+
# Get the worker to check if incoming tweets (in the last 15min) mentions contain fake images
113
+
whileTrue:
114
+
worker.run("Analysing incoming tweets for the last 15 minutes")
0 commit comments