Heyyaha commited on
Commit
a917675
·
verified ·
1 Parent(s): a772234

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -3
app.py CHANGED
@@ -3,7 +3,6 @@ import os
3
  from datetime import datetime
4
  from gradio_client import Client
5
  import re
6
- import uuid
7
  import json
8
 
9
  # 初始化任务生成客户端(腾讯混元 Space)
@@ -57,10 +56,19 @@ def generate_solutions_from_task(task):
57
 
58
  任务: {task}"""
59
  response = taskgen_client.predict(message=message, api_name="/chat")
60
- # fallback:若正则提取失败,直接展示原始响应
61
- solutions = re.findall(r"方案[123][::]\s*(.*)", response)
 
 
 
 
 
 
 
 
62
  if len(solutions) < 3:
63
  return response.strip(), "(解析失败,显示原始回复)", ""
 
64
  s1 = solutions[0].strip()
65
  s2 = solutions[1].strip()
66
  s3 = solutions[2].strip()
 
3
  from datetime import datetime
4
  from gradio_client import Client
5
  import re
 
6
  import json
7
 
8
  # 初始化任务生成客户端(腾讯混元 Space)
 
56
 
57
  任务: {task}"""
58
  response = taskgen_client.predict(message=message, api_name="/chat")
59
+
60
+ # 输出原始响应内容以便调试
61
+ print("原始响应内容:", response)
62
+
63
+ # 尝试通过正则提取所有方案内容
64
+ solutions = re.findall(r"方案[123][::]\s*(.*?)(?=\n|方案[123][::]|$)", response, re.DOTALL)
65
+
66
+ # 输出提取的方案内容,方便调试
67
+ print("提取的方案内容:", solutions)
68
+
69
  if len(solutions) < 3:
70
  return response.strip(), "(解析失败,显示原始回复)", ""
71
+
72
  s1 = solutions[0].strip()
73
  s2 = solutions[1].strip()
74
  s3 = solutions[2].strip()