mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-05-03 12:52:37 +02:00
update format
This commit is contained in:
parent
6b1f3ee398
commit
c8df235303
1 changed files with 12 additions and 7 deletions
|
|
@ -16,11 +16,11 @@ import asyncio
|
|||
|
||||
from PIL import Image
|
||||
|
||||
from metagpt.roles.role import Role
|
||||
from metagpt.actions.action import Action
|
||||
from metagpt.utils.common import encode_image
|
||||
from metagpt.schema import Message
|
||||
from metagpt.logs import logger
|
||||
from metagpt.roles.role import Role
|
||||
from metagpt.schema import Message
|
||||
from metagpt.utils.common import encode_image
|
||||
|
||||
|
||||
class GenAndImproveImageAction(Action):
|
||||
|
|
@ -31,15 +31,19 @@ class GenAndImproveImageAction(Action):
|
|||
return imgs[0]
|
||||
|
||||
async def refine_prompt(self, old_prompt: str, image: Image) -> str:
|
||||
msg = f"You are a creative painter, with the given generated image and old prompt: {old_prompt}, " \
|
||||
f"please refine the prompt and generate new one. Just output the new prompt."
|
||||
msg = (
|
||||
f"You are a creative painter, with the given generated image and old prompt: {old_prompt}, "
|
||||
f"please refine the prompt and generate new one. Just output the new prompt."
|
||||
)
|
||||
b64_img = encode_image(image)
|
||||
new_prompt = await self.llm.aask(msg=msg, images=[b64_img])
|
||||
return new_prompt
|
||||
|
||||
async def evaluate_images(self, old_prompt: str, images: list[Image]) -> str:
|
||||
msg = "With the prompt and two generated image, to judge if the second one is better than the first one. " \
|
||||
"If so, just output True else output False"
|
||||
msg = (
|
||||
"With the prompt and two generated image, to judge if the second one is better than the first one. "
|
||||
"If so, just output True else output False"
|
||||
)
|
||||
b64_imgs = [encode_image(img) for img in images]
|
||||
res = await self.llm.aask(msg=msg, images=b64_imgs)
|
||||
return res
|
||||
|
|
@ -76,5 +80,6 @@ async def main():
|
|||
role = Painter()
|
||||
await role.run(with_message="a girl with flowers")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue