diff --git a/packages/dvilela/agents/memeooorr/aea-config.yaml b/packages/dvilela/agents/memeooorr/aea-config.yaml index b0051501..f183c440 100644 --- a/packages/dvilela/agents/memeooorr/aea-config.yaml +++ b/packages/dvilela/agents/memeooorr/aea-config.yaml @@ -21,7 +21,7 @@ contracts: - valory/gnosis_safe:0.1.0:bafybeihtqcpqthb37msgqabpzcc2xc3l3yzkp5pl2sodeghqyzzzyuevgi - valory/gnosis_safe_proxy_factory:0.1.0:bafybeifr4xpmzeb5hvpgd6h4nxlsu3ef2c3f6l5bgs34vym5ok6vllwhmy - valory/multisend:0.1.0:bafybeig5byt5urg2d2bsecufxe5ql7f4mezg3mekfleeh32nmuusx66p4y -- dvilela/meme_factory:0.1.0:bafybeiawjmrohaarpx3fw5653if2tmwzirktihrqidmdnhmhw4nhu5nk6y +- dvilela/meme_factory:0.1.0:bafybeida7lxud3pi76hnisz6fdpbhnty6qncykbzotkv5zkm3bjm6wdr4a - dvilela/service_registry:0.1.0:bafybeift2qis3njkyehk3hbjdj2n3srty6hepfb5gavaorhffztplke4dm protocols: - open_aea/signing:1.0.0:bafybeihv62fim3wl2bayavfcg3u5e5cxu3b7brtu4cn5xoxd6lqwachasi @@ -41,8 +41,8 @@ skills: - valory/transaction_settlement_abci:0.1.0:bafybeifmgmwdkx4esemxjacjwzqkqymkuklb5nehkwqkx7v335fllgswcq - valory/registration_abci:0.1.0:bafybeiagi6e2h7kochmlemy5c5yk6hwn37tfxiqvk2en74jhowsdwlmrny - valory/reset_pause_abci:0.1.0:bafybeiezfedmmseox3ce5aucxsiszdmvskrwwbtpb2a3vw3sbmc5jt7nri -- dvilela/memeooorr_abci:0.1.0:bafybeifbcsie7jvb4ddknqfitgt7bougucvrxxpa2uvxou4voajq4xqhly -- dvilela/memeooorr_chained_abci:0.1.0:bafybeidixgfirfyyv7pjodsuj7zscouboqfxtvqmustdqittecxlqer7ba +- dvilela/memeooorr_abci:0.1.0:bafybeicnsyshxyp3hgu6awtpqsbgh7mi6yycrn57jjv6kigsnstaa4g3ti +- dvilela/memeooorr_chained_abci:0.1.0:bafybeieahsjlcdsvd33krdb7nb36b6mhfr2jsnr7bkfjivstrlcxok3djy default_ledger: ethereum required_ledgers: - ethereum diff --git a/packages/dvilela/contracts/meme_factory/contract.py b/packages/dvilela/contracts/meme_factory/contract.py index ca559f0e..b2416377 100644 --- a/packages/dvilela/contracts/meme_factory/contract.py +++ b/packages/dvilela/contracts/meme_factory/contract.py @@ -223,7 +223,9 @@ def get_events( # pylint: disable=too-many-arguments contract_instance = cls.get_instance(ledger_api, contract_address) if from_block is None: - from_block = ledger_api.api.eth.get_block_number() - 15000 # approx 48h ago + from_block = ( + ledger_api.api.eth.get_block_number() - 86400 + ) # approx 48h ago (2s per block) # Avoid parsing too many blocks at a time. This might take too long and # the connection could time out. @@ -236,7 +238,7 @@ def get_events( # pylint: disable=too-many-arguments ) _logger.info( - f"Getting {event_name} events from block {from_block} to {to_block}" + f"Getting {event_name} events from block {from_block} to {to_block} ({int(to_block) - int(from_block)} blocks)" ) ranges: List[int] = list(range(from_block, cast(int, to_block), MAX_BLOCKS)) + [ @@ -250,6 +252,8 @@ def get_events( # pylint: disable=too-many-arguments to_block = ranges[i + 1] new_events = [] + _logger.info(f"Block batch {from_block} to {to_block}...") + while True: try: new_events = event.create_filter( diff --git a/packages/dvilela/contracts/meme_factory/contract.yaml b/packages/dvilela/contracts/meme_factory/contract.yaml index 47ae57f3..cfb6895e 100644 --- a/packages/dvilela/contracts/meme_factory/contract.yaml +++ b/packages/dvilela/contracts/meme_factory/contract.yaml @@ -9,7 +9,7 @@ fingerprint: README.md: bafybeies3iafkjwo4xvqtqpdxvood7pf2wgto4t76dqswy55rya7vl5zgu __init__.py: bafybeiddslgyschgiuwsfiovqgxqqbkazdy6h3d4swwnq3tvpqaxzy37si build/MemeBase.json: bafybeibr3pkkofhukwqjuqxuxsb52g2xlquzhu5uv6xqo527s2zzmp3cq4 - contract.py: bafybeielgqjcxrz5yuchvhhecicq3wiynisajhj35ihwuffhcph4rzgd3a + contract.py: bafybeiad534saeucoeksxdrwk6wdvq33yzapcln75jhlxxhge6g7lb7jpy fingerprint_ignore_patterns: [] contracts: [] class_name: MemeFactoryContract diff --git a/packages/dvilela/services/memeooorr/service.yaml b/packages/dvilela/services/memeooorr/service.yaml index 2aed2bf1..35e5fd57 100644 --- a/packages/dvilela/services/memeooorr/service.yaml +++ b/packages/dvilela/services/memeooorr/service.yaml @@ -7,7 +7,7 @@ license: Apache-2.0 fingerprint: README.md: bafybeiaekcmielp6mb4qvmo2twwkpmoun36bqajrh7wnnkcpdnia45ycl4 fingerprint_ignore_patterns: [] -agent: dvilela/memeooorr:0.1.0:bafybeic3ba6egnxtry4bsd4jzdko4vl4ahwwzo6wvtn3dwyp3phhv2nppi +agent: dvilela/memeooorr:0.1.0:bafybeick3akanspfledyeauzdhipftsbidfrmkmjg77sukiimldokzw7hq number_of_agents: 1 deployment: agent: diff --git a/packages/dvilela/skills/memeooorr_abci/behaviour_classes/base.py b/packages/dvilela/skills/memeooorr_abci/behaviour_classes/base.py index 6596236e..271dfab5 100644 --- a/packages/dvilela/skills/memeooorr_abci/behaviour_classes/base.py +++ b/packages/dvilela/skills/memeooorr_abci/behaviour_classes/base.py @@ -442,6 +442,7 @@ def get_memeooorr_handles_from_chain(self) -> Generator[None, None, List[str]]: def get_meme_coins_from_chain(self) -> Generator[None, None, Optional[List]]: """Get a list of meme coins""" + self.context.logger.info("Getting meme tokens from the chain") # Use the contract api to interact with the factory contract response_msg = yield from self.get_contract_api_response( diff --git a/packages/dvilela/skills/memeooorr_abci/prompts.py b/packages/dvilela/skills/memeooorr_abci/prompts.py index 9270946f..ffd193a4 100644 --- a/packages/dvilela/skills/memeooorr_abci/prompts.py +++ b/packages/dvilela/skills/memeooorr_abci/prompts.py @@ -26,7 +26,9 @@ You come up with ideas for new tweets that match your persona and you post them on Twitter (aka X). -Your task it to create a new tweet based on your persona. Remember that tweets can't be longer than 280 characters. +Your task it to create a new tweet based on your persona. +Remember that tweets can't be longer than 280 characters. +Also, please do not include any hastags on the tweet unless your persona explicitly ask for them. """ ANALYZE_FEEDBACK_PROMPT = """ @@ -60,7 +62,7 @@ - token_ticker: a new ticker for the token. Empty if no token is going to be deployed. - token_supply: the ERC-20 token supply in wei units. Empty if no token is going to be deployed. Token supply must be at least 1 million * 10**18 and at most the maximum number of uint256. - amount: the amount in wei units of {ticker} to invest in this token if it is going to be deployed, or 0 otherwise. - - tweet: a tweet to announce the new token. Empty if no token is going to be deployed. + - tweet: a tweet to announce the new token. Empty if no token is going to be deployed. Please do not include any hastags on the tweet unless your persona explicitly ask for them. * Output only the JSON object. Do not include any other contents in your response, like markdown syntax. * This is incorrect:"```json{{response}}```" * This is incorrect:```json"{{response}}"``` @@ -117,7 +119,7 @@ - token_address: a string with the token address of the meme coin you selected, or empty if none - token_nonce: a string with the token nonce of the meme coin you selected, or empty if none - amount: the amount (in wei units of {ticker}) to heart (invest) if the action is heart, or 0 otherwise - - tweet: a short tweet to announce the action taken, or empty if none + - tweet: a short tweet to announce the action taken, or empty if none. Please do not include any hastags on the tweet. * This is incorrect:"```json{{response}}```" * This is incorrect:```json"{{response}}"``` * This is correct:"{{response}}" @@ -138,7 +140,7 @@ * Your output response must be only a single JSON object to be parsed by Python's "json.loads()". * The JSON must be a list containing your tweet responses. Each response needs to contain two fields only: "tweet_id", and "text". - tweet_id: the id of the tweet you are responding to. - - text: a short response to the tweet + - text: a short response to the tweet. Please do not include any hastags on the tweet unless your persona explicitly ask for them. * This is incorrect:"```json{{response}}```" * This is incorrect:```json"{{response}}"``` * This is correct:"{{response}}" diff --git a/packages/dvilela/skills/memeooorr_abci/skill.yaml b/packages/dvilela/skills/memeooorr_abci/skill.yaml index e4b3f4b4..76d41ee6 100644 --- a/packages/dvilela/skills/memeooorr_abci/skill.yaml +++ b/packages/dvilela/skills/memeooorr_abci/skill.yaml @@ -8,7 +8,7 @@ aea_version: '>=1.0.0, <2.0.0' fingerprint: __init__.py: bafybeidorrnxjv4n4ngovxnu4mzod46kyrdncfmli4hapqeqnzp7imq7hm behaviour_classes/__init__.py: bafybeicjks4kxsb2r6a4armmaqxyxngwm3pouegq3fycm37rbe7otiwsre - behaviour_classes/base.py: bafybeigo366arkc56coazlytm5hy74dcxct7e3revuhr6o3jq3pesnotz4 + behaviour_classes/base.py: bafybeie3anacgvmujazbph52oqyj7ap7arhbs57izygw7nmojwtsr7ioxi behaviour_classes/chain.py: bafybeigxfwko3rofqlzyjjhgeo6yabxseqngo2uz5muyfk3f2jjpgdrsli behaviour_classes/db.py: bafybeieuhjes2gsiidepjxcojgnn3swx2znem5uwvz7rwkxpwls3dmlxf4 behaviour_classes/llm.py: bafybeifqdewudvaw6qh5iherjm6l3brzbe6z27ik3l4ptmdnlj4abx5k6e @@ -19,7 +19,7 @@ fingerprint: handlers.py: bafybeigdxkm45w27sh7cpgiwuperjldql6oupbhxqtizhbwfv7abxe3dku models.py: bafybeia4mupvgav4eoipxz6t7m5gwygreqhlikz2cxpl4hcwaxvg6gt4um payloads.py: bafybeibyukr3aewwlbx6c6xe43j6nhgdqwqdgbemswrsvnqp3ftqodvvmi - prompts.py: bafybeicqvwxe25ytkaetkrouzybi4irbpusdkle7b6wfxew26qdgt23m3q + prompts.py: bafybeid236zygjf2v7evnriwhu2pxgmhdksoo7oyhnkt5ophgjxm232hga rounds.py: bafybeidbk55zxmhrdvcfehneff7nr7rqajpcacd7h3kctshskmkxjxtixi rounds_info.py: bafybeieqaemvqwiwku7nlxkdebsqzldpvvidijf6wcwy7e3xbyz335jr6i subgraph.py: bafybeigme6r3cwiiu5l7r55rcbj7y37b62cxtlsnewpkbjqcbadwte32xm @@ -31,7 +31,7 @@ connections: - valory/http_server:0.22.0:bafybeihpgu56ovmq4npazdbh6y6ru5i7zuv6wvdglpxavsckyih56smu7m contracts: - valory/gnosis_safe:0.1.0:bafybeihtqcpqthb37msgqabpzcc2xc3l3yzkp5pl2sodeghqyzzzyuevgi -- dvilela/meme_factory:0.1.0:bafybeiawjmrohaarpx3fw5653if2tmwzirktihrqidmdnhmhw4nhu5nk6y +- dvilela/meme_factory:0.1.0:bafybeida7lxud3pi76hnisz6fdpbhnty6qncykbzotkv5zkm3bjm6wdr4a - dvilela/service_registry:0.1.0:bafybeift2qis3njkyehk3hbjdj2n3srty6hepfb5gavaorhffztplke4dm protocols: - valory/srr:0.1.0:bafybeihrixgptxuqpf2s4nujypwlv5aed2nboozq5kl4c26cxw6r7si2x4 diff --git a/packages/dvilela/skills/memeooorr_chained_abci/skill.yaml b/packages/dvilela/skills/memeooorr_chained_abci/skill.yaml index bba45122..a92e7274 100644 --- a/packages/dvilela/skills/memeooorr_chained_abci/skill.yaml +++ b/packages/dvilela/skills/memeooorr_chained_abci/skill.yaml @@ -23,7 +23,7 @@ skills: - valory/reset_pause_abci:0.1.0:bafybeiezfedmmseox3ce5aucxsiszdmvskrwwbtpb2a3vw3sbmc5jt7nri - valory/transaction_settlement_abci:0.1.0:bafybeifmgmwdkx4esemxjacjwzqkqymkuklb5nehkwqkx7v335fllgswcq - valory/termination_abci:0.1.0:bafybeiea67epwwgngp7b3wavs6hpkaxv6etyaps6g6325bchfnf354mibq -- dvilela/memeooorr_abci:0.1.0:bafybeifbcsie7jvb4ddknqfitgt7bougucvrxxpa2uvxou4voajq4xqhly +- dvilela/memeooorr_abci:0.1.0:bafybeicnsyshxyp3hgu6awtpqsbgh7mi6yycrn57jjv6kigsnstaa4g3ti behaviours: main: args: {} diff --git a/packages/packages.json b/packages/packages.json index a2ad5638..91309357 100644 --- a/packages/packages.json +++ b/packages/packages.json @@ -1,12 +1,12 @@ { "dev": { - "contract/dvilela/meme_factory/0.1.0": "bafybeiawjmrohaarpx3fw5653if2tmwzirktihrqidmdnhmhw4nhu5nk6y", + "contract/dvilela/meme_factory/0.1.0": "bafybeida7lxud3pi76hnisz6fdpbhnty6qncykbzotkv5zkm3bjm6wdr4a", "contract/dvilela/service_registry/0.1.0": "bafybeift2qis3njkyehk3hbjdj2n3srty6hepfb5gavaorhffztplke4dm", "connection/dvilela/twikit/0.1.0": "bafybeigevblbawp34wax2y3xsb3nyaea7s7yq3dyuruovssmu3pxmrfuda", - "skill/dvilela/memeooorr_abci/0.1.0": "bafybeifbcsie7jvb4ddknqfitgt7bougucvrxxpa2uvxou4voajq4xqhly", - "skill/dvilela/memeooorr_chained_abci/0.1.0": "bafybeidixgfirfyyv7pjodsuj7zscouboqfxtvqmustdqittecxlqer7ba", - "agent/dvilela/memeooorr/0.1.0": "bafybeic3ba6egnxtry4bsd4jzdko4vl4ahwwzo6wvtn3dwyp3phhv2nppi", - "service/dvilela/memeooorr/0.1.0": "bafybeiewgf4fjpuoskpvycywbey2yer5qibfywyxgcfymzec5q62rut7bm" + "skill/dvilela/memeooorr_abci/0.1.0": "bafybeicnsyshxyp3hgu6awtpqsbgh7mi6yycrn57jjv6kigsnstaa4g3ti", + "skill/dvilela/memeooorr_chained_abci/0.1.0": "bafybeieahsjlcdsvd33krdb7nb36b6mhfr2jsnr7bkfjivstrlcxok3djy", + "agent/dvilela/memeooorr/0.1.0": "bafybeick3akanspfledyeauzdhipftsbidfrmkmjg77sukiimldokzw7hq", + "service/dvilela/memeooorr/0.1.0": "bafybeiayfvoreuxgytuvjxrxutzxpwlugcjmytnjncu4ksbnftgo7b5rr4" }, "third_party": { "protocol/open_aea/signing/1.0.0": "bafybeihv62fim3wl2bayavfcg3u5e5cxu3b7brtu4cn5xoxd6lqwachasi", diff --git a/scripts/test_prompts.py b/scripts/test_prompts.py new file mode 100644 index 00000000..38168fd1 --- /dev/null +++ b/scripts/test_prompts.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# ------------------------------------------------------------------------------ +# +# Copyright 2021-2024 Valory AG +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------------ + +"""Test prompts""" + +import os + +import dotenv +import google.generativeai as genai # type: ignore + +from packages.dvilela.skills.memeooorr_abci.prompts import DEFAULT_TWEET_PROMPT + + +dotenv.load_dotenv(override=True) + +persona = "A cat lover" +genai.configure(api_key=os.getenv("GENAI_API_KEY")) +model = genai.GenerativeModel("gemini-1.5-flash") +response = model.generate_content(DEFAULT_TWEET_PROMPT.format(persona=persona)) +print(response.text)