mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-06-17 15:35:21 +02:00
Merge branch 'feat-exp-example' into 'mgx_ops'
Feat exp example See merge request pub/MetaGPT!322
This commit is contained in:
commit
c89c487b95
2 changed files with 8 additions and 3 deletions
|
|
@ -46,6 +46,7 @@ async def add_exp(req: str, resp: str, tag: str, metric: Metric = None):
|
|||
metric=metric or Metric(score=Score(val=10, reason="Manual")),
|
||||
)
|
||||
exp_manager = get_exp_manager()
|
||||
exp_manager.config.exp_pool.enabled = True
|
||||
exp_manager.config.exp_pool.enable_write = True
|
||||
exp_manager.create_exp(exp)
|
||||
logger.info(f"New experience created for the request `{req[:10]}`.")
|
||||
|
|
@ -59,8 +60,10 @@ async def add_exps(exps: list, tag: str):
|
|||
tag: A tag for categorizing the experiences.
|
||||
|
||||
"""
|
||||
|
||||
tasks = [add_exp(req=json.dumps(exp["req"]), resp=exp["resp"], tag=tag) for exp in exps]
|
||||
tasks = [
|
||||
add_exp(req=exp["req"] if isinstance(exp["req"], str) else json.dumps(exp["req"]), resp=exp["resp"], tag=tag)
|
||||
for exp in exps
|
||||
]
|
||||
await asyncio.gather(*tasks)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -35,8 +35,10 @@ def exp_cache(
|
|||
Note:
|
||||
1. This can be applied to both synchronous and asynchronous functions.
|
||||
2. The function must have a `req` parameter, and it must be provided as a keyword argument.
|
||||
3. If `config.exp_pool.enable_read` is False, the decorator will just directly execute the function.
|
||||
3. If `config.exp_pool.enabled` is False, the decorator will just directly execute the function.
|
||||
4. If `config.exp_pool.enable_write` is False, the decorator will skip evaluating and saving the experience.
|
||||
5. If `config.exp_pool.enable_read` is False, the decorator will skip reading from the experience pool.
|
||||
|
||||
|
||||
Args:
|
||||
_func: Just to make the decorator more flexible, for example, it can be used directly with @exp_cache by default, without the need for @exp_cache().
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue