Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/plan and solve #125

Merged
merged 3 commits into from
Feb 28, 2024
Merged

Feat/plan and solve #125

merged 3 commits into from
Feb 28, 2024

Conversation

kyaukyuai
Copy link
Owner

@kyaukyuai kyaukyuai commented Feb 28, 2024

Summary by CodeRabbit

  • 新機能: create_replanning_chain関数と開発計画の詳細なテンプレート作成機能を追加しました。これにより、ユーザーの要求と現在の実装に基づいて元の計画を更新するタスクを生成し、開発計画を詳細に作成することが可能になりました。
  • 新機能: 新たなパラメータplan_and_solveを導入しました。これにより、タスクの再計画が可能になり、アプリケーションの仕様が明確化されました。
  • リファクタリング: StepType列挙型からUIDesignを削除し、ステップのタイプとタスクリストを変更しました。

Copy link
Contributor

sweep-ai bot commented Feb 28, 2024

Apply Sweep Rules to your PR?

  • Apply: All new business logic should have corresponding unit tests.
  • Apply: Refactor large functions to be more modular.
  • Apply: Add docstrings to all functions and file headers.

This is an automated message generated by Sweep AI.

Copy link

github-actions bot commented Feb 28, 2024

Image description CodeRabbit

Walkthrough

このプルリクエストでは、開発計画の再計画と詳細なテンプレート作成機能が追加され、新たなパラメータplan_and_solveが導入されました。これにより、タスクの再計画が可能になり、アプリケーションの仕様が明確化されました。また、StepType列挙型からUIDesignが削除され、ステップのタイプとタスクリストが変更されました。

Changes

ファイル 概要
gpt_all_star/core/agents/chain.py, gpt_all_star/core/steps/development/replanning_prompt.py 新たな関数create_replanning_chainと開発計画の詳細なテンプレート作成機能が追加されました。
gpt_all_star/core/project.py, gpt_all_star/core/steps/development/development.py, gpt_all_star/core/steps/step.py, gpt_all_star/core/team.py, gpt_all_star/main.py 新たなパラメータplan_and_solveが追加され、タスクの再計画機能が導入されました。
gpt_all_star/core/steps/development/planning_prompt.py, gpt_all_star/core/steps/specification/additional_tasks.py アプリケーションの制約部分に新たな項目が追加され、create_additional_tasks関数内の文字列リテラルが更新されました。
gpt_all_star/core/steps/steps.py StepType列挙型からUIDesignが削除され、ステップのタイプとタスクリストが変更されました。

🐰

コードの海を泳ぎ、

新たな機能を追い求めて、

うさぎは跳ねる、

そして、変更を祝う! 🎉


Uplevel your code reviews with CodeRabbit Pro

CodeRabbit Pro

If you like this project, please support us by purchasing the Pro version. The Pro version has advanced context, superior noise reduction and several proprietary improvements compared to the open source version. Moreover, CodeRabbit Pro is free for open source projects.

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image description CodeRabbit

Commits Files that changed from the base of the PR and between 79c77a8 and 8195f3d commits.
Files selected (10)
  • gpt_all_star/core/agents/chain.py (2)
  • gpt_all_star/core/project.py (2)
  • gpt_all_star/core/steps/development/development.py (1)
  • gpt_all_star/core/steps/development/planning_prompt.py (1)
  • gpt_all_star/core/steps/development/replanning_prompt.py (1)
  • gpt_all_star/core/steps/specification/additional_tasks.py (1)
  • gpt_all_star/core/steps/step.py (1)
  • gpt_all_star/core/steps/steps.py (1)
  • gpt_all_star/core/team.py (6)
  • gpt_all_star/main.py (1)
Review comments generated (18)
  • Review: 8
  • LGTM: 10

Tips

Chat with Image description CodeRabbit Bot (@coderabbitai)

  • Reply on review comments left by this bot to ask follow-up questions. A review comment is a comment on a diff or a file.
  • Invite the bot into a review comment chain by tagging @coderabbitai in a reply.

Code suggestions

  • The bot may make code suggestions, but please review them carefully before committing since the line number ranges may be misaligned.
  • You can edit the comment made by the bot and manually tweak the suggestion if it is slightly off.

Pausing incremental reviews

  • Add @coderabbitai: ignore anywhere in the PR description to pause further reviews from the bot.

@@ -10,6 +10,7 @@ def __init__(
) -> None:
super().__init__(copilot)
self.working_directory = self.copilot.storages.app.path.absolute()
self.plan_and_solve = True

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image description CodeRabbit

新たにself.plan_and_solve = Trueが追加されていますが、この変数は他のメソッドで使用されていないようです。この変数が必要な場合は、それがどのように使用されるのかを明確にするために、その使用例を追加することを検討してみてください。もし不要ならば、この行は削除しても問題ありません。

