docs: updating guides to provide more clarity around moderator (#628)

This commit is contained in:
Ebony Louis
2025-01-17 09:00:38 -05:00
committed by GitHub
parent 08f9e640fa
commit 89d464c305
8 changed files with 29 additions and 24 deletions
+3
View File
@@ -40,6 +40,9 @@ Rules designed to control or manage the output of the model. Moderators that cur
- `passive`: does not actively intervene in every response
- `truncate`: truncates the first contexts when the contexts exceed the max token size
- `synopsis`: instead of truncating, it uses LLMs to summarize and condense context dynamically, keeping relevant information while staying under the token limit.
> **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.
#### toolkits
+10 -1
View File
@@ -23,7 +23,12 @@ default:
provider: anthropic
processor: claude-3-5-sonnet-20241022
accelerator: claude-3-5-sonnet-20241022
moderator: synopsis
toolkits:
- name: synopsis
requires: {}
```
> **Important** Anthropic performs the best when both the `synopsis` toolkit and moderator are enabled.
### Azure
@@ -68,8 +73,12 @@ default:
provider: google
processor: gemini-1.5-flash
accelerator: gemini-1.5-flash
moderator: truncate
toolkits:
- name: developer
requires: {}
```
> **Important** Gemini performs the best when both the `developer` toolkit and `truncate` moderator are enabled.
### Ollama
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.
@@ -119,7 +119,7 @@ class AwsClient(httpx.Client):
credential_scope = f"{date_stamp}/{self.region}/{service}/aws4_request"
string_to_sign = (
f"{algorithm}\n{amz_date}\n{credential_scope}\n"
f'{hashlib.sha256(canonical_request.encode("utf-8")).hexdigest()}'
f"{hashlib.sha256(canonical_request.encode('utf-8')).hexdigest()}"
)
# Create the signing key
+3 -3
View File
@@ -75,9 +75,9 @@ def test_context_summarizer_rewrite(exchange_instance: Exchange, summarizer_inst
# Ensure roles alternate in the output
for i in range(1, len(exchange_instance.messages)):
assert (
exchange_instance.messages[i - 1].role != exchange_instance.messages[i].role
), "Messages must alternate between user and assistant"
assert exchange_instance.messages[i - 1].role != exchange_instance.messages[i].role, (
"Messages must alternate between user and assistant"
)
MESSAGE_SEQUENCE = [
+1 -1
View File
@@ -13,7 +13,7 @@ from prompt_toolkit.lexers import Lexer
def completion_for_command(target_string: str) -> re.Pattern[str]:
escaped_string = re.escape(target_string)
vals = [f"(?:{escaped_string[:i]}(?=$))" for i in range(len(escaped_string), 0, -1)]
return re.compile(rf'(?<!\S)\/({"|".join(vals)})(?:\s^|$)')
return re.compile(rf"(?<!\S)\/({'|'.join(vals)})(?:\s^|$)")
def command_itself(target_string: str) -> re.Pattern[str]:
+3 -3
View File
@@ -46,9 +46,9 @@ class SynopsisDeveloper(Toolkit):
working_dir (str, optional): The directory to change to.
source_path (str, optional): The file to source before running the command.
"""
assert any(
[command, working_dir, source_path]
), "At least one of the parameters for bash shell must be provided."
assert any([command, working_dir, source_path]), (
"At least one of the parameters for bash shell must be provided."
)
bash_tool = Bash(notifier=self.notifier, exchange_view=self.exchange_view)
outputs = []
+6 -6
View File
@@ -7,9 +7,9 @@ def lint_toolkits() -> None:
first_line_of_docstring = toolkit.__doc__.split("\n")[0]
assert len(first_line_of_docstring.split(" ")) > 5, f"`{toolkit_name}` toolkit docstring is too short"
assert len(first_line_of_docstring.split(" ")) < 12, f"`{toolkit_name}` toolkit docstring is too long"
assert first_line_of_docstring[
0
].isupper(), f"`{toolkit_name}` toolkit docstring must start with a capital letter"
assert first_line_of_docstring[0].isupper(), (
f"`{toolkit_name}` toolkit docstring must start with a capital letter"
)
def lint_providers() -> None:
@@ -18,6 +18,6 @@ def lint_providers() -> None:
first_line_of_docstring = provider.__doc__.split("\n")[0]
assert len(first_line_of_docstring.split(" ")) > 5, f"`{provider_name}` provider docstring is too short"
assert len(first_line_of_docstring.split(" ")) < 20, f"`{provider_name}` provider docstring is too long"
assert first_line_of_docstring[
0
].isupper(), f"`{provider_name}` provider docstring must start with a capital letter"
assert first_line_of_docstring[0].isupper(), (
f"`{provider_name}` provider docstring must start with a capital letter"
)
+2 -9
View File
@@ -2,14 +2,7 @@ from goose.toolkit.utils import parse_plan
def test_parse_plan_simple():
plan_str = (
"Here is python repo\n"
"-use uv\n"
"-do not use poetry\n\n"
"Now you should:\n\n"
"-Open a file\n"
"-Run a test"
)
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"
expected_result = {
"kickoff_message": "Here is python repo\n-use uv\n-do not use poetry\n\nNow you should:",
"tasks": ["Open a file", "Run a test"],
@@ -57,7 +50,7 @@ def test_parse_plan_empty_kickoff_message():
def test_parse_plan_with_numbers():
plan_str = "Here is python repo\n" "Now you should:\n\n" "-1 Open a file\n" "-2 Run a test"
plan_str = "Here is python repo\nNow you should:\n\n-1 Open a file\n-2 Run a test"
expected_result = {
"kickoff_message": "Here is python repo\nNow you should:",
"tasks": ["1 Open a file", "2 Run a test"],