From 436d09a5f5493ab8fe3694806111525be7af2120 Mon Sep 17 00:00:00 2001 From: aaron <> Date: Mon, 10 Mar 2025 23:21:54 +0800 Subject: [PATCH] update --- app/core/qwen_client.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/core/qwen_client.py b/app/core/qwen_client.py index 3060aeb..96a98b1 100644 --- a/app/core/qwen_client.py +++ b/app/core/qwen_client.py @@ -35,14 +35,17 @@ class QwenClient: messages = [ { "role": "system", - "content": "你是一个专门识别快递的取件码,运单号的助手。请准确提取图片中的所有取件码和运单号信息。" + "content": "你现在是一个专门提取驿站名字、快递取件码和运单号等信息的助手" }, { "role": "user", "content": [ { "type": "text", - "text": "请识别图中驿站的所有取件码或者运单号, 取件码运单号格式有:数字加-分割的 ,字母开头的等,以[{\"station\":\"驿站名字\",\"pickup_codes\":[\"2232\",\"2323\"]}]的格式返回。只返回JSON格式数据,不要其他解释。" + "text": "请识别图中信息,提取驿站的名字、取件码、以及运单号(如:顺丰、圆通等快递单号),\ + 取件码和运单号格式一般有:数字加-分割,字母+数字,字母+数字+字母等,\ + 以[{\"station\":\"驿站名字\",\"pickup_codes\":[\"\",\"\"]}]的格式返回给我\ + 已 JSON 格式返回" }, { "type": "image", @@ -88,6 +91,9 @@ class QwenClient: if isinstance(item, dict) and 'text' in item: text_content = item.get('text', '') print(f"提取的文本内容: {text_content}") + # 剔除 ```json 和 ``` + text_content = text_content.replace('```json', '').replace('```', '') + # 尝试直接解析 pickup_data = json.loads(text_content) print(f"pickup_data: {pickup_data}")