mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-07-11 16:22:15 +02:00
fixbug: unit test
This commit is contained in:
parent
251352e802
commit
1523a0df81
19 changed files with 152 additions and 82 deletions
|
|
@ -35,7 +35,7 @@ class Action(SerializationMixin, ContextMixin, BaseModel):
|
|||
|
||||
@property
|
||||
def project_repo(self):
|
||||
return ProjectRepo(git_repo=self.context.git_repo)
|
||||
return ProjectRepo(self.context.git_repo)
|
||||
|
||||
@property
|
||||
def prompt_schema(self):
|
||||
|
|
|
|||
|
|
@ -55,10 +55,6 @@ class Context(BaseModel):
|
|||
|
||||
_llm: Optional[BaseLLM] = None
|
||||
|
||||
@property
|
||||
def file_repo(self):
|
||||
return self.git_repo.new_file_repository()
|
||||
|
||||
@property
|
||||
def options(self):
|
||||
"""Return all key-values"""
|
||||
|
|
|
|||
|
|
@ -30,8 +30,8 @@ async def text_to_image(text, size_type: str = "512x512", model_url="", config:
|
|||
|
||||
if model_url:
|
||||
binary_data = await oas3_metagpt_text_to_image(text, size_type, model_url)
|
||||
elif oai_llm := config.get_openai_llm():
|
||||
binary_data = await oas3_openai_text_to_image(text, size_type, LLM(oai_llm))
|
||||
elif config.get_openai_llm():
|
||||
binary_data = await oas3_openai_text_to_image(text, size_type, LLM())
|
||||
else:
|
||||
raise ValueError("Missing necessary parameters.")
|
||||
base64_data = base64.b64encode(binary_data).decode("utf-8")
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ class Role(SerializationMixin, ContextMixin, BaseModel):
|
|||
|
||||
@property
|
||||
def project_repo(self) -> ProjectRepo:
|
||||
project_repo = ProjectRepo(git_repo=self.context.git_repo)
|
||||
project_repo = ProjectRepo(self.context.git_repo)
|
||||
return project_repo.with_src_path(self.context.src_workspace) if self.context.src_workspace else project_repo
|
||||
|
||||
@property
|
||||
|
|
|
|||
|
|
@ -78,12 +78,14 @@ class ResourceFileRepositories(FileRepository):
|
|||
|
||||
|
||||
class ProjectRepo(FileRepository):
|
||||
def __init__(self, root: str | Path = None, git_repo: GitRepository = None):
|
||||
if not root and not git_repo:
|
||||
raise ValueError("Invalid root and git_repo")
|
||||
git_repo_ = git_repo or GitRepository(local_path=Path(root))
|
||||
def __init__(self, root: str | Path | GitRepository):
|
||||
if isinstance(root, str) or isinstance(root, Path):
|
||||
git_repo_ = GitRepository(local_path=Path(root))
|
||||
elif isinstance(root, GitRepository):
|
||||
git_repo_ = root
|
||||
else:
|
||||
raise ValueError("Invalid root")
|
||||
super().__init__(git_repo=git_repo_, relative_path=Path("."))
|
||||
|
||||
self._git_repo = git_repo_
|
||||
self.docs = DocFileRepositories(self._git_repo)
|
||||
self.resources = ResourceFileRepositories(self._git_repo)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue