feat: +OAS framework

This commit is contained in:
莘权 马 2023-08-17 20:41:07 +08:00
parent 966d7f212f
commit de610df25d
9 changed files with 282 additions and 55 deletions

View file

@ -4,14 +4,18 @@
@Time : 2023/4/29 16:07
@Author : alexanderwu
@File : common.py
@Modified By: mashenquan, 2023-8-17, add `initalize_enviroment()` to load `config/config.yaml` to `os.environ`
"""
import ast
import contextlib
import inspect
import os
import re
from pathlib import Path
from typing import List, Tuple
import yaml
from metagpt.logs import logger
@ -254,3 +258,12 @@ def parse_recipient(text):
pattern = r"## Send To:\s*([A-Za-z]+)\s*?" # hard code for now
recipient = re.search(pattern, text)
return recipient.group(1) if recipient else ""
def initalize_enviroment():
"""Load `config/config.yaml` to `os.environ`"""
yaml_file_path = Path(__file__).resolve().parent.parent.parent / "config/config.yaml"
with open(str(yaml_file_path), "r") as yaml_file:
data = yaml.safe_load(yaml_file)
for k, v in data.items():
os.environ[k] = str(v)