Skip to content

Commit

Permalink
Merge pull request #6 from dvilelaf/fix/suno-memory
Browse files Browse the repository at this point in the history
Fix/suno memory
  • Loading branch information
dvilelaf authored Apr 23, 2024
2 parents 56b6eab + 2aa07cb commit 0ef958a
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 9 deletions.
4 changes: 2 additions & 2 deletions packages/dvilela/agents/tsunami/aea-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ skills:
- valory/transaction_settlement_abci:0.1.0:bafybeigtzlk4uakmd54rxnznorcrstsr52kta474lgrnvx5ovr546vj7sq
- valory/registration_abci:0.1.0:bafybeiek7zcsxbucjwzgqfftafhfrocvc7q4yxllh2q44jeemsjxg3rcfm
- valory/reset_pause_abci:0.1.0:bafybeidw4mbx3os3hmv7ley7b3g3gja7ydpitr7mxbjpwzxin2mzyt5yam
- dvilela/tsunami_abci:0.1.0:bafybeig3mg2bwkxbsi5fwryzw533bzwj2pzwj7i6nywuahrfsauqw2dprm
- dvilela/tsunami_chained_abci:0.1.0:bafybeifabksyadyfdfe2mcqqxuisowacmvedynj5unfd5gfuvslg4e5sq4
- dvilela/tsunami_abci:0.1.0:bafybeihw7ecxhxxxhv5xru33lehu7jw2qcpf4l5ntspiby5sger5fwjdwm
- dvilela/tsunami_chained_abci:0.1.0:bafybeigvezvvzhnx3hbgz3zte2tsrtx7uczgems5uzrhx27dqdxndzz5wm
default_ledger: ethereum
required_ledgers:
- ethereum
Expand Down
2 changes: 1 addition & 1 deletion packages/dvilela/services/tsunami/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ license: Apache-2.0
fingerprint:
README.md: bafybeibh5bgshii5oqjfuhwmiivfvfqy7fw5pzvarxkpe4qrgivxtc3xym
fingerprint_ignore_patterns: []
agent: dvilela/tsunami:0.1.0:bafybeiabblusrfbkeie5gnxhfgxlntz3h2scbbqgqu2mekdrnugg5t6fqy
agent: dvilela/tsunami:0.1.0:bafybeihktqlhcqx6hfx3m2mgxbpfovnqap2norpa574r3ssshmf2hgnzym
number_of_agents: 1
deployment:
agent:
Expand Down
23 changes: 23 additions & 0 deletions packages/dvilela/skills/tsunami_abci/behaviours.py
Original file line number Diff line number Diff line change
Expand Up @@ -1193,6 +1193,23 @@ def get_suno_tweets( # pylint: disable=too-many-locals,too-many-return-statemen
n_agents = len(agents)
self.context.logger.info(f"Got {n_agents} agents")

# Filter out agents from past songs
response = yield from self._read_kv(keys=("previous_suno_agents",))

if response is None:
self.context.logger.error(
"Error reading previous_suno_agents from the database."
)
return tweets

previous_suno_agents = response["previous_suno_agents"]
self.context.logger.info(
f"Loaded previous_suno_agents from db: {previous_suno_agents}"
)

previous_suno_agents = json.loads(previous_suno_agents or "[]")
agents = [a for a in agents if int(a["tokenId"]) not in previous_suno_agents]

# Select a random agent and genre
agent = secrets.choice(agents) # nosec
agent_name = agent["publicId"].split("/")[-1]
Expand All @@ -1204,6 +1221,7 @@ def get_suno_tweets( # pylint: disable=too-many-locals,too-many-return-statemen
agent_description=agent_description,
)
self.context.logger.info("Suno prompt is: {prompt}")
previous_suno_agents.append(int(agent["tokenId"]))

# Call Suno conection
suno_response = yield from self._call_suno(prompt=prompt)
Expand Down Expand Up @@ -1246,6 +1264,11 @@ def get_suno_tweets( # pylint: disable=too-many-locals,too-many-return-statemen
# Save run time to the db
yield from self._write_kv({"suno_last_run_date": today.strftime("%Y-%m-%d")})

# Save agents to the db
yield from self._write_kv(
{"previous_suno_agents": json.dumps(previous_suno_agents, sort_keys=True)}
)

return tweets


Expand Down
2 changes: 1 addition & 1 deletion packages/dvilela/skills/tsunami_abci/skill.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ license: Apache-2.0
aea_version: '>=1.0.0, <2.0.0'
fingerprint:
__init__.py: bafybeiaicsttkv5xapta2eqove7si2pyv3zmshkqolluxpnrh3hkulqsqu
behaviours.py: bafybeifaqd6qukdqppqf7kzkqmufmrz2uqyox7joap6og2k7hbvrqhrwmi
behaviours.py: bafybeigmridv5zedpqqmksziomt4vkg7ryi5rv4axugqizoaptsgr3ewwe
dialogues.py: bafybeidmgjji6zw6wcvhijrxb74batj2kc2lskfuqxv76duv2j7azcqwra
fsm_specification.yaml: bafybeibrbzzs726xnbay6yyknx7nkcyrvprrvb5sojlyxy4ndoksugcfq4
handlers.py: bafybeialhc4f2333c6lvyt3yhrwju6h46ph2fc4qysydhcf5fe45zw43ly
Expand Down
2 changes: 1 addition & 1 deletion packages/dvilela/skills/tsunami_chained_abci/skill.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ skills:
- valory/reset_pause_abci:0.1.0:bafybeidw4mbx3os3hmv7ley7b3g3gja7ydpitr7mxbjpwzxin2mzyt5yam
- valory/transaction_settlement_abci:0.1.0:bafybeigtzlk4uakmd54rxnznorcrstsr52kta474lgrnvx5ovr546vj7sq
- valory/termination_abci:0.1.0:bafybeihq6qtbwt6i53ayqym63vhjexkcppy26gguzhhjqywfmiuqghvv44
- dvilela/tsunami_abci:0.1.0:bafybeig3mg2bwkxbsi5fwryzw533bzwj2pzwj7i6nywuahrfsauqw2dprm
- dvilela/tsunami_abci:0.1.0:bafybeihw7ecxhxxxhv5xru33lehu7jw2qcpf4l5ntspiby5sger5fwjdwm
behaviours:
main:
args: {}
Expand Down
8 changes: 4 additions & 4 deletions packages/packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
"connection/dvilela/llama/0.1.0": "bafybeientp27ic3s2wbmrxxsmxg3wvshcoecjl3nvo75lb5faw3rersu7u",
"connection/valory/twitter/0.1.0": "bafybeihotqawulig3g4a7fosi4pljsjii2neiqxtepd42e2neemhqecfcq",
"connection/dvilela/suno/0.1.0": "bafybeialefoyek6fxtlowsj34rmycdqvs7y5e73fmojy5te7yibu6mheia",
"skill/dvilela/tsunami_abci/0.1.0": "bafybeig3mg2bwkxbsi5fwryzw533bzwj2pzwj7i6nywuahrfsauqw2dprm",
"skill/dvilela/tsunami_chained_abci/0.1.0": "bafybeifabksyadyfdfe2mcqqxuisowacmvedynj5unfd5gfuvslg4e5sq4",
"agent/dvilela/tsunami/0.1.0": "bafybeiabblusrfbkeie5gnxhfgxlntz3h2scbbqgqu2mekdrnugg5t6fqy",
"service/dvilela/tsunami/0.1.0": "bafybeiau2smuqemiptf5cnw2zipvx34fxv2cg7wf4km2cd5j5tuu3xskdu"
"skill/dvilela/tsunami_abci/0.1.0": "bafybeihw7ecxhxxxhv5xru33lehu7jw2qcpf4l5ntspiby5sger5fwjdwm",
"skill/dvilela/tsunami_chained_abci/0.1.0": "bafybeigvezvvzhnx3hbgz3zte2tsrtx7uczgems5uzrhx27dqdxndzz5wm",
"agent/dvilela/tsunami/0.1.0": "bafybeihktqlhcqx6hfx3m2mgxbpfovnqap2norpa574r3ssshmf2hgnzym",
"service/dvilela/tsunami/0.1.0": "bafybeie3algsst3s3lbsi6gnrvcihl55likwjivk7qzfgch5fmts5rujee"
},
"third_party": {
"protocol/open_aea/signing/1.0.0": "bafybeihv62fim3wl2bayavfcg3u5e5cxu3b7brtu4cn5xoxd6lqwachasi",
Expand Down

0 comments on commit 0ef958a

Please sign in to comment.