Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add config for other LLM #37

Merged
merged 11 commits into from
Dec 29, 2023
42 changes: 31 additions & 11 deletions src/en/guide/get_started/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ We provide several ways for installing MetaGPT, please take the one most conveni
## Support system and version

| System Version | Python Version | Supported |
| -------------- | -------------- | --------- |
|----------------|----------------|-----------|
| macOS 13.x | python 3.9 | Yes |
| Windows 11 | python 3.9 | Yes |
| Ubuntu 22.04 | python 3.9 | Yes |
Expand All @@ -18,7 +18,8 @@ python3 --version

## Install stable version

Recommended for most users. You can import MetaGPT like any python package, employ teams of diverse built-in roles, and build your own agents to serve all kinds of application.
Recommended for most users. You can import MetaGPT like any python package, employ teams of diverse built-in roles, and
build your own agents to serve all kinds of application.

```
pip install metagpt
Expand All @@ -34,7 +35,8 @@ pip install git+https://github.com/geekan/MetaGPT

## Install in development mode

Recommended for developers and researchers looking to customize the framework for their unique requirements, experiment on new ideas, or create sophisticated functionalities like a novel memory mechanism using the framework.
Recommended for developers and researchers looking to customize the framework for their unique requirements, experiment
on new ideas, or create sophisticated functionalities like a novel memory mechanism using the framework.

```
git clone https://github.com/geekan/MetaGPT.git
Expand Down Expand Up @@ -89,29 +91,41 @@ cd MetaGPT && docker build -t metagpt:custom .

## Installation for full features

