mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-06-20 15:38:09 +02:00
refactor: git tools
This commit is contained in:
parent
4b35573730
commit
8937352f36
4 changed files with 166 additions and 350 deletions
|
|
@ -9,6 +9,9 @@ import pytest
|
|||
from github import Auth, Github
|
||||
from pydantic import BaseModel
|
||||
|
||||
from metagpt.context import Context
|
||||
from metagpt.roles.di.data_interpreter import DataInterpreter
|
||||
from metagpt.schema import UserMessage
|
||||
from metagpt.tools.libs.git import git_checkout, git_clone
|
||||
from metagpt.utils.common import awrite
|
||||
from metagpt.utils.git_repository import GitRepository
|
||||
|
|
@ -121,5 +124,24 @@ async def test_github(context):
|
|||
assert pr
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize(
|
||||
"content",
|
||||
[
|
||||
# "create a new issue to github repo 'iorisa/snake-game' :'The snake did not grow longer after eating'",
|
||||
"Resolve the issue #1 'Snake not growing longer after eating' in the GitHub repository https://github.com/iorisa/snake-game.git', and create a new pull request about the issue"
|
||||
],
|
||||
)
|
||||
async def test_git_create_issue(content: str):
|
||||
context = Context()
|
||||
di = DataInterpreter(context=context, tools=["<all>"])
|
||||
|
||||
prerequisite = "from metagpt.tools.libs import get_env"
|
||||
await di.execute_code.run(code=prerequisite, language="python")
|
||||
di.put_message(UserMessage(content=content))
|
||||
while not di.is_idle:
|
||||
await di.run()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
pytest.main([__file__, "-s"])
|
||||
|
|
|
|||
|
|
@ -4,9 +4,6 @@ from typing import Dict
|
|||
|
||||
import pytest
|
||||
|
||||
from metagpt.context import Context
|
||||
from metagpt.roles.di.data_interpreter import DataInterpreter
|
||||
from metagpt.schema import UserMessage
|
||||
from metagpt.tools.libs.software_development import import_git_repo
|
||||
|
||||
|
||||
|
|
@ -22,27 +19,5 @@ async def test_import_repo():
|
|||
assert path
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize(
|
||||
"content",
|
||||
[
|
||||
# "create a new issue to github repo 'iorisa/snake-game' :'The snake did not grow longer after eating'",
|
||||
"Resolve the issue #1 'Snake not growing longer after eating' in the GitHub repository https://github.com/iorisa/snake-game.git', and create a new pull request about the issue"
|
||||
],
|
||||
)
|
||||
async def test_git_create_issue(content: str):
|
||||
context = Context()
|
||||
di = DataInterpreter(context=context, tools=["<all>"])
|
||||
|
||||
prerequisite = "from metagpt.tools.libs import get_env"
|
||||
await di.execute_code.run(code=prerequisite, language="python")
|
||||
usage = await get_env_description()
|
||||
acknowledge = [f"- You can use `{k}` to '{v}'" for k, v in usage.items()]
|
||||
content += "\n---\n## Acknowledge\n" + "\n".join(acknowledge)
|
||||
di.put_message(UserMessage(content=content))
|
||||
while not di.is_idle:
|
||||
await di.run()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
pytest.main([__file__, "-s"])
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue