-
Notifications
You must be signed in to change notification settings - Fork 56
/
Copy pathexample-custom.py
43 lines (40 loc) · 1.34 KB
/
example-custom.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import os
from game_sdk.hosted_game.agent import Agent, Function, FunctionArgument, FunctionConfig
agent = Agent(
api_key=os.environ.get("VIRTUALS_API_KEY"),
goal="search for best songs",
description="Test Description",
world_info="Test World Info"
)
# running reaction module for other platforms
# adding custom functions for platform specifics
agent.add_custom_function(
Function(
fn_name="custom_search_internet",
fn_description="search the internet for the best songs",
args=[
FunctionArgument(
name="query",
type="string",
description="The query to search for"
)
],
config=FunctionConfig(
method="get",
url="https://google.com",
platform="telegram", # this function will only be used for telegram
success_feedback="I found the best songs",
error_feedback="I couldn't find the best songs",
)
)
)
# running reaction module only for platform telegram
agent.react(
session_id="session-telegram",
# specify the platform telegram
platform="telegram",
# specify the event that triggers the reaction
event="message from user: give me some great music?",
# specify the task that the agent should do
task="reply with a music recommendation",
)