docs: updating guides to provide more clarity around moderator (#628)
This commit is contained in:
@@ -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
|
- `passive`: does not actively intervene in every response
|
||||||
- `truncate`: truncates the first contexts when the contexts exceed the max token size
|
- `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
|
#### toolkits
|
||||||
|
|||||||
@@ -23,7 +23,12 @@ default:
|
|||||||
provider: anthropic
|
provider: anthropic
|
||||||
processor: claude-3-5-sonnet-20241022
|
processor: claude-3-5-sonnet-20241022
|
||||||
accelerator: 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
|
### Azure
|
||||||
|
|
||||||
@@ -68,8 +73,12 @@ default:
|
|||||||
provider: google
|
provider: google
|
||||||
processor: gemini-1.5-flash
|
processor: gemini-1.5-flash
|
||||||
accelerator: 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
|
### 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.
|
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"
|
credential_scope = f"{date_stamp}/{self.region}/{service}/aws4_request"
|
||||||
string_to_sign = (
|
string_to_sign = (
|
||||||
f"{algorithm}\n{amz_date}\n{credential_scope}\n"
|
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
|
# Create the signing key
|
||||||
|
|||||||
@@ -75,9 +75,9 @@ def test_context_summarizer_rewrite(exchange_instance: Exchange, summarizer_inst
|
|||||||
|
|
||||||
# Ensure roles alternate in the output
|
# Ensure roles alternate in the output
|
||||||
for i in range(1, len(exchange_instance.messages)):
|
for i in range(1, len(exchange_instance.messages)):
|
||||||
assert (
|
assert exchange_instance.messages[i - 1].role != exchange_instance.messages[i].role, (
|
||||||
exchange_instance.messages[i - 1].role != exchange_instance.messages[i].role
|
"Messages must alternate between user and assistant"
|
||||||
), "Messages must alternate between user and assistant"
|
)
|
||||||
|
|
||||||
|
|
||||||
MESSAGE_SEQUENCE = [
|
MESSAGE_SEQUENCE = [
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ from prompt_toolkit.lexers import Lexer
|
|||||||
def completion_for_command(target_string: str) -> re.Pattern[str]:
|
def completion_for_command(target_string: str) -> re.Pattern[str]:
|
||||||
escaped_string = re.escape(target_string)
|
escaped_string = re.escape(target_string)
|
||||||
vals = [f"(?:{escaped_string[:i]}(?=$))" for i in range(len(escaped_string), 0, -1)]
|
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]:
|
def command_itself(target_string: str) -> re.Pattern[str]:
|
||||||
|
|||||||
@@ -46,9 +46,9 @@ class SynopsisDeveloper(Toolkit):
|
|||||||
working_dir (str, optional): The directory to change to.
|
working_dir (str, optional): The directory to change to.
|
||||||
source_path (str, optional): The file to source before running the command.
|
source_path (str, optional): The file to source before running the command.
|
||||||
"""
|
"""
|
||||||
assert any(
|
assert any([command, working_dir, source_path]), (
|
||||||
[command, working_dir, source_path]
|
"At least one of the parameters for bash shell must be provided."
|
||||||
), "At least one of the parameters for bash shell must be provided."
|
)
|
||||||
|
|
||||||
bash_tool = Bash(notifier=self.notifier, exchange_view=self.exchange_view)
|
bash_tool = Bash(notifier=self.notifier, exchange_view=self.exchange_view)
|
||||||
outputs = []
|
outputs = []
|
||||||
|
|||||||
@@ -7,9 +7,9 @@ def lint_toolkits() -> None:
|
|||||||
first_line_of_docstring = toolkit.__doc__.split("\n")[0]
|
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(" ")) > 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 len(first_line_of_docstring.split(" ")) < 12, f"`{toolkit_name}` toolkit docstring is too long"
|
||||||
assert first_line_of_docstring[
|
assert first_line_of_docstring[0].isupper(), (
|
||||||
0
|
f"`{toolkit_name}` toolkit docstring must start with a capital letter"
|
||||||
].isupper(), f"`{toolkit_name}` toolkit docstring must start with a capital letter"
|
)
|
||||||
|
|
||||||
|
|
||||||
def lint_providers() -> None:
|
def lint_providers() -> None:
|
||||||
@@ -18,6 +18,6 @@ def lint_providers() -> None:
|
|||||||
first_line_of_docstring = provider.__doc__.split("\n")[0]
|
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(" ")) > 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 len(first_line_of_docstring.split(" ")) < 20, f"`{provider_name}` provider docstring is too long"
|
||||||
assert first_line_of_docstring[
|
assert first_line_of_docstring[0].isupper(), (
|
||||||
0
|
f"`{provider_name}` provider docstring must start with a capital letter"
|
||||||
].isupper(), f"`{provider_name}` provider docstring must start with a capital letter"
|
)
|
||||||
|
|||||||
@@ -2,14 +2,7 @@ from goose.toolkit.utils import parse_plan
|
|||||||
|
|
||||||
|
|
||||||
def test_parse_plan_simple():
|
def test_parse_plan_simple():
|
||||||
plan_str = (
|
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"
|
||||||
"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"
|
|
||||||
)
|
|
||||||
expected_result = {
|
expected_result = {
|
||||||
"kickoff_message": "Here is python repo\n-use uv\n-do not use poetry\n\nNow you should:",
|
"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"],
|
"tasks": ["Open a file", "Run a test"],
|
||||||
@@ -57,7 +50,7 @@ def test_parse_plan_empty_kickoff_message():
|
|||||||
|
|
||||||
|
|
||||||
def test_parse_plan_with_numbers():
|
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 = {
|
expected_result = {
|
||||||
"kickoff_message": "Here is python repo\nNow you should:",
|
"kickoff_message": "Here is python repo\nNow you should:",
|
||||||
"tasks": ["1 Open a file", "2 Run a test"],
|
"tasks": ["1 Open a file", "2 Run a test"],
|
||||||
|
|||||||
Reference in New Issue
Block a user