mirror of
https://github.com/FoundationAgents/MetaGPT.git
synced 2026-06-11 15:15:18 +02:00
check image path before encoding
This commit is contained in:
parent
e52672aea5
commit
dce5502c07
1 changed files with 5 additions and 1 deletions
|
|
@ -2,6 +2,7 @@ from __future__ import annotations
|
|||
|
||||
import inspect
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import traceback
|
||||
from typing import Annotated, Callable, Dict, List, Literal, Optional, Tuple
|
||||
|
|
@ -222,7 +223,10 @@ class RoleZero(Role):
|
|||
return memory
|
||||
for i, msg in enumerate(memory):
|
||||
if msg.role == "user" and isinstance(msg.content, str) and extract_image_paths(msg.content):
|
||||
images = [encode_image(path) for path in extract_image_paths(msg.content)]
|
||||
images = []
|
||||
for path in extract_image_paths(msg.content):
|
||||
if os.path.exists(path):
|
||||
images.append(encode_image(path))
|
||||
memory[i] = self.llm._user_msg_with_imgs(msg.content, images=images)
|
||||
return memory
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue