mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-07-11 16:22:15 +02:00
Merge branch 'feature-remove-global-config' into 'mgx_ops'
remove global config See merge request pub/MetaGPT!308
This commit is contained in:
commit
c7dadaa4d7
42 changed files with 208 additions and 131 deletions
|
|
@ -14,7 +14,6 @@ from typing import Optional, Set, Tuple
|
|||
import aiofiles
|
||||
|
||||
from metagpt.actions import Action
|
||||
from metagpt.config2 import config
|
||||
from metagpt.const import (
|
||||
AGGREGATION,
|
||||
COMPOSITION,
|
||||
|
|
@ -40,7 +39,7 @@ class RebuildClassView(Action):
|
|||
|
||||
graph_db: Optional[GraphRepository] = None
|
||||
|
||||
async def run(self, with_messages=None, format=config.prompt_schema):
|
||||
async def run(self, with_messages=None, format=None):
|
||||
"""
|
||||
Implementation of `Action`'s `run` method.
|
||||
|
||||
|
|
@ -48,6 +47,7 @@ class RebuildClassView(Action):
|
|||
with_messages (Optional[Type]): An optional argument specifying messages to react to.
|
||||
format (str): The format for the prompt schema.
|
||||
"""
|
||||
format = format if format else self.config.prompt_schema
|
||||
graph_repo_pathname = self.context.git_repo.workdir / GRAPH_REPO_FILE_REPO / self.context.git_repo.workdir.name
|
||||
self.graph_db = await DiGraphRepository.load_from(str(graph_repo_pathname.with_suffix(".json")))
|
||||
repo_parser = RepoParser(base_directory=Path(self.i_context))
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ from pydantic import BaseModel
|
|||
from tenacity import retry, stop_after_attempt, wait_random_exponential
|
||||
|
||||
from metagpt.actions import Action
|
||||
from metagpt.config2 import config
|
||||
from metagpt.const import GRAPH_REPO_FILE_REPO
|
||||
from metagpt.logs import logger
|
||||
from metagpt.repo_parser import CodeBlockInfo, DotClassInfo
|
||||
|
|
@ -84,7 +83,7 @@ class RebuildSequenceView(Action):
|
|||
|
||||
graph_db: Optional[GraphRepository] = None
|
||||
|
||||
async def run(self, with_messages=None, format=config.prompt_schema):
|
||||
async def run(self, with_messages=None, format=None):
|
||||
"""
|
||||
Implementation of `Action`'s `run` method.
|
||||
|
||||
|
|
@ -92,6 +91,7 @@ class RebuildSequenceView(Action):
|
|||
with_messages (Optional[Type]): An optional argument specifying messages to react to.
|
||||
format (str): The format for the prompt schema.
|
||||
"""
|
||||
format = format if format else self.config.prompt_schema
|
||||
graph_repo_pathname = self.context.git_repo.workdir / GRAPH_REPO_FILE_REPO / self.context.git_repo.workdir.name
|
||||
self.graph_db = await DiGraphRepository.load_from(str(graph_repo_pathname.with_suffix(".json")))
|
||||
if not self.i_context:
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ from typing import Any, Callable, Coroutine, Optional, Union
|
|||
from pydantic import TypeAdapter, model_validator
|
||||
|
||||
from metagpt.actions import Action
|
||||
from metagpt.config2 import config
|
||||
from metagpt.logs import logger
|
||||
from metagpt.tools.search_engine import SearchEngine
|
||||
from metagpt.tools.web_browser_engine import WebBrowserEngine
|
||||
|
|
@ -134,8 +133,8 @@ class CollectLinks(Action):
|
|||
if len(remove) == 0:
|
||||
break
|
||||
|
||||
model_name = config.llm.model
|
||||
prompt = reduce_message_length(gen_msg(), model_name, system_text, config.llm.max_token)
|
||||
model_name = self.config.llm.model
|
||||
prompt = reduce_message_length(gen_msg(), model_name, system_text, self.config.llm.max_token)
|
||||
logger.debug(prompt)
|
||||
queries = await self._aask(prompt, [system_text])
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ class SearchEnhancedQA(Action):
|
|||
desc: str = "Integrating search engine results to anwser the question."
|
||||
|
||||
collect_links_action: CollectLinks = Field(
|
||||
default=CollectLinks(), description="Action to collect relevant links from a search engine."
|
||||
default_factory=CollectLinks, description="Action to collect relevant links from a search engine."
|
||||
)
|
||||
web_browse_and_summarize_action: WebBrowseAndSummarize = Field(
|
||||
default=None,
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@
|
|||
from typing import Optional
|
||||
|
||||
from metagpt.actions import Action
|
||||
from metagpt.config2 import config
|
||||
from metagpt.logs import logger
|
||||
from metagpt.schema import Message
|
||||
|
||||
|
|
@ -26,7 +25,7 @@ class TalkAction(Action):
|
|||
|
||||
@property
|
||||
def language(self):
|
||||
return self.context.kwargs.language or config.language
|
||||
return self.context.kwargs.language or self.config.language
|
||||
|
||||
@property
|
||||
def prompt(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue