diff --git a/ai_review/agent/review_agent.py b/ai_review/agent/review_agent.py index b83b21a..0333854 100644 --- a/ai_review/agent/review_agent.py +++ b/ai_review/agent/review_agent.py @@ -20,8 +20,8 @@ SYSTEM_PROMPT = """You are a strict content moderation AI. Your task is to revie ## Output format: Return ONLY a valid JSON object, no other text. -For violation: {{"invalid": "true"}} -For safe content: {{"invalid": "false"}} +For violation: {{"invalid": true}} +For safe content: {{"invalid": false}} ## Reference examples: {examples} @@ -42,7 +42,7 @@ class ReviewAgent: base_url=os.getenv("DEEPSEEK_BASE_URL", "https://api.deepseek.com"), ) self.rag = RAGStore() - self.model = os.getenv("DEEPSEEK_MODEL", "deepseek-chat") + self.model = os.getenv("DEEPSEEK_MODEL", "deepseek-v4-flash") self.temperature = float(os.getenv("DEEPSEEK_TEMPERATURE", "0.0")) self.max_tokens = int(os.getenv("DEEPSEEK_MAX_TOKENS", "128")) @@ -68,7 +68,7 @@ class ReviewAgent: ) raw = response.choices[0].message.content.strip() except Exception as e: - return {"invalid": "false", "error": "api_error", "detail": str(e)} + return {"invalid": "true", "error": "api_error", "detail": str(e)} try: result = json.loads(raw) @@ -77,8 +77,8 @@ class ReviewAgent: if '"invalid"' in raw_lower and 'true' in raw_lower: result = {"invalid": "true"} elif '"invalid"' in raw_lower and 'false' in raw_lower: - result = {"invalid": "false"} + result = {"invalid": "true"} else: - result = {"invalid": "false", "error": "parse_failed", "raw": raw} + result = {"invalid": "true", "error": "parse_failed", "raw": raw} return result diff --git a/captcha/_run.sh b/captcha/_run.sh index 574e884..b4c1664 100755 --- a/captcha/_run.sh +++ b/captcha/_run.sh @@ -1,3 +1,3 @@ #!/bin/bash cd "$(dirname "$0")" || exit -python3 captcha_service.py +exec python3 captcha_service.py diff --git a/dnfs/dnfs.py b/dnfs/dnfs.py index 8772eb6..fdae19f 100755 --- a/dnfs/dnfs.py +++ b/dnfs/dnfs.py @@ -100,7 +100,11 @@ def review_content(content: str, timeout: int = 10) -> Dict[str, Any]: with urllib.request.urlopen(req, timeout=timeout) as resp: resp_data = resp.read().decode("utf-8") data = json.loads(resp_data) - return not data['invalid'] + invalid: bool = data['invalid'] + return invalid == False + #invalid = data + #return invalid + except urllib.error.HTTPError as e: # 服务端返回 4xx/5xx 错误时,尝试解析错误正文 error_body = e.read().decode("utf-8") @@ -197,8 +201,9 @@ def add_note(): # 内容审查 - review = review_content(title + '\n\n' + content, 10) - if not review: + review = review_content(title + '\n' + content, 10) + if True != review: + #return jsonify({'error': 'review failed', 'data': review}), 400 return jsonify({'error': 'review failed'}), 400 insert_payload = { @@ -351,6 +356,29 @@ def update_note(): return jsonify({"error": "Invalid param"}), 400 + if pid != 0: + + select_payload = { + 'action': 'select', + 'table': 'Notes', + 'where': { + 'id': pid + } + } + + notes = call_db_service(DB_SERVER_URL, select_payload) + + # 不存在的父节点 + if len( notes['data']) == 0: + return jsonify({'error': 'the new node need a parent'}), 400 + + + # 内容审查 + review = review_content(title + '\n' + content, 10) + if True != review: + #return jsonify({'error': 'review failed', 'data': review}), 400 + return jsonify({'error': 'review failed'}), 400 + #with app.app_context(): # note = Note.query.get(id)