├── LICENSE ├── README.md ├── advice.txt ├── ai_settings.yaml ├── instructions.txt ├── learnings.txt ├── output ├── file_logger.txt ├── strategy.txt ├── sudoku_generator.py ├── sudoku_puzzle.json └── sudoku_solver.py └── strategy.txt /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Samuel Butler 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # wonda 2 | AutoGPT prompt template for file based instructions and advice 3 | 4 | The goals and role of the AI as set in `ai_settings.yaml` should likely stay the same for all AI's regardless of their task. The goal of wonda is to create a general purpose AI that can be given instructions and advice through files within its workspace. This will allow you to control the AI's instructions by editing `instructions.txt` as well as give the AI advice while it is running by writing in `advice.txt`. Although if you write in `advice.txt`, you will likely need to tell the AI in-between commands to go read the file as it won't know the contents have changed. 5 | 6 | You should write your instructions for the AI in `instructions.txt`. It helps to be explicit and to break the task down into its subtasks if possible. This allows the AI to start with a high level overview of its strategy and will help it avoid getting stuck loop or doing nothing. 7 | 8 | `ai_settings.yaml` should be in the root of your AutoGPT project. 9 | 10 | The following files should be placed in the `auto_gpt_workspace` folder: 11 | 12 | - `instructions.txt` 13 | - `advice.txt` 14 | - `learnings.txt` 15 | - `strategy.txt` 16 | 17 | I have included in the `/output/` folder the following files which AutoGPT using GPT-4 created using the prompts in this repository. I have included these as an example of what AutoGPT should be able to produce. 18 | - `sudoko_generator.py` 19 | - `sudoku_solver.py` 20 | - `sudoku_puzzle.json` 21 | - `strategy.txt` - this is just a planning document AutoGPT created 22 | - `file_logger.txt` - this is an automatically generated file anytime AutoGPT does file operations 23 | -------------------------------------------------------------------------------- /advice.txt: -------------------------------------------------------------------------------- 1 | all return data MUST always be formatted as proper machine-readable JSON 2 | You do not need an editor. You are the editor. 3 | make sure to always save files to the local file system. 4 | make sure to write any new files or file changes to local file storage. 5 | divide complex tasks into sub-tasks and create new agents and delegate sub-tasks to them. 6 | 7 | -------------------------------------------------------------------------------- /ai_settings.yaml: -------------------------------------------------------------------------------- 1 | ai_goals: 2 | - Read the instructions.txt file in your workspace. This contains the goals for your project. Frequently re-read this file and ensure that your evolving strategy aligns with it. 3 | - Read the advice.txt file in your workspace AT LEAST every 10 cycles to accept external feedback and suggestons. Weigh this advice heavily. 4 | - Take notes on learnings and save them to the learnings.txt file. Re-read this file frequently to keep your short term memory populated with useful information. 5 | - Maintain an evolving strategy that is always aligned with the goal as defined in the instructions.txt file. Keep your strategy documented in the strategy.txt file and re-read it frequently to stay focused. 6 | - Maintain an evolving accomplishments.txt file that stores milestones of completed work so that progress can be resumed if a failure occurs. 7 | ai_name: wonda 8 | ai_role: An AI designed to autonomously accomplish any task by delegating tasks to sub-agents and enhancing short-term memory by frequently re-referencing local files and staying focused on a goal. 9 | -------------------------------------------------------------------------------- /instructions.txt: -------------------------------------------------------------------------------- 1 | create a sudoku puzzle generator using python. 2 | save your code in a file using the .py file extension. 3 | make sure generated puzzles are valid sudoku puzzles and are solvable. 4 | save the generted puzzles as valid machine-readle JSON files in your workspace. use the .json file extension. 5 | after you have generated a valid sudoku puzzle and saved the puzzle as a JSON file, write a sudoku solver algorithm in python. 6 | -------------------------------------------------------------------------------- /learnings.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/samuelbutler/wonda/d6a2354f5cfb7b82b5520380ce667fc2f8c85c91/learnings.txt -------------------------------------------------------------------------------- /output/file_logger.txt: -------------------------------------------------------------------------------- 1 | File Operation Logger write: strategy.txt 2 | write: sudoku_generator.py 3 | write: sudoku_puzzle.json 4 | write: sudoku_solver.py 5 | append: sudoku_solver.py 6 | -------------------------------------------------------------------------------- /output/strategy.txt: -------------------------------------------------------------------------------- 1 | 1. Develop a sudoku puzzle generator in Python. 2 | 2. Save generator code to a .py file. 3 | 3. Ensure generated puzzles are valid and solvable. 4 | 4. Save generated puzzles as .json files. 5 | 5. Write a sudoku solver algorithm in Python. -------------------------------------------------------------------------------- /output/sudoku_generator.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | 4 | def print_grid(grid): 5 | for row in grid: 6 | print(" ".join(str(x) for x in row)) 7 | 8 | 9 | def next_empty(grid): 10 | for i in range(9): 11 | for j in range(9): 12 | if grid[i][j] == 0: 13 | return i, j 14 | return -1, -1 15 | 16 | 17 | def is_valid(grid, num, row, col): 18 | if num in grid[row]: # Check row 19 | return False 20 | if num in (grid[i][col] for i in range(9)): # Check column 21 | return False 22 | 23 | box_row = (row // 3) * 3 24 | box_col = (col // 3) * 3 25 | for i in range(3): 26 | for j in range(3): 27 | if grid[box_row + i][box_col + j] == num: # Check 3x3 box 28 | return False 29 | return True 30 | 31 | 32 | def sudoku_solver(grid): 33 | row, col = next_empty(grid) 34 | if row == -1: # No more empty cells, solution found 35 | return True 36 | 37 | for num in range(1, 10): 38 | if is_valid(grid, num, row, col): 39 | grid[row][col] = num 40 | if sudoku_solver(grid): # Recursion 41 | return True 42 | grid[row][col] = 0 # Backtracking 43 | return False 44 | 45 | 46 | def sudoku_generator(): 47 | grid = [[0 for _ in range(9)] for _ in range(9)] 48 | for _ in range(20): # Fill grid with random numbers 49 | row, col = random.randint(0, 8), random.randint(0, 8) 50 | num = random.randint(1, 9) 51 | if is_valid(grid, num, row, col): 52 | grid[row][col] = num 53 | 54 | if sudoku_solver(grid): # Solve the randomly filled grid 55 | return grid 56 | return sudoku_generator() # If unsolvable, generate a new one 57 | 58 | 59 | sudoku_puzzle = sudoku_generator() 60 | print_grid(sudoku_puzzle) -------------------------------------------------------------------------------- /output/sudoku_puzzle.json: -------------------------------------------------------------------------------- 1 | { 2 | "data": [ 3 | [3, 1, 8, 4, 6, 9, 7, 2, 5], 4 | [6, 2, 4, 5, 1, 7, 3, 9, 8], 5 | [5, 9, 7, 2, 3, 8, 1, 4, 6], 6 | [2, 5, 1, 9, 7, 4, 6, 8, 3], 7 | [8, 7, 9, 3, 2, 6, 4, 5, 1], 8 | [4, 6, 3, 8, 5, 1, 9, 7, 2], 9 | [9, 4, 6, 1, 8, 2, 5, 3, 7], 10 | [1, 8, 5, 7, 4, 3, 2, 6, 9], 11 | [7, 3, 2, 6, 9, 5, 8, 1, 4] 12 | ] 13 | } -------------------------------------------------------------------------------- /output/sudoku_solver.py: -------------------------------------------------------------------------------- 1 | def is_valid(grid, row, col, num): 2 | # Check if the number is in the row or column 3 | for i in range(9): 4 | if grid[row][i] == num or grid[i][col] == num: 5 | return False 6 | 7 | # Check if the number is in the 3x3 square 8 | start_row, start_col = 3 * (row // 3), 3 * (col // 3) 9 | for i in range(3): 10 | for j in range(3): 11 | if grid[start_row + i][start_col + j] == num: 12 | return False 13 | 14 | return True 15 | 16 | 17 | def sudoku_solver(grid): 18 | # Find an empty cell 19 | empty_cell = find_empty_cell(grid) 20 | if not empty_cell: 21 | return True 22 | row, col = empty_cell 23 | 24 | # Attempt to fill the cell with a valid number 25 | for num in range(1, 10): 26 | if is_valid(grid, row, col, num): 27 | grid[row][col] = num 28 | 29 | # Continue with the next cell 30 | if sudoku_solver(grid): 31 | return True 32 | 33 | # If the placement was wrong, reset the cell to 0 34 | grid[row][col] = 0 35 | 36 | return False 37 | 38 | 39 | def find_empty_cell(grid): 40 | for i in range(9): 41 | for j in range(9): 42 | if grid[i][j] == 0: 43 | return i, j 44 | return None 45 | 46 | 47 | # Example usage 48 | sudoku_puzzle = [ 49 | [5, 3, 0, 0, 7, 0, 0, 0, 0], 50 | [6, 0, 0, 1, 9, 5, 0, 0, 0], 51 | [0, 9, 8, 0, 0, 0, 0, 6, 0], 52 | [8, 0, 0, 0, 6, 0, 0, 0, 3], 53 | [4, 0, 0, 8, 0, 3, 0, 0, 1], 54 | [7, 0, 0, 0, 2, 0, 0, 0, 6], 55 | [0, 6, 0, 0, 0, 0, 2, 8, 0], 56 | [0, 0, 0, 4, 1, 9, 0, 0, 5], 57 | [0, 0, 0, 0, 8, 0, 0, 7, 9] 58 | ] 59 | 60 | if sudoku_solver(sudoku_puzzle): 61 | for row in sudoku_puzzle: 62 | print(row) 63 | else: 64 | print("No solution exists.") 65 | 66 | # Read the generated Sudoku puzzle from the input file 67 | import json 68 | with open('sudoku_puzzle.json', 'r') as file: 69 | sudoku_puzzle = json.load(file)['data'] 70 | 71 | # Solve the generated Sudoku puzzle using the solver 72 | if sudoku_solver(sudoku_puzzle): 73 | for row in sudoku_puzzle: 74 | print(row) 75 | else: 76 | print('No solution exists.') -------------------------------------------------------------------------------- /strategy.txt: -------------------------------------------------------------------------------- 1 | 1. Develop a sudoku puzzle generator in Python. 2 | 2. Save generator code to a .py file. 3 | 3. Ensure generated puzzles are valid and solvable. 4 | 4. Save generated puzzles as .json files. 5 | 5. Write a sudoku solver algorithm in Python. --------------------------------------------------------------------------------