mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-05-02 04:12:45 +02:00
feat: +meta role
This commit is contained in:
parent
28c3bfd036
commit
80a189ad4a
5 changed files with 183 additions and 1 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -163,6 +163,7 @@ workspace/*
|
|||
*.mmd
|
||||
tmp
|
||||
output.wav
|
||||
*.bak
|
||||
|
||||
# output folder
|
||||
output
|
||||
|
|
|
|||
51
config/pattern/write_teaching_plan.yaml
Normal file
51
config/pattern/write_teaching_plan.yaml
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
# `fork` role demo
|
||||
- role_type: "fork"
|
||||
name: "Lily"
|
||||
profile: "{teaching_language} Teacher"
|
||||
goal: "writing a {language} teaching plan part by part"
|
||||
constraints: "writing in {language}"
|
||||
desc: ""
|
||||
actions:
|
||||
- name: ""
|
||||
topic: "Title"
|
||||
language: "Chinese"
|
||||
statements:
|
||||
- "Statement: Find and return the title of the lesson only in markdown first-level header format, without anything else."
|
||||
- name: ""
|
||||
topic: "Teaching Content"
|
||||
language: "Chinese"
|
||||
statements:
|
||||
- "Statement: \"Teaching Content\" must include vocabulary, analysis, and examples of various grammar structures that appear in the textbook, as well as the listening materials and key points."
|
||||
- "Statement: \"Teaching Content\" must include more examples."
|
||||
- name: ""
|
||||
topic: "Teaching Time Allocation"
|
||||
language: "Chinese"
|
||||
statements:
|
||||
- "Statement: \"Teaching Time Allocation\" must include how much time is allocated to each part of the textbook content."
|
||||
- name: ""
|
||||
topic: "Teaching Methods and Strategies"
|
||||
language: "Chinese"
|
||||
statements:
|
||||
- "Statement: \"Teaching Methods and Strategies\" must include teaching focus, difficulties, materials, procedures, in detail."
|
||||
- name: ""
|
||||
topic: "Vocabulary Cloze"
|
||||
language: "Chinese"
|
||||
statements:
|
||||
- "Statement: Based on the content of the textbook enclosed by \"[LESSON_BEGIN]\" and \"[LESSON_END]\", create vocabulary cloze. The cloze should include 10 {language} questions with {teaching_language} answers, and it should also include 10 {teaching_language} questions with {language} answers. The key-related vocabulary and phrases in the textbook content must all be included in the exercises."
|
||||
- name: ""
|
||||
topic: "Grammar Questions"
|
||||
language: "Chinese"
|
||||
statements:
|
||||
- "Statement: Based on the content of the textbook enclosed by \"[LESSON_BEGIN]\" and \"[LESSON_END]\", create grammar questions. 10 questions."
|
||||
- name: ""
|
||||
topic: "Choice Questions"
|
||||
language: "Chinese"
|
||||
statements:
|
||||
- "Statement: Based on the content of the textbook enclosed by \"[LESSON_BEGIN]\" and \"[LESSON_END]\", create choice questions. 10 questions."
|
||||
- name: ""
|
||||
topic: "Translation Questions"
|
||||
language: "Chinese"
|
||||
statements:
|
||||
- "Statement: Based on the content of the textbook enclosed by \"[LESSON_BEGIN]\" and \"[LESSON_END]\", create translation questions. The translation should include 10 {language} questions with {teaching_language} answers, and it should also include 10 {teaching_language} questions with {language} answers."
|
||||
|
||||
|
||||
|
|
@ -1,7 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
@Modified By: mashenquan, 2023-07-27, + `industry` concept
|
||||
@Time : 2023-07-27
|
||||
@Author : mashenquan
|
||||
@File : write_teaching_plan.py
|
||||
@Desc: Write teaching plan demo
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
|
|
|
|||
98
metagpt/roles/fork_meta_role.py
Normal file
98
metagpt/roles/fork_meta_role.py
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
@Time : 2023/8/7
|
||||
@Author : mashenquan
|
||||
@File : fork_meta_role.py
|
||||
@Desc : 我试图将UML的一些符号概念引入到MetaGPT,使其具备通过符号拼接自由搭建flow的能力。同时我也尝试将这些符号做得配置化和标准化,让flow搭建流程更便捷。这是一个`fork` meta-role demo,实现的是write_teaching_plan功能。
|
||||
"""
|
||||
|
||||
|
||||
|
||||
async def startup(lesson_file: str, investment: float = 3.0, n_round: int = 1, *args, **kwargs):
|
||||
"""Run a startup. Be a teacher in education industry."""
|
||||
|
||||
demo_lesson = """
|
||||
UNIT 1 Making New Friends
|
||||
TOPIC 1 Welcome to China!
|
||||
Section A
|
||||
|
||||
1a Listen and number the following names.
|
||||
Jane Mari Kangkang Michael
|
||||
Look, listen and understand. Then practice the conversation.
|
||||
Work in groups. Introduce yourself using
|
||||
I ’m ... Then practice 1a
|
||||
with your own hometown or the following places.
|
||||
|
||||
1b Listen and number the following names
|
||||
Jane Michael Maria Kangkang
|
||||
1c Work in groups. Introduce yourself using I ’m ... Then practice 1a with your own hometown or the following places.
|
||||
China the USA the UK Hong Kong Beijing
|
||||
|
||||
2a Look, listen and understand. Then practice the conversation
|
||||
Hello!
|
||||
Hello!
|
||||
Hello!
|
||||
Hello! Are you Maria?
|
||||
No, I’m not. I’m Jane.
|
||||
Oh, nice to meet you, Jane
|
||||
Nice to meet you, too.
|
||||
Hi, Maria!
|
||||
Hi, Kangkang!
|
||||
Welcome to China!
|
||||
Thanks.
|
||||
|
||||
2b Work in groups. Make up a conversation with your own name and the
|
||||
following structures.
|
||||
A: Hello! / Good morning! / Hi! I’m ... Are you ... ?
|
||||
B: ...
|
||||
|
||||
3a Listen, say and trace
|
||||
Aa Bb Cc Dd Ee Ff Gg
|
||||
|
||||
3b Listen and number the following letters. Then circle the letters with the same sound as Bb.
|
||||
Aa Bb Cc Dd Ee Ff Gg
|
||||
|
||||
3c Match the big letters with the small ones. Then write them on the lines.
|
||||
"""
|
||||
|
||||
lesson = ""
|
||||
if lesson_file is not None and Path(lesson_file).exists():
|
||||
async with aiofiles.open(lesson_file, mode="r", encoding="utf-8") as reader:
|
||||
lesson = await reader.read()
|
||||
logger.info(f"Course content: {lesson}")
|
||||
if not lesson:
|
||||
logger.info("No course content provided, using the demo course.")
|
||||
lesson = demo_lesson
|
||||
|
||||
|
||||
|
||||
company = SoftwareCompany()
|
||||
company.hire([(*args, **kwargs)])
|
||||
company.invest(investment)
|
||||
company.start_project(lesson, role="Teacher", cause_by=TeachingPlanRequirement)
|
||||
await company.run(n_round=1)
|
||||
|
||||
|
||||
def main(idea: str, investment: float = 3.0, n_round: int = 5, *args, **kwargs):
|
||||
"""
|
||||
We are a software startup comprised of AI. By investing in us, you are empowering a future filled with limitless possibilities.
|
||||
:param idea: lesson filename.
|
||||
:param investment: As an investor, you have the opportunity to contribute a certain dollar amount to this AI company.
|
||||
:param n_round: Reserved.
|
||||
:param args: Parameters passed in format: `python your_script.py arg1 arg2 arg3`
|
||||
:param kwargs: Parameters passed in format: `python your_script.py --param1=value1 --param2=value2`
|
||||
:return:
|
||||
"""
|
||||
asyncio.run(startup(idea, investment, n_round, *args, **kwargs))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
"""
|
||||
Formats:
|
||||
```
|
||||
python write_teaching_plan.py lesson_filename --teaching_language=<the language you are teaching> --language=<your native language>
|
||||
```
|
||||
If `lesson_filename` is not available, a demo lesson content will be used.
|
||||
"""
|
||||
fire.Fire(main)
|
||||
29
metagpt/roles/meta_role.py
Normal file
29
metagpt/roles/meta_role.py
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
@Time : 2023/8/7
|
||||
@Author : mashenquan
|
||||
@File : meta_role.py
|
||||
@Desc : 我试图将UML的一些符号概念引入到MetaGPT,使其具备通过符号拼接自由搭建flow的能力。同时我也尝试将这些符号做得配置化和标准化,让flow搭建流程更便捷。
|
||||
分工参照UML 2.0 activity diagrams: `https://www.uml-diagrams.org/activity-diagrams.html`
|
||||
"""
|
||||
from typing import Dict, List
|
||||
|
||||
from metagpt.roles import Role
|
||||
from pydantic import BaseModel
|
||||
|
||||
class UMLMetaRoleArgs(BaseModel):
|
||||
role_type: str
|
||||
name: str = ""
|
||||
profile: str = ""
|
||||
goal: str = ""
|
||||
constraints: str = ""
|
||||
desc: str = ""
|
||||
actions: List
|
||||
|
||||
class UMLMetaRole(Role):
|
||||
"""UML activity roles抽象父类"""
|
||||
|
||||
def __init__(self, role_args: Dict):
|
||||
""""""
|
||||
self.role_args
|
||||
Loading…
Add table
Add a link
Reference in a new issue