mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-04-25 00:36:55 +02:00
test strategy
This commit is contained in:
parent
4a7957416c
commit
0789f2c109
9 changed files with 24 additions and 9 deletions
|
|
@ -5,7 +5,7 @@
|
|||
import asyncio
|
||||
from typing import Any, List
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
|
||||
from metagpt.llm import LLM
|
||||
from metagpt.logs import logger
|
||||
|
|
@ -29,6 +29,8 @@ Output a list of jsons following the format:
|
|||
|
||||
|
||||
class ThoughtSolverBase(BaseModel):
|
||||
model_config = ConfigDict(arbitrary_types_allowed=True)
|
||||
|
||||
thought_tree: str = ""
|
||||
llm: BaseLLM = Field(default_factory=LLM, exclude=True)
|
||||
config: ThoughtSolverConfig = Field(default_factory=ThoughtSolverConfig)
|
||||
|
|
|
|||
|
|
@ -58,3 +58,4 @@ websockets~=12.0
|
|||
networkx~=3.2.1
|
||||
google-generativeai==0.3.1
|
||||
playwright==1.40.0
|
||||
anytree
|
||||
|
|
|
|||
7
tests/metagpt/strategy/__init__.py
Normal file
7
tests/metagpt/strategy/__init__.py
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
@Time : 2023/12/30 00:33
|
||||
@Author : alexanderwu
|
||||
@File : __init__.py
|
||||
"""
|
||||
|
|
@ -3,8 +3,8 @@
|
|||
# @Author : stellahong (stellahong@fuzhi.ai)
|
||||
# @Desc :
|
||||
import re
|
||||
from typing import Dict
|
||||
|
||||
from metagpt.strategy.prompt_templates.creative_writing import cot_prompt, vote_prompt
|
||||
from metagpt.strategy.tot import TreeofThought
|
||||
from metagpt.strategy.tot_schema import (
|
||||
BaseEvaluator,
|
||||
|
|
@ -12,6 +12,10 @@ from metagpt.strategy.tot_schema import (
|
|||
Strategy,
|
||||
ThoughtSolverConfig,
|
||||
)
|
||||
from tests.metagpt.strategy.prompt_templates.creative_writing import (
|
||||
cot_prompt,
|
||||
vote_prompt,
|
||||
)
|
||||
|
||||
|
||||
class TextGenParser(BaseParser):
|
||||
|
|
@ -31,8 +35,8 @@ class TextGenParser(BaseParser):
|
|||
|
||||
|
||||
class TextGenEvaluator(BaseEvaluator):
|
||||
value_map = {"impossible": 0.001, "likely": 1, "sure": 20} # TODO: ad hoc
|
||||
status_map = {val: key for key, val in value_map.items()}
|
||||
value_map: Dict[str, float] = {"impossible": 0.001, "likely": 1, "sure": 20} # TODO: ad hoc
|
||||
status_map: Dict = {val: key for key, val in value_map.items()}
|
||||
|
||||
def __call__(self, evaluation: str, **kwargs) -> float:
|
||||
try:
|
||||
|
|
@ -59,7 +63,7 @@ class TextGenEvaluator(BaseEvaluator):
|
|||
return status
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
def test_creative_writing():
|
||||
import asyncio
|
||||
|
||||
initial_prompt = """It isn't difficult to do a handstand if you just stand on your hands. It caught him off guard that space smelled of seared steak. When she didn’t like a guy who was trying to pick her up, she started using sign language. Each person who knows you has a different perception of who you are."""
|
||||
|
|
@ -3,8 +3,8 @@
|
|||
# @Author : stellahong (stellahong@fuzhi.ai)
|
||||
# @Desc :
|
||||
import re
|
||||
from typing import Dict
|
||||
|
||||
from metagpt.strategy.prompt_templates.game24 import propose_prompt, value_prompt
|
||||
from metagpt.strategy.tot import TreeofThought
|
||||
from metagpt.strategy.tot_schema import (
|
||||
BaseEvaluator,
|
||||
|
|
@ -12,6 +12,7 @@ from metagpt.strategy.tot_schema import (
|
|||
Strategy,
|
||||
ThoughtSolverConfig,
|
||||
)
|
||||
from tests.metagpt.strategy.prompt_templates.game24 import propose_prompt, value_prompt
|
||||
|
||||
|
||||
class Game24Parser(BaseParser):
|
||||
|
|
@ -31,8 +32,8 @@ class Game24Parser(BaseParser):
|
|||
|
||||
|
||||
class Game24Evaluator(BaseEvaluator):
|
||||
value_map = {"impossible": 0.001, "likely": 1, "sure": 20} # TODO: ad hoc
|
||||
status_map = {val: key for key, val in value_map.items()}
|
||||
value_map: Dict[str, float] = {"impossible": 0.001, "likely": 1, "sure": 20} # TODO: ad hoc
|
||||
status_map: Dict = {val: key for key, val in value_map.items()}
|
||||
|
||||
def __call__(self, evaluation: str, **kwargs) -> float:
|
||||
try:
|
||||
|
|
@ -51,7 +52,7 @@ class Game24Evaluator(BaseEvaluator):
|
|||
return status
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
def test_game24():
|
||||
import asyncio
|
||||
|
||||
initial_prompt = """4 5 6 10"""
|
||||
Loading…
Add table
Add a link
Reference in a new issue