参照:Datawhale wow agent day12
Python 3.9+ に対応
pip install metagpt==0.8.0
Metagpt チュートリアルに基づいています。
ステップ#
-
Python 3.9 の仮想環境を作成します:conda create -n metagpt python=3.9 && conda activate metagpt
-
pip install metagpt
-
metagpt --init-config で yaml ファイルを生成します。config フォルダー内の config2.yaml に API 設定を記入します。
ここではローカル設定の ollama を使用しています:
llm:
api_type: 'ollama'
base_url: 'http://192.168.0.70:11434/api'
model: 'qwen2:7b'repair_llm_output: true
コード内の 192.168.0.70 は、大モデルをデプロイしたコンピュータの IP です。
実際の状況に応じて置き換えてください。
検証#
from metagpt.config2 import Config
def print_llm_config():
# デフォルト設定を読み込む
config = Config.default()
# LLM 設定を取得
llm_config = config.llm
# LLM 設定の詳細情報を表示
if llm_config:
print(f"APIタイプ: {llm_config.api_type}")
print(f"APIキー: {llm_config.api_key}")
print(f"モデル: {llm_config.model}")
else:
print("LLM が設定されていません")
if __name__ == "__main__":
print_llm_config()