Merge branch 'dev' into code_intepreter

This commit is contained in:
yzlin 2024-02-01 00:27:42 +08:00
commit ff970ab1c7
20 changed files with 93 additions and 131 deletions

View file

@ -8,7 +8,7 @@ RUN apt update &&\
# Install Mermaid CLI globally
ENV CHROME_BIN="/usr/bin/chromium" \
PUPPETEER_CONFIG="/app/metagpt/config/puppeteer-config.json"\
puppeteer_config="/app/metagpt/config/puppeteer-config.json"\
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD="true"
RUN npm install -g @mermaid-js/mermaid-cli &&\
npm cache clean --force

View file

@ -67,10 +67,10 @@ # Step 2: Clone the repository to your local machine for latest version, and ins
cd MetaGPT
pip3 install -e . # or pip3 install metagpt # for stable version
# Step 3: setup your OPENAI_API_KEY, or make sure it existed in the env
# Step 3: setup your LLM key in the config2.yaml file
mkdir ~/.metagpt
cp config/config.yaml ~/.metagpt/config.yaml
vim ~/.metagpt/config.yaml
cp config/config2.yaml ~/.metagpt/config2.yaml
vim ~/.metagpt/config2.yaml
# Step 4: run metagpt cli
metagpt "Create a 2048 game in python"
@ -87,16 +87,16 @@ ### Docker installation
> Note: In the Windows, you need to replace "/opt/metagpt" with a directory that Docker has permission to create, such as "D:\Users\x\metagpt"
```bash
# Step 1: Download metagpt official image and prepare config.yaml
# Step 1: Download metagpt official image and prepare config2.yaml
docker pull metagpt/metagpt:latest
mkdir -p /opt/metagpt/{config,workspace}
docker run --rm metagpt/metagpt:latest cat /app/metagpt/config/config.yaml > /opt/metagpt/config/key.yaml
vim /opt/metagpt/config/key.yaml # Change the config
docker run --rm metagpt/metagpt:latest cat /app/metagpt/config/config2.yaml > /opt/metagpt/config/config2.yaml
vim /opt/metagpt/config/config2.yaml # Change the config
# Step 2: Run metagpt demo with container
docker run --rm \
--privileged \
-v /opt/metagpt/config/key.yaml:/app/metagpt/config/key.yaml \
-v /opt/metagpt/config/config2.yaml:/app/metagpt/config/config2.yaml \
-v /opt/metagpt/workspace:/app/metagpt/workspace \
metagpt/metagpt:latest \
metagpt "Write a cli snake game"

View file

@ -37,6 +37,3 @@ IFLYTEK_API_KEY: "YOUR_API_KEY"
IFLYTEK_API_SECRET: "YOUR_API_SECRET"
METAGPT_TEXT_TO_IMAGE_MODEL_URL: "YOUR_MODEL_URL"
PYPPETEER_EXECUTABLE_PATH: "/Applications/Google Chrome.app"

View file

@ -83,10 +83,10 @@
1. PRD stuck / unable to access/ connection interrupted
1. The official OPENAI_BASE_URL address is `https://api.openai.com/v1`
1. If the official OPENAI_BASE_URL address is inaccessible in your environment (this can be verified with curl), it's recommended to configure using the reverse proxy OPENAI_BASE_URL provided by libraries such as openai-forward. For instance, `OPENAI_BASE_URL: "``https://api.openai-forward.com/v1``"`
1. If the official OPENAI_BASE_URL address is inaccessible in your environment (again, verifiable via curl), another option is to configure the OPENAI_PROXY parameter. This way, you can access the official OPENAI_BASE_URL via a local proxy. If you don't need to access via a proxy, please do not enable this configuration; if accessing through a proxy is required, modify it to the correct proxy address. Note that when OPENAI_PROXY is enabled, don't set OPENAI_BASE_URL.
1. Note: OpenAI's default API design ends with a v1. An example of the correct configuration is: `OPENAI_BASE_URL: "``https://api.openai.com/v1``"`
1. The official openai base_url address is `https://api.openai.com/v1`
1. If the official openai base_url address is inaccessible in your environment (this can be verified with curl), it's recommended to configure using the reverse proxy openai base_url provided by libraries such as openai-forward. For instance, `openai base_url: "``https://api.openai-forward.com/v1``"`
1. If the official openai base_url address is inaccessible in your environment (again, verifiable via curl), another option is to configure the llm.proxy parameter. This way, you can access the official openai base_url via a local proxy. If you don't need to access via a proxy, please do not enable this configuration; if accessing through a proxy is required, modify it to the correct proxy address. Note that when llm.proxy is enabled, don't set openai base_url.
1. Note: OpenAI's default API design ends with a v1. An example of the correct configuration is: `openai base_url: "``https://api.openai.com/v1``"`
1. Absolutely! How can I assist you today?
@ -119,28 +119,6 @@
1. When using a database, it often gets the implementation wrong — since the SQL database initialization process is usually not in the code.
1. With more lines of code, there's a higher chance of false impressions, leading to calls to non-existent APIs.
1. Instructions for using SD Skills/UI Role:
1. Currently, there is a test script located in /tests/metagpt/roles. The file ui_role provides the corresponding code implementation. For testing, you can refer to the test_ui in the same directory.
1. The UI role takes over from the product manager role, extending the output from the 【UI Design draft】 provided by the product manager role. The UI role has implemented the UIDesign Action. Within the run of UIDesign, it processes the respective context, and based on the set template, outputs the UI. The output from the UI role includes:
1. UI Design Description: Describes the content to be designed and the design objectives.
1. Selected Elements Describes the elements in the design that need to be illustrated.
1. HTML Layout Outputs the HTML code for the page.
1. CSS Styles (styles.css) Outputs the CSS code for the page.
1. Currently, the SD skill is a tool invoked by UIDesign. It instantiates the SDEngine, with specific code found in metagpt/tools/libs/sd_engine.py.
1. Configuration instructions for SD Skills: The SD interface is currently deployed based on *https://github.com/AUTOMATIC1111/stable-diffusion-webui* **For environmental configurations and model downloads, please refer to the aforementioned GitHub repository. To initiate the SD service that supports API calls, run the command specified in cmd with the parameter nowebui, i.e.,
1. > python3 webui.py --enable-insecure-extension-access --port xxx --no-gradio-queue --nowebui
1.     Once it runs without errors, the interface will be accessible after approximately 1 minute when the model finishes loading.
1. Configure SD_URL and SD_T2I_API in the config.yaml/key.yaml files.
1. ![](https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/065295a67b0b4feea665d1372722d49d~tplv-k3u1fbpfcp-zoom-1.image)
1.     SD_URL is the deployed server/machine IP, and Port is the specified port above, defaulting to 7860.
1. > SD_URL: IP:Port
1. An error occurred during installation: "Another program is using this file...egg".
1. Delete the file and try again.

