Skip to content

Commit 5e26b6f

Browse files
authored
Update image format correction
Some model has strict requirements matching of image format and codes
1 parent b65b979 commit 5e26b6f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

tests/test_llm_api.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,14 @@ class LLMConfig:
2222

2323
def create_message_content(text, image_path=None):
2424
content = [{"type": "text", "text": text}]
25-
25+
image_format = "png" if image_path and image_path.endswith(".png") else "jpeg"
2626
if image_path:
2727
from src.utils import utils
2828
image_data = utils.encode_image(image_path)
2929
content.append({
3030
"type": "image_url",
31-
"image_url": {"url": f"data:image/jpeg;base64,{image_data}"}
31+
"image_url": {"url": f"data:image/{image_format};base64,{image_data}"}
3232
})
33-
3433
return content
3534

3635
def get_env_value(key, provider):
@@ -41,6 +40,7 @@ def get_env_value(key, provider):
4140
"deepseek": {"api_key": "DEEPSEEK_API_KEY", "base_url": "DEEPSEEK_ENDPOINT"},
4241
"mistral": {"api_key": "MISTRAL_API_KEY", "base_url": "MISTRAL_ENDPOINT"},
4342
"alibaba": {"api_key": "ALIBABA_API_KEY", "base_url": "ALIBABA_ENDPOINT"},
43+
"moonshot":{"api_key": "MOONSHOT_API_KEY", "base_url": "MOONSHOT_ENDPOINT"},
4444
}
4545

4646
if provider in env_mappings and key in env_mappings[provider]:

0 commit comments

Comments
 (0)