Heyyaha commited on
Commit
d46930c
·
verified ·
1 Parent(s): 6a0ce2e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -12
app.py CHANGED
@@ -1,8 +1,8 @@
1
  import gradio as gr
2
  from gradio_client import Client
3
  import re
4
- import json
5
  from datetime import datetime
 
6
 
7
  # 初始化任务生成客户端(腾讯混元 Space)
8
  taskgen_client = Client("tencent/Hunyuan-Large")
@@ -27,21 +27,25 @@ def build_ui():
27
  solution_state = gr.State([])
28
 
29
  def handle_jd_submit(jd_text):
30
- # 从 JD 中提取任务描述
31
  message = f"""你是一个任务解析助手,请根据以下 JD 提取出相关的任务:
32
  JD: {jd_text}
33
- 请提取一个任务描述并用简洁明了的语言表达。
34
- """
35
  response = taskgen_client.predict(message=message, api_name="/chat")
36
- task_match = re.search(r"任务[::](.*)", response)
37
-
38
  task = task_match.group(1).strip() if task_match else "任务解析失败"
39
- # 生成解法选项
40
- solution_options = [
41
- f"解法1:基于数据分析工具,生成详细报告",
42
- f"解法2:通过市场调研,提出优化建议",
43
- f"解法3:结合用户需求,制定定制化销售策略"
44
- ]
 
 
 
 
 
45
 
46
  return task, solution_options, jd_text, task, solution_options
47
 
 
1
  import gradio as gr
2
  from gradio_client import Client
3
  import re
 
4
  from datetime import datetime
5
+ import json
6
 
7
  # 初始化任务生成客户端(腾讯混元 Space)
8
  taskgen_client = Client("tencent/Hunyuan-Large")
 
27
  solution_state = gr.State([])
28
 
29
  def handle_jd_submit(jd_text):
30
+ # 从 JD 中提取任务
31
  message = f"""你是一个任务解析助手,请根据以下 JD 提取出相关的任务:
32
  JD: {jd_text}
33
+ 请提取一个任务描述并用简洁明了的语言表达。"""
34
+
35
  response = taskgen_client.predict(message=message, api_name="/chat")
36
+ task_match = re.search(r"负责(.*?)(、|。)", response) # 提取任务描述
 
37
  task = task_match.group(1).strip() if task_match else "任务解析失败"
38
+
39
+ # 动态生成解法选项
40
+ solution_message = f"""根据以下任务描述,生成三个解决方案选项:
41
+ 任务:{task}
42
+ 请为该任务生成三个具体的解决方案,并列出其优缺点。"""
43
+
44
+ # 调用模型生成解法选项
45
+ solution_response = taskgen_client.predict(message=solution_message, api_name="/chat")
46
+
47
+ # 解析模型返回的解法选项(假设模型返回每个选项单独一行)
48
+ solution_options = solution_response.split("\n") # 假设解法选项按行分开
49
 
50
  return task, solution_options, jd_text, task, solution_options
51