فهرست منبع

智普大模型图片识别加入提振词

dzr 5 ماه پیش
والد
کامیت
31031e11c4
1فایلهای تغییر یافته به همراه27 افزوده شده و 0 حذف شده
  1. 27 0
      services/apis.py

+ 27 - 0
services/apis.py

@@ -210,3 +210,30 @@ async def zhipu_ocr(file: UploadFile = File(...)):
             "code": ret
             "code": ret
         }
         }
     }
     }
+
+
+@images_router.post("/verify_a", summary="Ocr")
+async def zhipu_ocr_a(
+    file: UploadFile = File(...),
+    text: str = Query(..., description="要识别的图片特征描述")
+):
+    start = time.time()
+    img_bytes = await file.read()
+    image = prepare_image(img_bytes)
+
+    client = ZhipuFileExtract(
+        api_key="4abf8f53d1daed90f8a03fc982899418.dyK8ivPgzm3M1Nx5"
+    )
+    ret = client.glm_4v_flash(
+        image,
+        text=text
+    )
+
+    return {
+        "msg": "success",
+        "code": 0,
+        "r": {
+            "time": float("{:.2f}".format(time.time() - start)),
+            "code": ret
+        }
+    }