View file

@ -48,7 +48,7 @@ # 第 2 步:克隆最新仓库到您的本地机器,并进行安装。
pip3 install -e. # 或者 pip3 install metagpt # 安装稳定版本
# 第 3 步执行metagpt
# 拷贝config.yaml为key.yaml并设置你自己的OPENAI_API_KEY
# 拷贝config2.yaml为~/.metagpt/config2.yaml并设置你自己的api_key
metagpt "Write a cli snake game"
# 第 4 步【可选的】如果你想在执行过程中保存像象限图、系统设计、序列流程等图表这些产物可以在第3步前执行该步骤。默认的框架做了兼容在不执行该步的情况下也可以完整跑完整个流程。
@ -63,16 +63,16 @@ ### Docker安装
> 注意在Windows中你需要将 "/opt/metagpt" 替换为Docker具有创建权限的目录比如"D:\Users\x\metagpt"
```bash
# 步骤1: 下载metagpt官方镜像并准备好config.yaml
# 步骤1: 下载metagpt官方镜像并准备好config2.yaml
docker pull metagpt/metagpt:latest
mkdir -p /opt/metagpt/{config,workspace}
docker run --rm metagpt/metagpt:latest cat /app/metagpt/config/config.yaml > /opt/metagpt/config/key.yaml
vim /opt/metagpt/config/key.yaml # 修改配置文件
docker run --rm metagpt/metagpt:latest cat /app/metagpt/config/config2.yaml > /opt/metagpt/config/config2.yaml
vim /opt/metagpt/config/config2.yaml # 修改配置文件
# 步骤2: 使用容器运行metagpt演示
docker run --rm \
--privileged \
-v /opt/metagpt/config/key.yaml:/app/metagpt/config/key.yaml \
-v /opt/metagpt/config/config2.yaml:/app/metagpt/config/config2.yaml \
-v /opt/metagpt/workspace:/app/metagpt/workspace \
metagpt/metagpt:latest \
metagpt "Write a cli snake game"

View file

@ -68,7 +68,7 @@ # ステップ 2: リポジトリをローカルマシンにクローンし、
pip install -e.
# ステップ 3: metagpt を実行する
# config.yaml を key.yaml にコピーし、独自の OPENAI_API_KEY を設定します
# config/config2.yaml を ~/.metagpt/config2.yaml にコピーし、独自の api_key を設定します
metagpt "Write a cli snake game"
# ステップ 4 [オプション]: 実行中に PRD ファイルなどのアーティファクトを保存する場合は、ステップ 3 の前にこのステップを実行できます。デフォルトでは、フレームワークには互換性があり、この手順を実行しなくてもプロセス全体を完了できます。
@ -91,8 +91,8 @@ # NPM がシステムにインストールされていることを確認して
- config.yml に mmdc のコンフィグを記述するのを忘れないこと
```yml
PUPPETEER_CONFIG: "./config/puppeteer-config.json"
MMDC: "./node_modules/.bin/mmdc"
puppeteer_config: "./config/puppeteer-config.json"
path: "./node_modules/.bin/mmdc"
```
- もし `pip install -e.` がエラー `[Errno 13] Permission denied: '/usr/local/lib/python3.11/dist-packages/test-easy-install-13129.write-test'` で失敗したら、代わりに `pip install -e. --user` を実行してみてください
@ -114,12 +114,13 @@ # NPM がシステムにインストールされていることを確認して
playwright install --with-deps chromium
```
- **modify `config.yaml`**
- **modify `config2.yaml`**
config.yaml から MERMAID_ENGINE のコメントを外し、`playwright` に変更する
config2.yaml から mermaid.engine のコメントを外し、`playwright` に変更する
```yaml
MERMAID_ENGINE: playwright
mermaid:
engine: playwright
```
- pyppeteer
@ -143,21 +144,23 @@ # NPM がシステムにインストールされていることを確認して
pyppeteer-install
```
- **`config.yaml` を修正**
- **`config2.yaml` を修正**
config.yaml から MERMAID_ENGINE のコメントを外し、`pyppeteer` に変更する
config2.yaml から mermaid.engine のコメントを外し、`pyppeteer` に変更する
```yaml
MERMAID_ENGINE: pyppeteer
mermaid:
engine: pyppeteer
```
- mermaid.ink
- **`config.yaml` を修正**
- **`config2.yaml` を修正**
config.yaml から MERMAID_ENGINE のコメントを外し、`ink` に変更する
config2.yaml から mermaid.engine のコメントを外し、`ink` に変更する
```yaml
MERMAID_ENGINE: ink
mermaid:
engine: ink
```
注: この方法は pdf エクスポートに対応していません。
@ -166,16 +169,16 @@ ### Docker によるインストール
> Windowsでは、"/opt/metagpt"をDockerが作成する権限を持つディレクトリに置き換える必要があります。例えば、"D:\Users\x\metagpt"などです。
```bash
# ステップ 1: metagpt 公式イメージをダウンロードし、config.yaml を準備する
# ステップ 1: metagpt 公式イメージをダウンロードし、config2.yaml を準備する
docker pull metagpt/metagpt:latest
mkdir -p /opt/metagpt/{config,workspace}
docker run --rm metagpt/metagpt:latest cat /app/metagpt/config/config.yaml > /opt/metagpt/config/key.yaml
vim /opt/metagpt/config/key.yaml # 設定を変更する
docker run --rm metagpt/metagpt:latest cat /app/metagpt/config/config2.yaml > /opt/metagpt/config/config2.yaml
vim /opt/metagpt/config/config2.yaml # 設定を変更する
# ステップ 2: コンテナで metagpt デモを実行する
docker run --rm \
--privileged \
-v /opt/metagpt/config/key.yaml:/app/metagpt/config/key.yaml \
-v /opt/metagpt/config/config2.yaml:/app/metagpt/config/config2.yaml \
-v /opt/metagpt/workspace:/app/metagpt/workspace \
metagpt/metagpt:latest \
metagpt "Write a cli snake game"
@ -183,7 +186,7 @@ # ステップ 2: コンテナで metagpt デモを実行する
# コンテナを起動し、その中でコマンドを実行することもできます
docker run --name metagpt -d \
--privileged \
-v /opt/metagpt/config/key.yaml:/app/metagpt/config/key.yaml \
-v /opt/metagpt/config/config2.yaml:/app/metagpt/config/config2.yaml \
-v /opt/metagpt/workspace:/app/metagpt/workspace \
metagpt/metagpt:latest
@ -194,7 +197,7 @@ # コンテナを起動し、その中でコマンドを実行することもで
コマンド `docker run ...` は以下のことを行います:
- 特権モードで実行し、ブラウザの実行権限を得る
- ホスト設定ファイル `/opt/metagpt/config/key.yaml` をコンテナ `/app/metagpt/config/key.yaml` にマップします
- ホスト設定ファイル `/opt/metagpt/config/config2.yaml` をコンテナ `/app/metagpt/config/config2.yaml` にマップします
- ホストディレクトリ `/opt/metagpt/workspace` をコンテナディレクトリ `/app/metagpt/workspace` にマップするs
- デモコマンド `metagpt "Write a cli snake game"` を実行する
@ -208,19 +211,14 @@ # また、自分で metagpt イメージを構築することもできます。
## 設定
- `OPENAI_API_KEY` を `config/key.yaml / config/config.yaml / env` のいずれかで設定します。
- 優先順位は: `config/key.yaml > config/config.yaml > env` の順です。
- `api_key` を `~/.metagpt/config2.yaml / config/config2.yaml` のいずれかで設定します。
- 優先順位は: `~/.metagpt/config2.yaml > config/config2.yaml > env` の順です。
```bash
# 設定ファイルをコピーし、必要な修正を加える。
cp config/config.yaml config/key.yaml
cp config/config2.yaml ~/.metagpt/config2.yaml
```
| 変数名 | config/key.yaml | env |
| --------------------------------------- | ----------------------------------------- | ----------------------------------------------- |
| OPENAI_API_KEY # 自分のキーに置き換える | OPENAI_API_KEY: "sk-..." | export OPENAI_API_KEY="sk-..." |
| OPENAI_BASE_URL # オプション | OPENAI_BASE_URL: "https://<YOUR_SITE>/v1" | export OPENAI_BASE_URL="https://<YOUR_SITE>/v1" |
## チュートリアル: スタートアップの開始
```shell

View file

@ -36,8 +36,8 @@ # Step 3: Clone the repository to your local machine, and install it.
- don't forget to the configuration for mmdc in config.yml
```yml
PUPPETEER_CONFIG: "./config/puppeteer-config.json"
MMDC: "./node_modules/.bin/mmdc"
puppeteer_config: "./config/puppeteer-config.json"
path: "./node_modules/.bin/mmdc"
```
- if `pip install -e.` fails with error `[Errno 13] Permission denied: '/usr/local/lib/python3.11/dist-packages/test-easy-install-13129.write-test'`, try instead running `pip install -e. --user`
@ -59,12 +59,13 @@ # Step 3: Clone the repository to your local machine, and install it.
playwright install --with-deps chromium
```
- **modify `config.yaml`**
- **modify `config2.yaml`**
uncomment MERMAID_ENGINE from config.yaml and change it to `playwright`
uncomment mermaid.engine from config2.yaml and change it to `playwright`
```yaml
MERMAID_ENGINE: playwright
mermaid:
engine: playwright
```
- pyppeteer
@ -88,21 +89,23 @@ # Step 3: Clone the repository to your local machine, and install it.
pyppeteer-install
```
- **modify `config.yaml`**
- **modify `config2.yaml`**
uncomment MERMAID_ENGINE from config.yaml and change it to `pyppeteer`
uncomment mermaid.engine from config2.yaml and change it to `pyppeteer`
```yaml
MERMAID_ENGINE: pyppeteer
mermaid:
engine: pyppeteer
```
- mermaid.ink
- **modify `config.yaml`**
- **modify `config2.yaml`**
uncomment MERMAID_ENGINE from config.yaml and change it to `ink`
uncomment mermaid.engine from config2.yaml and change it to `ink`
```yaml
MERMAID_ENGINE: ink
mermaid:
engine: ink
```
Note: this method does not support pdf export.

View file

@ -36,8 +36,8 @@ # 第 3 步:克隆仓库到您的本地机器,并进行安装。
- 不要忘记在config.yml中为mmdc配置配置
```yml
PUPPETEER_CONFIG: "./config/puppeteer-config.json"
MMDC: "./node_modules/.bin/mmdc"
puppeteer_config: "./config/puppeteer-config.json"
path: "./node_modules/.bin/mmdc"
```
- 如果`pip install -e.`失败并显示错误`[Errno 13] Permission denied: '/usr/local/lib/python3.11/dist-packages/test-easy-install-13129.write-test'`,请尝试使用`pip install -e. --user`运行。

View file

@ -3,16 +3,16 @@ ## Docker Installation
### Use default MetaGPT image
```bash
# Step 1: Download metagpt official image and prepare config.yaml
# Step 1: Download metagpt official image and prepare config2.yaml
docker pull metagpt/metagpt:latest
mkdir -p /opt/metagpt/{config,workspace}
docker run --rm metagpt/metagpt:latest cat /app/metagpt/config/config.yaml > /opt/metagpt/config/key.yaml
vim /opt/metagpt/config/key.yaml # Change the config
docker run --rm metagpt/metagpt:latest cat /app/metagpt/config/config2.yaml > /opt/metagpt/config/config2.yaml
vim /opt/metagpt/config/config2.yaml # Change the config
# Step 2: Run metagpt demo with container
docker run --rm \
--privileged \
-v /opt/metagpt/config/key.yaml:/app/metagpt/config/key.yaml \
-v /opt/metagpt/config/config2.yaml:/app/metagpt/config/config2.yaml \
-v /opt/metagpt/workspace:/app/metagpt/workspace \
metagpt/metagpt:latest \
metagpt "Write a cli snake game"
@ -20,7 +20,7 @@ # Step 2: Run metagpt demo with container
# You can also start a container and execute commands in it
docker run --name metagpt -d \
--privileged \
-v /opt/metagpt/config/key.yaml:/app/metagpt/config/key.yaml \
-v /opt/metagpt/config/config2.yaml:/app/metagpt/config/config2.yaml \
-v /opt/metagpt/workspace:/app/metagpt/workspace \
metagpt/metagpt:latest
@ -31,7 +31,7 @@ # You can also start a container and execute commands in it
The command `docker run ...` do the following things:
- Run in privileged mode to have permission to run the browser
- Map host configure file `/opt/metagpt/config/key.yaml` to container `/app/metagpt/config/key.yaml`
- Map host configure file `/opt/metagpt/config/config2.yaml` to container `/app/metagpt/config/config2.yaml`
- Map host directory `/opt/metagpt/workspace` to container `/app/metagpt/workspace`
- Execute the demo command `metagpt "Write a cli snake game"`

View file

@ -3,16 +3,16 @@ ## Docker安装
### 使用MetaGPT镜像
```bash
# 步骤1: 下载metagpt官方镜像并准备好config.yaml
# 步骤1: 下载metagpt官方镜像并准备好config2.yaml
docker pull metagpt/metagpt:latest
mkdir -p /opt/metagpt/{config,workspace}
docker run --rm metagpt/metagpt:latest cat /app/metagpt/config/config.yaml > /opt/metagpt/config/key.yaml
vim /opt/metagpt/config/key.yaml # 修改配置文件
docker run --rm metagpt/metagpt:latest cat /app/metagpt/config/config2.yaml > /opt/metagpt/config/config2.yaml
vim /opt/metagpt/config/config2.yaml # 修改配置文件
# 步骤2: 使用容器运行metagpt演示
docker run --rm \
--privileged \
-v /opt/metagpt/config/key.yaml:/app/metagpt/config/key.yaml \
-v /opt/metagpt/config/config2.yaml:/app/metagpt/config/config2.yaml \
-v /opt/metagpt/workspace:/app/metagpt/workspace \
metagpt/metagpt:latest \
metagpt "Write a cli snake game"
@ -20,7 +20,7 @@ # 步骤2: 使用容器运行metagpt演示
# 您也可以启动一个容器并在其中执行命令
docker run --name metagpt -d \
--privileged \
-v /opt/metagpt/config/key.yaml:/app/metagpt/config/key.yaml \
-v /opt/metagpt/config/config2.yaml:/app/metagpt/config/config2.yaml \
-v /opt/metagpt/workspace:/app/metagpt/workspace \
metagpt/metagpt:latest
@ -31,7 +31,7 @@ # 您也可以启动一个容器并在其中执行命令
`docker run ...`做了以下事情:
- 以特权模式运行,有权限运行浏览器
- 将主机文件 `/opt/metagpt/config/key.yaml` 映射到容器文件 `/app/metagpt/config/key.yaml`
- 将主机文件 `/opt/metagpt/config/config2.yaml` 映射到容器文件 `/app/metagpt/config/config2.yaml`
- 将主机目录 `/opt/metagpt/workspace` 映射到容器目录 `/app/metagpt/workspace`
- 执行示例命令 `metagpt "Write a cli snake game"`

View file

@ -2,19 +2,14 @@ ## MetaGPT Usage
### Configuration
- Configure your `OPENAI_API_KEY` in any of `config/key.yaml / config/config.yaml / env`
- Priority order: `config/key.yaml > config/config.yaml > env`
- Configure your `key` in any of `~/.metagpt/config2.yaml / config/config2.yaml`
- Priority order: `~/.metagpt/config2.yaml > config/config2.yaml`
```bash
# Copy the configuration file and make the necessary modifications.
cp config/config.yaml config/key.yaml
cp config/config2.yaml ~/.metagpt/config2.yaml
```
| Variable Name | config/key.yaml | env |
| ------------------------------------------ | ----------------------------------------- | ----------------------------------------------- |
| OPENAI_API_KEY # Replace with your own key | OPENAI_API_KEY: "sk-..." | export OPENAI_API_KEY="sk-..." |
| OPENAI_BASE_URL # Optional | OPENAI_BASE_URL: "https://<YOUR_SITE>/v1" | export OPENAI_BASE_URL="https://<YOUR_SITE>/v1" |
### Initiating a startup
```shell

