feat: + education industry

This commit is contained in:
莘权 马 2023-07-28 11:42:13 +08:00
parent 8cc8b80e49
commit 9d1a261bf6
9 changed files with 498 additions and 17 deletions

View file

@ -0,0 +1,94 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Time : 2023/5/23 17:25
@Author : mashenquan
@File : teacher.py
"""
from typing import Dict, Optional
from pydantic import BaseModel
from metagpt.roles.teacher import Teacher
def test_init():
class Inputs(BaseModel):
name: str
profile: str
goal: str
constraints: str
desc: str
options: Optional[Dict] = None
expect_name: str
expect_profile: str
expect_goal: str
expect_constraints: str
expect_desc: str
inputs = [
{
"name": "Lily{language}",
"expect_name": "LilyCN",
"profile": "X {teaching_language}",
"expect_profile": "X EN",
"goal": "Do {something_big}, {language}",
"expect_goal": "Do sleep, CN",
"constraints": "Do in {key1}, {language}",
"expect_constraints": "Do in HaHa, CN",
"options": {"language": "CN", "key1": "HaHa", "something_big": "sleep", "teaching_language": "EN"},
"desc": "aaa{language}",
"expect_desc": "aaaCN"
},
{
"name": "Lily{language}",
"expect_name": "LilyChinese",
"profile": "X {teaching_language}",
"expect_profile": "X English",
"goal": "Do {something_big}, {language}",
"expect_goal": "Do {something_big}, Chinese",
"constraints": "Do in {key1}, {language}",
"expect_constraints": "Do in {key1}, Chinese",
"desc": "aaa{language}",
"expect_desc": "aaaChinese"
},
]
for i in inputs:
seed = Inputs(**i)
teacher = Teacher(name=seed.name, profile=seed.profile, goal=seed.goal, constraints=seed.constraints,
desc=seed.desc, options=seed.options)
assert teacher.name == seed.expect_name
assert teacher.desc == seed.expect_desc
assert teacher.profile == seed.expect_profile
assert teacher.goal == seed.expect_goal
assert teacher.constraints == seed.expect_constraints
assert teacher.course_title == "teaching_plan"
def test_new_file_name():
class Inputs(BaseModel):
lesson_title: str
ext: str
expect: str
inputs = [
{
"lesson_title": "# @344\n12",
"ext": ".md",
"expect": "_344_12.md"
},
{
"lesson_title": "1#@$%!*&\\/:*?\"<>|\n\t \'1",
"ext": ".cc",
"expect": "1_1.cc"
}
]
for i in inputs:
seed = Inputs(**i)
result = Teacher.new_file_name(seed.lesson_title, seed.ext)
assert result == seed.expect
if __name__ == '__main__':
test_init()