Skip to content

Commit 0f49ff1

Browse files
authored
[Docs Agent] Docs Agent release version 0.4.1 (#536)
What's changed: - **New how-to guide**: Publish a new how-to guide on creating a new task. - **Add response type flag**: Add a new flag that allows users to specify the response type of `agent runtask`.
1 parent 4203530 commit 0f49ff1

File tree

3 files changed

+258
-1
lines changed

3 files changed

+258
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,248 @@
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

examples/gemini/python/docs-agent/docs_agent/utilities/tasks.py

+9
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ def __init__(
4040
cont: typing.Optional[str] = None,
4141
terminal: typing.Optional[str] = None,
4242
default_input: typing.Optional[str] = None,
43+
response_type: typing.Optional[str] = None,
4344
):
4445
self.model = model
4546
self.file = file
@@ -53,6 +54,7 @@ def __init__(
5354
self.cont = cont
5455
self.terminal = terminal
5556
self.default_input = default_input
57+
self.response_type = response_type
5658

5759
def __str__(self):
5860
help_str = ""
@@ -72,6 +74,8 @@ def __str__(self):
7274
help_str += f"RAG: {str(self.rag)}\n"
7375
if self.yaml is not None and self.yaml != "":
7476
help_str += f"YAML: {self.yaml}\n"
77+
if self.response_type is not None and self.response_type != "":
78+
help_str += f"Response type: {self.response_type}\n"
7579
if self.out is not None and self.out != "":
7680
help_str += f"Out: {self.out}\n"
7781
if self.new is not None and self.new != False:
@@ -132,6 +136,10 @@ def dictionaryToFlags(flags: dict) -> Flags:
132136
default_input = str(flags["default_input"])
133137
else:
134138
default_input = ""
139+
if "response_type" in flags:
140+
response_type = str(flags["response_type"])
141+
else:
142+
response_type = ""
135143
flags = Flags(
136144
model=model,
137145
file=file,
@@ -145,6 +153,7 @@ def dictionaryToFlags(flags: dict) -> Flags:
145153
cont=cont,
146154
terminal=terminal,
147155
default_input=default_input,
156+
response_type=response_type,
148157
)
149158
return flags
150159

examples/gemini/python/docs-agent/pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "docs-agent"
3-
version = "0.4.0"
3+
version = "0.4.1"
44
description = ""
55
authors = ["Docs Agent contributors"]
66
readme = "README.md"

0 commit comments

Comments
 (0)