This is relevant if you want to generate diagrams such as quadrant chart, system designs, sequence flow, etc. They are provided as intermediate results if you run the [software startup example](https://github.com/geekan/MetaGPT/blob/main/metagpt/startup.py).
This is relevant if you want to generate diagrams such as quadrant chart, system designs, sequence flow, etc. They are
provided as intermediate results if you run
the [software startup example](https://github.com/geekan/MetaGPT/blob/main/metagpt/startup.py).

### Mermaid

Mermaid is a language that uses text to generate flowcharts, pie charts, Gantt charts, and other diagrams. MetaGPT uses Mermaid to create flowcharts, sequence diagrams, Gantt charts, etc. Mermaid is implemented in Node.js, and direct installation can be somewhat costly. MetaGPT provides the following Mermaid Engines to convert Mermaid text into diagrams:
Mermaid is a language that uses text to generate flowcharts, pie charts, Gantt charts, and other diagrams. MetaGPT uses
Mermaid to create flowcharts, sequence diagrams, Gantt charts, etc. Mermaid is implemented in Node.js, and direct
installation can be somewhat costly. MetaGPT provides the following Mermaid Engines to convert Mermaid text into
diagrams:

**nodejs**
Install mermaid-cli directly through nodejs. MetaGPT calls the command line to turn Mermaid text into diagrams. You need to install nodejs first, then use npm to install:
Install mermaid-cli directly through nodejs. MetaGPT calls the command line to turn Mermaid text into diagrams. You need
to install nodejs first, then use npm to install:

```
npm install -g @mermaid-js/mermaid-cli
```

The official method provided by mermaid, installed via nodejs, thus it basically supports all platforms and also supports output in png/svg/pdf formats. However, it requires the installation of nodejs and mermaid-cli, which comes with certain costs for installation and use, and also requires a browser environment at runtime.
The official method provided by mermaid, installed via nodejs, thus it basically supports all platforms and also
supports output in png/svg/pdf formats. However, it requires the installation of nodejs and mermaid-cli, which comes
with certain costs for installation and use, and also requires a browser environment at runtime.

**pyppeteer**
Mermaid can also be called via JavaScript, and pyppeteer is a web automation testing tool implemented in Python that can execute JavaScript scripts. Therefore, using pyppeteer + mermaidjs can convert Mermaid text into diagrams. You can install pyppeteer with pip:
Mermaid can also be called via JavaScript, and pyppeteer is a web automation testing tool implemented in Python that can
execute JavaScript scripts. Therefore, using pyppeteer + mermaidjs can convert Mermaid text into diagrams. You can
install pyppeteer with pip:

```
pip install pyppeteer
```

This method is relatively simple to install, has no platform restrictions, and supports output in png/svg/pdf formats. However, it requires a dependency on a browser, so you need to install a browser first and set the browser path when running:
This method is relatively simple to install, has no platform restrictions, and supports output in png/svg/pdf formats.
However, it requires a dependency on a browser, so you need to install a browser first and set the browser path when
running:

```
export PUPPETEER_EXECUTABLE_PATH=/path/to/your/chromium # or edge or chrome
Expand All @@ -120,7 +134,9 @@ export PUPPETEER_EXECUTABLE_PATH=/path/to/your/chromium # or edge or chrome
(Note: pyppeteer is no longer maintained)

**playwright**
As pyppeteer is no longer maintained, it recommends using playwright-python as a replacement. The principle of running mermaid with playwright is the same as with pyppeteer. However, playwright-python requires the installation of its own provided browser and cannot use an already installed browser. The official only supports the following platforms:
As pyppeteer is no longer maintained, it recommends using playwright-python as a replacement. The principle of running
mermaid with playwright is the same as with pyppeteer. However, playwright-python requires the installation of its own
provided browser and cannot use an already installed browser. The official only supports the following platforms:

- Windows 10+, Windows Server 2016+ or Windows Subsystem for Linux (WSL).
- MacOS 12 Monterey or MacOS 13 Ventura.
Expand All @@ -132,7 +148,11 @@ playwright install --with-deps chromium
```

**ink**
The mermaid.ink project provides the function to convert Mermaid text into diagrams online, refer to https://mermaid.ink/. Thus, any internet-connected device can use ink method without the need for a local browser or other dependencies. However, this method only supports generating png and svg, not pdf, and requires access to https://mermaid.ink/ during operation, so it may be affected by the network and other factors, possibly impacting stability.
The mermaid.ink project provides the function to convert Mermaid text into diagrams online, refer
to https://mermaid.ink/. Thus, any internet-connected device can use ink method without the need for a local browser or
other dependencies. However, this method only supports generating png and svg, not pdf, and requires access
to https://mermaid.ink/ during operation, so it may be affected by the network and other factors, possibly impacting
stability.

Comparison
| Mermaid Engine | nodejs | pyppeteer | playwright | ink |
Expand Down
153 changes: 142 additions & 11 deletions src/en/guide/get_started/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

Using MetaGPT involves connecting with model providers. We will walk through the setup in this page.

## Setup for LLM API
After your [Installation](./installation.md) is complete, follow the instructions in this document to complete the
configuration before use.
At the moment, the example of this project only needs to configure OpenAi API.

## OpenAI API

We will take OpenAI API as an example. You can finish the setup in either way:

Expand All @@ -22,34 +26,161 @@ Or in python:

```python
import os

os.environ["OPENAI_API_KEY"] = "sk-..." # YOUR_API_KEY
os.environ["OPENAI_API_MODEL"] = "intended model" # gpt-4, gpt-3.5-turbo, etc.
os.environ["OPENAI_API_MODEL"] = "intended model" # gpt-4, gpt-3.5-turbo, etc.
```

### 2. Use a config or key file

1. In your current working directory, create a folder `config` and add a new file named `config.yaml` or `key.yaml` under it.
2. Copy the content from the example [config.yaml](https://github.com/geekan/MetaGPT/blob/main/config/config.yaml) file into your new files
1. In your current working directory, create a folder `config` and add a new file named `config.yaml` or `key.yaml`
under it.
2. Copy the content from the example [config.yaml](https://github.com/geekan/MetaGPT/blob/main/config/config.yaml) file
into your new files
3. Fill in your own values to the file:

```yaml
OPENAI_API_KEY: 'sk-...' # YOUR_API_KEY
OPENAI_API_MODEL: 'intended model' # gpt-4, gpt-3.5-turbo, etc.
```

Remember: If you follow the `git clone` approach in [Installation](./installation), `config/config.yaml` will already be there. Just edit it or make a copy named `config/key.yaml` for editting. This way you don't accidentally commit and share your API key using git.
Remember: If you follow the `git clone` approach in [Installation](./installation), `config/config.yaml` will already be
there. Just edit it or make a copy named `config/key.yaml` for editting. This way you don't accidentally commit and
share your API key using git.

> Note:
> MetaGPT will read your setup in this priority order: `config/key.yaml > config/config.yaml > environment variable`

Here you are good to go! See [Quickstart](./quickstart) or our [Tutorials](/guide/tutorials/agent_101) for your first run!
Here you are good to go! See [Quickstart](./quickstart) or our [Tutorials](/guide/tutorials/agent_101) for your first
run!

MetaGPT also supports various LLM models, configure the keys of model APIs according to your needs.

## Zhipu API

```yaml
#### if zhipuai from `https://open.bigmodel.cn`. You can set here or export API_KEY="YOUR_API_KEY"
ZHIPUAI_API_KEY: "YOUR_API_KEY"
```

## iFlytek's large model Spark API :

``` yaml
#### if Spark
### Nomally YOU only need to modify SPARK_APPID SPARK_API_SECRET SPARK_API_KEY
SPARK_APPID : "YOUR_APPID"
SPARK_API_SECRET : "YOUR_API_SECRET"
SPARK_API_KEY : "YOUR_API_KEY"
DOMAIN : "generalv2"
SPARK_URL : "ws://spark-api.xf-yun.com/v2.1/chat"
```

## Baidu's large model Ernie API
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are two spaces, only need one.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

使用PyCharm自动格式化了.


``` yaml
#### if Ernie
ERNIE_API_KEY : "YOUR_API_KEY"
ERNIE_SECRET_KEY : "YOUR_API_SECRET"
```

## Anthropic API

``` yaml
#### if Anthropic
Anthropic_API_KEY: "YOUR_API_KEY"
```
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

还有个疑问,ernie和anthropic现在应该还不支持吧?应该先去掉或者放后面些留空?


## Microsoft Azure Based Openai

``` yaml
#### if AZURE, check https://github.com/openai/openai-cookbook/blob/main/examples/azure/chat.ipynb
#### You can use ENGINE or DEPLOYMENT mode
OPENAI_API_TYPE: "azure"
OPENAI_API_BASE: "YOUR_AZURE_ENDPOINT"
OPENAI_API_KEY: "YOUR_AZURE_API_KEY"
OPENAI_API_VERSION: "YOUR_AZURE_API_VERSION"
DEPLOYMENT_NAME: "YOUR_DEPLOYMENT_NAME"
DEPLOYMENT_ID: "YOUR_DEPLOYMENT_ID"
```

## Web Searching API
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

belows are not LLM API configuration

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

尽管不是,但本章讲的是配置问题。

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the above has writen with MetaGPT also supports various LLM models. If it's focus on configuration, you can split it with LLM-configuration and non-LLM-configuration. Put them together will make people think it's all about LLM-configuration.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个我后面提个PR来改吧


``` yaml
#### for Search

## Supported values: serpapi/google/serper/ddg
SEARCH_ENGINE: serpapi

## Visit https://serpapi.com/ to get key.
SERPAPI_API_KEY: "YOUR_API_KEY"

## Visit https://console.cloud.google.com/apis/credentials to get key.
GOOGLE_API_KEY: "YOUR_API_KEY"
## Visit https://programmablesearchengine.google.com/controlpanel/create to get id.
GOOGLE_CSE_ID: "YOUR_CSE_ID"

## Visit https://serper.dev/ to get key.
SERPER_API_KEY: "YOUR_API_KEY"
```

## Website Access For Agent

``` yaml
#### for web access

## Supported values: playwright/selenium
WEB_BROWSER_ENGINE: playwright

## Supported values: chromium/firefox/webkit, visit https://playwright.dev/python/docs/api/class-browsertype
PLAYWRIGHT_BROWSER_TYPE: chromium

## Supported values: chrome/firefox/edge/ie, visit https://www.selenium.dev/documentation/webdriver/browsers/
SELENIUM_BROWSER_TYPE: chrome
```

## Auzre TTS

```` yaml
#### for TTS

AZURE_TTS_SUBSCRIPTION_KEY: "YOUR_API_KEY"
AZURE_TTS_REGION: "eastus"
````

## Stable Diffusion Local Deployment

````yaml
#### for Stable Diffusion
## Use SD service, based on https://github.com/AUTOMATIC1111/stable-diffusion-webui
SD_URL: "YOUR_SD_URL"
SD_T2I_API: "/sdapi/v1/txt2img"

````

## Other Abilities

````yaml
#### for Execution
LONG_TERM_MEMORY: false
#### for Mermaid CLI
## 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"


## Setup for different model providers
### for calc_usage
CALC_USAGE: false

### OpenAI
### for Research
MODEL_FOR_RESEARCHER_SUMMARY: gpt-3.5-turbo
MODEL_FOR_RESEARCHER_REPORT: gpt-3.5-turbo-16k

### Azure
### choose the engine for mermaid conversion,
# default is nodejs, you can change it to playwright,pyppeteer or ink
MERMAID_ENGINE: nodejs

### Anthropic
### browser path for pyppeteer engine, support Chrome, Chromium,MS Edge
PYPPETEER_EXECUTABLE_PATH: "/usr/bin/google-chrome-stable"

## Setup for other APIs
PROMPT_FORMAT: json #json or markdown
````
Loading