Skip to content

Commit

Permalink
Merge pull request #32 from valory-xyz/chore/modify-prompt
Browse files Browse the repository at this point in the history
Update prompt
  • Loading branch information
jmoreira-valory authored Jul 27, 2023
2 parents 07685d7 + 284f9b9 commit 1e3a810
Show file tree
Hide file tree
Showing 10 changed files with 113 additions and 116 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,8 @@ agent/

ethereum_private_key.txt
keys.json
market_maker/
market_maker/
fetched_service/
keys_json/
market_approval_server/market_approval_server.log
market_approval_server/server_config.json
15 changes: 7 additions & 8 deletions market_identification_prompt.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
Based on the following news snippets under "INPUT", formulate 5 prediction market questions with clear, objective
outcomes that can be verified on specific dates and leave no room for interpretation or subjectivity.
Avoid incorporating questions that could potentially encourage unethical behavior or violence. Feel
free to use the same event with different dates as necessary. Every question should be resolvable in a
random day between 1st and the 31st of August 2023, with a requirement that all questions
be resolvable in a different day of the month.
Based on the following news snippets under INPUT, formulate 5 prediction market questions with clear, objective
outcomes that can be verified on a specific date and leave no room for interpretation or subjectivity.
Avoid incorporating questions that could potentially encourage unethical behavior or violence.
Every question must be related to an event happening on or by {event_day}. The answer to the question
must be unknown until that day, but it must be known after that day.
Your questions should follow a structure similar to this:
"Will VERIFIABLE_BINARY_OUTCOME_OR_PREDICTION occur on SPECIFIC_DAY_OF_AUGUST_2023".
"Will VERIFIABLE_BINARY_OUTCOME_OR_PREDICTION occur on {event_day}".
Your output must follow the output format detailed under "OUTPUT FORMAT".

INPUT
{input_news}

