Skip to content

Commit

Permalink
[Docs Agent] Docs Agent release version 0.4.1
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
kyolee415 committed Nov 21, 2024
1 parent 4203530 commit ae323af
Show file tree
Hide file tree
Showing 3 changed files with 258 additions and 1 deletion.
248 changes: 248 additions & 0 deletions examples/gemini/python/docs-agent/docs/create-a-new-task.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,248 @@
# Create a new Docs Agent task

This guide provides instructions on how to create a new Docs Agent
task file (`.yaml`) for automating a workflow.

## Create a new task

To create a new task in your Docs Agent setup, follow these steps:

1. Go to your Docs Agent directory, for example:

```
cd ~/docs_agent
```

2. Go to the `tasks` directory:

```
cd tasks
```

3. Open a text editor and create a new `yaml` file, for example:

```
nano my-new-task.yaml
```

4. Copy and paste the following task template:

```
tasks:
- name: "<TASKNAME>"
model: "models/gemini-1.5-flash"
description: "<DESCRIPTION>"
preamble: <”PREAMBLE>”
steps:
- prompt: "<PROMPT_1>"
- prompt: "<PROMPT_2>"
- prompt: "<PROMPT_3>"
```

5. Update the task name (`<TASKNAME>`).
6. (**Optional**) Update the model (see this
[Gemini model code][model-code]).
7. Update the task description (`<DESCRIPTION>`).
8. (**Optional**) Update the preamble (`<PREAMBLE>`).

**Note**: The `preamble` field is not required. If it's not used,
remove the `preamble` field.

9. Update the prompts (`<PROMPT_#>`).
10. (**Optional**) Add more prompts under the `steps` section.
11. Save the file and exit the text editor.
12. To verify that your new task is available, run the following command:

```
agent runtask
```
13. Run the new task using the task name:
```
agent runtask --task <TASKNAME>
```
For example:
```
agent runtask --task MyNewExampleTask
```
If your task accepts custom input, you can run it with the
`--custom_input` field, for example:
```
agent runtask --task MyNewExampleTask --custom_input ~/my_project/my_example_doc.md
```
## A minimum task file
The example task below is created using only the **required fields**:
```
tasks:
- name: "MyExampleTask"
model: "models/gemini-1.5-flash"
description: "An agent example that is created using only the required fields for a task."
steps:
- prompt: "This is my first prompt."
- prompt: "This is my second prompt."
- prompt: "This is my third prompt."
```
A task can have one `prompt` step at a minimum.
For more examples, see the [`tasks`][tasks-dir] directory.
## More examples for steps
This section contains more `prompt` examples and optional fields.
### A standard prompt step
A step that runs the `helpme` command:
```
steps:
- prompt: "Revise the PSA email draft above to be more concise and better structured."
```
### A POSIX command step
A step that runs a POSIX command:
```
steps:
- prompt: "git --no-pager log --since=2024-10-15"
function: "posix"
```
**Important**: To run a POSIX command, the `function` field
must be set to `posix`.
### A step that reads a file
The `file` flag reads the specified file and added its content
to the prompt's context.
A step that runs the `helpme` command with the `file` flag:
```
steps:
- prompt: "Analyze this file to understand the overall structure and key concepts."
flags:
file: "/home/user/docs_agent/README.md"
```
A step that runs the `helpme` command with the `file` flag and accepts custom input:
```
steps:
- prompt: "Analyze this file to understand the overall structure and key concepts."
flags:
file: "<INPUT>"
default_input: "/home/user/docs_agent/README.md"
```
When this step is run, the `<INPUT>` string will be replaced with
the value provided in the `--custom_input` field at runtime.
### A step that reads all files in a directory
The `allfiles` flag reads all the files in the specified directory
and added their content to the prompt's context.
A step that runs the `helpme` command with the `allfiles` flag:
```
steps:
- prompt: "Analyze the files in this directory to understand the overall structure and key concepts."
flags:
allfiles: "/home/user/docs_agent/docs"
```
A step that runs the `helpme` command with the `allfiles` flag
and accepts custom input:
```
steps:
- prompt: "Analyze the files in this directory to understand the overall structure and key concepts."
flags:
allfiles: "<INPUT>"
default_input: "/home/user/docs_agent/docs"
```
When this step is run, the `<INPUT>` string will be replaced with
the value provided in the `--custom_input` field at runtime.
### A step that reads each file in a directory
Similar to a `foreach` loop, the `perfile` flag reads each file in
the specified directory and added the file's content to the prompt's
context. For instance, if there are 5 files in the input directory,
the same prompt will run 5 times using each file's content as context.
A step that runs the `helpme` command with the `perfile` flag:
```
steps:
- prompt: "Analyze this file to understand the overall structure and key concepts."
flags:
perfile: "/home/user/docs_agent/docs"
```
A step that runs the `helpme` command with the `perfile` flag
and accepts custom input:
```
steps:
- prompt: "Analyze this file to understand the overall structure and key concepts."
flags:
perfile: "<INPUT>"
default_input: "/home/user/docs_agent/docs"
```
When this step is run, the `<INPUT>` string will be replaced with
the value provided in the `--custom_input` field at runtime.
### A step with the name field
A step that runs the `helpme` command and the `name` field
(which is for display only) is provided:
```
steps:
- name: "Revise the PSA email"
prompt: "Revise the PSA email draft above to be more concise and better structured."
```
### A step with the function field
A step that runs the `helpme` command that explicitly mentions
which `function` to use:
```
steps:
- prompt: "Revise the PSA email draft above to be more concise and better structured."
function: "helpme"
```
Without the `function` field, the prompt is set to use the `helpme` command by default.
### A question step
A step that runs the `tellme` command:
```
steps:
- prompt: "Does Flutter support Material Design 3?"
function: "tellme"
```
Using the `tellme` command requires **a vector database setup**.
<!-- Referene links -->
[model-code]: https://ai.google.dev/gemini-api/docs/models/gemini
[tasks-dir]: ../tasks
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def __init__(
cont: typing.Optional[str] = None,
terminal: typing.Optional[str] = None,
default_input: typing.Optional[str] = None,
response_type: typing.Optional[str] = None,
):
self.model = model
self.file = file
Expand All @@ -53,6 +54,7 @@ def __init__(
self.cont = cont
self.terminal = terminal
self.default_input = default_input
self.response_type = response_type

def __str__(self):
help_str = ""
Expand All @@ -72,6 +74,8 @@ def __str__(self):
help_str += f"RAG: {str(self.rag)}\n"
if self.yaml is not None and self.yaml != "":
help_str += f"YAML: {self.yaml}\n"
if self.response_type is not None and self.response_type != "":
help_str += f"Response type: {self.response_type}\n"
if self.out is not None and self.out != "":
help_str += f"Out: {self.out}\n"
if self.new is not None and self.new != False:
Expand Down Expand Up @@ -132,6 +136,10 @@ def dictionaryToFlags(flags: dict) -> Flags:
default_input = str(flags["default_input"])
else:
default_input = ""
if "response_type" in flags:
response_type = str(flags["response_type"])
else:
response_type = ""
flags = Flags(
model=model,
file=file,
Expand All @@ -145,6 +153,7 @@ def dictionaryToFlags(flags: dict) -> Flags:
cont=cont,
terminal=terminal,
default_input=default_input,
response_type=response_type,
)
return flags

Expand Down
2 changes: 1 addition & 1 deletion examples/gemini/python/docs-agent/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "docs-agent"
version = "0.4.0"
version = "0.4.1"
description = ""
authors = ["Docs Agent contributors"]
readme = "README.md"
Expand Down

0 comments on commit ae323af

Please sign in to comment.