diff --git a/config/config.yaml b/config/config.yaml index 179985a6f..93301fcf2 100644 --- a/config/config.yaml +++ b/config/config.yaml @@ -79,4 +79,7 @@ MODEL_FOR_RESEARCHER_REPORT: gpt-3.5-turbo-16k ### choose the engine for mermaid conversion, # default is nodejs, you can change it to playwright,pyppeteer or ink -# MERMAID_ENGINE: nodejs \ No newline at end of file +# MERMAID_ENGINE: nodejs + +### browser path for pyppeteer engine, support Chrome, Chromium,MS Edge +#PYPPETEER_EXECUTABLE_PATH: "/usr/bin/google-chrome-stable" \ No newline at end of file diff --git a/metagpt/config.py b/metagpt/config.py index 9260ae605..b4e0fe7fa 100644 --- a/metagpt/config.py +++ b/metagpt/config.py @@ -84,6 +84,7 @@ class Config(metaclass=Singleton): self.model_for_researcher_summary = self._get("MODEL_FOR_RESEARCHER_SUMMARY") self.model_for_researcher_report = self._get("MODEL_FOR_RESEARCHER_REPORT") self.mermaid_engine = self._get("MERMAID_ENGINE", 'nodejs') + self.pyppeteer_executable_path = self._get("PYPPETEER_EXECUTABLE_PATH", '') def _init_with_config_files_and_env(self, configs: dict, yaml_file): """Load from config/key.yaml, config/config.yaml, and env in decreasing order of priority""" diff --git a/metagpt/utils/mmdc_pyppeteer.py b/metagpt/utils/mmdc_pyppeteer.py index 56367236f..7ec30fd12 100644 --- a/metagpt/utils/mmdc_pyppeteer.py +++ b/metagpt/utils/mmdc_pyppeteer.py @@ -9,6 +9,7 @@ import os from urllib.parse import urljoin from pyppeteer import launch from metagpt.logs import logger +from metagpt.config import CONFIG async def mermaid_to_file(mermaid_code, output_file_without_suffix, width=2048, height=2048)-> int: """ @@ -26,14 +27,14 @@ async def mermaid_to_file(mermaid_code, output_file_without_suffix, width=2048, suffixes = ['png', 'svg', 'pdf'] __dirname = os.path.dirname(os.path.abspath(__file__)) - executablePath = os.getenv('PUPPETEER_EXECUTABLE_PATH',"") - if executablePath: + + if CONFIG.pyppeteer_executable_path: browser = await launch(headless=True, - executablePath=executablePath, + executablePath=CONFIG.pyppeteer_executable_path, args=['--disable-extensions',"--no-sandbox"] ) else: - logger.error("Please set the environment variable:PUPPETEER_EXECUTABLE_PATH.") + logger.error("Please set the environment variable:PYPPETEER_EXECUTABLE_PATH.") return -1 page = await browser.newPage() device_scale_factor = 1.0