fixbug: gbk UnicodeEncodeError

This commit is contained in:
莘权 马 2024-03-07 17:04:44 +08:00
parent f6260ec084
commit 0867dad4d7
10 changed files with 43 additions and 42 deletions

View file

@ -9,11 +9,11 @@
from pathlib import Path
from typing import Dict, List, Optional
import aiofiles
import yaml
from pydantic import BaseModel, Field
from metagpt.context import Context
from metagpt.utils.common import aread
class Example(BaseModel):
@ -68,8 +68,7 @@ class SkillsDeclaration(BaseModel):
async def load(skill_yaml_file_name: Path = None) -> "SkillsDeclaration":
if not skill_yaml_file_name:
skill_yaml_file_name = Path(__file__).parent.parent.parent / "docs/.well-known/skills.yaml"
async with aiofiles.open(str(skill_yaml_file_name), mode="r") as reader:
data = await reader.read(-1)
data = await aread(filename=skill_yaml_file_name)
skill_data = yaml.safe_load(data)
return SkillsDeclaration(**skill_data)