View file

@ -2,19 +2,14 @@ ## MetaGPT 使用
### 配置
- 在 `config/key.yaml / config/config.yaml / env` 中配置您的 `OPENAI_API_KEY`
- 优先级顺序:`config/key.yaml > config/config.yaml > env`
- 在 `~/.metagpt/config2.yaml / config/config2.yaml` 中配置您的 `key`
- 优先级顺序:`~/.metagpt/config2.yaml > config/config2.yaml`
```bash
# 复制配置文件并进行必要的修改
cp config/config.yaml config/key.yaml
cp config/config2.yaml ~/.metagpt/config2.yaml
```
| 变量名 | config/key.yaml | env |
| ----------------------------------- | ----------------------------------------- | ----------------------------------------------- |
| OPENAI_API_KEY # 用您自己的密钥替换 | OPENAI_API_KEY: "sk-..." | export OPENAI_API_KEY="sk-..." |
| OPENAI_BASE_URL # 可选 | OPENAI_BASE_URL: "https://<YOUR_SITE>/v1" | export OPENAI_BASE_URL="https://<YOUR_SITE>/v1" |
### 示例:启动一个创业公司
```shell

View file

@ -117,4 +117,4 @@ class WriteDesign(Action):
async def _save_mermaid_file(self, data: str, pathname: Path):
pathname.parent.mkdir(parents=True, exist_ok=True)
await mermaid_to_file(self.config.mermaid_engine, data, pathname)
await mermaid_to_file(self.config.mermaid.engine, data, pathname)

View file

@ -159,7 +159,7 @@ class WritePRD(Action):
return
pathname = self.repo.workdir / COMPETITIVE_ANALYSIS_FILE_REPO / Path(prd_doc.filename).stem
pathname.parent.mkdir(parents=True, exist_ok=True)
await mermaid_to_file(self.config.mermaid_engine, quadrant_chart, pathname)
await mermaid_to_file(self.config.mermaid.engine, quadrant_chart, pathname)
async def _rename_workspace(self, prd):
if not self.project_name:

View file

@ -67,14 +67,9 @@ class Config(CLIParams, YamlModel):
code_review_k_times: int = 2
# Will be removed in the future
llm_for_researcher_summary: str = "gpt3"
llm_for_researcher_report: str = "gpt3"
METAGPT_TEXT_TO_IMAGE_MODEL_URL: str = ""
language: str = "English"
redis_key: str = "placeholder"
mmdc: str = "mmdc"
puppeteer_config: str = ""
pyppeteer_executable_path: str = ""
IFLYTEK_APP_ID: str = ""
IFLYTEK_API_SECRET: str = ""
IFLYTEK_API_KEY: str = ""
@ -86,7 +81,7 @@ class Config(CLIParams, YamlModel):
@classmethod
def from_home(cls, path):
"""Load config from ~/.metagpt/config.yaml"""
"""Load config from ~/.metagpt/config2.yaml"""
pathname = CONFIG_ROOT / path
if not pathname.exists():
return None

View file

@ -74,5 +74,5 @@ class LLMConfig(YamlModel):
@classmethod
def check_llm_key(cls, v):
if v in ["", None, "YOUR_API_KEY"]:
raise ValueError("Please set your API key in config.yaml")
raise ValueError("Please set your API key in config2.yaml")
return v

View file

@ -14,5 +14,6 @@ class MermaidConfig(YamlModel):
"""Config for Mermaid"""
engine: Literal["nodejs", "ink", "playwright", "pyppeteer"] = "nodejs"
path: str = ""
puppeteer_config: str = "" # Only for nodejs engine
path: str = "mmdc" # mmdc
puppeteer_config: str = ""
pyppeteer_path: str = "/usr/bin/google-chrome-stable"

View file

@ -35,10 +35,10 @@ async def mermaid_to_file(engine, mermaid_code, output_file_without_suffix, widt
# tmp.write_text(mermaid_code, encoding="utf-8")
if engine == "nodejs":
if check_cmd_exists(config.mmdc) != 0:
if check_cmd_exists(config.mermaid.path) != 0:
logger.warning(
"RUN `npm install -g @mermaid-js/mermaid-cli` to install mmdc,"
"or consider changing MERMAID_ENGINE to `playwright`, `pyppeteer`, or `ink`."
"or consider changing engine to `playwright`, `pyppeteer`, or `ink`."
)
return -1
@ -47,11 +47,11 @@ async def mermaid_to_file(engine, mermaid_code, output_file_without_suffix, widt
# Call the `mmdc` command to convert the Mermaid code to a PNG
logger.info(f"Generating {output_file}..")
if config.puppeteer_config:
if config.mermaid.puppeteer_config:
commands = [
config.mmdc,
config.mermaid.path,
"-p",
config.puppeteer_config,
config.mermaid.puppeteer_config,
"-i",
str(tmp),
"-o",
@ -62,7 +62,7 @@ async def mermaid_to_file(engine, mermaid_code, output_file_without_suffix, widt
str(height),
]
else:
commands = [config.mmdc, "-i", str(tmp), "-o", output_file, "-w", str(width), "-H", str(height)]
commands = [config.mermaid.path, "-i", str(tmp), "-o", output_file, "-w", str(width), "-H", str(height)]
process = await asyncio.create_subprocess_shell(
" ".join(commands), stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.PIPE
)

View file

@ -30,14 +30,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__))
if config.pyppeteer_executable_path:
if config.mermaid.pyppeteer_path:
browser = await launch(
headless=True,
executablePath=config.pyppeteer_executable_path,
executablePath=config.mermaid.pyppeteer_path,
args=["--disable-extensions", "--no-sandbox"],
)
else:
logger.error("Please set the environment variable:PYPPETEER_EXECUTABLE_PATH.")
logger.error("Please set the var mermaid.pyppeteer_path in the config2.yaml.")
return -1
page = await browser.newPage()
device_scale_factor = 1.0

View file

@ -42,7 +42,7 @@ class YamlModelWithoutDefault(YamlModel):
@model_validator(mode="before")
@classmethod
def check_not_default_config(cls, values):
"""Check if there is any default config in config.yaml"""
"""Check if there is any default config in config2.yaml"""
if any(["YOUR" in v for v in values]):
raise ValueError("Please set your config in config.yaml")
raise ValueError("Please set your config in config2.yaml")
return values