Sfoglia il codice sorgente

fix:jpg图片类型

wangzaijun 3 settimane fa
parent
commit
336146a28e
1 ha cambiato i file con 8 aggiunte e 0 eliminazioni
  1. 8 0
      mo-daq-openai/web/route.py

+ 8 - 0
mo-daq-openai/web/route.py

@@ -15,6 +15,13 @@ client = OpenAI(
 DEFAULT_USER_MSG = f"""解析文件中的表格内容:要求准确识别金额等小数的位数,去掉金额单位、英文和多余的空格,结果用json返回;
                    检查所有字段是否完整,确保没有遗漏或错误,可能需要多次校对,以确保生成的json准确无误。"""
 
+ALL_IMG_CONTENT_TYPE = {
+   "jpg": "jpeg",
+   "png": "png",
+   "jpeg": "jpeg",
+   "webp": "webp",
+}
+
 
 @app.get("hearth")
 async def hearth():
@@ -96,6 +103,7 @@ async def parse_image(image_url: str,
                privacy data. Please output the results as required.The input json schema content is as follows:
                 {result_schema}。""" if user_msg is None else user_msg
     extension = image_url.split(".")[-1]
+    extension = ALL_IMG_CONTENT_TYPE.get(extension)
     base64_image = encode_image(image_url)
     completion = client.chat.completions.create(
         model="qwen-vl-ocr-latest",