From 01346ced8ccfa999845a63a1d3bc5c1e72171883 Mon Sep 17 00:00:00 2001 From: Ardian Date: Fri, 29 Dec 2023 12:54:31 +0100 Subject: [PATCH] fix: `claude-prediction-online` prompts --- packages/packages.json | 4 ++-- packages/valory/agents/mech/aea-config.yaml | 2 +- packages/valory/services/mech/service.yaml | 2 +- .../prediction_request_claude.py | 9 +++++---- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/packages/packages.json b/packages/packages.json index 7c1af02e..6d6f1f48 100644 --- a/packages/packages.json +++ b/packages/packages.json @@ -2,10 +2,10 @@ "dev": { "connection/valory/websocket_client/0.1.0": "bafybeiflmystocxaqblhpzqlcop2vkhsknpzjx2jomohomaxamwskeokzm", "skill/valory/contract_subscription/0.1.0": "bafybeicyugrkx5glat4p4ezwf6i7oduh26eycfie6ftd4uxrknztzl3ik4", - "agent/valory/mech/0.1.0": "bafybeifg3hcc5inhmp7yhl7sjwdiuioemmcg2gc7id2ob3ttty3t3iaery", + "agent/valory/mech/0.1.0": "bafybeigpn5qnabtrwamfqpnerefnlgo2dumjni22kl4zcwhjzq4srrmnt4", "skill/valory/mech_abci/0.1.0": "bafybeiej4fot4ee27d5tujxxb2u5w4rtbanpm7txwfti73rrhgmf43xmwq", "contract/valory/agent_mech/0.1.0": "bafybeiggowhbqwg7ex2yfz57l3qzorlnu4fkipdrlzs23nrldrbbfa7dri", - "service/valory/mech/0.1.0": "bafybeiebh5mqqiist7kw3mi6lam7stlpqc3ss5vqmbids5xi5jvdb5pae4", + "service/valory/mech/0.1.0": "bafybeieany5auucyblft2i7hssabpv6hi3v7j3ulugrnkqcngawgbqqkze", "protocol/valory/acn_data_share/0.1.0": "bafybeih5ydonnvrwvy2ygfqgfabkr47s4yw3uqxztmwyfprulwfsoe7ipq", "skill/valory/task_submission_abci/0.1.0": "bafybeiewwpv5veykxbd7wfbq7vvnlcnfsraxhz6ymqxcaf5nfz6nz7g2pa", "skill/valory/task_execution/0.1.0": "bafybeidmvbucjd472m5lo3ebyhlojpl2o25mndlnllqtakqe73r7vghztq", diff --git a/packages/valory/agents/mech/aea-config.yaml b/packages/valory/agents/mech/aea-config.yaml index be700868..2218f5c6 100644 --- a/packages/valory/agents/mech/aea-config.yaml +++ b/packages/valory/agents/mech/aea-config.yaml @@ -194,7 +194,7 @@ models: args: agent_mech_contract_addresses: ${list:["0xFf82123dFB52ab75C417195c5fDB87630145ae81"]} task_deadline: ${float:240.0} - file_hash_to_tools_json: ${list:[["bafybeialjint727x536gsfs23dzsxttc3tqatfmv7gnu77jfljo5xihvq4",["claude-prediction-offline","claude-prediction-online"]],["bafybeibi34bhbvesmvd6o24jxvuldrwen4wj62na3lhva7k4afkg2shinu",["openai-text-davinci-002","openai-text-davinci-003","openai-gpt-3.5-turbo","openai-gpt-4"]],["bafybeiafdm3jctiz6wwo3rmo3vdubk7j7l5tumoxi5n5rc3x452mtkgyua",["stabilityai-stable-diffusion-v1-5","stabilityai-stable-diffusion-xl-beta-v2-2-2","stabilityai-stable-diffusion-512-v2-1","stabilityai-stable-diffusion-768-v2-1"]],["bafybeidpbnqbruzqlq424qt3i5dcvyqmcimshjilftabnrroujmjhdmteu",["transfer-native"]],["bafybeiglhy5epaytvt5qqdx77ld23ekouli53qrf2hjyebd5xghlunidfi",["prediction-online","prediction-offline"]]]} + file_hash_to_tools_json: ${list:[["bafybeifp6tn3ovhuz4oipy67ijfdm4y7t2o7en3xuggn6kh5wbwokxmczu",["claude-prediction-offline","claude-prediction-online"]],["bafybeibi34bhbvesmvd6o24jxvuldrwen4wj62na3lhva7k4afkg2shinu",["openai-text-davinci-002","openai-text-davinci-003","openai-gpt-3.5-turbo","openai-gpt-4"]],["bafybeiafdm3jctiz6wwo3rmo3vdubk7j7l5tumoxi5n5rc3x452mtkgyua",["stabilityai-stable-diffusion-v1-5","stabilityai-stable-diffusion-xl-beta-v2-2-2","stabilityai-stable-diffusion-512-v2-1","stabilityai-stable-diffusion-768-v2-1"]],["bafybeidpbnqbruzqlq424qt3i5dcvyqmcimshjilftabnrroujmjhdmteu",["transfer-native"]],["bafybeiglhy5epaytvt5qqdx77ld23ekouli53qrf2hjyebd5xghlunidfi",["prediction-online","prediction-offline"]]]} api_keys_json: ${list:[["openai", "dummy_api_key"],["stabilityai", "dummy_api_key"],["google_api_key", "dummy_api_key"],["google_engine_id", "dummy_api_key"]]} polling_interval: ${float:30.0} diff --git a/packages/valory/services/mech/service.yaml b/packages/valory/services/mech/service.yaml index 56cffffe..3cf7d327 100644 --- a/packages/valory/services/mech/service.yaml +++ b/packages/valory/services/mech/service.yaml @@ -7,7 +7,7 @@ license: Apache-2.0 fingerprint: README.md: bafybeif7ia4jdlazy6745ke2k2x5yoqlwsgwr6sbztbgqtwvs3ndm2p7ba fingerprint_ignore_patterns: [] -agent: valory/mech:0.1.0:bafybeifg3hcc5inhmp7yhl7sjwdiuioemmcg2gc7id2ob3ttty3t3iaery +agent: valory/mech:0.1.0:bafybeigpn5qnabtrwamfqpnerefnlgo2dumjni22kl4zcwhjzq4srrmnt4 number_of_agents: 4 deployment: agent: diff --git a/tools/prediction_request_claude/prediction_request_claude.py b/tools/prediction_request_claude/prediction_request_claude.py index add6909f..ed3febbb 100644 --- a/tools/prediction_request_claude/prediction_request_claude.py +++ b/tools/prediction_request_claude/prediction_request_claude.py @@ -113,9 +113,9 @@ or lead to obtain the same set of results. * Output only the JSON object to be parsed by Python's "json.loads()". Do not include any other contents in your response. * Never use Markdown syntax highlighting, such as ```json```. Only output the raw json string. -* This is incorrect: "```json{\n \"p_yes\": 0.2,\n \"p_no\": 0.8,\n \"confidence\": 0.7,\n \"info_utility\": 0.5\n}```" -* This is incorrect: ```json"{\n \"p_yes\": 0.2,\n \"p_no\": 0.8,\n \"confidence\": 0.7,\n \"info_utility\": 0.5\n}"``` -* This is correct: "{\n \"p_yes\": 0.2,\n \"p_no\": 0.8,\n \"confidence\": 0.7,\n \"info_utility\": 0.5\n}" +* This is incorrect:"```json{{\n \"queries\": [\"term1\", \"term2\"]}}```" +* This is incorrect:```json"{{\n \"queries\": [\"term1\", \"term2\"]}}"``` +* This is correct:"{{\n \"quries\": [\"term1\", \"term2\"]}}" """ ASSISTANT_TEXT = "```json" @@ -217,11 +217,12 @@ def fetch_additional_information( ) -> str: """Fetch additional information.""" url_query_prompt = URL_QUERY_PROMPT.format(user_prompt=prompt) - url_query_prompt = f"{HUMAN_PROMPT}{url_query_prompt}{AI_PROMPT}" + url_query_prompt = f"{HUMAN_PROMPT}{url_query_prompt}{AI_PROMPT}{ASSISTANT_TEXT}" completion = anthropic.completions.create( model=engine, max_tokens_to_sample=300, prompt=url_query_prompt, + stop_sequences=STOP_SEQUENCES, ) json_data = json.loads(completion.completion) urls = get_urls_from_queries(