Skip to content

Commit 98defbf

Browse files
committed
update README and some configurations
1 parent c1c6db8 commit 98defbf

File tree

5 files changed

+47
-32
lines changed

5 files changed

+47
-32
lines changed

README.md

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ If you wish to have your applications powered by Agent using GAME, you may use G
1212

1313
Open the [Virtuals Platform](https://app.virtuals.io/) and create/get an API key from the Virtuals Sandbox by clicking “Access G.A.M.E API”
1414

15-
![getGAMEApi](/accesskey.png)
15+
![getGAMEApi](./docs/imgs/accesskey.png)
1616

1717
Store the key in a safe location, like a `.bashrc` or a `.zshrc` file.
1818

@@ -115,22 +115,27 @@ agent.add_custom_function(search_function)
115115

116116
### Evaluate with Simulate, Deploy
117117

118-
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/). Hence, when running
118+
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/).
119119

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

124-
# To more realistically simulate deployment you can
126+
```python
127+
sid = "456"
128+
num_steps = 10
129+
for i in range(num_steps):
130+
response = agent.simulate_twitter(session_id=sid)
125131
```
126132

127133
```python
128134
# Simulate response to a certain event
129135
response = agent.react(
130136
session_id="567", # string identifier that you decide
131-
task_description="",
132-
context="",
133-
platform="",
137+
tweet_id="xxxx",
138+
platform="twitter",
134139
)
135140
```
136141

@@ -150,7 +155,7 @@ We are releasing this simpler setup as a more generalised/platform agnostic fram
150155
<aside>
151156
🖥️ Low-Level Planner (LLP) as a Task-based Agent
152157

153-
![llp.png](/llp.png)
158+
![llp.png](./docs/imgs/llp.png)
154159

155160
</aside>
156161

@@ -160,15 +165,14 @@ After configuring the agent’s character card or description and setting up the
160165
# React/respond to a certain event
161166
response = agent.react(
162167
session_id="567", # string identifier that you decide
163-
task_description="",
164-
context="Hi how are you?",
168+
task_description="Be friendly and help people who talk to you. Do not be rude.",
169+
event="Hi how are you?",
165170
platform="TELEGRAM",
166171
)
167172
```
168173

169174
<aside>
170175
⚠️ Remember that the `platform` tag determines what functions are available to the agent. The agent will have access to functions that have the same `platform` tag. All the default available functions listed on `agent.list_available_default_twitter_functions()` and set via `agent.use_default_twitter_functions()` have the `platform` tag of “twitter”.
171-
172176
</aside>
173177

174178
## Arguments Definition
@@ -188,3 +192,30 @@ Task description serves as the prompt for the agent to respond. Since the reacti
188192
- User message
189193
- Conversation history
190194
- Instructions
195+
196+
197+
## Importing Functions and Sharing Functions
198+
With this SDK and function structure, importing and sharing functions is also possible.
199+
200+
```python
201+
from virtuals_sdk.functions.telegram import TelegramClient
202+
203+
# define your token so that it can attach it to create the correspodning functions
204+
tg_client = TelegramClient(bot_token="xxx")
205+
print(tg_client.available_functions)
206+
207+
# get functions
208+
reply_message_fn = tg_client.get_function("send_message")
209+
create_poll_fn = tg_client.get_function("create_poll")
210+
pin_message_fn = tg_client.get_function("pin_message")
211+
212+
# test the execution of functions
213+
reply_message_fn("xxxxxxxx", "Hello World")
214+
create_poll_fn("xxxxxxxx", "What is your favorite color?", ["Red", "Blue", "Green"], "True")
215+
pin_message_fn("xxxxxxxx", "xx", "True")
216+
217+
# add these functions to your agent
218+
agent.add_custom_function(reply_message_fn)
219+
agent.add_custom_function(create_poll_fn)
220+
agent.add_custom_function(pin_message_fn)
221+
```
File renamed without changes.
File renamed without changes.

src/virtuals_sdk/functions/telegram.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ def _create_send_message(self) -> Function:
7676
config=FunctionConfig(
7777
method="post",
7878
url=self.create_api_url("sendMessage"),
79+
platform="telegram",
7980
headers={"Content-Type": "application/json"},
8081
payload={
8182
"chat_id": "{{chat_id}}",
@@ -120,6 +121,7 @@ def _create_send_media(self) -> Function:
120121
config=FunctionConfig(
121122
method="post",
122123
url=self.create_api_url("send{{media_type}}"),
124+
platform="telegram",
123125
headers={"Content-Type": "application/json"},
124126
payload={
125127
"chat_id": "{{chat_id}}",
@@ -164,6 +166,7 @@ def _create_poll(self) -> Function:
164166
config=FunctionConfig(
165167
method="post",
166168
url=self.create_api_url("sendPoll"),
169+
platform="telegram",
167170
headers={"Content-Type": "application/json"},
168171
payload={
169172
"chat_id": "{{chat_id}}",
@@ -204,6 +207,7 @@ def _create_pin_message(self) -> Function:
204207
config=FunctionConfig(
205208
method="post",
206209
url=self.create_api_url("pinChatMessage"),
210+
platform="telegram",
207211
headers={"Content-Type": "application/json"},
208212
payload={
209213
"chat_id": "{{chat_id}}",
@@ -238,6 +242,7 @@ def _create_delete_message(self) -> Function:
238242
config=FunctionConfig(
239243
method="post",
240244
url=self.create_api_url("deleteMessage"),
245+
platform="telegram",
241246
headers={"Content-Type": "application/json"},
242247
payload={
243248
"chat_id": "{{chat_id}}",
@@ -272,6 +277,7 @@ def _create_delete_message(self) -> Function:
272277
# config=FunctionConfig(
273278
# method="post",
274279
# url=self.create_api_url("setChatTitle"),
280+
# platform="telegram",
275281
# headers={"Content-Type": "application/json"},
276282
# payload={
277283
# "chat_id": "{{chat_id}}",

src/virtuals_sdk/game.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -88,28 +88,6 @@ def _interpolate_template(self, template_str: str, values: Dict[str, Any]) -> st
8888
python_style = template_str.replace('{{', '$').replace('}}', '')
8989
return Template(python_style).safe_substitute(values)
9090

91-
# def _prepare_request(self, arg_dict: Dict[str, Any]) -> Dict[str, Any]:
92-
# """Prepare the request configuration with interpolated values"""
93-
# config = self.config
94-
95-
# # Interpolate URL
96-
# url = self._interpolate_template(config.url, arg_dict)
97-
98-
# # Interpolate payload
99-
# payload = {}
100-
# for key, value in config.payload.items():
101-
# if isinstance(value, str):
102-
# payload[self._interpolate_template(key, arg_dict)] = self._interpolate_template(value, arg_dict)
103-
# else:
104-
# payload[key] = value
105-
106-
# return {
107-
# "method": config.method,
108-
# "url": url,
109-
# "headers": config.headers,
110-
# "data": json.dumps(payload)
111-
# }
112-
11391
def _prepare_request(self, arg_dict: Dict[str, Any]) -> Dict[str, Any]:
11492
"""Prepare the request configuration with interpolated values"""
11593
config = self.config

0 commit comments

Comments
 (0)