12.24 禅道bug修改
This commit is contained in:
parent
27d973de3c
commit
edfdb9e2f4
@ -213,14 +213,13 @@ def extract_text_with_keywords(doc_path, keywords, follow_up_keywords):
|
||||
if match_keywords(text, follow_up_keywords):
|
||||
continue_collecting = True
|
||||
section_number = re.match(r'^(\d+([..]\d+)*)\s*[..]?', text) # 修改后的正则,支持 '数字 、' 和 '数字.'
|
||||
if section_number:
|
||||
if section_number: #当前匹配的行前有序号,那么就匹配到下个相似序号为止停止收集
|
||||
current_section_number = section_number.group(1)
|
||||
level_count = current_section_number.count('.')
|
||||
|
||||
# Pattern to match current level, e.g., 3.4.5
|
||||
pattern = r'^' + (r'\d+\s*[..]\s*') * level_count + r'\d+'
|
||||
# Generate patterns for next section at same level and parent level
|
||||
# 获取章节的各级部分
|
||||
parts = current_section_number.split('.')
|
||||
# Pattern to match current level, e.g., 3.4.5 添加负向前瞻以防止匹配四级或更高层级
|
||||
pattern = r'^' + (r'\d+\s*[..]\s*') * level_count + r'\d+' + r'(?!\s*[..]\s*\d+)'
|
||||
matched_patterns = [pattern] # start with the full pattern
|
||||
|
||||
# for i in range(1, 6): #同级,与matched_patterns = [pattern]重复了,故注释
|
||||
@ -236,7 +235,7 @@ def extract_text_with_keywords(doc_path, keywords, follow_up_keywords):
|
||||
for i in range(1, 6): #考虑原文档的书写不规范,跳序号的情况,目前设置了范围<5
|
||||
parent_section_parts = parts[:-1].copy()
|
||||
parent_section_parts[-1] = str(int(parent_section_parts[-1]) + i)
|
||||
parent_pattern = r'^' + r'\s*[..]\s*'.join(parent_section_parts)
|
||||
parent_pattern = r'^' + r'\s*[..]\s*'.join(parent_section_parts)+ r'(?!\s*[..]\s*\d+)'
|
||||
matched_patterns.append(parent_pattern)
|
||||
|
||||
# 添加对 '数字 、' 格式的支持
|
||||
@ -522,7 +521,9 @@ def handle_query(file_path, user_query, output_file, result_key, keywords):
|
||||
all_tables1, all_tables2 = extract_table_with_keywords(table_data_list, keywords, follow_up_keywords)
|
||||
qianwen_txt = all_texts1 + all_tables1
|
||||
# Proceed only if there is content to write
|
||||
selected_contents = set() # 使用 set 去重
|
||||
selected_contents = [] # 使用列表保持顺序
|
||||
seen_contents = set() # 使用集合跟踪已添加的内容以去重
|
||||
|
||||
if qianwen_txt:
|
||||
with open(output_file, 'w', encoding='utf-8') as file:
|
||||
counter = 1
|
||||
@ -531,20 +532,24 @@ def handle_query(file_path, user_query, output_file, result_key, keywords):
|
||||
file.write("..............." + '\n')
|
||||
counter += 1
|
||||
user_query = generate_full_user_query(output_file, user_query)
|
||||
model_ans=doubao_model(user_query) #豆包
|
||||
model_ans = doubao_model(user_query) # 豆包模型
|
||||
# file_id = upload_file(output_file)
|
||||
# model_ans = qianwen_long(file_id, user_query)
|
||||
num_list = process_string_list(model_ans)
|
||||
print(result_key + "选中的序号:" + str(num_list))
|
||||
|
||||
for index in num_list:
|
||||
if index - 1 < len(qianwen_txt):
|
||||
if 1 <= index <= len(qianwen_txt):
|
||||
content = qianwen_txt[index - 1]
|
||||
selected_contents.add(content)
|
||||
if content not in seen_contents:
|
||||
selected_contents.append(content)
|
||||
seen_contents.add(content)
|
||||
|
||||
# 无论 qianwen_txt 是否为空,都添加 all_texts2 和 all_tables2 的内容
|
||||
selected_contents.update(all_texts2)
|
||||
selected_contents.update(all_tables2)
|
||||
for item in all_texts2 + all_tables2:
|
||||
if item not in seen_contents:
|
||||
selected_contents.append(item)
|
||||
seen_contents.add(item)
|
||||
|
||||
# 如果 selected_contents 不为空,则返回结果,否则返回空字符串
|
||||
if selected_contents:
|
||||
@ -590,42 +595,42 @@ def combine_find_invalid(invalid_docpath, output_dir):
|
||||
os.path.join(output_dir, "temp1.txt"),
|
||||
"否决和无效投标情形"
|
||||
),
|
||||
(
|
||||
r'废\s*标',
|
||||
"""以下是从招标文件中摘取的内容,文本内之间的信息以'...............'分割。
|
||||
请根据该内容回答以下问题:
|
||||
废标项的情况有哪些?
|
||||
要求与指南:
|
||||
文本中可能存在无关的信息,请准确筛选符合条件的信息,并将符合条件的信息的序号返回。
|
||||
若存在语义相同或重复的情况,只需返回其中一个序号。
|
||||
请以[x, x, x]格式返回结果,其中x为符合的信息的序号;若没有符合的情况,请返回[]。
|
||||
文本内容:{full_text}
|
||||
""",
|
||||
os.path.join(output_dir, "temp2.txt"),
|
||||
"废标项"
|
||||
),
|
||||
(
|
||||
r'不\s*得|禁\s*止\s*投\s*标',
|
||||
"""以下是从招标文件中摘取的内容,文本内之间的信息以'...............'分割,每条信息规定了各方不得存在的情形。请根据以下要求进行筛选:
|
||||
**筛选要求**:
|
||||
1. **仅筛选**出主语为“投标人”、“中标人”、“供应商”、“联合体投标各方”或“磋商小组”或其他投标相关主体的条款。
|
||||
2. **排除**主语为“招标人”、“采购人”、“评标委员会”或其他非投标相关主体的条款。
|
||||
3. **仅包含**明确描述禁止情形的条款,不包含笼统或未具体说明情形的条款。若信息内容诸如'投标人不得存在的其他关联情形'这样笼统的内容,而未说明具体的情形,则无需添加这条信息。
|
||||
|
||||
**示例**:
|
||||
- **符合条件**:
|
||||
- `1. 投标人不得...` → 包含,返回序号 1。
|
||||
- `6. 联合体投标各方不得...` → 包含,返回序号 6。
|
||||
- **不符合条件**:
|
||||
- `14. 采购人不得...` → 主语为“采购人”,排除。
|
||||
|
||||
请根据上述筛选要求,阅读以下文本内容,并以 `[x,x,x]` 格式返回符合条件的条款序号,如果没有符合条件的条款,返回 `[]`。
|
||||
|
||||
文本内容:{full_text}
|
||||
""",
|
||||
os.path.join(output_dir, "temp3.txt"),
|
||||
"不得存在的情形"
|
||||
)
|
||||
# (
|
||||
# r'废\s*标',
|
||||
# """以下是从招标文件中摘取的内容,文本内之间的信息以'...............'分割。
|
||||
# 请根据该内容回答以下问题:
|
||||
# 废标项的情况有哪些?
|
||||
# 要求与指南:
|
||||
# 文本中可能存在无关的信息,请准确筛选符合条件的信息,并将符合条件的信息的序号返回。
|
||||
# 若存在语义相同或重复的情况,只需返回其中一个序号。
|
||||
# 请以[x, x, x]格式返回结果,其中x为符合的信息的序号;若没有符合的情况,请返回[]。
|
||||
# 文本内容:{full_text}
|
||||
# """,
|
||||
# os.path.join(output_dir, "temp2.txt"),
|
||||
# "废标项"
|
||||
# ),
|
||||
# (
|
||||
# r'不\s*得|禁\s*止\s*投\s*标',
|
||||
# """以下是从招标文件中摘取的内容,文本内之间的信息以'...............'分割,每条信息规定了各方不得存在的情形。请根据以下要求进行筛选:
|
||||
# **筛选要求**:
|
||||
# 1. **仅筛选**出主语为“投标人”、“中标人”、“供应商”、“联合体投标各方”或“磋商小组”或其他投标相关主体的条款。
|
||||
# 2. **排除**主语为“招标人”、“采购人”、“评标委员会”或其他非投标相关主体的条款。
|
||||
# 3. **仅包含**明确描述禁止情形的条款,不包含笼统或未具体说明情形的条款。若信息内容诸如'投标人不得存在的其他关联情形'这样笼统的内容,而未说明具体的情形,则无需添加这条信息。
|
||||
#
|
||||
# **示例**:
|
||||
# - **符合条件**:
|
||||
# - `1. 投标人不得...` → 包含,返回序号 1。
|
||||
# - `6. 联合体投标各方不得...` → 包含,返回序号 6。
|
||||
# - **不符合条件**:
|
||||
# - `14. 采购人不得...` → 主语为“采购人”,排除。
|
||||
#
|
||||
# 请根据上述筛选要求,阅读以下文本内容,并以 `[x,x,x]` 格式返回符合条件的条款序号,如果没有符合条件的条款,返回 `[]`。
|
||||
#
|
||||
# 文本内容:{full_text}
|
||||
# """,
|
||||
# os.path.join(output_dir, "temp3.txt"),
|
||||
# "不得存在的情形"
|
||||
# )
|
||||
]
|
||||
results = []
|
||||
|
||||
@ -669,10 +674,10 @@ if __name__ == '__main__':
|
||||
# doc_path = r'C:\Users\Administrator\Desktop\new招标文件\tmp\2024-贵州-贵州省罗甸县 2024 年度广州市协作资金龙坪镇、边阳镇产业路硬化建设项目.docx'
|
||||
pdf_path=r'C:\Users\Administrator\Desktop\fsdownload\8a9ebd69-af0d-4661-a8ce-78136cb6bc4f\ztbfile.pdf'
|
||||
|
||||
output_dir = r"D:\flask_project\flask_app\static\output\output1\05298da2-a797-4f77-b7d3-8fb5b401d4c2\tmp"
|
||||
output_dir = r"D:\flask_project\flask_app\static\output\output1\000aac0d-4aa4-4bc3-a9f9-76ff82ec2470\tmp"
|
||||
# invalid_added=insert_mark(pdf_path)
|
||||
# invalid_added_docx=pdf2docx(invalid_added)
|
||||
invalid_added_docx=r'D:\flask_project\flask_app\static\output\output1\05298da2-a797-4f77-b7d3-8fb5b401d4c2\invalid_added.docx'
|
||||
invalid_added_docx=r'D:\flask_project\flask_app\static\output\output1\000aac0d-4aa4-4bc3-a9f9-76ff82ec2470\invalid_added.docx'
|
||||
results = combine_find_invalid(invalid_added_docx, output_dir)
|
||||
end_time = time.time()
|
||||
print("Results:", json.dumps(results, ensure_ascii=False, indent=4))
|
||||
|
@ -0,0 +1,20 @@
|
||||
import re
|
||||
|
||||
# 修改后的正则表达式
|
||||
pattern = re.compile(r'^\d+\s*[..]\s*\d+\s*[..]\s*\d+(?![..])')
|
||||
|
||||
# 测试字符串
|
||||
test_strings = [
|
||||
'5.1.3 投标文件未按时上传系统的。',
|
||||
'5.1.3.1 投标文件未按时上传系统的。',
|
||||
'5.1 投标文件未按时上传系统的。',
|
||||
'5.1.3 投标成功。',
|
||||
]
|
||||
|
||||
# 测试匹配
|
||||
for test_string in test_strings:
|
||||
match = pattern.search(test_string)
|
||||
if match:
|
||||
print(f"匹配成功: {match.group()} -> {test_string}")
|
||||
else:
|
||||
print(f"未匹配: {test_string}")
|
@ -386,138 +386,138 @@ def get_technical_requirements(invalid_path,processed_filepath,model_type=1):
|
||||
user_query = generate_prompt(judge_res, full_text)
|
||||
model_res = doubao_model(user_query)
|
||||
print(model_res)
|
||||
cleaned_res = clean_json_string(model_res) #转字典
|
||||
processed_data=truncate_system_keys(cleaned_res['采购需求'])
|
||||
key_paths, grouped_paths, good_list, data_copy= generate_key_paths(processed_data) # 提取需要采购的货物清单 key_list:交通监控视频子系统.高清视频抓拍像机 ... grouped_paths是同一系统下同时有'交换机-1'和'交换机-2',提取'交换机' ,输出eg:{'交通标志.标志牌铝板', '交通信号灯.交换机'}
|
||||
modified_data=rename_keys(data_copy)
|
||||
user_query_template = """请根据货物标中采购要求部分的内容,告诉我\"{}\"的技术参数或采购要求是什么。请以 JSON 格式返回结果,键名为\"{}\",键值为一个列表,列表中包含若干描述\"{}\"的技术参数或采购要求或功能说明的字符串,请按原文内容回答,保留三角▲、五角★和序号,不可擅自增删内容,尤其是不可擅自添加序号。
|
||||
**重要限制**:
|
||||
- **仅提取技术参数或采购要求,不包括任何商务要求**。商务要求通常涉及供应商资格、报价条款、交货时间、质保等内容,是整体的要求;而技术参数或采购要求则具体描述产品的技术规格、功能、性能指标等。
|
||||
- **商务要求的关键词示例**(仅供参考,不限于此):报价、交货、合同、资质、认证、服务、保修期等。如果内容包含上述关键词,请仔细甄别是否属于商务要求。
|
||||
|
||||
要求与指南:
|
||||
1. 你的键值应该全面,不要遗漏。
|
||||
-a.若技术参数或采购要求在表格中,那么单元格内的内容基本都要涵盖
|
||||
-对于单元格内以序号分隔的各条参数要求,应逐条提取,并分别作为键值中的字符串列表项。
|
||||
-对于无序号标明且在同一单元格内的参数要求或功能说明,也要根据语义分别添加进键值中。
|
||||
-b.若技术参数或采购要求在正文部分,应准确定位到与目标货物(设备、系统、功能模块)相关的内容,将其后的技术参数或采购要求或功能说明完整提取,逐一添加到键值的字符串列表中,不得擅自添加或修改序号。
|
||||
2. 如果存在嵌套结构,且原文为Markdown 的表格语法,如'摄像机|有效像素|≥900W像素', 请不要返回该Markdown语法,而是使用冒号':'将相关信息拼接在一起,生成一条完整且清晰的技术参数(或采购要求)描述,作为列表中的一个字符串。如"摄像机:有效像素:≥900W像素"。
|
||||
3. 字符串中的内容为具体的技术参数要求或采购要求,请不要返回诸如'(1)高清录像功能'这种标题性质且不能体现要求的内容。
|
||||
4. 如果该货物没有相关采购要求或技术参数要求,键值应为空列表[]。
|
||||
|
||||
### 示例输出1如下:
|
||||
{{
|
||||
"摄像机控制键盘": [
|
||||
"1、▲支持串行 RS232/RS422 和 IP 混合控制,允许在一个控制器上使用 RS232/RS422/IP 控制单个系统中的摄像机;",
|
||||
"2、支持 2 组 RS422 串口 VISCA 协议菊花链控制 2x7 台摄像机。",
|
||||
"★能够自动对焦,提供检测报告"
|
||||
]
|
||||
}}
|
||||
|
||||
### 示例输出2如下(包含嵌套结构):
|
||||
{{
|
||||
"摄像机": [
|
||||
"摄像机:有效像素:≥900W像素",
|
||||
"摄像机:最低照度:彩色≤0.001lx",
|
||||
"协议:routes 接口开放:具备;▲支持标准 ONVIF 协议与第三方厂家设备进行互联;支持 GB/T28181;应提供 SDK"
|
||||
]
|
||||
}}
|
||||
|
||||
{}
|
||||
"""
|
||||
user_query_template_two="""请根据货物标中采购要求部分的内容,告诉我\"{}\"的技术参数或采购要求是什么。由于该货物存在 {} 种不同的采购要求或技术参数,请逐一列出,并以 JSON 格式返回结果。请以'货物名-编号'区分多种型号,编号为从 1 开始的自然数,依次递增,即第一个键名为\"{}-1\";键值为一个列表,列表中包含若干描述\"{}\"的技术参数或采购要求或功能说明的字符串,请按原文内容回答,保留三角▲、五角★和序号(若有),不可擅自增删内容,尤其是不可擅自添加序号。
|
||||
|
||||
要求与指南:
|
||||
1. 你的键值应该全面,不要遗漏。
|
||||
-a.若技术参数或采购要求在表格中,那么单元格内的内容基本都要涵盖
|
||||
-对于单元格内以序号分隔的各条参数要求,应逐条提取,并分别作为键值中的字符串列表项。
|
||||
-对于无序号标明且在同一单元格内的参数要求或功能说明,也要根据语义分别添加进键值中。
|
||||
-b.若技术参数或采购要求在正文部分,应准确定位到与目标货物(设备、系统、功能模块)相关的内容,将其后的技术参数或采购要求或功能说明完整提取,逐一添加到键值的字符串列表中,不得擅自添加或修改序号。
|
||||
2. 如果存在嵌套结构,且原文为Markdown 的表格语法,如'摄像机|有效像素|≥900W像素', 请不要返回该Markdown语法,而是使用冒号':'将相关信息拼接在一起,生成一条完整且清晰的技术参数(或采购要求)描述,作为列表中的一个字符串。如"摄像机:有效像素:≥900W像素"。
|
||||
3. 字符串中的内容为具体的技术参数要求或采购要求,请不要返回诸如'(1)高清录像功能'这种标题性质且不能体现要求的内容。
|
||||
4. 如果该货物没有相关采购要求或技术参数要求,键值应为空列表[]。
|
||||
|
||||
### 示例输出1如下:
|
||||
{{
|
||||
"交换机-1": [
|
||||
"★1、支持固化千兆电口≥8 个,固化千兆光口≥2 个,桌面型设备;",
|
||||
"2、支持静态链路聚合"
|
||||
],
|
||||
"交换机-2": [
|
||||
"1、交换容量≥52Gbps,包转发率≥38.69Mpps,",
|
||||
"2、提供国家强制性产品认证证书及测试报告(3C)",
|
||||
"★能实现信号控制独立传输"
|
||||
]
|
||||
}}
|
||||
|
||||
### 示例输出2如下(包含嵌套结构):
|
||||
{{
|
||||
"摄像机-1": [
|
||||
"摄像机:有效像素:≥900W像素",
|
||||
"摄像机:最低照度:彩色≤0.001lx",
|
||||
"协议:routes 接口开放:具备;▲支持标准 ONVIF 协议与第三方厂家设备进行互联;支持 GB/T28181;应提供 SDK"
|
||||
],
|
||||
"摄像机-2": [
|
||||
"支持夜视", "支持云存储"
|
||||
]
|
||||
}}
|
||||
|
||||
{}
|
||||
"""
|
||||
queries = []
|
||||
for key in key_paths:
|
||||
# 将键中的 '.' 替换为 '下的'
|
||||
modified_key = key.replace('.', '下的')
|
||||
# 使用修改后的键填充第一个占位符,原始键填充第二个占位符
|
||||
if model_type:
|
||||
new_query = user_query_template.format(modified_key, key, modified_key,f"文件内容:{full_text}") #转豆包后取消注释
|
||||
else:
|
||||
new_query = user_query_template.format(modified_key, key, modified_key,"")
|
||||
queries.append(new_query)
|
||||
|
||||
# 处理 grouped_paths 中的项,应用 user_query_template_two
|
||||
for grouped_dict in grouped_paths:
|
||||
for grouped_key, grouped_key_cnt in grouped_dict.items():
|
||||
# 将键中的 '.' 替换为 '下的'
|
||||
modified_grouped_key = grouped_key.replace('.', '下的')
|
||||
if model_type:
|
||||
new_query = user_query_template_two.format(modified_grouped_key, grouped_key_cnt, grouped_key,
|
||||
modified_grouped_key, f"文件内容:{full_text}")
|
||||
else:
|
||||
new_query = user_query_template_two.format(modified_grouped_key, grouped_key_cnt, grouped_key,
|
||||
modified_grouped_key, "")
|
||||
queries.append(new_query)
|
||||
if model_type:
|
||||
results = multi_threading(queries, "", "", 3,True) # 豆包
|
||||
else:
|
||||
results = multi_threading(queries, "", file_id, 2,True) # 豆包
|
||||
temp_final={}
|
||||
if not results:
|
||||
print("errror!未获得大模型的回答!")
|
||||
else:
|
||||
# 第一步:收集需要调用 `continue_answer` 的问题和解析结果
|
||||
questions_to_continue = [] # 存储需要调用 continue_answer 的 (question, parsed)
|
||||
max_tokens=3900 if model_type==1 else 5900
|
||||
for question, response in results:
|
||||
message=response[0]
|
||||
parsed = clean_json_string(message)
|
||||
total_tokens=response[1]
|
||||
if not parsed and total_tokens>max_tokens:
|
||||
questions_to_continue.append((question, message))
|
||||
else:
|
||||
temp_final.update(parsed)
|
||||
# 第二步:多线程处理需要调用 `continue_answer` 的问题
|
||||
if questions_to_continue:
|
||||
continued_results = process_continue_answers(questions_to_continue, model_type, file_id)
|
||||
temp_final.update(continued_results)
|
||||
|
||||
"""根据所有键是否已添加处理技术要求"""
|
||||
# 更新原始采购需求字典
|
||||
final_res=combine_and_update_results(modified_data, temp_final)
|
||||
ffinal_res=all_postprocess(final_res)
|
||||
ffinal_res["货物列表"] = good_list
|
||||
# 输出最终的 JSON 字符串
|
||||
return {"采购需求":ffinal_res}
|
||||
# cleaned_res = clean_json_string(model_res) #转字典
|
||||
# processed_data=truncate_system_keys(cleaned_res['采购需求'])
|
||||
# key_paths, grouped_paths, good_list, data_copy= generate_key_paths(processed_data) # 提取需要采购的货物清单 key_list:交通监控视频子系统.高清视频抓拍像机 ... grouped_paths是同一系统下同时有'交换机-1'和'交换机-2',提取'交换机' ,输出eg:{'交通标志.标志牌铝板', '交通信号灯.交换机'}
|
||||
# modified_data=rename_keys(data_copy)
|
||||
# user_query_template = """请根据货物标中采购要求部分的内容,告诉我\"{}\"的技术参数或采购要求是什么。请以 JSON 格式返回结果,键名为\"{}\",键值为一个列表,列表中包含若干描述\"{}\"的技术参数或采购要求或功能说明的字符串,请按原文内容回答,保留三角▲、五角★和序号,不可擅自增删内容,尤其是不可擅自添加序号。
|
||||
# **重要限制**:
|
||||
# - **仅提取技术参数或采购要求,不包括任何商务要求**。商务要求通常涉及供应商资格、报价条款、交货时间、质保等内容,是整体的要求;而技术参数或采购要求则具体描述产品的技术规格、功能、性能指标等。
|
||||
# - **商务要求的关键词示例**(仅供参考,不限于此):报价、交货、合同、资质、认证、服务、保修期等。如果内容包含上述关键词,请仔细甄别是否属于商务要求。
|
||||
#
|
||||
# 要求与指南:
|
||||
# 1. 你的键值应该全面,不要遗漏。
|
||||
# -a.若技术参数或采购要求在表格中,那么单元格内的内容基本都要涵盖
|
||||
# -对于单元格内以序号分隔的各条参数要求,应逐条提取,并分别作为键值中的字符串列表项。
|
||||
# -对于无序号标明且在同一单元格内的参数要求或功能说明,也要根据语义分别添加进键值中。
|
||||
# -b.若技术参数或采购要求在正文部分,应准确定位到与目标货物(设备、系统、功能模块)相关的内容,将其后的技术参数或采购要求或功能说明完整提取,逐一添加到键值的字符串列表中,不得擅自添加或修改序号。
|
||||
# 2. 如果存在嵌套结构,且原文为Markdown 的表格语法,如'摄像机|有效像素|≥900W像素', 请不要返回该Markdown语法,而是使用冒号':'将相关信息拼接在一起,生成一条完整且清晰的技术参数(或采购要求)描述,作为列表中的一个字符串。如"摄像机:有效像素:≥900W像素"。
|
||||
# 3. 字符串中的内容为具体的技术参数要求或采购要求,请不要返回诸如'(1)高清录像功能'这种标题性质且不能体现要求的内容。
|
||||
# 4. 如果该货物没有相关采购要求或技术参数要求,键值应为空列表[]。
|
||||
#
|
||||
# ### 示例输出1如下:
|
||||
# {{
|
||||
# "摄像机控制键盘": [
|
||||
# "1、▲支持串行 RS232/RS422 和 IP 混合控制,允许在一个控制器上使用 RS232/RS422/IP 控制单个系统中的摄像机;",
|
||||
# "2、支持 2 组 RS422 串口 VISCA 协议菊花链控制 2x7 台摄像机。",
|
||||
# "★能够自动对焦,提供检测报告"
|
||||
# ]
|
||||
# }}
|
||||
#
|
||||
# ### 示例输出2如下(包含嵌套结构):
|
||||
# {{
|
||||
# "摄像机": [
|
||||
# "摄像机:有效像素:≥900W像素",
|
||||
# "摄像机:最低照度:彩色≤0.001lx",
|
||||
# "协议:routes 接口开放:具备;▲支持标准 ONVIF 协议与第三方厂家设备进行互联;支持 GB/T28181;应提供 SDK"
|
||||
# ]
|
||||
# }}
|
||||
#
|
||||
# {}
|
||||
# """
|
||||
# user_query_template_two="""请根据货物标中采购要求部分的内容,告诉我\"{}\"的技术参数或采购要求是什么。由于该货物存在 {} 种不同的采购要求或技术参数,请逐一列出,并以 JSON 格式返回结果。请以'货物名-编号'区分多种型号,编号为从 1 开始的自然数,依次递增,即第一个键名为\"{}-1\";键值为一个列表,列表中包含若干描述\"{}\"的技术参数或采购要求或功能说明的字符串,请按原文内容回答,保留三角▲、五角★和序号(若有),不可擅自增删内容,尤其是不可擅自添加序号。
|
||||
#
|
||||
# 要求与指南:
|
||||
# 1. 你的键值应该全面,不要遗漏。
|
||||
# -a.若技术参数或采购要求在表格中,那么单元格内的内容基本都要涵盖
|
||||
# -对于单元格内以序号分隔的各条参数要求,应逐条提取,并分别作为键值中的字符串列表项。
|
||||
# -对于无序号标明且在同一单元格内的参数要求或功能说明,也要根据语义分别添加进键值中。
|
||||
# -b.若技术参数或采购要求在正文部分,应准确定位到与目标货物(设备、系统、功能模块)相关的内容,将其后的技术参数或采购要求或功能说明完整提取,逐一添加到键值的字符串列表中,不得擅自添加或修改序号。
|
||||
# 2. 如果存在嵌套结构,且原文为Markdown 的表格语法,如'摄像机|有效像素|≥900W像素', 请不要返回该Markdown语法,而是使用冒号':'将相关信息拼接在一起,生成一条完整且清晰的技术参数(或采购要求)描述,作为列表中的一个字符串。如"摄像机:有效像素:≥900W像素"。
|
||||
# 3. 字符串中的内容为具体的技术参数要求或采购要求,请不要返回诸如'(1)高清录像功能'这种标题性质且不能体现要求的内容。
|
||||
# 4. 如果该货物没有相关采购要求或技术参数要求,键值应为空列表[]。
|
||||
#
|
||||
# ### 示例输出1如下:
|
||||
# {{
|
||||
# "交换机-1": [
|
||||
# "★1、支持固化千兆电口≥8 个,固化千兆光口≥2 个,桌面型设备;",
|
||||
# "2、支持静态链路聚合"
|
||||
# ],
|
||||
# "交换机-2": [
|
||||
# "1、交换容量≥52Gbps,包转发率≥38.69Mpps,",
|
||||
# "2、提供国家强制性产品认证证书及测试报告(3C)",
|
||||
# "★能实现信号控制独立传输"
|
||||
# ]
|
||||
# }}
|
||||
#
|
||||
# ### 示例输出2如下(包含嵌套结构):
|
||||
# {{
|
||||
# "摄像机-1": [
|
||||
# "摄像机:有效像素:≥900W像素",
|
||||
# "摄像机:最低照度:彩色≤0.001lx",
|
||||
# "协议:routes 接口开放:具备;▲支持标准 ONVIF 协议与第三方厂家设备进行互联;支持 GB/T28181;应提供 SDK"
|
||||
# ],
|
||||
# "摄像机-2": [
|
||||
# "支持夜视", "支持云存储"
|
||||
# ]
|
||||
# }}
|
||||
#
|
||||
# {}
|
||||
# """
|
||||
# queries = []
|
||||
# for key in key_paths:
|
||||
# # 将键中的 '.' 替换为 '下的'
|
||||
# modified_key = key.replace('.', '下的')
|
||||
# # 使用修改后的键填充第一个占位符,原始键填充第二个占位符
|
||||
# if model_type:
|
||||
# new_query = user_query_template.format(modified_key, key, modified_key,f"文件内容:{full_text}") #转豆包后取消注释
|
||||
# else:
|
||||
# new_query = user_query_template.format(modified_key, key, modified_key,"")
|
||||
# queries.append(new_query)
|
||||
#
|
||||
# # 处理 grouped_paths 中的项,应用 user_query_template_two
|
||||
# for grouped_dict in grouped_paths:
|
||||
# for grouped_key, grouped_key_cnt in grouped_dict.items():
|
||||
# # 将键中的 '.' 替换为 '下的'
|
||||
# modified_grouped_key = grouped_key.replace('.', '下的')
|
||||
# if model_type:
|
||||
# new_query = user_query_template_two.format(modified_grouped_key, grouped_key_cnt, grouped_key,
|
||||
# modified_grouped_key, f"文件内容:{full_text}")
|
||||
# else:
|
||||
# new_query = user_query_template_two.format(modified_grouped_key, grouped_key_cnt, grouped_key,
|
||||
# modified_grouped_key, "")
|
||||
# queries.append(new_query)
|
||||
# if model_type:
|
||||
# results = multi_threading(queries, "", "", 3,True) # 豆包
|
||||
# else:
|
||||
# results = multi_threading(queries, "", file_id, 2,True) # 豆包
|
||||
# temp_final={}
|
||||
# if not results:
|
||||
# print("errror!未获得大模型的回答!")
|
||||
# else:
|
||||
# # 第一步:收集需要调用 `continue_answer` 的问题和解析结果
|
||||
# questions_to_continue = [] # 存储需要调用 continue_answer 的 (question, parsed)
|
||||
# max_tokens=3900 if model_type==1 else 5900
|
||||
# for question, response in results:
|
||||
# message=response[0]
|
||||
# parsed = clean_json_string(message)
|
||||
# total_tokens=response[1]
|
||||
# if not parsed and total_tokens>max_tokens:
|
||||
# questions_to_continue.append((question, message))
|
||||
# else:
|
||||
# temp_final.update(parsed)
|
||||
# # 第二步:多线程处理需要调用 `continue_answer` 的问题
|
||||
# if questions_to_continue:
|
||||
# continued_results = process_continue_answers(questions_to_continue, model_type, file_id)
|
||||
# temp_final.update(continued_results)
|
||||
#
|
||||
# """根据所有键是否已添加处理技术要求"""
|
||||
# # 更新原始采购需求字典
|
||||
# final_res=combine_and_update_results(modified_data, temp_final)
|
||||
# ffinal_res=all_postprocess(final_res)
|
||||
# ffinal_res["货物列表"] = good_list
|
||||
# # 输出最终的 JSON 字符串
|
||||
# return {"采购需求":ffinal_res}
|
||||
|
||||
def test_all_files_in_folder(input_folder, output_folder):
|
||||
# 确保输出文件夹存在
|
||||
@ -551,10 +551,10 @@ if __name__ == "__main__":
|
||||
# truncate_file="D:\\flask_project\\flask_app\\static\\output\\output1\\e7dda5cb-10ba-47a8-b989-d2993d34bb89\\ztbfile_procurement.docx"
|
||||
# output_folder="C:\\Users\\Administrator\\Desktop\\货物标\\output1\\tmp"
|
||||
# file_id = upload_file(truncate_file)
|
||||
invalid_path=r"D:\flask_project\flask_app\static\output\output1\6ac4326a-fa73-470c-9c2a-42657841c0c0\invalid_added.docx"
|
||||
invalid_path=r"D:\flask_project\flask_app\static\output\output1\000aac0d-4aa4-4bc3-a9f9-76ff82ec2470\invalid_added.docx"
|
||||
# file_id=upload_file(truncate_file)
|
||||
# processed_filepath = pdf2txt(truncate_file)
|
||||
processed_filepath=r"D:\flask_project\flask_app\static\output\output1\6ac4326a-fa73-470c-9c2a-42657841c0c0\extract1.txt"
|
||||
processed_filepath=r"D:\flask_project\flask_app\static\output\output1\000aac0d-4aa4-4bc3-a9f9-76ff82ec2470\extract1.txt"
|
||||
res=get_technical_requirements(invalid_path,processed_filepath)
|
||||
json_string = json.dumps(res, ensure_ascii=False, indent=4)
|
||||
print(json_string)
|
||||
|
Loading…
x
Reference in New Issue
Block a user