Skip to content

Commit 89d464c

Browse files
authored
docs: updating guides to provide more clarity around moderator (#628)
1 parent 08f9e64 commit 89d464c

File tree

8 files changed

+29
-24
lines changed

8 files changed

+29
-24
lines changed

docs/configuration.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ Rules designed to control or manage the output of the model. Moderators that cur
4040

4141
- `passive`: does not actively intervene in every response
4242
- `truncate`: truncates the first contexts when the contexts exceed the max token size
43+
- `synopsis`: instead of truncating, it uses LLMs to summarize and condense context dynamically, keeping relevant information while staying under the token limit.
44+
45+
> **Important:** `synopsis` only works when the `synopsis` toolkit is enabled. Be sure to update your [`profile.yml` configurations](https://block.github.io/goose/guidance/getting-started.html#configuring-goose-with-the-profilesyaml-file) to enable both.
4346

4447

4548
#### toolkits

docs/plugins/providers.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,12 @@ default:
2323
provider: anthropic
2424
processor: claude-3-5-sonnet-20241022
2525
accelerator: claude-3-5-sonnet-20241022
26+
moderator: synopsis
27+
toolkits:
28+
- name: synopsis
29+
requires: {}
2630
```
31+
> **Important** Anthropic performs the best when both the `synopsis` toolkit and moderator are enabled.
2732

2833
### Azure
2934

@@ -68,8 +73,12 @@ default:
6873
provider: google
6974
processor: gemini-1.5-flash
7075
accelerator: gemini-1.5-flash
76+
moderator: truncate
77+
toolkits:
78+
- name: developer
79+
requires: {}
7180
```
72-
81+
> **Important** Gemini performs the best when both the `developer` toolkit and `truncate` moderator are enabled.
7382
### Ollama
7483

7584
For Ollama, refer to the setup process on [Ollama's site](https://ollama.com/) for obtaining necessary credentials. Make sure your environment has all the required tokens set up.

packages/exchange/src/exchange/providers/bedrock.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def get_signature_key(key: str, date_stamp: str, region_name: str, service_name:
119119
credential_scope = f"{date_stamp}/{self.region}/{service}/aws4_request"
120120
string_to_sign = (
121121
f"{algorithm}\n{amz_date}\n{credential_scope}\n"
122-
f'{hashlib.sha256(canonical_request.encode("utf-8")).hexdigest()}'
122+
f"{hashlib.sha256(canonical_request.encode('utf-8')).hexdigest()}"
123123
)
124124

125125
# Create the signing key

packages/exchange/tests/test_summarizer.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ def test_context_summarizer_rewrite(exchange_instance: Exchange, summarizer_inst
7575

7676
# Ensure roles alternate in the output
7777
for i in range(1, len(exchange_instance.messages)):
78-
assert (
79-
exchange_instance.messages[i - 1].role != exchange_instance.messages[i].role
80-
), "Messages must alternate between user and assistant"
78+
assert exchange_instance.messages[i - 1].role != exchange_instance.messages[i].role, (
79+
"Messages must alternate between user and assistant"
80+
)
8181

8282

8383
MESSAGE_SEQUENCE = [

src/goose/cli/prompt/lexer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
def completion_for_command(target_string: str) -> re.Pattern[str]:
1414
escaped_string = re.escape(target_string)
1515
vals = [f"(?:{escaped_string[:i]}(?=$))" for i in range(len(escaped_string), 0, -1)]
16-
return re.compile(rf'(?<!\S)\/({"|".join(vals)})(?:\s^|$)')
16+
return re.compile(rf"(?<!\S)\/({'|'.join(vals)})(?:\s^|$)")
1717

1818

1919
def command_itself(target_string: str) -> re.Pattern[str]:

src/goose/synopsis/toolkit.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ def bash(
4646
working_dir (str, optional): The directory to change to.
4747
source_path (str, optional): The file to source before running the command.
4848
"""
49-
assert any(
50-
[command, working_dir, source_path]
51-
), "At least one of the parameters for bash shell must be provided."
49+
assert any([command, working_dir, source_path]), (
50+
"At least one of the parameters for bash shell must be provided."
51+
)
5252

5353
bash_tool = Bash(notifier=self.notifier, exchange_view=self.exchange_view)
5454
outputs = []

src/goose/toolkit/lint.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ def lint_toolkits() -> None:
77
first_line_of_docstring = toolkit.__doc__.split("\n")[0]
88
assert len(first_line_of_docstring.split(" ")) > 5, f"`{toolkit_name}` toolkit docstring is too short"
99
assert len(first_line_of_docstring.split(" ")) < 12, f"`{toolkit_name}` toolkit docstring is too long"
10-
assert first_line_of_docstring[
11-
0
12-
].isupper(), f"`{toolkit_name}` toolkit docstring must start with a capital letter"
10+
assert first_line_of_docstring[0].isupper(), (
11+
f"`{toolkit_name}` toolkit docstring must start with a capital letter"
12+
)
1313

1414

1515
def lint_providers() -> None:
@@ -18,6 +18,6 @@ def lint_providers() -> None:
1818
first_line_of_docstring = provider.__doc__.split("\n")[0]
1919
assert len(first_line_of_docstring.split(" ")) > 5, f"`{provider_name}` provider docstring is too short"
2020
assert len(first_line_of_docstring.split(" ")) < 20, f"`{provider_name}` provider docstring is too long"
21-
assert first_line_of_docstring[
22-
0
23-
].isupper(), f"`{provider_name}` provider docstring must start with a capital letter"
21+
assert first_line_of_docstring[0].isupper(), (
22+
f"`{provider_name}` provider docstring must start with a capital letter"
23+
)

tests/toolkit/test_utils.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,7 @@
22

33

44
def test_parse_plan_simple():
5-
plan_str = (
6-
"Here is python repo\n"
7-
"-use uv\n"
8-
"-do not use poetry\n\n"
9-
"Now you should:\n\n"
10-
"-Open a file\n"
11-
"-Run a test"
12-
)
5+
plan_str = "Here is python repo\n-use uv\n-do not use poetry\n\nNow you should:\n\n-Open a file\n-Run a test"
136
expected_result = {
147
"kickoff_message": "Here is python repo\n-use uv\n-do not use poetry\n\nNow you should:",
158
"tasks": ["Open a file", "Run a test"],
@@ -57,7 +50,7 @@ def test_parse_plan_empty_kickoff_message():
5750

5851

5952
def test_parse_plan_with_numbers():
60-
plan_str = "Here is python repo\n" "Now you should:\n\n" "-1 Open a file\n" "-2 Run a test"
53+
plan_str = "Here is python repo\nNow you should:\n\n-1 Open a file\n-2 Run a test"
6154
expected_result = {
6255
"kickoff_message": "Here is python repo\nNow you should:",
6356
"tasks": ["1 Open a file", "2 Run a test"],

0 commit comments

Comments
 (0)