zbparse/flask_app/general/判断是否是招标文件.py

38 lines
1.6 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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")