38 lines
1.6 KiB
Python
38 lines
1.6 KiB
Python
from PyPDF2 import PdfReader
|
||
|
||
from flask_app.general.通义千问long import upload_file, qianwen_long
|
||
|
||
|
||
def judge_zbfile(file_path):
|
||
|
||
try:
|
||
# 检查文件是否存在且是pdf格式(不区分大小写)
|
||
if file_path.lower().endswith(('.pdf', '.PDF')):
|
||
reader = PdfReader(file_path)
|
||
num_pages = len(reader.pages)
|
||
if num_pages <= 5:
|
||
return False
|
||
user_query = """该文件是否属于招标文件?如果是的话,请返回'是',如果不是的话,返回'否'。请不要返回其他解释或内容。
|
||
以下是常见的招标文件类型:
|
||
公开招标文件、邀请招标文件、竞争性谈判文件、竞争性磋商文件、询价文件、问询文件、货物类招标文件、工程类招标文件、施工类招标文件、服务类招标文件、比选文件。
|
||
若有未涵盖的类型,但其内容明确表达了项目需求、采购或招标信息,且包含指导投标人参与的关键要素,则可视为招标文件。
|
||
请基于上述内容判断文件是否属于招标文件。
|
||
"""
|
||
file_id = upload_file(pdf_path)
|
||
model_res = qianwen_long(file_id, user_query)
|
||
print(f"判断是否属于招标文件:{model_res}")
|
||
if '否' in model_res:
|
||
return False
|
||
return True
|
||
|
||
except Exception as e:
|
||
print(f"处理PDF文件时出错: {e}")
|
||
return False
|
||
|
||
if __name__ == '__main__':
|
||
pdf_path=r"C:\Users\Administrator\Desktop\测试信号测试信号.docx"
|
||
res=judge_zbfile(pdf_path)
|
||
if res:
|
||
print("yes")
|
||
else:
|
||
print("no") |