@@ -22,15 +22,14 @@ class LLMConfig:
22
22
23
23
def create_message_content (text , image_path = None ):
24
24
content = [{"type" : "text" , "text" : text }]
25
-
25
+ image_format = "png" if image_path and image_path . endswith ( ".png" ) else "jpeg"
26
26
if image_path :
27
27
from src .utils import utils
28
28
image_data = utils .encode_image (image_path )
29
29
content .append ({
30
30
"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 } " }
32
32
})
33
-
34
33
return content
35
34
36
35
def get_env_value (key , provider ):
@@ -41,6 +40,7 @@ def get_env_value(key, provider):
41
40
"deepseek" : {"api_key" : "DEEPSEEK_API_KEY" , "base_url" : "DEEPSEEK_ENDPOINT" },
42
41
"mistral" : {"api_key" : "MISTRAL_API_KEY" , "base_url" : "MISTRAL_ENDPOINT" },
43
42
"alibaba" : {"api_key" : "ALIBABA_API_KEY" , "base_url" : "ALIBABA_ENDPOINT" },
43
+ "moonshot" :{"api_key" : "MOONSHOT_API_KEY" , "base_url" : "MOONSHOT_ENDPOINT" },
44
44
}
45
45
46
46
if provider in env_mappings and key in env_mappings [provider ]:
@@ -122,6 +122,10 @@ def test_mistral_model():
122
122
config = LLMConfig (provider = "mistral" , model_name = "pixtral-large-latest" )
123
123
test_llm (config , "Describe this image" , "assets/examples/test.png" )
124
124
125
+ def test_moonshot_model ():
126
+ config = LLMConfig (provider = "moonshot" , model_name = "moonshot-v1-32k-vision-preview" )
127
+ test_llm (config , "Describe this image" , "assets/examples/test.png" )
128
+
125
129
if __name__ == "__main__" :
126
130
# test_openai_model()
127
131
# test_google_model()
0 commit comments