Comment on lines +192 to +277
def create_replanning_chain(self, profile: str = ""):
system_prompt = f"""{profile}
Based on the user request provided and the current implementation, your task is to update the original plan that includes following items:
- action: it must be one of {", ".join(ACTIONS)}
- working_directory: a directory where the command is to be executed or the file is to be placed, it should be started from '.', e.g. './src'
- filename: specify only if the name of the file to be added or changed is specifically determined
- command: command to be executed if necessary
- context: all contextual information that should be communicated to the person performing the task
- objective: very detailed description of the objective to be achieved for the task to be executed to accomplish the entire plan
- reason: clear reasons why the task should be performed

If no more steps are needed and you can return to the user, then respond with that.
Otherwise, fill out the plan.
"""
function_def = {
"name": "replanning",
"description": "Create the replan.",
"parameters": {
"title": "planSchema",
"type": "object",
"properties": {
"plan": {
"type": "array",
"items": {
"type": "object",
"description": "Task to do.",
"properties": {
"action": {
"type": "string",
"description": "Task",
"anyOf": [
{"enum": ACTIONS},
],
},
"working_directory": {
"type": "string",
"description": "Directory where the command is to be executed or the file is to be located, it should be started from '.', e.g. './src'",
},
"filename": {
"type": "string",
"description": "Specify only if the name of the file to be added or changed is specifically determined",
},
"command": {
"type": "string",
"description": "Command to be executed if necessary",
},
"context": {
"type": "string",
"description": "All contextual information that should be communicated to the person performing the task",
},
"objective": {
"type": "string",
"description": "Very detailed description of the goals to be achieved for the task to be executed to accomplish the entire plan",
},
"reason": {
"type": "string",
"reason": "Clear reasons why the task should be performed",
},
},
},
}
},
"required": ["plan"],
},
}
prompt = ChatPromptTemplate.from_messages(
[
("system", system_prompt),
MessagesPlaceholder(variable_name="messages"),
(
"system",
"""
Given the conversation above, update the original plan to fully meet the user's requirements."
""",
),
]
).partial()

return (
prompt
| self._llm.bind_functions(
functions=[function_def], function_call="replanning"
)
| JsonOutputFunctionsParser()
)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image description CodeRabbit

新たな関数create_replanning_chainが追加されています。この関数は、ユーザーの要求と現在の実装に基づいて元の計画を更新するタスクを生成します。各タスクにはアクション、作業ディレクトリ、ファイル名、コマンド、コンテキスト、目的、理由などの詳細が含まれます。この変更は、開発計画の詳細なテンプレートを作成する新機能を追加するためのものです。

Comment on lines +30 to +34
plan_and_solve: bool = False,
) -> None:
self.copilot = Copilot()
self.start_time = None
self.plan_and_solve = plan_and_solve

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image description CodeRabbit

新たなパラメータplan_and_solveが追加され、クラスの属性として設定されました。この変更により、plan_and_solveの値がクラスの他のメソッドで利用可能になります。

+         plan_and_solve: bool = False,
+     ) -> None:
+         self.copilot = Copilot()
+         self.start_time = None
+         self.plan_and_solve = plan_and_solve

@@ -118,6 +120,7 @@ def start(self) -> None:
copilot=self.copilot,
members=self.agents,
japanese_mode=self.japanese_mode,
plan_and_solve=self.plan_and_solve,

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image description CodeRabbit

plan_and_solveパラメータがTeamクラスのインスタンス化に追加されました。これにより、Teamクラスのメソッドでplan_and_solveの値が利用可能になります。

+             plan_and_solve=self.plan_and_solve,

Comment on lines +31 to +34
plan_and_solve: bool = False,
):
self.japanese_mode = japanese_mode
self.plan_and_solve = plan_and_solve

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image description CodeRabbit

新たなパラメータplan_and_solveが追加され、クラスの属性として設定されました。これにより、plan_and_solveの値がクラスの他のメソッドで利用可能になります。

Comment on lines +123 to +127
MAX_REPLANNING = 5
replanning = 0
completed_plan = []
while len(tasks["plan"]) > 0:
task = tasks["plan"][0]

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image description CodeRabbit

新たな再計画機能が追加され、タスクが完了するたびに再計画が行われ、最大5回まで再計画が可能になります。

Comment on lines +136 to +146
Task: {todo}
Context: {task['context']}
Objective: {task['objective']}
Reason: {task['reason']}
---
"""
)
else:
self.supervisor.state(f"({(i+1)}/{len(tasks['plan'])}) {todo}")
self.supervisor.state(
f"({(1/len(tasks['plan']) * 100):.1f}%) {todo}"
)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image description CodeRabbit

タスクの進行状況が表示されるようになりました。これにより、ユーザーはタスクの進行状況をより詳細に把握することができます。

Comment on lines +166 to 202
tasks["plan"].pop(0)

if (
self.plan_and_solve
and step_plan_and_solve
and replanning < MAX_REPLANNING
):
completed_plan.append(task)
tasks = (
Chain()
.create_replanning_chain(self.supervisor.profile)
.invoke(
{
"messages": [
Message.create_human_message(
replanning_template.format(
original_plan=tasks,
completed_plan=completed_plan,
implementation=self.copilot.storages.current_source_code(),
specifications=self.copilot.storages.docs.get(
"specifications.md", "N/A"
),
technologies=self.copilot.storages.docs.get(
"technologies.md", "N/A"
),
)
)
],
}
)
)
replanning += 1
if self.supervisor.debug_mode:
self.supervisor.console.print(
json.dumps(tasks, indent=4, ensure_ascii=False)
)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Image description CodeRabbit

_runメソッドのタスク実行ロジックが大幅に変更され、タスクの再計画機能が追加されました。これにより、タスクが完了するたびに再計画が行われ、最大5回まで再計画が可能になります。また、再計画の結果はデバッグモードが有効な場合に表示されます。

@kyaukyuai kyaukyuai merged commit f901bdf into main Feb 28, 2024
3 checks passed
@kyaukyuai kyaukyuai deleted the feat/plan-and-solve branch February 28, 2024 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant