tejoess commited on
Commit
12f0773
Β·
1 Parent(s): 8d12d5b

πŸ”„ Auto-deploy from GitHub commit 7c163a7d2533a22582efdbe9cb653564cd8433d6

Browse files
Files changed (5) hide show
  1. README.md +10 -8
  2. app.py +141 -0
  3. packages.txt +1 -0
  4. requirements.txt +9 -0
  5. space_repo/README.md +13 -0
README.md CHANGED
@@ -1,13 +1,15 @@
1
  ---
2
- title: usecase1
3
- emoji: ⚑
4
- colorFrom: gray
5
- colorTo: blue
6
- sdk: streamlit
7
- python_version: 3.10
8
- sdk_version: 1.46.1
9
  app_file: app.py
10
  pinned: false
11
  ---
12
 
13
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
1
  ---
2
+ title: Usecase 1 Demo
3
+ emoji: πŸš€
4
+ colorFrom: indigo
5
+ colorTo: purple
6
+ sdk: streamlit # or gradio / static
7
+ sdk_version: 1.46.1 # pin the Streamlit version you’ve tested
 
8
  app_file: app.py
9
  pinned: false
10
  ---
11
 
12
+ # Usecase 1 Demo – Streamlit
13
+
14
+ Short description of what the Space does. Feel free to expand this section
15
+ with setup notes, screenshots, or usage instructions.
app.py ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ from langchain_core.documents import Document
4
+ from langchain.prompts import PromptTemplate
5
+ from langchain_community.llms import LlamaCpp # To run the GGUF model
6
+ from langchain_community.vectorstores import FAISS
7
+ from langchain.text_splitter import MarkdownHeaderTextSplitter
8
+ from langchain_huggingface import HuggingFaceEmbeddings
9
+ import json
10
+ import hashlib
11
+
12
+ # --- Streamlit Page Configuration ---
13
+ st.set_page_config(
14
+ page_title="URS document extractor",
15
+ page_icon="πŸ“„",
16
+ layout="wide"
17
+ )
18
+
19
+ st.title("πŸ“„ URS Document Data Extractor")
20
+ st.markdown("This app extracts key information from a hardcoded URS document context using Llama 3 on Hugging Face Spaces.")
21
+
22
+ # --- Core Logic from your script ---
23
+
24
+ # Using the hardcoded context you provided
25
+ CONTEXT_DOCUMENTS = [
26
+ Document(id='2345ac4a-b3ee-4444-bc09-3a8ebceaaa3e', metadata={}, page_content='||Revision History|4|\n|1.0|PROJECT DESCRIPTION|5|\n|2.0|PROCESS DESCRIPTION|5|\n|2.1|Name of the Equipment / System / Facility|5|\n|2.2|Purpose of the Equipment / System / Facility|5|\n|2.3|Number of Equipments Required|5|\n|2.4|Process Description and Schematic Flow diagram|5|'), Document(id='38fdcc4a-40f4-4f56-bc5c-c8eac5aa42a7', metadata={}, page_content='|3.5|Desirable material unloading method from the equipment / System|Desirable material unloading method from the equipment / System|Desirable material unloading method from the equipment / System|'), Document(id='5f7e1af4-114a-4b97-9da9-cfcf258541f4', metadata={}, page_content='|---|---|\n|2.0|PROCESS DESCRIPTION|\n|2.1|Name of the Equipment|\n||Pure Steam Generation and Distribution System.|\n|2.2|Purpose of the Equipment|\n||To provide Pure Steam as per pharmacopeia’s specifications.|\n|2.3|Number of Equipments Required|\n||Two Equipment’s|'), Document(id='7f4dffbe-f6f3-42ed-bc3c-821063de39bc', metadata={}, page_content='|5|Compound gauge|Warre / Baumer|\n|6|ORP Sensor|Georg fischer|\n|7|Manual ball valve for jacket condensate|Shaktti /approved vendor|\n|8|PLC|Allen bradlly / Siemens|\n|9|Temperature sensor|Radix|\n|10|Level transmitter|Endress + Hauses|\n|11|Pump|Ground foss|\n|12|Safety valve|Approved vendor|'), Document(id='f12dd67d-592b-4059-9e09-91f15c5817c0', metadata={}, page_content='|3.3|Desired outcome from the Equipment|6|\n|3.4|Desirable material loading method into the equipment / System|6|\n|3.5|Desirable material unloading method from the Equipment / System|6|\n|3.6|Expected operational hours per day and output in lots per day|6|\n|3.7|Preferable method of cleaning|6|'), Document(id='e879abf7-7202-49a1-9ac3-c2316872d84b', metadata={}, page_content='agents, etc.)<br>2. Preventive maintenance manual including:<br>β€’ Equipment and Instrument list with component descriptions<br>β€’ Electrical component parts list with descriptions<br>β€’ Spare parts list with appropriate identification nos., if any<br>β€’ Change parts list with appropriate'), Document(id='12716da2-cd79-4fae-b9b8-beb8406cfc29', metadata={}, page_content='|3.9|Utility Name|Specification|Purpose|\n|3.9|Compressed Air|Pharma grade, oil free.<br>Pressure: NLT 6.0 kg / cm2|For pneumatic operations|\n|3.9|Electric supply|400-440 V, 50 Hz, 3 phase|Power supply|\n|3.9|Purified water|2 Kg/Cm2|For product input|'), Document(id='737b9974-8fa7-4e7e-888b-8df3b04156a1', metadata={}, page_content='|9.0|Operational Qualification|YES|Supplier / user|\n|9.0|Performance Qualification|YES|Supplier / user|\n|10.0|ABBREVIATIONS|ABBREVIATIONS|ABBREVIATIONS| \nPage **12** of **13** \n__________________________________________________________________________________'), Document(id='94467a07-391a-48ac-a389-49daecba4ebb', metadata={}, page_content='if any<br>β€’ Change parts list with appropriate identification nos., if any<br>β€’ The equipment shall be designed to use standard tools for maintenance and repairing.<br>β€’ Any special tools required for maintenance should be provided along with the<br>equipment.<br>3. Drawings:<br>β€’ Engineering'), Document(id='d3016427-a1c3-414a-b378-7c9847670ce0', metadata={}, page_content='|3.4|Desirable material loading method into the equipment / System|Desirable material loading method into the equipment / System|Desirable material loading method into the equipment / System|'), Document(id='506745d1-33d9-4f81-bf81-235e7a86f11d', metadata={}, page_content='|3.1|Production Stage|Production Stage|Production Stage|\n||Generation of pure steam.|Generation of pure steam.|Generation of pure steam.|\n|3.2|Material inputs to the equipment and function|Material inputs to the equipment and function|Material inputs to the equipment and function|'), Document(id='8de5e683-6ed2-4514-b8f4-9ef14886636c', metadata={}, page_content='on post installation vendor equipment and training for Operation and<br>Maintenance to staff concerned.|'), Document(id='ce978272-570a-4c59-8bb7-3addff00cea3', metadata={}, page_content='**END OF DOCUMNET** \nPage **13** of **13** \n__________________________________________________________________________________'), Document(id='03a50379-c0d3-45e7-b99d-f6cf4b0c80f4', metadata={}, page_content='**USER REQUIREMENT SPECIFICATION FOR PURE**\n**TITLE** **:**\n**STEAM GENERATION AND DISTRIBUTION SYSTEM** \n**REFERENCE SOP** **:** **FU4-QA-GEN-001** \n|S.No.|Name of the Content|Page No.|\n|---|---|---|\n||Table of Contents|2 & 3|\n||Revision History|4|\n|1.0|PROJECT DESCRIPTION|5|'), Document(id='61ecc642-7bad-499d-84bb-2daa85c687ac', metadata={}, page_content='|Name / Designation|Signature|Date|\n|---|---|---|\n|Prepared By|Prepared By|Prepared By|\n||||\n|Reviewed By|Reviewed By|Reviewed By|\n||||\n|Approved By|Approved By|Approved By|\n|||| \n**END OF DOCUMNET** \nPage **13** of **13**'), Document(id='2bd9594d-54de-42fd-ae9e-86b5a108589f', metadata={}, page_content='|3.19|Any other specific requirements|9 - 10|\n|4.0|GMP REQUIREMENTS|10|\n|4.1|Main component|10| \nPage **2** of **13** \n__________________________________________________________________________________ \n**USER REQUIREMENT SPECIFICATION FOR PURE**\n**TITLE** **:**'), Document(id='ec3f77f5-e3e2-4fee-9f7b-7d66c5be9524', metadata={}, page_content='|---|---|\n|Department / Area|Production|\n|Quantity Required|02 No’s.| \n|S.No.|Name of the Content|Page No.|\n|---|---|---|\n||Cover Page|1| \nPage **1** of **13** \n__________________________________________________________________________________ \n**USER REQUIREMENT SPECIFICATION FOR PURE**'), Document(id='8f9ced91-f33e-478f-b97e-cdf9a73a97fb', metadata={}, page_content='**TITLE** **:**\n**STEAM GENERATION AND DISTRIBUTION SYSTEM** \n**REFERENCE SOP** **:** **FU4-QA-GEN-001** \n|S.No.|Name of the Content|Page No.|\n|---|---|---|\n|4.2|Specification for Material of Construction|10|\n|4.3|Working area Environmental requirement|10|'), Document(id='af6b7e87-0e23-43d8-b0d2-8c3d79bda7a3', metadata={}, page_content='00 **––** First Issue \n|1.0|PROJECT DESCRIPTION|\n|---|---|'), Document(id='baac7140-1017-4d04-8ffd-93341d03ae29', metadata={}, page_content='unit.|In feed through SS 316, < 0.8 Ra electro polished pipeline from Purified Water storage tank to<br>Pure steam generation unit.|'), Document(id='27b03f2d-2b87-4163-8695-152037dcd7ca', metadata={}, page_content='acceptance certificates (such as weld inspection, Passivation,<br>pressure / vacuum holds, etc.)<br>5. Validation documents:<br>β€’ Detailed list of modifications after contract &/or in final approved design<br>β€’ Material specifications and test certificates<br>β€’ Instrument Calibration'), Document(id='a654d68f-5f43-4c4e-993a-e857a568c6dd', metadata={}, page_content='help Pharma Ltd to prepare the SOP of Operation, Cleaning and<br>Preventive maintenance of the equipment.|FAT required before delivery. Supplier should provide a checklist and is responsible for total<br>completion up to performance qualification including training.<br>i. Technical staff of'), Document(id='d438426d-95a0-4fdb-afc3-320df8d8f915', metadata={}, page_content='ORP Sensor Georg fischer<br>7 Manual ball valve for jacket condensate Shaktti /approved vendor<br>8 PLC Allen bradlly / Siemens<br>9 Temperature sensor Radix<br>10 Level transmitter Endress + Hauses<br>11 Pump Ground foss<br>12 Safety valve Approved vendor|'), Document(id='17c60f16-b9ae-4661-8507-18bb50751992', metadata={}, page_content='**REFERENCE SOP** **:** **FU4-QA-GEN-001** \n|4.1|Main component|Col3|\n|---|---|---|\n|4.1|Main component should comply with valid regulated guidelines for cGMP practice.|Main component should comply with valid regulated guidelines for cGMP practice.|'), Document(id='74431d53-260f-48ac-9886-4665602ef9c0', metadata={}, page_content='ORP Sensor Georg fischer<br>7 Manual ball valve for jacket condensate Shaktti /approved vendor<br>8 PLC Allen bradlly / Siemens<br>9 Temperature sensor Radix<br>10 Level transmitter Endress + Hauses<br>11 Pump Ground foss<br>12 Safety valve Approved vendor|β€’ All product contact pipeline should be'), Document(id='326a9661-293d-4997-8e39-e833e21828cb', metadata={}, page_content='shall be present up to<br>first three successful performance qualifications run.<br>ii. Technical staff of supplier shall train the applicable equipment operator of Pharma Ltd<br>before operation qualification testing.<br>iii. Technical staff shall help Pharma Ltd to prepare the SOP of Operation,'), Document(id='e29901d5-7e7e-49a5-b2ef-073cca9cee15', metadata={}, page_content='operator of Pharma Ltd<br>before operation qualification testing.<br>iii. Technical staff shall help Pharma Ltd to prepare the SOP of Operation, Cleaning and<br>Preventive maintenance of the equipment.|FAT required before delivery. Supplier should provide a checklist and is responsible for'), Document(id='3d335625-329b-48da-ae86-7139fd2fdf43', metadata={}, page_content='**TITLE** **:**\n**STEAM GENERATION AND DISTRIBUTION SYSTEM** \n**REFERENCE SOP** **:** **FU4-QA-GEN-001** \n|Col1|regulator<br>β€’ Required indication of any respective fault at the P & I diagram with LED indication|\n|---|---|\n|3.11|Desired level of instrumentation and Accuracy levels|'), Document(id='dcea4482-c32e-4d63-b93c-e573b2006aab', metadata={}, page_content='**TITLE** **:**\n**STEAM GENERATION AND DISTRIBUTION SYSTEM** \n**REFERENCE SOP** **:** **FU4-QA-GEN-001**'), Document(id='b0afae6c-c048-4987-b2c2-b5e9545dcba4', metadata={}, page_content='|3.9|Required Utilities: The system will interface with required utilities such as compressed air,<br>electric supply, purified water and plant steam.|Required Utilities: The system will interface with required utilities such as compressed air,<br>electric supply, purified water and plant'), Document(id='88210785-aedf-49ba-a68b-6dc2296fea1a', metadata={}, page_content='|3.9|Purified water|2 Kg/Cm2|For product input|\n|3.9|Plant steam supply|6.0 kg / cm2|For Column Heating|\n|3.9|Vendor should specify the utility requirements|Vendor should specify the utility requirements|Vendor should specify the utility requirements|'), Document(id='59ccbc56-557f-4978-a3a9-c31b62317161', metadata={}, page_content='air,<br>electric supply, purified water and plant steam.|Required Utilities: The system will interface with required utilities such as compressed air,<br>electric supply, purified water and plant steam.|'), Document(id='b2d87404-8c6e-4217-a3d4-c99adc2fd6f5', metadata={}, page_content='|8.1|Foot prints of Machine, Utilities and Piping requirements.|Foot prints of Machine, Utilities and Piping requirements.|Foot prints of Machine, Utilities and Piping requirements.|\n|8.2|Start up support|Start up support|Start up support|'), Document(id='2ad3e821-0ef1-4189-83ea-cedee05b7e14', metadata={}, page_content='through the Supervisory Control and Data Acquisition System<br>(SCADA). Operation of system is through PLC, which is programmed and stored in<br>CPU of the PLC set.<br>β€’ The equipment should have control system to stop the feed pump in case of low plant<br>steam temperature and low feed water level'), Document(id='b5c5c47d-ed51-46d6-a044-403a7a0ac811', metadata={}, page_content='|3.14|β€’<br>Required attachment to Purified water storage tank for input of feed water<br>β€’<br>Required attachment to pure steam distribution loop.<br>β€’<br>Required attachment to Plant steam generator and Compressed air generator|\n|3.15|Software details|'), Document(id='9311d9b1-a5ef-493b-a8b7-b9701b2bd5fe', metadata={}, page_content='is programmed and stored in<br>CPU of the PLC set.<br>β€’ The equipment should have control system to stop the feed pump in case of low plant<br>steam temperature and low feed water level in column.<br>β€’ The equipment should have pressure control system to regulate the cooling water<br>β€’ The'), Document(id='d095f3c6-4c15-4d8a-8578-0bf6d6b9e516', metadata={}, page_content='|4.3|Working area Environmental requirement|10|\n|4.4|Desired means for avoiding contamination & cross contamination of the<br>products|10|\n|4.5|Power supply – Specify if uninterrupted power supply is required or not|10|'), Document(id='d45c1cf6-ad81-4406-97b9-7b7b6a8e39e5', metadata={}, page_content='PLC set.<br>β€’ The equipment should have control system to stop the feed pump in case of low plant<br>steam temperature and low feed water level in column.<br>β€’ The equipment should have pressure control system to regulate the cooling water<br>β€’ The equipment should have Flow control flow meter for'), Document(id='33cdaf61-1478-4af7-a81f-abd9dc24b84f', metadata={}, page_content='|3.18|Least Count (if applicable)|Least Count (if applicable)|\n|3.18|Minimum legibility.|Minimum legibility.|\n|3.19|Any other specific requirements (e.g. Maintenance requirement)|Any other specific requirements (e.g. Maintenance requirement)|'), Document(id='55ac2b3d-d67e-419b-9f5f-799374d567ae', metadata={}, page_content='|4.0|GMP REQUIREMENTS|GMP REQUIREMENTS| \n|S. No|COMPONENT DESCRIPTION|MAKE|\n|---|---|---|\n|I|Diaphragm valves with SS handle with PTFE<br>diaphragm|Gemu|\n|2|Conductivity sensor|Rose mount|\n|3|Flow meter|E + H|\n|4|Pressure gauge|Warre / Baumer|\n|5|Compound gauge|Warre / Baumer|'), Document(id='86a4b33e-5951-4280-9c56-b95554954a80', metadata={}, page_content='|8.4|Any other specific requirement|Any other specific requirement|Any other specific requirement|'), Document(id='c93eef70-5136-49be-b130-b514c33d2cd1', metadata={}, page_content='|4.6|Power failure and recovery – Specify the action taken in case of power<br>failure.|10|\n|4.7|Any other specific GMP requirement|10 - 11|\n|5.0|SAFETY REQUIREMENTS|11|\n|5.1|Desired Product / Process safety systems|11|\n|5.2|Desired personnel safety systems|11|\n|6.0|DOCUMENTATION REQUIREMENT|11-12|'), Document(id='a5d42321-4543-4e23-b36c-e7db58755cf7', metadata={}, page_content='|9.0|VALIDATION REQUIREMENT WITH SCOPE|VALIDATION REQUIREMENT WITH SCOPE|VALIDATION REQUIREMENT WITH SCOPE|\n|9.0|Validation topic|Yes/ No|Scope|\n|9.0|Design Qualification|YES|Supplier|\n|9.0|FAT & SAT|YES|Supplier / user|\n|9.0|Installation Qualification|YES|Supplier / user|'), Document(id='5575ea25-9133-407f-936a-77687d42007f', metadata={}, page_content='**USER REQUIREMENT SPECIFICATION FOR PURE**\n**TITLE** **:**\n**STEAM GENERATION AND DISTRIBUTION SYSTEM** \n**REFERENCE SOP** **:** **FU4-QA-GEN-001** \n|Name of The<br>Equipment / System|Pure Steam Generation and Distribution System|\n|---|---|\n|Department / Area|Production|'), Document(id='62319524-7caf-44ae-93a9-10200e24814e', metadata={}, page_content='out components make:<br>S. No COMPONENT DESCRIPTION MAKE<br>Diaphragm valves with SS handle with PTFE<br>I Gemu<br>diaphragm<br>2 Conductivity sensor Rose mount<br>3 Flow meter E + H<br>4 Pressure gauge Warre / Baumer<br>5 Compound gauge Warre / Baumer<br>6 ORP Sensor Georg fischer<br>7 Manual ball'), Document(id='05447a5d-8468-41c8-88f3-b540524ec6e5', metadata={}, page_content='|8.2|FAT required before delivery. Supplier should provide a checklist and is responsible for total<br>completion up to performance qualification including training.<br>i. Technical staff of supplier shall come to install the equipment and shall be present up to<br>first three successful'), Document(id='7316a81b-a1d1-46d4-9673-6155f703742f', metadata={}, page_content='|4.2|Non contact parts|SS 304|\n|4.3|Working area environmental requirement|Working area environmental requirement|\n|4.3|Machine should operate under clean environment / unclassified area.|Machine should operate under clean environment / unclassified area.|'), Document(id='7c991ef9-ab9b-47f8-a614-1c3727d04ed7', metadata={}, page_content='|12|Safety valve|Approved vendor| \nPage **9** of **13** \n__________________________________________________________________________________ \n**USER REQUIREMENT SPECIFICATION FOR PURE**\n**TITLE** **:**\n**STEAM GENERATION AND DISTRIBUTION SYSTEM** \n**REFERENCE SOP** **:** **FU4-QA-GEN-001**'), Document(id='50671880-aed3-45df-9db5-6002ba29f0d6', metadata={}, page_content='|4.2|Specification for material of construction|Specification for material of construction|\n|4.2|Product contact parts|SS 316L, <0.38 Β΅ Ra electro polished. System should be mechanically<br>polished and passivated and or electropolished.|\n|4.2|Non contact parts|SS 304|'), Document(id='47aa3e0a-a26d-4da0-8b6f-4522fa443c50', metadata={}, page_content='|2.5|Chemical / Physical characteristics of the process material|5|\n|2.6|Suggested capacity|5|\n|2.7|Any other specific requirement|5 - 6|\n|3.0|OPERATIONAL / FUNCTIONAL REQUIREMENTS|6|\n|3.1|Production Stage|6|\n|3.2|Material inputs to the Equipment and Function|6|'), Document(id='f83dcd01-29f5-49a8-9f05-70aa2f4cde44', metadata={}, page_content='Drawings:<br>β€’ Engineering drawings (For approval, Approved, As built, As installed)<br>β€’ Electrical circuit diagrams<br>β€’ Piping and Instrument drawings for the product path shall meet the ASME and 3A<br>specifications requirements as applicable.<br>β€’ System schematics.<br>4. Factory Acceptance'), Document(id='ba557316-f5a4-400c-b02b-defa1b21a966', metadata={}, page_content='|8.4|Any other specific requirements.|13|\n|9.0|VALIDATION REQUIREMENT WITH SCOPE|13|\n|10.0|ABBREVIATIONS|13|\n|11.0|DISCUSSION REVIEW / COMMENTS|13|\n||APPROVAL SIGNATORIES|14| \n**REVISION HISTORY** \n**Revision No.** **Date** **Revision Summary** \nPage **3** of **13**'), Document(id='c44dc000-983c-4cc3-b37b-2d2fbcd5cc6b', metadata={}, page_content='System schematics.<br>4. Factory Acceptance test:<br>β€’ Detailed list of modifications after contract and / or in final approved design,<br>Material specifications and test certificates, Instrument Calibration certificates,<br>Functional / Factory acceptance certificates (such as weld inspection,'), Document(id='3a25bd42-6c83-4e76-a524-bf88780fed98', metadata={}, page_content='|3.12|Language requirement (Specify such as English/others).|\n|3.12|English|\n|3.13|Data Acquisition|\n|3.13|The vendor should provide the print out facility with memory and with 3 level password<br>protection.|\n|3.14|Attachment / connectivity with other equipments|'), Document(id='419fc230-e716-472a-b4c7-bdd5ce4794ea', metadata={}, page_content='Page **10** of **13** \n__________________________________________________________________________________ \n**USER REQUIREMENT SPECIFICATION FOR PURE**\n**TITLE** **:**\n**STEAM GENERATION AND DISTRIBUTION SYSTEM** \n**REFERENCE SOP** **:** **FU4-QA-GEN-001** \n|5.2|Desired personnel safety systems|'), Document(id='227cc26c-3341-4e4f-b408-7145144c8f27', metadata={}, page_content='|3.12|Language requirement|9|\n|3.13|Data Acquisition|9|\n|3.14|Attachment / connectivity with other equipments|9|\n|3.15|Software details|9|\n|3.16|Operational Range (Minimum & Maximum)|9|\n|3.17|Tolerance Limits|9|\n|3.18|Least Count (if applicable)|9|\n|3.19|Any other specific requirements|9 - 10|'), Document(id='69cee82e-9141-49d5-982b-669746119794', metadata={}, page_content='is low, in case of insufficient evaporation, feed water pressure low.<br>β€’<br>Inner and Outer column shell should be < 0.6 Ra, electro polished. Pipeline should be<br>orbital welded wherever technically possible.<br>β€’<br>Required to control the water droplets, particulate matter and Endotoxin from'), Document(id='e18c71c6-d09b-472f-a2e3-c3e186e3c1a9', metadata={}, page_content='|2.5|Chemical / Physical characteristics of the process material|'), Document(id='dc7a77ff-376e-4575-ac83-5c48b0bffaf5', metadata={}, page_content='||β€’<br>Require sanitary construction features such as double tube sheets, sloped piping and low<br>point drains, minimum dead legs and sanitary connections.<br>β€’<br>Required uniform wetting and heat transfer. Elimination of bio growth Feed water level<br>control: Need PID control loop senses the'), Document(id='e5ada173-60c6-4475-b02e-0f9307af4670', metadata={}, page_content='Page **11** of **13** \n__________________________________________________________________________________ \n**USER REQUIREMENT SPECIFICATION FOR PURE**\n**TITLE** **:**\n**STEAM GENERATION AND DISTRIBUTION SYSTEM** \n**REFERENCE SOP** **:** **FU4-QA-GEN-001** \n|7.0|AUTOMATION|Col3|Col4|'), Document(id='135281c2-d96a-4e25-ae8d-90a81955a7bb', metadata={}, page_content='**REFERENCE SOP** **:** **FU4-QA-GEN-001** \n|Col1|β€’<br>Required a provision for non-condensable gas removal arrangement.|Col3|Col4|\n|---|---|---|---|\n|3.0|OPERATIONAL / FUNCTIONAL REQUIREMENTS|OPERATIONAL / FUNCTIONAL REQUIREMENTS|OPERATIONAL / FUNCTIONAL REQUIREMENTS|'), Document(id='a43c5b45-ab19-42dc-ba91-2b17ffe4ac94', metadata={}, page_content='|3.19|β€’ All product contact pipeline should be orbital welded.<br>β€’ The vendor must be able to provide routine repairs when needed beyond the warranty<br>period at cost to the customer.<br>β€’ Required audio / visual alarms for all critical insufficiency.<br>Bought out components make:<br>S. No'), Document(id='51a793f4-0ca8-41e1-9782-0f5f03eb8133', metadata={}, page_content='vendor|β€’ All product contact pipeline should be orbital welded.<br>β€’ The vendor must be able to provide routine repairs when needed beyond the warranty<br>period at cost to the customer.<br>β€’ Required audio / visual alarms for all critical insufficiency.<br>Bought out components make:<br>S. No'), Document(id='169e4b66-dacc-404d-b12a-a208d2a94c6d', metadata={}, page_content='|---|---|---|\n|3.16|Operational Range|Operational Range|\n|3.16|Minimum|Maximum|\n|3.16|Supplier should provide operating ranges.|Supplier should provide operating ranges.|\n|3.17|Tolerance Limits|Tolerance Limits|\n|3.17|0.2 to 0.3 of any instrument|0.2 to 0.3 of any instrument|'), Document(id='6d995642-8167-401a-983e-159aba636da1', metadata={}, page_content='and test certificates<br>β€’ Instrument Calibration certificates<br>β€’ Design Qualification Protocol.<br>β€’ Installation Qualification Protocol<br>β€’ Operational Qualification Protocol<br>β€’ Required PLC validation<br>β€’ Certificates of Materials and gauges with respect to NIST/NPL.<br>β€’ Certificates of'), Document(id='5ff3d789-6fbd-41d7-af42-bb3cbcb8ee5b', metadata={}, page_content='should provide a checklist and is responsible for total<br>completion up to performance qualification including training.<br>i. Technical staff of supplier shall come to install the equipment and shall be present up to<br>first three successful performance qualifications run.<br>ii. Technical staff'), Document(id='0204e75a-0444-4f0f-9ada-44c95dd44d5b', metadata={}, page_content='|8.4|β€’<br>Required failure modes and effective analysis document.<br>β€’<br>Operation and maintenance manuals.<br>β€’<br>Calibration certificates with traceability|β€’<br>Required failure modes and effective analysis document.<br>β€’<br>Operation and maintenance manuals.<br>β€’<br>Calibration certificates'), Document(id='c2d6f1e7-b1e4-4916-bcc0-e1cf51d653c7', metadata={}, page_content='qualifications run.<br>ii. Technical staff of supplier shall train the applicable equipment operator of Pharma Ltd<br>before operation qualification testing.<br>iii. Technical staff shall help Pharma Ltd to prepare the SOP of Operation, Cleaning and<br>Preventive maintenance of the equipment.|')]
27
+ FINAL_QUERY = {
28
+ "[Equipment Name]": "What is the name of the equipment mentioned in the document?",
29
+ "[URS Title]": "What is the title of the URS document as stated in the document?",
30
+ "[URS #]": "Which Reference SOP is assigned to the URS?",
31
+ "[Utility#]": "List the names of various utilities required to run the system (usually multiple, present as table in the input pdf)",
32
+ "[URS Requirement_Utility]": "What are the required Utilities?",
33
+ "[Requirement number_Utility]": "Which section number or unique requirement number corresponds to the required Utilities?",
34
+ "[URS Requirement_BOM]": "What is the documentation requirement for a spare parts list?",
35
+ "[Requirement number_BOM]": "Which section number corresponds to the documentation requirement for a spare parts list?",
36
+ "[URS Requirement_P&ID]": "What drawings are mentioned in the documentation requirement?",
37
+ "[Requirement number_P&ID]": "Which section number corresponds to the drawings mentioned in the documentation requirement?",
38
+ "[URS Requirement_Surface Finish]": "What is the inner and outer column shell specification?",
39
+ "[Requirement number_SF value]": "Which section number corresponds to the inner and outer column shell specification?",
40
+ "[URS Requirement_GA DWG]": "What are the specifications for product contact parts?",
41
+ "[Requirement number_GA DWG]": "Which section number corresponds to the specifications for product contact parts?",
42
+ "[URS Requirement_MOC]": "What is the slope value of the desired level of instruments and accuracy levels?",
43
+ "[Requirement number_MOC]": "Which section number corresponds to the slope value of the desired level of instruments and accuracy levels?"
44
+ }
45
+
46
+ # Use Streamlit's cache to load the model only once
47
+ @st.cache_resource
48
+ def get_llm():
49
+ """Loads the Llama 3 model from Hugging Face."""
50
+ st.info("Downloading and loading the Llama 3 model... This may take a few minutes on first run.")
51
+
52
+ # This function will download the model from the Hugging Face Hub and cache it.
53
+ llm = LlamaCpp(
54
+ # The repo ID of the model you want to use
55
+ model_path_or_repo_id="QuantFactory/Meta-Llama-3-8B-Instruct-GGUF",
56
+ # The specific model file in that repository
57
+ model_basename="Meta-Llama-3-8B-Instruct.Q4_K_M.gguf",
58
+ n_gpu_layers=-1, # Offload all layers to GPU if available (won't use on basic HF space)
59
+ n_batch=512,
60
+ n_ctx=4096, # Context window
61
+ f16_kv=True, # Must be set to True on metal for Apple silicon
62
+ verbose=True,
63
+ temperature=0,
64
+ max_tokens=2048
65
+ )
66
+ return llm
67
+
68
+ def generating_results(context, Final_Query, llm):
69
+ """Generates results using the loaded LLM."""
70
+
71
+ prompt = PromptTemplate(
72
+ template="""
73
+ You are an expert in extracting data from User Requirement Specification (URS) documents.
74
+ You are given:
75
+
76
+ ## CONTEXT:
77
+ {context}
78
+
79
+ ## PLACEHOLDER-HINT DICTIONARY:
80
+ {Final_Query}
81
+
82
+ ## TASK:
83
+ - Extract the exact values for the provided placeholders using the information from the relevant document chunks.
84
+ - If the hint is "Not given", skip that placeholder.
85
+ - For placeholders like "[Utility#]", return multiple values as "[Utility#1]", "[Utility#2]", etc.
86
+ - Your final output MUST be a single, valid JSON object.
87
+ - The keys of the JSON object must be the placeholders from the dictionary.
88
+ - The values must be the extracted information. Do not add any extra text, explanations, or markdown formatting around the JSON.
89
+ - Start your response directly with ```json and end it with ```.
90
+
91
+ ## RESPONSE (must be a single JSON object):
92
+ """,
93
+ input_variables=['context', 'Final_Query']
94
+ )
95
+
96
+ chain = prompt | llm
97
+
98
+ response = chain.invoke({
99
+ 'context': "\n".join([doc.page_content for doc in context]),
100
+ 'Final_Query': Final_Query
101
+ })
102
+
103
+ return response
104
+
105
+ # --- Streamlit App UI ---
106
+
107
+ st.info("Click the button below to start the extraction process. Note: This uses a large model on a free CPU, so it will be slow and may take several minutes.")
108
+
109
+ if st.button("✨ Start Extraction", type="primary"):
110
+ with st.spinner("Please wait... The Llama 3 model is processing the document..."):
111
+ try:
112
+ # 1. Load the LLM
113
+ # This is cached, so it's fast after the first run.
114
+ llm_extraction = get_llm()
115
+
116
+ # 2. Call the generation function
117
+ # The context is already hardcoded in this example.
118
+ # In a real app, you would generate it from a file upload.
119
+ raw_response = generating_results(CONTEXT_DOCUMENTS, FINAL_QUERY, llm_extraction)
120
+
121
+ st.subheader("Raw Model Output")
122
+ st.text(raw_response)
123
+
124
+ # 3. Safely parse the JSON from the response
125
+ try:
126
+ # The model is instructed to return a JSON block. Find it.
127
+ json_start = raw_response.find('{')
128
+ json_end = raw_response.rfind('}') + 1
129
+ json_str = raw_response[json_start:json_end]
130
+ result = json.loads(json_str)
131
+
132
+ st.success("βœ… Extraction Complete!")
133
+ st.subheader("Parsed JSON Result")
134
+ st.json(result)
135
+
136
+ except Exception as e:
137
+ st.error(f"⚠️ Failed to parse JSON from the model's response. Error: {e}")
138
+ st.text_area("Model's Raw Response for Debugging:", raw_response, height=300)
139
+
140
+ except Exception as e:
141
+ st.error(f"An unexpected error occurred during the extraction process: {e}")
packages.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ build-essential
requirements.txt ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ streamlit
2
+ pandas
3
+ langchain
4
+ langchain-core
5
+ langchain-community
6
+ langchain-huggingface
7
+ faiss-cpu
8
+ sentence-transformers
9
+ llama-cpp-python
space_repo/README.md ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: usecase1
3
+ emoji: ⚑
4
+ colorFrom: gray
5
+ colorTo: blue
6
+ sdk: streamlit
7
+ python_version: 3.10
8
+ sdk_version: 1.46.1
9
+ app_file: app.py
10
+ pinned: false
11
+ ---
12
+
13
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference