test strategy

This commit is contained in:
geekan 2023-12-30 00:39:07 +08:00
parent 4a7957416c
commit 0789f2c109
9 changed files with 24 additions and 9 deletions

View file

@ -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)

View file

@ -58,3 +58,4 @@ websockets~=12.0
networkx~=3.2.1
google-generativeai==0.3.1
playwright==1.40.0
anytree

View file

@ -0,0 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@Time : 2023/12/30 00:33
@Author : alexanderwu
@File : __init__.py
"""

View file

@ -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 didnt 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."""

View file

@ -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"""