Naming conventions
This commit is contained in:
13
omnitool/gradio/agent/llm_utils/utils.py
Normal file
13
omnitool/gradio/agent/llm_utils/utils.py
Normal file
@@ -0,0 +1,13 @@
|
||||
import base64
|
||||
|
||||
def is_image_path(text):
|
||||
image_extensions = (".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tiff", ".tif")
|
||||
if text.endswith(image_extensions):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
def encode_image(image_path):
|
||||
"""Encode image file to base64."""
|
||||
with open(image_path, "rb") as image_file:
|
||||
return base64.b64encode(image_file.read()).decode("utf-8")
|
||||
Reference in New Issue
Block a user