add gpt-4v support for aask and AN.fill

This commit is contained in:
better629 2024-01-30 11:59:53 +08:00
parent 9e49e2252d
commit 310687258e
8 changed files with 113 additions and 14 deletions

View file

@ -6,9 +6,11 @@
@File : llm_hello_world.py
"""
import asyncio
from pathlib import Path
from metagpt.llm import LLM
from metagpt.logs import logger
from metagpt.utils.common import encode_image
async def main():
@ -27,6 +29,15 @@ async def main():
if hasattr(llm, "completion"):
logger.info(llm.completion(hello_msg))
# check llm-vision capacity if it supports
invoice_path = Path(__file__).parent.joinpath("..", "tests", "data", "invoices", "invoice-2.png")
img_base64 = encode_image(invoice_path)
try:
res = await llm.aask(msg="if this is a invoice, just return True else return False", images=[img_base64])
assert "true" in res.lower()
except Exception:
pass
if __name__ == "__main__":
asyncio.run(main())