()
| 309 | return jsonify({'status': 'error', 'message': f'保存配置失败:{str(e)}'}), 500 |
| 310 | |
| 311 | @app.route('/delete_llm_config/<config_id>', methods=['POST']) |
| 312 | def delete_llm_config(config_id): |
| 313 | try: |
| 314 | data = load_config_file() |
| 315 | configs = data.get('configs', []) |
| 316 | |
| 317 | if len(configs) <= 1: |
| 318 | return jsonify({'status': 'error', 'message': '至少需要保留一个配置'}), 400 |
| 319 | |
| 320 | new_configs = [c for c in configs if c.get('id') != config_id] |
| 321 | if len(new_configs) == len(configs): |
| 322 | return jsonify({'status': 'error', 'message': f'配置 {config_id} 不存在'}), 404 |
| 323 | |
| 324 | data['configs'] = new_configs |
| 325 | if data.get('active_id') == config_id: |
| 326 | data['active_id'] = new_configs[0]['id'] |
| 327 | |
| 328 | save_config_file(data) |
| 329 | return jsonify({'status': 'success', 'message': '配置已删除', 'active_id': data['active_id']}) |
| 330 | except Exception as e: |
| 331 | logger.error(f"删除 LLM 配置失败:{str(e)}") |
nothing calls this directly
no outgoing calls
no test coverage detected