Browse Source

返回结果改为相对路径

fulian23 4 months ago
parent
commit
b3e90a6cbb
1 changed files with 3 additions and 4 deletions
  1. 3 4
      api/aiRouter.py

+ 3 - 4
api/aiRouter.py

@@ -96,9 +96,8 @@ def analysis_results(local_path,path):
     response = Application.call(
     response = Application.call(
         # 若没有配置环境变量,可用百炼API Key将下行替换为:api_key="sk-xxx"。但不建议在生产环境中直接将API Key硬编码到代码中,以减少API Key泄露风险。
         # 若没有配置环境变量,可用百炼API Key将下行替换为:api_key="sk-xxx"。但不建议在生产环境中直接将API Key硬编码到代码中,以减少API Key泄露风险。
         api_key=ai_key,
         api_key=ai_key,
-        app_id='b6edb4f5ff1c49f9855af27b14a0e8b4',  # 替换为实际的应用 ID
+        app_id='b6edb4f5ff1c49f9855af27b14a0e8b4',
         prompt=prompt)
         prompt=prompt)
-
     if response.status_code == HTTPStatus.OK:
     if response.status_code == HTTPStatus.OK:
         try:
         try:
             json_data = json.loads(response.output.text)
             json_data = json.loads(response.output.text)
@@ -110,7 +109,7 @@ def analysis_results(local_path,path):
     else:
     else:
         print(f"请求失败: {response.message}")
         print(f"请求失败: {response.message}")
         json_data = {"summary":None}
         json_data = {"summary":None}
-    json_data["path"]=file_path
+    json_data["path"]=path
 
 
     return json_data
     return json_data
 
 
@@ -173,7 +172,7 @@ async def analysis(local_path, task_id):
     file_list = await get_code_files(local_path)
     file_list = await get_code_files(local_path)
     print(file_list)
     print(file_list)
     results = []
     results = []
-    tasks = [process_batch2(local_path, file) for file in file_list]  # 假设process_batch2已改为异步函数
+    tasks = [process_batch2(local_path, file) for file in file_list]
     batch_results = await asyncio.gather(*tasks, return_exceptions=True)
     batch_results = await asyncio.gather(*tasks, return_exceptions=True)
 
 
     for result in batch_results:
     for result in batch_results: