Spaces:
Sleeping
Sleeping
Update technicalDocCompliance.py
Browse files- technicalDocCompliance.py +55 -0
technicalDocCompliance.py
CHANGED
|
@@ -72,3 +72,58 @@ def compliance_tech(file: str, client, MANUAL_RULES):
|
|
| 72 |
)
|
| 73 |
|
| 74 |
return response.choices[0].message.content # Fixed: access output text[web:32]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
)
|
| 73 |
|
| 74 |
return response.choices[0].message.content # Fixed: access output text[web:32]
|
| 75 |
+
|
| 76 |
+
def compliance_tech_pdf(file_name: str, client, MANUAL_RULES):
|
| 77 |
+
|
| 78 |
+
PROMPT = f"""
|
| 79 |
+
|
| 80 |
+
You are a strict procurement compliance auditor.
|
| 81 |
+
|
| 82 |
+
Your task is to check whether the uploaded file FULLY complies against each point of each heading of the MANUAL RULES.
|
| 83 |
+
|
| 84 |
+
MANDATORY INSTRUCTIONS:
|
| 85 |
+
|
| 86 |
+
1. Do NOT assume anything.
|
| 87 |
+
2. Do NOT interpret beyond what is written.
|
| 88 |
+
3. If information is missing → mark as NON-COMPLIANT.
|
| 89 |
+
4. If partially satisfied → mark as NON-COMPLIANT.
|
| 90 |
+
5. Only explicit written evidence is valid.
|
| 91 |
+
6. Quote exact sentence from document as evidence.
|
| 92 |
+
7. Do not provide explanation beyond required format.
|
| 93 |
+
8. Include subject in the response.
|
| 94 |
+
|
| 95 |
+
Summarise the response only on rule headingwise and not pointwise mentioned under each heading.
|
| 96 |
+
|
| 97 |
+
OUTPUT FORMAT (STRICT):
|
| 98 |
+
|
| 99 |
+
Rule heading: Heading of the rule
|
| 100 |
+
Status: COMPLIANT / NON-COMPLIANT
|
| 101 |
+
Evidence: "<Exact quoted sentence from document>" OR "Not found in document"
|
| 102 |
+
Deviations: <short bullet-style description or 'None'>
|
| 103 |
+
COMPLIANCE ANALYSIS: <2–4 sentences explaining reasoning>
|
| 104 |
+
|
| 105 |
+
MANUAL RULES:
|
| 106 |
+
{MANUAL_RULES}
|
| 107 |
+
"""
|
| 108 |
+
|
| 109 |
+
with open(file_name, "rb") as f:
|
| 110 |
+
file = client.files.create(file=f, purpose="vision")
|
| 111 |
+
|
| 112 |
+
response = client.responses.create(
|
| 113 |
+
model="gpt-4o-mini",
|
| 114 |
+
input=[
|
| 115 |
+
{
|
| 116 |
+
"role": "user",
|
| 117 |
+
"content": [
|
| 118 |
+
{"type": "input_text", "text": PROMPT},
|
| 119 |
+
{
|
| 120 |
+
"type": "input_file",
|
| 121 |
+
"file_id": file.id
|
| 122 |
+
}
|
| 123 |
+
]
|
| 124 |
+
}
|
| 125 |
+
],
|
| 126 |
+
temperature=0, # 👈 VERY IMPORTANT
|
| 127 |
+
max_output_tokens=1200
|
| 128 |
+
)
|
| 129 |
+
return response.output_text
|