2
2
# -*- coding: utf-8 -*-
3
3
4
4
import asyncio
5
- import shutil
6
5
from pathlib import Path
7
6
8
7
import typer
9
8
10
- from metagpt .config2 import config
11
- from metagpt .const import CONFIG_ROOT , METAGPT_ROOT
12
- from metagpt .context import Context
9
+ from metagpt .const import CONFIG_ROOT
13
10
from metagpt .utils .project_repo import ProjectRepo
14
11
15
12
app = typer .Typer (add_completion = False , pretty_exceptions_show_locals = False )
@@ -30,6 +27,8 @@ def generate_repo(
30
27
recover_path = None ,
31
28
) -> ProjectRepo :
32
29
"""Run the startup logic. Can be called from CLI or other Python scripts."""
30
+ from metagpt .config2 import config
31
+ from metagpt .context import Context
33
32
from metagpt .roles import (
34
33
Architect ,
35
34
Engineer ,
@@ -122,7 +121,17 @@ def startup(
122
121
)
123
122
124
123
125
- def copy_config_to (config_path = METAGPT_ROOT / "config" / "config2.yaml" ):
124
+ DEFAULT_CONFIG = """# Full Example: https://github.com/geekan/MetaGPT/blob/main/config/config2.example.yaml
125
+ # Reflected Code: https://github.com/geekan/MetaGPT/blob/main/metagpt/config2.py
126
+ llm:
127
+ api_type: "openai" # or azure / ollama / open_llm etc. Check LLMType for more options
128
+ model: "gpt-4-turbo-preview" # or gpt-3.5-turbo-1106 / gpt-4-1106-preview
129
+ base_url: "https://api.openai.com/v1" # or forward url / other llm url
130
+ api_key: "YOUR_API_KEY"
131
+ """
132
+
133
+
134
+ def copy_config_to ():
126
135
"""Initialize the configuration file for MetaGPT."""
127
136
target_path = CONFIG_ROOT / "config2.yaml"
128
137
@@ -136,7 +145,7 @@ def copy_config_to(config_path=METAGPT_ROOT / "config" / "config2.yaml"):
136
145
print (f"Existing configuration file backed up at { backup_path } " )
137
146
138
147
# 复制文件
139
- shutil . copy ( str ( config_path ), target_path )
148
+ target_path . write_text ( DEFAULT_CONFIG , encoding = "utf-8" )
140
149
print (f"Configuration file initialized at { target_path } " )
141
150
142
151
0 commit comments