mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-06-14 15:25:17 +02:00
update simple_scorer
This commit is contained in:
parent
f61506bd32
commit
1ead3e4d80
6 changed files with 71 additions and 75 deletions
|
|
@ -1,20 +1,27 @@
|
|||
import asyncio
|
||||
|
||||
from metagpt.exp_pool.scorers import SimpleScorer
|
||||
from metagpt.logs import logger
|
||||
|
||||
REQ = "Write a program to implement quicksort in python."
|
||||
|
||||
def echo(req: str):
|
||||
"""Echo from req."""
|
||||
RESP1 = """
|
||||
def quicksort(arr):
|
||||
return quicksort([x for x in arr[1:] if x <= arr[0]]) + [arr[0]] + quicksort([x for x in arr[1:] if x > arr[0]])
|
||||
"""
|
||||
|
||||
return req
|
||||
RESP2 = """
|
||||
def quicksort(arr):
|
||||
if len(arr) <= 1:
|
||||
return arr
|
||||
return quicksort([x for x in arr[1:] if x <= arr[0]]) + [arr[0]] + quicksort([x for x in arr[1:] if x > arr[0]])
|
||||
"""
|
||||
|
||||
|
||||
async def simple():
|
||||
scorer = SimpleScorer()
|
||||
|
||||
score = await scorer.evaluate(echo, "data", ("data",))
|
||||
logger.info(f"The score is: {score}")
|
||||
await scorer.evaluate(req=REQ, resp=RESP1)
|
||||
await scorer.evaluate(req=REQ, resp=RESP2)
|
||||
|
||||
|
||||
async def main():
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue