# Capchdo会话消息管理系统-日志管理系统 **Repository Path**: czleader/chat-bot ## Basic Information - **Project Name**: Capchdo会话消息管理系统-日志管理系统 - **Description**: No description available - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2025-03-27 - **Last Updated**: 2025-03-27 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Capchdo会话消息管理系统-日志管理系统 Capchdo会话消息管理系统是简便的日志管理系统,可以用友善易读的方式展示日志信息。包括查看网页、后端服务器等。用户可以在网页进行会话的重命名、删除等。 ## 开始 初始化 ```cmd node init-db.js ``` 运行 ```cmd node server.js ``` Python创建会话 ```python def create_conversation(name): try: response = requests.post( 'http://localhost:3000/api/conversations', json={'name': name[:50] if name else "未命名会话"} ) response.raise_for_status() return response.json()['id'] except Exception as e: print(f"创建会话失败: {e}") return None ``` Python创建对话 ```python def log_message(conversation_id, sender, content_type, content): try: # # 添加解释类型支持 # if content_type == 'explanation': # content = f"[操作解释] {content}" # 如果是图片且太大,进一步压缩 if content_type == 'image' and len(content) > 5 * 1024 * 1024: # 如果大于5MB try: # 从base64解码 img_data = base64.b64decode(content) img = Image.open(BytesIO(img_data)) # 进一步压缩 buffer = BytesIO() # 降低宽度和质量 width = img.width // 2 height = int(img.height * (width / img.width)) img.resize((width, height)).save(buffer, "JPEG", quality=50) # 重新编码 content = base64.b64encode(buffer.getvalue()).decode('utf-8') print(f"图片已压缩至 {len(content)/(1024*1024):.2f} MB") except Exception as e: print(f"图片压缩失败: {e}") response = requests.post( 'http://localhost:3000/api/messages', json={ 'conversation_id': conversation_id, 'sender': sender, 'type': content_type, 'content': content }, timeout=30 ) response.raise_for_status() except Exception as e: print(f"记录消息失败: {e}") ``` ## 运行截图 ![alt text](image-1.png) ![alt text](image.png) ![alt text](image-2.png) ## 注意 - 注意日志信息并未加密,且并没有设置读写权限,即任何软件都可以尝试访问与修改。 完成时间 2025/3/10 公开时间 2025/3/27