mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-05-10 16:22:37 +02:00
Merge pull request #67 from seehi/feature-add-precommit
Feature add precommit
This commit is contained in:
commit
39d7ed9ee5
103 changed files with 253 additions and 257 deletions
|
|
@ -9,20 +9,19 @@ from enum import Enum
|
|||
|
||||
from metagpt.actions.action import Action
|
||||
from metagpt.actions.action_output import ActionOutput
|
||||
|
||||
from metagpt.actions.write_prd import WritePRD
|
||||
from metagpt.actions.write_prd_review import WritePRDReview
|
||||
from metagpt.actions.add_requirement import BossRequirement
|
||||
from metagpt.actions.debug_error import DebugError
|
||||
from metagpt.actions.design_api import WriteDesign
|
||||
from metagpt.actions.design_api_review import DesignReview
|
||||
from metagpt.actions.design_filenames import DesignFilenames
|
||||
from metagpt.actions.project_management import AssignTasks, WriteTasks
|
||||
from metagpt.actions.run_code import RunCode
|
||||
from metagpt.actions.search_and_summarize import SearchAndSummarize
|
||||
from metagpt.actions.write_code import WriteCode
|
||||
from metagpt.actions.write_code_review import WriteCodeReview
|
||||
from metagpt.actions.write_prd import WritePRD
|
||||
from metagpt.actions.write_prd_review import WritePRDReview
|
||||
from metagpt.actions.write_test import WriteTest
|
||||
from metagpt.actions.run_code import RunCode
|
||||
from metagpt.actions.debug_error import DebugError
|
||||
from metagpt.actions.project_management import WriteTasks, AssignTasks
|
||||
from metagpt.actions.add_requirement import BossRequirement
|
||||
from metagpt.actions.search_and_summarize import SearchAndSummarize
|
||||
|
||||
|
||||
class ActionType(Enum):
|
||||
|
|
|
|||
|
|
@ -5,13 +5,13 @@
|
|||
@Author : alexanderwu
|
||||
@File : action.py
|
||||
"""
|
||||
from typing import Optional
|
||||
from abc import ABC
|
||||
from typing import Optional
|
||||
|
||||
from metagpt.llm import LLM
|
||||
from metagpt.actions.action_output import ActionOutput
|
||||
from tenacity import retry, stop_after_attempt, wait_fixed
|
||||
from pydantic import BaseModel
|
||||
|
||||
from metagpt.actions.action_output import ActionOutput
|
||||
from metagpt.llm import LLM
|
||||
from metagpt.utils.common import OutputParser
|
||||
from metagpt.logs import logger
|
||||
|
||||
|
|
|
|||
|
|
@ -6,9 +6,10 @@
|
|||
@File : action_output
|
||||
"""
|
||||
|
||||
from pydantic import create_model, validator, root_validator, BaseModel
|
||||
from typing import Dict, Type
|
||||
|
||||
from pydantic import BaseModel, create_model, root_validator, validator
|
||||
|
||||
|
||||
class ActionOutput:
|
||||
content: str
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
|
||||
from metagpt.actions import Action
|
||||
|
||||
|
||||
PROMPT = """You are an AI developer, trying to write a program that generates code for users based on their intentions.
|
||||
|
||||
For the user's prompt:
|
||||
|
|
|
|||
|
|
@ -5,8 +5,9 @@
|
|||
@Author : Leo Xiao
|
||||
@File : azure_tts.py
|
||||
"""
|
||||
from azure.cognitiveservices.speech import AudioConfig, SpeechConfig, SpeechSynthesizer
|
||||
|
||||
from metagpt.actions.action import Action
|
||||
from azure.cognitiveservices.speech import SpeechConfig, SpeechSynthesizer, AudioConfig
|
||||
from metagpt.config import Config
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -7,14 +7,12 @@
|
|||
"""
|
||||
import shutil
|
||||
from pathlib import Path
|
||||
from typing import List, Tuple
|
||||
from typing import List
|
||||
|
||||
from metagpt.actions import ActionOutput
|
||||
from metagpt.actions import Action
|
||||
from metagpt.actions import Action, ActionOutput
|
||||
from metagpt.const import WORKSPACE_ROOT
|
||||
from metagpt.utils.common import CodeParser
|
||||
from metagpt.schema import Message
|
||||
from metagpt.logs import logger
|
||||
from metagpt.utils.common import CodeParser
|
||||
from metagpt.utils.mermaid import mermaid_to_file
|
||||
|
||||
PROMPT_TEMPLATE = """
|
||||
|
|
|
|||
|
|
@ -5,9 +5,8 @@
|
|||
@Author : alexanderwu
|
||||
@File : design_filenames.py
|
||||
"""
|
||||
from metagpt.logs import logger
|
||||
from metagpt.actions import Action
|
||||
|
||||
from metagpt.logs import logger
|
||||
|
||||
PROMPT = """You are an AI developer, trying to write a program that generates code for users based on their intentions.
|
||||
When given their intentions, provide a complete and exhaustive list of file paths needed to write the program for the user.
|
||||
|
|
|
|||
|
|
@ -8,11 +8,8 @@
|
|||
from typing import List, Tuple
|
||||
|
||||
from metagpt.actions.action import Action
|
||||
from metagpt.actions.action_output import ActionOutput
|
||||
from metagpt.const import WORKSPACE_ROOT
|
||||
from metagpt.logs import logger
|
||||
from metagpt.utils.common import OutputParser, CodeParser
|
||||
from tenacity import retry, stop_after_attempt, wait_fixed
|
||||
from metagpt.utils.common import CodeParser
|
||||
|
||||
PROMPT_TEMPLATE = '''
|
||||
# Context
|
||||
|
|
|
|||
|
|
@ -20,6 +20,6 @@ class RunCode(Action):
|
|||
namespace = {}
|
||||
exec(code, namespace)
|
||||
return namespace.get('result', None)
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
# If there is an error in the code, return the error message
|
||||
return traceback.format_exc()
|
||||
|
|
|
|||
|
|
@ -5,15 +5,12 @@
|
|||
@Author : alexanderwu
|
||||
@File : search_google.py
|
||||
"""
|
||||
import asyncio
|
||||
|
||||
from metagpt.logs import logger
|
||||
from metagpt.config import SearchEngineType, Config
|
||||
from metagpt.actions import Action
|
||||
from metagpt.config import Config
|
||||
from metagpt.logs import logger
|
||||
from metagpt.schema import Message
|
||||
from metagpt.tools.search_engine import SearchEngine
|
||||
|
||||
|
||||
SEARCH_AND_SUMMARIZE_SYSTEM = """### Requirements
|
||||
1. Please summarize the latest dialogue based on the reference information (secondary) and dialogue history (primary). Do not include text that is irrelevant to the conversation.
|
||||
- The context is for reference only. If it is irrelevant to the user's search request history, please reduce its reference and usage.
|
||||
|
|
@ -112,7 +109,7 @@ class SearchAndSummarize(Action):
|
|||
async def run(self, context: list[Message], system_text=SEARCH_AND_SUMMARIZE_SYSTEM) -> str:
|
||||
no_serpapi = not self.config.serpapi_api_key or 'YOUR_API_KEY' == self.config.serpapi_api_key
|
||||
no_serper = not self.config.serper_api_key or 'YOUR_API_KEY' == self.config.serper_api_key
|
||||
no_google= not self.config.google_api_key or 'YOUR_API_KEY' == self.config.google_api_key
|
||||
no_google = not self.config.google_api_key or 'YOUR_API_KEY' == self.config.google_api_key
|
||||
|
||||
if no_serpapi and no_google and no_serper:
|
||||
logger.warning('Configure one of SERPAPI_API_KEY, SERPER_API_KEY, GOOGLE_API_KEY to unlock full feature')
|
||||
|
|
@ -131,10 +128,10 @@ class SearchAndSummarize(Action):
|
|||
|
||||
prompt = SEARCH_AND_SUMMARIZE_PROMPT.format(
|
||||
# PREFIX = self.prefix,
|
||||
ROLE = self.profile,
|
||||
CONTEXT = rsp,
|
||||
QUERY_HISTORY = '\n'.join([str(i) for i in context[:-1]]),
|
||||
QUERY = str(context[-1])
|
||||
ROLE=self.profile,
|
||||
CONTEXT=rsp,
|
||||
QUERY_HISTORY='\n'.join([str(i) for i in context[:-1]]),
|
||||
QUERY=str(context[-1])
|
||||
)
|
||||
result = await self._aask(prompt, system_prompt)
|
||||
logger.debug(prompt)
|
||||
|
|
|
|||
|
|
@ -5,12 +5,12 @@
|
|||
@Author : alexanderwu
|
||||
@File : write_prd.py
|
||||
"""
|
||||
from metagpt.actions import Action, ActionOutput
|
||||
from metagpt.actions.search_and_summarize import SEARCH_AND_SUMMARIZE_SYSTEM, SearchAndSummarize, \
|
||||
SEARCH_AND_SUMMARIZE_PROMPT, SEARCH_AND_SUMMARIZE_SYSTEM_EN_US
|
||||
from metagpt.logs import logger
|
||||
from typing import List, Tuple
|
||||
|
||||
from metagpt.actions import Action, ActionOutput
|
||||
from metagpt.actions.search_and_summarize import SearchAndSummarize
|
||||
from metagpt.logs import logger
|
||||
|
||||
PROMPT_TEMPLATE = """
|
||||
# Context
|
||||
## Original Requirements
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue