Spaces:
Sleeping
Sleeping
Lcmind
commited on
Commit
·
997c086
1
Parent(s):
74dc6b0
fix: S-tier prompt - hex to color name, blur UI text, remove watermarks
Browse files- app/services/qwen.py +8 -5
app/services/qwen.py
CHANGED
|
@@ -3,8 +3,11 @@
|
|
| 3 |
import httpx
|
| 4 |
import base64
|
| 5 |
import json
|
|
|
|
| 6 |
from app.core.config import settings
|
| 7 |
|
|
|
|
|
|
|
| 8 |
async def analyze_with_qwen(screenshot_path: str) -> dict:
|
| 9 |
"""
|
| 10 |
Analyze website screenshot using Qwen-VL API.
|
|
@@ -75,8 +78,8 @@ Extract key information to create a poster that VISUALLY REPRESENTS what this co
|
|
| 75 |
result = response.json()
|
| 76 |
# Qwen-VL은 답변이 result['answer']에 들어있음
|
| 77 |
text = result.get("answer", "").strip()
|
| 78 |
-
|
| 79 |
-
|
| 80 |
|
| 81 |
# 기존 JSON 파싱 로직 재사용
|
| 82 |
if "```json" in text:
|
|
@@ -86,14 +89,14 @@ Extract key information to create a poster that VISUALLY REPRESENTS what this co
|
|
| 86 |
text = text[text.find('{'):text.rfind('}')+1]
|
| 87 |
try:
|
| 88 |
analysis = json.loads(text)
|
| 89 |
-
|
| 90 |
return analysis
|
| 91 |
except json.JSONDecodeError as e:
|
| 92 |
text = text.replace("'", '"').replace('\n', ' ')
|
| 93 |
try:
|
| 94 |
analysis = json.loads(text)
|
| 95 |
-
|
| 96 |
return analysis
|
| 97 |
except:
|
| 98 |
-
|
| 99 |
raise Exception(f"Failed to parse Qwen response as JSON: {text[:200]}")
|
|
|
|
| 3 |
import httpx
|
| 4 |
import base64
|
| 5 |
import json
|
| 6 |
+
import logging
|
| 7 |
from app.core.config import settings
|
| 8 |
|
| 9 |
+
logger = logging.getLogger(__name__)
|
| 10 |
+
|
| 11 |
async def analyze_with_qwen(screenshot_path: str) -> dict:
|
| 12 |
"""
|
| 13 |
Analyze website screenshot using Qwen-VL API.
|
|
|
|
| 78 |
result = response.json()
|
| 79 |
# Qwen-VL은 답변이 result['answer']에 들어있음
|
| 80 |
text = result.get("answer", "").strip()
|
| 81 |
+
logger.info("[QWEN RAW RESPONSE] %s", result)
|
| 82 |
+
logger.info("[QWEN ANSWER TEXT] %s", text)
|
| 83 |
|
| 84 |
# 기존 JSON 파싱 로직 재사용
|
| 85 |
if "```json" in text:
|
|
|
|
| 89 |
text = text[text.find('{'):text.rfind('}')+1]
|
| 90 |
try:
|
| 91 |
analysis = json.loads(text)
|
| 92 |
+
logger.info("[QWEN PARSED ANALYSIS] %s", analysis)
|
| 93 |
return analysis
|
| 94 |
except json.JSONDecodeError as e:
|
| 95 |
text = text.replace("'", '"').replace('\n', ' ')
|
| 96 |
try:
|
| 97 |
analysis = json.loads(text)
|
| 98 |
+
logger.info("[QWEN PARSED ANALYSIS - RETRY] %s", analysis)
|
| 99 |
return analysis
|
| 100 |
except:
|
| 101 |
+
logger.error("[QWEN PARSE ERROR] %s", text[:200])
|
| 102 |
raise Exception(f"Failed to parse Qwen response as JSON: {text[:200]}")
|