Revert "Merge branch 'dynamic_think' into 'mgx_ops'"

This reverts merge request !98
This commit is contained in:
林义章 2024-05-11 19:29:12 +08:00
parent 476e6256a7
commit de27855c56
8 changed files with 60 additions and 154 deletions

View file

@ -159,101 +159,44 @@ class SimpleExpRetriever(ExpRetriever):
class KeywordExpRetriever(ExpRetriever):
"""An experience retriever that returns examples based on keywords in the context."""
EXAMPLE: dict = {
"deploy": """
## example 1
User Requirement: launch a service from workspace/web_snake_game/web_snake_game, and deploy it to public
Explanation: Launching a service requires Terminal tool with daemon mode, write this into task instruction.
```json
[
{
"command_name": "append_task",
"args": {
"task_id": "1",
"dependent_task_ids": [],
"instruction": "Use the Terminal tool to launch the service in daemon mode",
"assignee": "David"
}
},
{
"command_name": "append_task",
"args": {
"task_id": "2",
"dependent_task_ids": ["1"],
"instruction": "Test the service with a simple request",
"assignee": "David"
}
},
{
"command_name": "append_task",
"args": {
"task_id": "3",
"dependent_task_ids": ["2"],
"instruction": "Deploy the service to public",
"assignee": "David"
}
},
"""
}
def retrieve(self, context: str) -> str:
if "deploy" in context.lower():
return DEPLOY_EXAMPLE
elif "issue" in context.lower():
return FIX_ISSUE_EXAMPLE
return self.EXAMPLE["deploy"]
return ""
DEPLOY_EXAMPLE = """
## example 1
User Requirement: launch a service from workspace/web_snake_game/web_snake_game, and deploy it to public
Explanation: Launching a service requires Terminal tool with daemon mode, write this into task instruction.
```json
[
{
"command_name": "append_task",
"args": {
"task_id": "1",
"dependent_task_ids": [],
"instruction": "Use the Terminal tool to launch the service in daemon mode",
"assignee": "David"
}
},
{
"command_name": "append_task",
"args": {
"task_id": "2",
"dependent_task_ids": ["1"],
"instruction": "Test the service with a simple request",
"assignee": "David"
}
},
{
"command_name": "append_task",
"args": {
"task_id": "3",
"dependent_task_ids": ["2"],
"instruction": "Deploy the service to public",
"assignee": "David"
}
},
"""
FIX_ISSUE_EXAMPLE = """
## example 1
User Requirement: Write a fix for this issue: https://github.com/xxx/xxx/issues/xxx, and commit and push your changes.
Explanation: The requirement is for software development, focusing on fixing an issue in an existing repository. The process is broken down into several steps, each demanding specific actions and tools.
```json
[
{
"command_name": "append_task",
"args": {
"task_id": "1",
"dependent_task_ids": [],
"instruction": "Read the issue description to understand the problem using the Browser tool.",
"assignee": "David"
}
},
{
"command_name": "append_task",
"args": {
"task_id": "2",
"dependent_task_ids": ["1"],
"instruction": "Clone the repository using the Terminal tool.",
"assignee": "David"
}
},
{
"command_name": "append_task",
"args": {
"task_id": "3",
"dependent_task_ids": ["2"],
"instruction": "Use Editor to search the relevant function(s), then diagnose and identify the source of the problem.",
"assignee": "David"
}
},
{
"command_name": "append_task",
"args": {
"task_id": "4",
"dependent_task_ids": ["3"],
"instruction": "Use Editor tool to fix the problem in the corresponding file(s).",
"assignee": "David"
}
},
{
"command_name": "append_task",
"args": {
"task_id": "5",
"dependent_task_ids": ["4"],
"instruction": "Commit, push the changes to the repository.",
"assignee": "David"
}
},
]
```
"""

View file

@ -36,12 +36,7 @@ class Command(Enum):
FINISH_CURRENT_TASK = CommandDef(
name="finish_current_task",
signature="finish_current_task()",
desc="Finishes current task, set Task.is_finished=True, set current task to next task. You should not finish current task if task instruction has not been fulfilled.",
)
CONTINUE_WITH_CURRENT_TASK = CommandDef(
name="continue_with_current_task",
signature="continue_with_current_task()",
desc="Continue with the current task, use this if you think you need more actions to achieve what is prescribed by the task instruction.",
desc="Finishes current task, set Task.is_finished=True, set current task to next task",
)
# commands for env interaction
@ -101,13 +96,7 @@ def run_plan_command(role: Role, cmd: list[dict]):
elif cmd["command_name"] == Command.RESET_TASK.cmd_name:
role.planner.plan.reset_task(**cmd["args"])
elif cmd["command_name"] == Command.REPLACE_TASK.cmd_name:
new_task = Task(
task_id=cmd["args"]["task_id"],
dependent_task_ids=cmd["args"]["new_dependent_task_ids"],
instruction=cmd["args"]["new_instruction"],
assignee=cmd["args"]["new_assignee"],
)
role.planner.plan.replace_task(new_task)
role.planner.plan.replace_task(Task(**cmd["args"]))
elif cmd["command_name"] == Command.FINISH_CURRENT_TASK.cmd_name:
if role.planner.plan.is_plan_finished():
return