|
@@ -210,3 +210,30 @@ async def zhipu_ocr(file: UploadFile = File(...)):
|
|
|
"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
|
|
|
+ }
|
|
|
+ }
|