添加一个代码

This commit is contained in:
ziming 2023-09-05 22:27:06 +08:00
commit 552547e662
58 changed files with 632 additions and 327 deletions

View file

@ -95,3 +95,4 @@ class Action(ABC):
async def run(self, *args, **kwargs):
"""Run action"""
raise NotImplementedError("The run method should be implemented in a subclass.")

View file

@ -40,3 +40,4 @@ class ActionOutput:
new_class.__validator_check_name = classmethod(check_name)
new_class.__root_validator_check_missing_fields = classmethod(check_missing_fields)
return new_class

View file

@ -28,10 +28,10 @@ Focus only on the names of shared dependencies, do not add any other explanation
class AnalyzeDepLibs(Action):
def __init__(self, name, context=None, llm=None):
super().__init__(name, context, llm)
self.desc = "根据上下文,分析程序运行依赖库"
self.desc = "Analyze the runtime dependencies of the program based on the context"
async def run(self, requirement, filepaths_string):
# prompt = f"以下是产品需求文档(PRD):\n\n{prd}\n\n{PROMPT}"
# prompt = f"Below is the product requirement document (PRD):\n\n{prd}\n\n{PROMPT}"
prompt = PROMPT.format(prompt=requirement, filepaths_string=filepaths_string)
design_filenames = await self._aask(prompt)
return design_filenames

View file

@ -16,7 +16,7 @@ class AzureTTS(Action):
super().__init__(name, context, llm)
self.config = Config()
# 参数参考:https://learn.microsoft.com/zh-cn/azure/cognitive-services/speech-service/language-support?tabs=tts#voice-styles-and-roles
# Parameters reference: https://learn.microsoft.com/zh-cn/azure/cognitive-services/speech-service/language-support?tabs=tts#voice-styles-and-roles
def synthesize_speech(self, lang, voice, role, text, output_file):
subscription_key = self.config.get('AZURE_TTS_SUBSCRIPTION_KEY')
region = self.config.get('AZURE_TTS_REGION')
@ -49,5 +49,5 @@ if __name__ == "__main__":
"zh-CN",
"zh-CN-YunxiNeural",
"Boy",
"你好,我是卡卡",
"Hello, I am Kaka",
"output.wav")

View file

@ -100,7 +100,7 @@ class WriteDesign(Action):
try:
shutil.rmtree(workspace)
except FileNotFoundError:
pass # 文件夹不存在,但我们不在意
pass # Folder does not exist, but we don't care
workspace.mkdir(parents=True, exist_ok=True)
def _save_prd(self, docs_path, resources_path, prd):
@ -141,3 +141,4 @@ class WriteDesign(Action):
system_design = await self._aask_v1(prompt, "system_design", OUTPUT_MAPPING)
self._save(context, system_design)
return system_design

View file

@ -19,3 +19,4 @@ class DesignReview(Action):
api_review = await self._aask(prompt)
return api_review

View file

@ -26,3 +26,4 @@ class DesignFilenames(Action):
logger.debug(prompt)
logger.debug(design_filenames)
return design_filenames

View file

@ -126,3 +126,4 @@ class AssignTasks(Action):
async def run(self, *args, **kwargs):
# Here you should implement the actual action
pass

View file

@ -140,3 +140,4 @@ class SearchAndSummarize(Action):
logger.debug(prompt)
logger.debug(result)
return result

View file

@ -79,3 +79,4 @@ class WriteCode(Action):
# code_rsp = await self._aask_v1(prompt, "code_rsp", OUTPUT_MAPPING)
# self._save(context, filename, code)
return code

View file

@ -79,3 +79,4 @@ class WriteCodeReview(Action):
# code_rsp = await self._aask_v1(prompt, "code_rsp", OUTPUT_MAPPING)
# self._save(context, filename, code)
return code

View file

@ -145,3 +145,4 @@ class WritePRD(Action):
prd = await self._aask_v1(prompt, "prd", OUTPUT_MAPPING)
return prd

View file

@ -25,3 +25,4 @@ class WritePRDReview(Action):
prompt = self.prd_review_prompt_template.format(prd=self.prd)
review = await self._aask(prompt)
return review

View file

@ -1,9 +1,9 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Time : 2023/5/11 17:45
@Time : 2023/5/11 22:12
@Author : alexanderwu
@File : write_test.py
@File : environment.py
"""
from metagpt.actions.action import Action
from metagpt.utils.common import CodeParser