turing-machines / mentals-ai

Agents in Markdown syntax (loops, memory and tools included) 🍓
https://x.com/mentals_ai
MIT License
344 stars 32 forks source link

split tools and instructions #2

Closed 078sky closed 4 months ago

078sky commented 5 months ago

It will be cleaner for debuging and management if we split this { "content": "Let's execute the task step by step.\n\nAvailable functions:\n<available_functions>\n# plato\nPlato debates with Xenophon.\nOutput only json object:\n{ \"name\" : \"plato\", \"input\" : \"Prompt to send to the tool or assistant. This may be instructions or question.\" }\n\n# socrates\nSocrates proofreads Plato and Xenophon.\nOutput only json object:\n{ \"name\" : \"socrates\", \"input\" : \"Prompt to send to the tool or assistant. This may be instructions or question.\" }\n\n# xenophon\nXenophon seeks Plato's wisdom.\nOutput only json object:\n{ \"name\" : \"xenophon\", \"input\" : \"Prompt to send to the tool or assistant. This may be instructions or question.\" }\n\n# print_to_stdout\nPrint message to console or screen.\nOutput only json object:\n\"{ \"name\" : \"print_to_stdout\", \"message\" : \"text for printing as a plain text\" }\"\n\n# run_python_code\nGenerate python code to execute.\n1. Always add to the code the 'print' function to output result of code execution to the console, e.g. outputting variables important for understanding the result.\n2. Handle potential None or unexpected types in the Python code within the JSON.\n3. If there is JSON in a script, ensure that no characters are before the starting {.\n4. In JSON, all strings must be enclosed in double quotes, and any double quotes within those strings must be escaped using a backslash (\").\n5. Ensure any backslashes in JSON string values are correctly escaped. This includes doubling them up (\\\\) or properly forming escape sequences for special characters.\nOutput only json object:\n\"{ \"name\" : \"run_python_code\", \"python_code\" : \"insert python code here\", \"dependencies\" : \"insert dependencies splitted by space\" }\"\n\n# bash_command_execute\nGenerate bash command to execute.\n1. Do not use for Python code execution and dependency installation.\n2. Do not use for printing.\n3. Do strings with escape charactres and use double quotes.\n4. For http requests, if the string has spaces, insert a '+' between words.\nOutput only json object:\n\"{ \"name\" : \"bash_command_execute\", \"bash_cmd\" : \"insert bash command here as a plain text\" }\"\n\n# store_in_short_term_memory\nWrite a value to a short-term memory.\nFor memorized data, you should always choose a relevant keyword.\nThe memory keyword is taken from the instruction text.\nOutput only json object:\n\"{ \"name\" : \"store_in_short_term_memory\", \"keyword\" : \"insert memory keyword here\", \"value\" : \"insert memory value here as a plain text\" }\"\n\n# stop\nStop and output a result.\nCalled if instructed to stop further execution or task completed.\nOutput only json object:\n\"{ \"name\" : \"stop\", \"output\" : \"insert output here\" }\"\n</available_functions>\n\nIf a function call is required, select the appropriate function from \n<available_functions> to call next and append to the response.\nOnly function names from the <available_functions> can be used.\nAlways add field 'name' with choosed function name to JSON object.\n\nEnsure that each special character that needs to be escaped in JSON, \nlike quotes within your string, is properly escaped.\n\nDon't output the text of the instruction itself.\nCall 'stop' function if the instruction completed.\n\nINSTRUCTION TO EXECUTE\n--------------------\nAsk Plato with user question: about ai\n", "role": "system" },

Into this { "content": "Let's execute the task step by step.\n\nAvailable functions:\n<available_functions>\n# plato\nPlato debates with Xenophon.\nOutput only json object:\n{ \"name\" : \"plato\", \"input\" : \"Prompt to send to the tool or assistant. This may be instructions or question.\" }\n\n# socrates\nSocrates proofreads Plato and Xenophon.\nOutput only json object:\n{ \"name\" : \"socrates\", \"input\" : \"Prompt to send to the tool or assistant. This may be instructions or question.\" }\n\n# xenophon\nXenophon seeks Plato's wisdom.\nOutput only json object:\n{ \"name\" : \"xenophon\", \"input\" : \"Prompt to send to the tool or assistant. This may be instructions or question.\" }\n\n# print_to_stdout\nPrint message to console or screen.\nOutput only json object:\n\"{ \"name\" : \"print_to_stdout\", \"message\" : \"text for printing as a plain text\" }\"\n\n# run_python_code\nGenerate python code to execute.\n1. Always add to the code the 'print' function to output result of code execution to the console, e.g. outputting variables important for understanding the result.\n2. Handle potential None or unexpected types in the Python code within the JSON.\n3. If there is JSON in a script, ensure that no characters are before the starting {.\n4. In JSON, all strings must be enclosed in double quotes, and any double quotes within those strings must be escaped using a backslash (\").\n5. Ensure any backslashes in JSON string values are correctly escaped. This includes doubling them up (\\\\) or properly forming escape sequences for special characters.\nOutput only json object:\n\"{ \"name\" : \"run_python_code\", \"python_code\" : \"insert python code here\", \"dependencies\" : \"insert dependencies splitted by space\" }\"\n\n# bash_command_execute\nGenerate bash command to execute.\n1. Do not use for Python code execution and dependency installation.\n2. Do not use for printing.\n3. Do strings with escape charactres and use double quotes.\n4. For http requests, if the string has spaces, insert a '+' between words.\nOutput only json object:\n\"{ \"name\" : \"bash_command_execute\", \"bash_cmd\" : \"insert bash command here as a plain text\" }\"\n\n# store_in_short_term_memory\nWrite a value to a short-term memory.\nFor memorized data, you should always choose a relevant keyword.\nThe memory keyword is taken from the instruction text.\nOutput only json object:\n\"{ \"name\" : \"store_in_short_term_memory\", \"keyword\" : \"insert memory keyword here\", \"value\" : \"insert memory value here as a plain text\" }\"\n\n# stop\nStop and output a result.\nCalled if instructed to stop further execution or task completed.\nOutput only json object:\n\"{ \"name\" : \"stop\", \"output\" : \"insert output here\" }\"\n</available_functions>\n\nIf a function call is required, select the appropriate function from \n<available_functions> to call next and append to the response.\nOnly function names from the <available_functions> can be used.\nAlways add field 'name' with choosed function name to JSON object.\n\nEnsure that each special character that needs to be escaped in JSON, \nlike quotes within your string, is properly escaped.\n\nDon't output the text of the instruction itself.\nCall 'stop' function if the instruction completed.\n\nINSTRUCTION TO EXECUTE", "role": "system" }, { "content": "Ask Plato with user question: about ai\n", "role": "system" }