allow image input for rolezero

This commit is contained in:
garylin2099 2024-08-13 19:30:49 +08:00
parent f84fe76d28
commit 78db50b432
4 changed files with 81 additions and 6 deletions

View file

@ -820,6 +820,19 @@ def decode_image(img_url_or_b64: str) -> Image:
return img
def is_support_image_input(model_name: str) -> bool:
# model name can be gpt-4o-2024-08-06
support_models = ["gpt-4o", "gpt-4o-mini"] # FIXME: hard code for now
return any([m in model_name for m in support_models])
def extract_image_paths(content: str) -> bool:
# We require that the path must have a space preceding it, like "xxx /an/absolute/path.jpg xxx"
pattern = r"[^\s]+\.(?:png|jpe?g|gif|bmp|tiff)"
image_paths = re.findall(pattern, content)
return image_paths
def log_and_reraise(retry_state: RetryCallState):
logger.error(f"Retry attempts exhausted. Last exception: {retry_state.outcome.exception()}")
logger.warning(