Skip to content

Commit

Permalink
Move puppeteer-config.json to config directory.
Browse files Browse the repository at this point in the history
  • Loading branch information
voidking committed Jul 30, 2023
1 parent 299ab5d commit 7526d59
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ python setup.py install
- don't forget to the configuration for mmdc in config.yml
```yml
PUPPETEER_CONFIG: "./puppeteer-config.json"
PUPPETEER_CONFIG: "./config/puppeteer-config.json"
MMDC: "./node_modules/.bin/mmdc"
```
Expand Down
5 changes: 2 additions & 3 deletions config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ SD_T2I_API: "/sdapi/v1/txt2img"
#LONG_TERM_MEMORY: false

#### for Mermaid CLI
# adds support for installing mmdc (Mermaid CLI) locally on the user's machine.
# PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true npm install @mermaid-js/mermaid-cli
#PUPPETEER_CONFIG: "./puppeteer-config.json"
## If you installed mmdc (Mermaid CLI) only for metagpt then enable the following configuration.
#PUPPETEER_CONFIG: "./config/puppeteer-config.json"
#MMDC: "./node_modules/.bin/mmdc"
File renamed without changes.
12 changes: 5 additions & 7 deletions metagpt/utils/mermaid.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
IS_DOCKER = os.environ.get('AM_I_IN_A_DOCKER_CONTAINER', 'false').lower()




def mermaid_to_file(mermaid_code, output_file_without_suffix, width=2048, height=2048) -> int:
"""suffix: png/svg/pdf
Expand All @@ -41,15 +39,15 @@ def mermaid_to_file(mermaid_code, output_file_without_suffix, width=2048, height
# Call the `mmdc` command to convert the Mermaid code to a PNG
logger.info(f"Generating {output_file}..")
if IS_DOCKER == 'true':
subprocess.run(['mmdc', '-p', '/app/metagpt/puppeteer-config.json', '-i',
subprocess.run(['mmdc', '-p', '/app/metagpt/config/puppeteer-config.json', '-i',
str(tmp), '-o', output_file, '-w', str(width), '-H', str(height)])
else:
if CONFIG.puppeteer_config:
subprocess.run([CONFIG.mmdc,'-p',CONFIG.puppeteer_config, '-i', str(tmp), '-o',
output_file, '-w', str(width), '-H', str(height)])
subprocess.run([CONFIG.mmdc, '-p', CONFIG.puppeteer_config, '-i', str(tmp), '-o',
output_file, '-w', str(width), '-H', str(height)])
else:
subprocess.run( [CONFIG.mmdc, '-i', str(tmp), '-o',
output_file, '-w', str(width), '-H', str(height)])
subprocess.run([CONFIG.mmdc, '-i', str(tmp), '-o',
output_file, '-w', str(width), '-H', str(height)])
return 0


Expand Down

0 comments on commit 7526d59

Please sign in to comment.