From e5a5223765b7634edf67bf572f9c8f71d300925d Mon Sep 17 00:00:00 2001 From: shenchucheng Date: Wed, 24 Jul 2024 22:14:21 +0800 Subject: [PATCH 1/4] add deepseek token price --- metagpt/utils/token_counter.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/metagpt/utils/token_counter.py b/metagpt/utils/token_counter.py index 1019a17af..f6ee0a232 100644 --- a/metagpt/utils/token_counter.py +++ b/metagpt/utils/token_counter.py @@ -53,6 +53,8 @@ TOKEN_COSTS = { "claude-3-opus-20240229": {"prompt": 0.015, "completion": 0.075}, "yi-34b-chat-0205": {"prompt": 0.0003, "completion": 0.0003}, "yi-34b-chat-200k": {"prompt": 0.0017, "completion": 0.0017}, + "deepseek-chat": {"prompt": 0.00014, "completion": 0.00028}, + "deepseek-coder": {"prompt": 0.00014, "completion": 0.00028}, } From da551f052696669fbc5357f6ca128fd50705267d Mon Sep 17 00:00:00 2001 From: shenchucheng Date: Wed, 24 Jul 2024 23:35:36 +0800 Subject: [PATCH 2/4] rm git-push tool --- metagpt/prompts/di/swe_agent.py | 9 ++---- metagpt/roles/di/swe_agent.py | 4 +-- metagpt/tools/libs/git.py | 53 +-------------------------------- 3 files changed, 5 insertions(+), 61 deletions(-) diff --git a/metagpt/prompts/di/swe_agent.py b/metagpt/prompts/di/swe_agent.py index fd95dc997..7f4fb956d 100644 --- a/metagpt/prompts/di/swe_agent.py +++ b/metagpt/prompts/di/swe_agent.py @@ -124,12 +124,9 @@ Thought: The bug has been fixed. Let's submit the changes. ##### Push the changes from the local repository to the remote repository. Thought: All changes have been saved, let's push the code to the remote repository. {{ - "command_name": "git_push", + "command_name": "Bash.run", "args": {{ - "local_path": "/workspace/MetaGPT", - "app_name": "github", - "comments": "Fix Issue #1275: produced TypeError: openai.types.completion_usage.CompletionUsage() argument after ** must be a mapping, not NoneType"", - "new_branch": "test-fix" + "cmd": "git push orign test-fix" }} }} -> @@ -220,7 +217,7 @@ IMPORTANT_TIPS = """ - Based on feedback of observation or bash command in trajectory to guide adjustments in your search strategy. 13. Save the code change: - - If you need to submit changes to the remote repository, first use the regular git commit command to save the changes locally, then select a command from the `Available Commands: [git_push, git_create_pull]` to submit the changes to the remote repository. + - If you need to submit changes to the remote repository, first use the regular git commit command to save the changes locally, then select a command from the `Available Commands: [git_create_pull]` to submit the changes to the remote repository. - If you don't need to submit code changes to the remote repository. use the command Bash.run('submit') to commit the changes locally. diff --git a/metagpt/roles/di/swe_agent.py b/metagpt/roles/di/swe_agent.py index e3cca3330..7be794265 100644 --- a/metagpt/roles/di/swe_agent.py +++ b/metagpt/roles/di/swe_agent.py @@ -9,7 +9,7 @@ from metagpt.prompts.di.swe_agent import ( SWE_AGENT_SYSTEM_TEMPLATE, ) from metagpt.roles.di.role_zero import RoleZero -from metagpt.tools.libs.git import git_create_pull, git_push +from metagpt.tools.libs.git import git_create_pull from metagpt.tools.libs.terminal import Bash @@ -23,7 +23,6 @@ class SWEAgent(RoleZero): "Bash", "Browser:goto,scroll", "RoleZero", - "git_push", "git_create_pull", ] terminal: Bash = Field(default_factory=Bash, exclude=True) @@ -42,7 +41,6 @@ class SWEAgent(RoleZero): self.tool_execution_map.update( { "Bash.run": self.terminal.run, - "git_push": git_push, "git_create_pull": git_create_pull, } ) diff --git a/metagpt/tools/libs/git.py b/metagpt/tools/libs/git.py index a2fd87a92..9a33ee4c1 100644 --- a/metagpt/tools/libs/git.py +++ b/metagpt/tools/libs/git.py @@ -2,8 +2,7 @@ # -*- coding: utf-8 -*- from __future__ import annotations -from pathlib import Path -from typing import Optional, Union +from typing import Optional from github.Issue import Issue from github.PullRequest import PullRequest @@ -11,56 +10,6 @@ from github.PullRequest import PullRequest from metagpt.tools.tool_registry import register_tool -@register_tool(tags=["software development", "git", "Push to remote git repository."]) -async def git_push( - local_path: Union[str, Path], - app_name: str, - comments: str = "Commit", - new_branch: str = "", -) -> "GitBranch": - """ - Pushes changes from a local Git repository to its remote counterpart. - - Args: - local_path (Union[str, Path]): The absolute path to the local Git repository. - app_name (str): The name of the platform hosting the repository (e.g., "github", "gitlab", "bitbucket"). - comments (str, optional): Comments to be associated with the push. Defaults to "Commit". - new_branch (str, optional): The name of the new branch to create and push changes to. - If not provided, changes will be pushed to the current branch. Defaults to "". - - Returns: - GitBranch: The branch to which the changes were pushed. - - Raises: - ValueError: If the provided local_path does not point to a valid Git repository. - - Example: - >>> url = "https://github.com/iorisa/snake-game.git" - >>> local_path = await git_clone(url=url) - >>> app_name = "github" - >>> comments = "Commit" - >>> new_branch = "feature/new" - >>> branch = await git_push(local_path=local_path, app_name=app_name, comments=comments, new_branch=new_branch) - >>> base = branch.base - >>> head = branch.head - >>> repo_name = branch.repo_name - >>> print(f"base branch:'{base}', head branch:'{head}', repo_name:'{repo_name}'") - base branch:'master', head branch:'feature/new', repo_name:'iorisa/snake-game' - """ - - from metagpt.tools.libs import get_env - from metagpt.utils.git_repository import GitRepository - - if not GitRepository.is_git_dir(local_path): - raise ValueError("Invalid local git repository") - - repo = GitRepository(local_path=local_path, auto_init=False) - # Read access token from environment variables. - access_token = await get_env(key="access_token", app_name=app_name) - branch = await repo.push(new_branch=new_branch, comments=comments, access_token=access_token) - return branch - - @register_tool(tags=["software development", "git", "create a git pull request or merge request"]) async def git_create_pull( base: str, From bb7508908b8b47e9d0c37951c04702e1fdefa238 Mon Sep 17 00:00:00 2001 From: shenchucheng Date: Thu, 25 Jul 2024 11:54:12 +0800 Subject: [PATCH 3/4] Revert "add deepseek token price" This reverts commit e5a5223765b7634edf67bf572f9c8f71d300925d. --- metagpt/utils/token_counter.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/metagpt/utils/token_counter.py b/metagpt/utils/token_counter.py index f6ee0a232..1019a17af 100644 --- a/metagpt/utils/token_counter.py +++ b/metagpt/utils/token_counter.py @@ -53,8 +53,6 @@ TOKEN_COSTS = { "claude-3-opus-20240229": {"prompt": 0.015, "completion": 0.075}, "yi-34b-chat-0205": {"prompt": 0.0003, "completion": 0.0003}, "yi-34b-chat-200k": {"prompt": 0.0017, "completion": 0.0017}, - "deepseek-chat": {"prompt": 0.00014, "completion": 0.00028}, - "deepseek-coder": {"prompt": 0.00014, "completion": 0.00028}, } From 65674bf49934efcb45468c45643c16c19493269d Mon Sep 17 00:00:00 2001 From: shenchucheng Date: Thu, 25 Jul 2024 11:56:42 +0800 Subject: [PATCH 4/4] update prompt --- metagpt/prompts/di/swe_agent.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/metagpt/prompts/di/swe_agent.py b/metagpt/prompts/di/swe_agent.py index 7f4fb956d..7455cf30a 100644 --- a/metagpt/prompts/di/swe_agent.py +++ b/metagpt/prompts/di/swe_agent.py @@ -126,7 +126,7 @@ Thought: All changes have been saved, let's push the code to the remote reposito {{ "command_name": "Bash.run", "args": {{ - "cmd": "git push orign test-fix" + "cmd": "git push origin test-fix" }} }} -> @@ -217,7 +217,7 @@ IMPORTANT_TIPS = """ - Based on feedback of observation or bash command in trajectory to guide adjustments in your search strategy. 13. Save the code change: - - If you need to submit changes to the remote repository, first use the regular git commit command to save the changes locally, then select a command from the `Available Commands: [git_create_pull]` to submit the changes to the remote repository. + - If you need to submit changes to the remote repository, first use the regular git commit command to save the changes locally, then use git push for pushing, and if requested, `git_create_pull` in Available Commands for creating pull request. - If you don't need to submit code changes to the remote repository. use the command Bash.run('submit') to commit the changes locally.