Spaces:
Running
Running
File size: 6,716 Bytes
d3a9651 3d78302 4258f5f 85f120c 2022358 1b55844 85f120c 1b55844 5324297 62005e7 5324297 62005e7 2b88de7 62005e7 2b88de7 f75226b 62005e7 5324297 c288bb8 5324297 3d78302 62005e7 c288bb8 62005e7 c288bb8 62005e7 5324297 62005e7 7210849 2d8d034 4e7d5d6 264bbb1 2d8d034 1151566 2d8d034 4e7d5d6 e819c2a 7210849 51f15cd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
"""
⚖️ Title: 🤖 eRAG-PDPA
License: Apache-2.0
This project is licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
For inquiries or contributions, please contact:
[email protected]
"""
import streamlit as st
import requests
import os
st.title('eRAG-PDPA-v1')
st.markdown("""
##### 🤖 AI เพื่อการเรียนรู้พระราชบัญญัติคุ้มครองข้อมูลส่วนบุคคล (PDPA)
ได้รับการออกแบบมาเพื่อช่วยให้ผู้ใช้งานเข้าถึงข้อมูลสำคัญได้อย่างรวดเร็วและเข้าใจง่าย
โดยระบบสามารถค้นหาและวิเคราะห์ความหมายในเชิงบริบทได้อย่างลึกซึ้ง
ทำให้สามารถเข้าใจความเชื่อมโยงและความหมายของข้อมูลได้อย่างแม่นยำ
รองรับการเรียนรู้เชิงลึกในประเด็นเกี่ยวกับ PDPA และการคุ้มครองข้อมูลส่วนบุคคลได้อย่างมีประสิทธิภาพ
[Powered by NT Lahnmah]
""", unsafe_allow_html=True)
def format_file_size(size_in_bytes):
for unit in ['B', 'KB', 'MB', 'GB']:
if size_in_bytes < 1024:
return f"{size_in_bytes:.2f} {unit}"
size_in_bytes /= 1024
return f"{size_in_bytes:.2f} GB"
def display_search_result(result, index):
with st.expander(f"🔍 Search Result #{index + 1} (Score: {result['score']:.4f})"):
st.markdown("#### 📄 Document Information")
col1, col2 = st.columns(2)
with col1:
st.write(f"• File Name: {result['metadata']['file_name']}")
st.write(f"• Page: {result['metadata']['page_label']}")
st.write(f"• Type: {result['metadata']['file_type']}")
st.write(f"• Size: {format_file_size(result['metadata']['file_size'])}")
with col2:
st.write(f"• Created: {result['metadata']['creation_date']}")
st.write(f"• Modified: {result['metadata']['last_modified_date']}")
st.markdown("#### 📝 Content")
st.markdown(f"<div style='background-color:#d3f9d8; padding: 10px; color: black;'><pre>{result['text']}</pre></div>", unsafe_allow_html=True)
access_token = os.getenv('eRAG_access_token')
headers = {
"Authorization": f"Bearer {access_token}"
}
st.markdown("""
<style>
.stTextInput>div>div>input {
background-color: #d3f9d8;
color: black;
cursor: text;
caret-color: black;
}
.stTextInput>div>div>input:focus {
border-color: black;
outline-color: black;
}
</style>
""", unsafe_allow_html=True)
api_url = os.getenv('api_url')
with st.form(key="input_form"):
user_input = st.text_input("ป้อนคำ ข้อความ หรือประโยคที่ต้องการค้นหา:", value="ข้อมูลส่วนบุคคล คืออะไร มีกี่ประเภท", key="input")
submit_button = st.form_submit_button("Send")
if submit_button and user_input:
st.write(f"คุณป้อนข้อความ: {user_input}")
try:
response = requests.post(api_url, json={"query": user_input}, headers=headers)
response.raise_for_status()
data = response.json()
search_results = data["results"]
st.markdown("### 🔎 Search Results")
for idx, result in enumerate(search_results):
display_search_result(result, idx)
except requests.RequestException as e:
st.error(f"Error: {str(e)}")
st.subheader("📄 ไฟล์เอกสารที่ใช้เป็นคลังข้อมูล PDPA")
st.markdown(
"""
- [FAQ-เกี่ยวกับการคุ้มครองข้อมูลส่วนบุคคล-PDPA.pdf](https://huggingface.co/spaces/amornpan/eRAG-PDPA-v1/blob/main/%E0%B9%80%E0%B8%AD%E0%B8%81%E0%B8%AA%E0%B8%B2%E0%B8%A3_PDPA/1.FAQ-%E0%B9%80%E0%B8%81%E0%B8%B5%E0%B9%88%E0%B8%A2%E0%B8%A7%E0%B8%81%E0%B8%B1%E0%B8%9A%E0%B8%81%E0%B8%B2%E0%B8%A3%E0%B8%84%E0%B8%B8%E0%B9%89%E0%B8%A1%E0%B8%84%E0%B8%A3%E0%B8%AD%E0%B8%87%E0%B8%82%E0%B9%89%E0%B8%AD%E0%B8%A1%E0%B8%B9%E0%B8%A5%E0%B8%AA%E0%B9%88%E0%B8%A7%E0%B8%99%E0%B8%9A%E0%B8%B8%E0%B8%84%E0%B8%84%E0%B8%A5-PDPA.pdf) (1.13 MB)
- [1612025563SummaryPDPA_DigitalCouncilofThailand.pdf](https://huggingface.co/spaces/amornpan/eRAG-PDPA-v1/blob/main/%E0%B9%80%E0%B8%AD%E0%B8%81%E0%B8%AA%E0%B8%B2%E0%B8%A3_PDPA/1612025563SummaryPDPA_DigitalCouncilofThailand.pdf) (1.35 MB)
- [PDPA_Guideline_v_1.pdf](https://huggingface.co/spaces/amornpan/eRAG-PDPA-v1/blob/main/%E0%B9%80%E0%B8%AD%E0%B8%81%E0%B8%AA%E0%B8%B2%E0%B8%A3_PDPA/PDPA_Guideline_v_1.pdf) (10.7 MB)
- [T_0024.pdf](https://huggingface.co/spaces/amornpan/eRAG-PDPA-v1/blob/main/%E0%B9%80%E0%B8%AD%E0%B8%81%E0%B8%AA%E0%B8%B2%E0%B8%A3_PDPA/T_0024.pdf) (81.1 kB)
- [T_0026.pdf](https://huggingface.co/spaces/amornpan/eRAG-PDPA-v1/blob/main/%E0%B9%80%E0%B8%AD%E0%B8%81%E0%B8%AA%E0%B8%B2%E0%B8%A3_PDPA/T_0026.pdf) (82.6 kB)
- [T_0028.pdf](https://huggingface.co/spaces/amornpan/eRAG-PDPA-v1/blob/main/%E0%B9%80%E0%B8%AD%E0%B8%81%E0%B8%AA%E0%B8%B2%E0%B8%A3_PDPA/T_0028.pdf) (105 kB)
- [T_0032.pdf](https://huggingface.co/spaces/amornpan/eRAG-PDPA-v1/blob/main/%E0%B9%80%E0%B8%AD%E0%B8%81%E0%B8%AA%E0%B8%B2%E0%B8%A3_PDPA/T_0032.pdf) (103 kB)
""",
unsafe_allow_html=True
)
st.subheader("👤 Authors")
st.write("""
- Amornpan Phornchaicharoen ([email protected])
- Aekanun Thongtae ([email protected])
- Montita Somsoo ([email protected])
- Jiranuwat Songpad ([email protected])
- Phongsatorn Somjai ([email protected])
- Benchawan Wangphoomyai ([email protected])
""") |