OUTPUT_FORMAT
* Your output response must be only a single JSON array to be parsed by Python's "json.loads()".
* Your output response must be only a single JSON array to be parsed by Python "json.loads()".
* All of the date strings should be represented in YYYY-MM-DD format.
* Each entry of the JSON array must be a JSON object containing the fields:
- question: The binary question to open a prediction market.
Expand Down
8 changes: 4 additions & 4 deletions packages/packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
"contract/valory/conditional_tokens/0.1.0": "bafybeig5vtn7bzpegfrzehdgeezqcnox3xlb5i54ehnqndazhcfh3bkdcq",
"contract/valory/fpmm_deterministic_factory/0.1.0": "bafybeig4ztnqgyaespzlcmcom56nvmi4c4paddsxsjsh5q7olnylu3z7ou",
"contract/valory/realtio/0.1.0": "bafybeihoj7w5dqdyo6ds2rdmi326cvl5wuc7xp6yms7lwks35m4nqypk4q",
"skill/valory/market_creation_manager_abci/0.1.0": "bafybeichgshhxeigjb46pyfbeokdkiwrc4jongf225bcwopkw7ka2azuda",
"skill/valory/market_maker_abci/0.1.0": "bafybeig4hmaqu3hka6ynblqvms6jpq4qbn6ofc2rdocwbxpeobyhyccwe4",
"agent/valory/market_maker/0.1.0": "bafybeicbjdxea7y5dndpsekx5rtovdzyjf4vsex5f5gy3urcgjx2lnmiou",
"service/valory/market_maker/0.1.0": "bafybeiawlstpxj2fjkeu2izza7xniynmfhmfqbow4vsnol5wbbuznwuof4",
"skill/valory/market_creation_manager_abci/0.1.0": "bafybeibaovti3jrf5syhtffkgnj34agk4decoiybeufh4yb6qpvvtqycve",
"skill/valory/market_maker_abci/0.1.0": "bafybeibidkqzpqpx4cd2kil4f53ag32v4xyotxz5fn55iorgl7ylwdhcga",
"agent/valory/market_maker/0.1.0": "bafybeib4yddbk7kutldwubejzaqbscut7liwkwoncgepydaqbr3w7ztfaa",
"service/valory/market_maker/0.1.0": "bafybeigfi7bvtbqvvruherltjunkdlhsyxl3nlehno5nrbhvfgp4hizhhe",
"contract/valory/wxdai/0.1.0": "bafybeie3c5enerf54jt75xc62mbzck4kjqxpjx2mzo6v4rrz4dmcy4xdgy",
"skill/valory/market_validation_abci/0.1.0": "bafybeifyfwynotmzg6wypbzbwsfnrplhjhumfx32dm2j3ddasp7ygrfoqa"
},
Expand Down
54 changes: 20 additions & 34 deletions packages/valory/agents/market_maker/aea-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ protocols:
skills:
- valory/abstract_abci:0.1.0:bafybeiamr3cwetayz6lr72buhq6iviabtboj4hhpq47tlumimxolvvqjcy
- valory/abstract_round_abci:0.1.0:bafybeiaseziuvbzh3trjggl5hx2tv3fduqrpiwiyksudaf6nvuxmwrg74i
- valory/market_maker_abci:0.1.0:bafybeig4hmaqu3hka6ynblqvms6jpq4qbn6ofc2rdocwbxpeobyhyccwe4
- valory/market_maker_abci:0.1.0:bafybeibidkqzpqpx4cd2kil4f53ag32v4xyotxz5fn55iorgl7ylwdhcga
- valory/registration_abci:0.1.0:bafybeibafy7qmcvvzaykimy3mbqdwtcuajmbghqilaa7zwkh6wla33cfce
- valory/market_creation_manager_abci:0.1.0:bafybeichgshhxeigjb46pyfbeokdkiwrc4jongf225bcwopkw7ka2azuda
- valory/market_creation_manager_abci:0.1.0:bafybeibaovti3jrf5syhtffkgnj34agk4decoiybeufh4yb6qpvvtqycve
- valory/market_validation_abci:0.1.0:bafybeifyfwynotmzg6wypbzbwsfnrplhjhumfx32dm2j3ddasp7ygrfoqa
- valory/reset_pause_abci:0.1.0:bafybeialcwck7fahrr23jckv5qjwg3cdq4ai2ihyjsofnbj44jzyl4cjmm
- valory/termination_abci:0.1.0:bafybeifqsogqiar4yook5bu3j6z66dbdcizey7dr3e5oxeocdjijvfbaja
Expand Down Expand Up @@ -128,38 +128,24 @@ models:
log_dir: ${str:/logs}
params:
args:
market_identification_prompt: ${str:You are an LLM inside a multi-agent system.
Your task is to propose a collection of prediction market\nquestions based
on your input. Your input is under the label \"INPUT\". You must follow the
instructions\nunder \"INSTRUCTIONS\". You must provide your response in the
format specified under \"OUTPUT_FORMAT\".\n\nINSTRUCTIONS\n* Read the input
under the label \"INPUT\" delimited by three backticks.\n* The \"INPUT\" specifies
a list of recent news headlines, their date, and short descriptions.\n* Based
on the \"INPUT\" and your training data, you must provide a list of binary
questions, valid\n answers and resolution dates to create prediction markets.\n*
Each market must satisfy the following conditions;\n - The outcome of the
market is unknown at the present date.\n - The outcome of the market must
be known by its resolution date.\n - The outcome of the market must be
related to a deterministic, measurable or verifiable fact.\n - Questions
whose answer is known at the present date are invalid.\n - Questions whose
answer is subjective or opinionated are invalid.\n - Questions with relative
dates are invalid.\n - Questions about moral values, subjective opinions,
and not facts are invalid.\n - Questions in which none of the answers are
valid will resolve as invalid.\n - Questions with multiple valid answers
are invalid.\n - Questions must not incentivize committing an immoral violent
action.\n - The dates in the question need to be in YYYY-MM-DD format.\n*
The created markets must be different and not overlap semantically.\n* You
must provide your response in the format specified under \"OUTPUT_FORMAT\".\n*
Do not include any other contents in your response.\n\nINPUT\n{input_news}\n\nOUTPUT_FORMAT\n*
Your output response must be only a single JSON array to be parsed by Python\'s
\"json.loads()\".\n* The JSON array must be of length 5.\n* All of the date
strings should be represented in YYYY-MM-DD format.\n* Each entry of the JSON
array must be a JSON object containing the fields;\n - question; The binary
question to open a prediction market.\n - answers; The possible answers
to the question.\n - resolution_date; The resolution date for the outcome
of the market to be verified.\n - topic; One word description of the topic
of the news and it should be one of; {topics}.\n* Output only the JSON object.
Do not include any other contents in your response.}
market_identification_prompt: ${str:Based on the following news snippets under
INPUT, formulate 5 prediction market questions with clear, objective\noutcomes
that can be verified on a specific date and leave no room for interpretation
or subjectivity.\nAvoid incorporating questions that could potentially encourage
unethical behavior or violence.\nEvery question must be related to an event
happening on or by {event_day}. The answer to the question\nmust be unknown
until that day, but it must be known after that day.\nYour questions should
follow a structure similar to this;\n\"Will VERIFIABLE_BINARY_OUTCOME_OR_PREDICTION
occur on {event_day}\".\nYour output must follow the output format detailed
under \"OUTPUT FORMAT\".\n\nINPUT\n{input_news}\n\nOUTPUT_FORMAT\n* Your output
response must be only a single JSON array to be parsed by Python \"json.loads()\".\n*
All of the date strings should be represented in YYYY-MM-DD format.\n* Each
entry of the JSON array must be a JSON object containing the fields;\n - question;
The binary question to open a prediction market.\n - answers; The possible
answers to the question.\n - resolution_date; The resolution date for the
outcome of the market to be verified.\n - topic; One word description of the
topic of the news and it should be one of; {topics}.\n* Output only the JSON
object. Do not include any other contents in your response.}
num_markets: ${int:1}
market_approval_server_url: ${str:http://127.0.0.1:5000}
market_approval_server_api_key: ${str:api_key}
Expand Down
52 changes: 19 additions & 33 deletions packages/valory/services/market_maker/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ license: Apache-2.0
fingerprint:
README.md: bafybeibwz3af6326msp4h3kqehijvmyhaytvyfbo3o2npc2w4b6zrg6pfq
fingerprint_ignore_patterns: []
agent: valory/market_maker:0.1.0:bafybeicbjdxea7y5dndpsekx5rtovdzyjf4vsex5f5gy3urcgjx2lnmiou
agent: valory/market_maker:0.1.0:bafybeib4yddbk7kutldwubejzaqbscut7liwkwoncgepydaqbr3w7ztfaa
number_of_agents: 1
deployment:
agent:
Expand All @@ -23,38 +23,24 @@ models:
log_dir: /logs
params:
args:
market_identification_prompt: ${MARKET_IDENTIFICATION_PROMPT:str:You are an
LLM inside a multi-agent system. Your task is to propose a collection of prediction
market\nquestions based on your input. Your input is under the label \"INPUT\".
You must follow the instructions\nunder \"INSTRUCTIONS\". You must provide
your response in the format specified under \"OUTPUT_FORMAT\".\n\nINSTRUCTIONS\n*
Read the input under the label \"INPUT\" delimited by three backticks.\n*
The \"INPUT\" specifies a list of recent news headlines, their date, and short
descriptions.\n* Based on the \"INPUT\" and your training data, you must provide
a list of binary questions, valid\n answers and resolution dates to create
prediction markets.\n* Each market must satisfy the following conditions;\n -
The outcome of the market is unknown at the present date.\n - The outcome
of the market must be known by its resolution date.\n - The outcome of
the market must be related to a deterministic, measurable or verifiable fact.\n -
Questions whose answer is known at the present date are invalid.\n - Questions
whose answer is subjective or opinionated are invalid.\n - Questions with
relative dates are invalid.\n - Questions about moral values, subjective
opinions, and not facts are invalid.\n - Questions in which none of the
answers are valid will resolve as invalid.\n - Questions with multiple
valid answers are invalid.\n - Questions must not incentivize committing
an immoral violent action.\n - The dates in the question need to be in
YYYY-MM-DD format.\n* The created markets must be different and not overlap
semantically.\n* You must provide your response in the format specified under
\"OUTPUT_FORMAT\".\n* Do not include any other contents in your response.\n\nINPUT\n{input_news}\n\nOUTPUT_FORMAT\n*
Your output response must be only a single JSON array to be parsed by Python\'s
\"json.loads()\".\n* The JSON array must be of length 5.\n* All of the date
strings should be represented in YYYY-MM-DD format.\n* Each entry of the JSON
array must be a JSON object containing the fields;\n - question; The binary
question to open a prediction market.\n - answers; The possible answers
to the question.\n - resolution_date; The resolution date for the outcome
of the market to be verified.\n - topic; One word description of the topic
of the news and it should be one of; {topics}.\n* Output only the JSON object.
Do not include any other contents in your response.}
market_identification_prompt: ${MARKET_IDENTIFICATION_PROMPT:str:Based on the
following news snippets under INPUT, formulate 5 prediction market questions
with clear, objective\noutcomes that can be verified on a specific date and
leave no room for interpretation or subjectivity.\nAvoid incorporating questions
that could potentially encourage unethical behavior or violence.\nEvery question
must be related to an event happening on or by {event_day}. The answer to
the question\nmust be unknown until that day, but it must be known after that
day.\nYour questions should follow a structure similar to this;\n\"Will VERIFIABLE_BINARY_OUTCOME_OR_PREDICTION
occur on {event_day}\".\nYour output must follow the output format detailed
under \"OUTPUT FORMAT\".\n\nINPUT\n{input_news}\n\nOUTPUT_FORMAT\n* Your output
response must be only a single JSON array to be parsed by Python \"json.loads()\".\n*
All of the date strings should be represented in YYYY-MM-DD format.\n* Each
entry of the JSON array must be a JSON object containing the fields;\n - question;
The binary question to open a prediction market.\n - answers; The possible
answers to the question.\n - resolution_date; The resolution date for the
outcome of the market to be verified.\n - topic; One word description of the
topic of the news and it should be one of; {topics}.\n* Output only the JSON
object. Do not include any other contents in your response.}
num_markets: ${NUM_MARKETS:int:1}
market_approval_server_url: ${MARKET_APPROVAL_SERVER_URL:str:http://127.0.0.1:5000}
market_approval_server_api_key: ${MARKET_APPROVAL_SERVER_API_KEY:str:api_key}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,9 +269,14 @@ def _get_llm_response(self) -> Generator[None, None, Optional[dict]]:
date = article["publishedAt"]
input_news += f"- ({date}) {title}\n {content}\n\n"

event_day = self._get_event_day()
topics = ", ".join(self.params.topics)
prompt_template = self.params.market_identification_prompt
prompt_values = {"input_news": input_news, "topics": topics}
prompt_values = {
"input_news": input_news,
"topics": topics,
"event_day": event_day,
}

self.context.logger.info(
f"Sending LLM request...\nprompt_template={prompt_template}\nprompt_values={prompt_values}"
Expand Down Expand Up @@ -333,6 +338,27 @@ def _get_llm_response(self) -> Generator[None, None, Optional[dict]]:
return None
return valid_responses[0]

def _get_event_day(self) -> str:
# Get the current date
n = self.synchronized_data.markets_created
today = datetime.datetime.now().date()

# Set the target year and month
target_year = 2023
target_month = 8
minimum_days_until_event = self.params.minimum_market_time + 1

# Calculate the start_date in August (at least today + 2 days)
start_date = max(
datetime.date(target_year, target_month, 1),
today + datetime.timedelta(days=minimum_days_until_event),
)
end_date = datetime.date(target_year, target_month, 31)
days_difference = abs((end_date - start_date).days)
event_day = start_date + datetime.timedelta(n % (days_difference + 1))

return event_day.strftime("%-d %B %Y")

def _do_llm_request(
self,
llm_message: LlmMessage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ aea_version: '>=1.0.0, <2.0.0'
fingerprint:
.gitignore: bafybeihdfdezgtr3s2lzq5y3oaitfrdy4u4pehionju2bdez35wcjgqx6y
__init__.py: bafybeibkyjt4covc4yhd22aw7kav45zozk3exdv344emt3lilln64soaxm
behaviours.py: bafybeifs3qwjzxaj6aofcydsp4gdhlejkp2adji6tqof7vymfvumqh3rze
behaviours.py: bafybeicvgjl3efqzc3yb5przgeui3qetsv3htjjeessr5gz37b66xy4voy
dialogues.py: bafybeicmaufkl7vdomnfciv7lw4536ssld7x4uemdapuhsyvfpd4ncibza
fsm_specification.yaml: bafybeiay4aepnfdkcsriajxqige65bsszrujin57riubflm7dyw2keapoi
handlers.py: bafybeietxjfli2i57kb7heoy772rcq2znusl36gg7jjj5g3pddw7egny3q
Expand Down
2 changes: 1 addition & 1 deletion packages/valory/skills/market_maker_abci/skill.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ skills:
- valory/abstract_round_abci:0.1.0:bafybeiaseziuvbzh3trjggl5hx2tv3fduqrpiwiyksudaf6nvuxmwrg74i
- valory/registration_abci:0.1.0:bafybeibafy7qmcvvzaykimy3mbqdwtcuajmbghqilaa7zwkh6wla33cfce
- valory/reset_pause_abci:0.1.0:bafybeialcwck7fahrr23jckv5qjwg3cdq4ai2ihyjsofnbj44jzyl4cjmm
- valory/market_creation_manager_abci:0.1.0:bafybeichgshhxeigjb46pyfbeokdkiwrc4jongf225bcwopkw7ka2azuda
- valory/market_creation_manager_abci:0.1.0:bafybeibaovti3jrf5syhtffkgnj34agk4decoiybeufh4yb6qpvvtqycve
- valory/market_validation_abci:0.1.0:bafybeifyfwynotmzg6wypbzbwsfnrplhjhumfx32dm2j3ddasp7ygrfoqa
- valory/termination_abci:0.1.0:bafybeifqsogqiar4yook5bu3j6z66dbdcizey7dr3e5oxeocdjijvfbaja
- valory/transaction_settlement_abci:0.1.0:bafybeiacwr7p4nhhufoey7uz2jqkegrlykdrmc7mm3rzkvh2mslu66gyle
Expand Down
3 changes: 2 additions & 1 deletion run_service.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# Load env vars
export $(grep -v '^#' .env | xargs)

export MARKET_IDENTIFICATION_PROMPT=$(sed -e ':a' -e 'N' -e '$!ba' \
-e 's/"/\\"/g' \
-e "s/'/\\\'/g" \
Expand All @@ -14,7 +15,7 @@ make clean
autonomy packages lock
autonomy push-all

autonomy fetch --local --service valory/market_maker && cd market_maker
autonomy fetch --local --service valory/market_maker --alias fetched_service && cd fetched_service

# Build the image
autonomy build-image
Expand Down
Loading

0 comments on commit 1e3a810

Please sign in to comment.