|
| 1 | +# Create a new Docs Agent task |
| 2 | + |
| 3 | +This guide provides instructions on how to create a new Docs Agent |
| 4 | +task file (`.yaml`) for automating a workflow. |
| 5 | + |
| 6 | +## Create a new task |
| 7 | + |
| 8 | +To create a new task in your Docs Agent setup, follow these steps: |
| 9 | + |
| 10 | +1. Go to your Docs Agent directory, for example: |
| 11 | + |
| 12 | + ``` |
| 13 | + cd ~/docs_agent |
| 14 | + ``` |
| 15 | + |
| 16 | +2. Go to the `tasks` directory: |
| 17 | + |
| 18 | + ``` |
| 19 | + cd tasks |
| 20 | + ``` |
| 21 | + |
| 22 | +3. Open a text editor and create a new `yaml` file, for example: |
| 23 | + |
| 24 | + ``` |
| 25 | + nano my-new-task.yaml |
| 26 | + ``` |
| 27 | + |
| 28 | +4. Copy and paste the following task template: |
| 29 | + |
| 30 | + ``` |
| 31 | + tasks: |
| 32 | + - name: "<TASKNAME>" |
| 33 | + model: "models/gemini-1.5-flash" |
| 34 | + description: "<DESCRIPTION>" |
| 35 | + preamble: <”PREAMBLE>” |
| 36 | + steps: |
| 37 | + - prompt: "<PROMPT_1>" |
| 38 | + - prompt: "<PROMPT_2>" |
| 39 | + - prompt: "<PROMPT_3>" |
| 40 | + ``` |
| 41 | + |
| 42 | +5. Update the task name (`<TASKNAME>`). |
| 43 | +6. (**Optional**) Update the model (see this |
| 44 | + [Gemini model code][model-code]). |
| 45 | +7. Update the task description (`<DESCRIPTION>`). |
| 46 | +8. (**Optional**) Update the preamble (`<PREAMBLE>`). |
| 47 | + |
| 48 | + **Note**: The `preamble` field is not required. If it's not used, |
| 49 | + remove the `preamble` field. |
| 50 | + |
| 51 | +9. Update the prompts (`<PROMPT_#>`). |
| 52 | +10. (**Optional**) Add more prompts under the `steps` section. |
| 53 | +11. Save the file and exit the text editor. |
| 54 | +12. To verify that your new task is available, run the following command: |
| 55 | + |
| 56 | + ``` |
| 57 | + agent runtask |
| 58 | + ``` |
| 59 | +
|
| 60 | +13. Run the new task using the task name: |
| 61 | +
|
| 62 | + ``` |
| 63 | + agent runtask --task <TASKNAME> |
| 64 | + ``` |
| 65 | +
|
| 66 | + For example: |
| 67 | +
|
| 68 | + ``` |
| 69 | + agent runtask --task MyNewExampleTask |
| 70 | + ``` |
| 71 | +
|
| 72 | + If your task accepts custom input, you can run it with the |
| 73 | + `--custom_input` field, for example: |
| 74 | +
|
| 75 | + ``` |
| 76 | + agent runtask --task MyNewExampleTask --custom_input ~/my_project/my_example_doc.md |
| 77 | + ``` |
| 78 | +
|
| 79 | +## A minimum task file |
| 80 | +
|
| 81 | +The example task below is created using only the **required fields**: |
| 82 | +
|
| 83 | +``` |
| 84 | +tasks: |
| 85 | + - name: "MyExampleTask" |
| 86 | + model: "models/gemini-1.5-flash" |
| 87 | + description: "An agent example that is created using only the required fields for a task." |
| 88 | + steps: |
| 89 | + - prompt: "This is my first prompt." |
| 90 | + - prompt: "This is my second prompt." |
| 91 | + - prompt: "This is my third prompt." |
| 92 | +``` |
| 93 | +
|
| 94 | +A task can have one `prompt` step at a minimum. |
| 95 | +
|
| 96 | +For more examples, see the [`tasks`][tasks-dir] directory. |
| 97 | +
|
| 98 | +## More examples for steps |
| 99 | +
|
| 100 | +This section contains more `prompt` examples and optional fields. |
| 101 | +
|
| 102 | +### A standard prompt step |
| 103 | +
|
| 104 | +A step that runs the `helpme` command: |
| 105 | +
|
| 106 | +``` |
| 107 | + steps: |
| 108 | + - prompt: "Revise the PSA email draft above to be more concise and better structured." |
| 109 | +``` |
| 110 | +
|
| 111 | +### A POSIX command step |
| 112 | +
|
| 113 | +A step that runs a POSIX command: |
| 114 | +
|
| 115 | +``` |
| 116 | + steps: |
| 117 | + - prompt: "git --no-pager log --since=2024-10-15" |
| 118 | + function: "posix" |
| 119 | +``` |
| 120 | +
|
| 121 | +**Important**: To run a POSIX command, the `function` field |
| 122 | +must be set to `posix`. |
| 123 | +
|
| 124 | +### A step that reads a file |
| 125 | +
|
| 126 | +The `file` flag reads the specified file and added its content |
| 127 | +to the prompt's context. |
| 128 | +
|
| 129 | +A step that runs the `helpme` command with the `file` flag: |
| 130 | +
|
| 131 | +``` |
| 132 | + steps: |
| 133 | + - prompt: "Analyze this file to understand the overall structure and key concepts." |
| 134 | + flags: |
| 135 | + file: "/home/user/docs_agent/README.md" |
| 136 | +``` |
| 137 | +
|
| 138 | +A step that runs the `helpme` command with the `file` flag and accepts custom input: |
| 139 | +
|
| 140 | +``` |
| 141 | + steps: |
| 142 | + - prompt: "Analyze this file to understand the overall structure and key concepts." |
| 143 | + flags: |
| 144 | + file: "<INPUT>" |
| 145 | + default_input: "/home/user/docs_agent/README.md" |
| 146 | +``` |
| 147 | +
|
| 148 | +When this step is run, the `<INPUT>` string will be replaced with |
| 149 | +the value provided in the `--custom_input` field at runtime. |
| 150 | +
|
| 151 | +### A step that reads all files in a directory |
| 152 | +
|
| 153 | +The `allfiles` flag reads all the files in the specified directory |
| 154 | +and added their content to the prompt's context. |
| 155 | +
|
| 156 | +A step that runs the `helpme` command with the `allfiles` flag: |
| 157 | +
|
| 158 | +``` |
| 159 | + steps: |
| 160 | + - prompt: "Analyze the files in this directory to understand the overall structure and key concepts." |
| 161 | + flags: |
| 162 | + allfiles: "/home/user/docs_agent/docs" |
| 163 | +``` |
| 164 | +
|
| 165 | +A step that runs the `helpme` command with the `allfiles` flag |
| 166 | +and accepts custom input: |
| 167 | +
|
| 168 | +``` |
| 169 | + steps: |
| 170 | + - prompt: "Analyze the files in this directory to understand the overall structure and key concepts." |
| 171 | + flags: |
| 172 | + allfiles: "<INPUT>" |
| 173 | + default_input: "/home/user/docs_agent/docs" |
| 174 | +``` |
| 175 | +
|
| 176 | +When this step is run, the `<INPUT>` string will be replaced with |
| 177 | +the value provided in the `--custom_input` field at runtime. |
| 178 | +
|
| 179 | +### A step that reads each file in a directory |
| 180 | +
|
| 181 | +Similar to a `foreach` loop, the `perfile` flag reads each file in |
| 182 | +the specified directory and added the file's content to the prompt's |
| 183 | +context. For instance, if there are 5 files in the input directory, |
| 184 | +the same prompt will run 5 times using each file's content as context. |
| 185 | +
|
| 186 | +A step that runs the `helpme` command with the `perfile` flag: |
| 187 | +
|
| 188 | +``` |
| 189 | + steps: |
| 190 | + - prompt: "Analyze this file to understand the overall structure and key concepts." |
| 191 | + flags: |
| 192 | + perfile: "/home/user/docs_agent/docs" |
| 193 | +``` |
| 194 | +
|
| 195 | +A step that runs the `helpme` command with the `perfile` flag |
| 196 | +and accepts custom input: |
| 197 | +
|
| 198 | +``` |
| 199 | + steps: |
| 200 | + - prompt: "Analyze this file to understand the overall structure and key concepts." |
| 201 | + flags: |
| 202 | + perfile: "<INPUT>" |
| 203 | + default_input: "/home/user/docs_agent/docs" |
| 204 | +``` |
| 205 | +
|
| 206 | +When this step is run, the `<INPUT>` string will be replaced with |
| 207 | +the value provided in the `--custom_input` field at runtime. |
| 208 | +
|
| 209 | +### A step with the name field |
| 210 | +
|
| 211 | +A step that runs the `helpme` command and the `name` field |
| 212 | +(which is for display only) is provided: |
| 213 | +
|
| 214 | +``` |
| 215 | + steps: |
| 216 | + - name: "Revise the PSA email" |
| 217 | + prompt: "Revise the PSA email draft above to be more concise and better structured." |
| 218 | +``` |
| 219 | +
|
| 220 | +### A step with the function field |
| 221 | +
|
| 222 | +A step that runs the `helpme` command that explicitly mentions |
| 223 | +which `function` to use: |
| 224 | +
|
| 225 | +``` |
| 226 | + steps: |
| 227 | + - prompt: "Revise the PSA email draft above to be more concise and better structured." |
| 228 | + function: "helpme" |
| 229 | +``` |
| 230 | +
|
| 231 | +Without the `function` field, the prompt is set to use the `helpme` command by default. |
| 232 | +
|
| 233 | +### A question step |
| 234 | +
|
| 235 | +A step that runs the `tellme` command: |
| 236 | +
|
| 237 | +``` |
| 238 | + steps: |
| 239 | + - prompt: "Does Flutter support Material Design 3?" |
| 240 | + function: "tellme" |
| 241 | +``` |
| 242 | +
|
| 243 | +Using the `tellme` command requires **a vector database setup**. |
| 244 | +
|
| 245 | +<!-- Referene links --> |
| 246 | +
|
| 247 | +[model-code]: https://ai.google.dev/gemini-api/docs/models/gemini |
| 248 | +[tasks-dir]: ../tasks |
0 commit comments