|
27 | 27 | from common.utils.logger import maxkb_logger |
28 | 28 | from common.utils.rsa_util import rsa_long_decrypt |
29 | 29 | from common.utils.tool_code import ToolExecutor |
30 | | -from knowledge.models import FileSourceType, State |
| 30 | +from knowledge.models import FileSourceType |
| 31 | +from knowledge.models.knowledge_action import State |
31 | 32 | from oss.serializers.file import FileSerializer |
32 | 33 | from tools.models import Tool, ToolRecord, ToolTaskTypeChoices |
33 | 34 |
|
@@ -265,16 +266,18 @@ def tool_exec_record(self, tool_lib, all_params): |
265 | 266 | result = function_executor.exec_code(tool_lib.code, all_params) |
266 | 267 | result_dict = _get_result_detail(result) |
267 | 268 | QuerySet(ToolRecord).filter(id=task_record_id).update( |
268 | | - state=State.SUCCESS.value, |
| 269 | + state=State.SUCCESS, |
269 | 270 | run_time=time.time() - start_time, |
270 | 271 | meta={'input': all_params, 'output': result_dict} |
271 | 272 | ) |
272 | 273 |
|
| 274 | + print(result) |
| 275 | + |
273 | 276 | return result |
274 | 277 | except Exception as e: |
275 | 278 | maxkb_logger.error(f"Tool execution error: {traceback.format_exc()}") |
276 | 279 | QuerySet(ToolRecord).filter(id=task_record_id).update( |
277 | | - state=State.FAILURE.value, |
| 280 | + state=State.FAILURE, |
278 | 281 | run_time=time.time() - start_time, |
279 | 282 | meta={'input': all_params, 'output': 'Error: ' + str(e)} |
280 | 283 | ) |
|
0 commit comments