kenplusplus commited on
Commit
f429841
1 Parent(s): 82e9971

initial import

Browse files

Signed-off-by: Lu Ken <ken.lu@intel.com>

Files changed (31) hide show
  1. .gitattributes +1 -0
  2. app.py +87 -0
  3. docs/24593.pdf +3 -0
  4. docs/252046-sdm-change-document.pdf +3 -0
  5. docs/325462-sdm-vol-1-2abcd-3abcd-4.pdf +3 -0
  6. docs/55766_SEV-KM_API_Specification.pdf +3 -0
  7. docs/58019.pdf +3 -0
  8. docs/ACPI_Spec_6_5_Aug29.pdf +3 -0
  9. docs/TDX Guest-Hypervisor Communication Interface_1.0_344426_006 - 20230311.pdf +3 -0
  10. docs/TDX Guest-Hypervisor Communication Interface_1.5_348552_004 - 20230317.pdf +3 -0
  11. docs/TDX Migration TD Design Guide Rev 0.8.9.pdf +3 -0
  12. docs/TDX-Whitepaper-February2022.pdf +3 -0
  13. docs/UEFI_PI_Spec_1_8_March3.pdf +3 -0
  14. docs/UEFI_Spec_2_10_Aug29.pdf +3 -0
  15. docs/White Paper - Linux Stack for Intel® TDX-v0.11.pdf +3 -0
  16. docs/amd-sev-intel-tdx.pdf +3 -0
  17. docs/art-amd-sev_en.pdf +3 -0
  18. docs/intel-tdx-connect-architecture-specification.pdf +3 -0
  19. docs/intel-tdx-cpu-architectural-specification.pdf +3 -0
  20. docs/intel-tdx-module-1.5-abi-incompatibilities-354808003.pdf +3 -0
  21. docs/intel-tdx-module-1.5-abi-spec-348551003.pdf +3 -0
  22. docs/intel-tdx-module-1.5-base-spec-348549003.pdf +3 -0
  23. docs/intel-tdx-module-1.5-td-migration-spec-348550003.pdf +3 -0
  24. docs/intel-tdx-module-1.5-td-partitioning-spec-354807002.pdf +3 -0
  25. docs/intel-tdx-seamldr-interface-specification.pdf +3 -0
  26. docs/memory-encryption-white-paper.pdf +3 -0
  27. docs/software-enabling-for-tdx-tee-io-fixed.pdf +3 -0
  28. docs/tdx-virtual-firmware-design-guide-rev-004-20231206.pdf +3 -0
  29. docs/whitepaper-device-attestation-model-in-confidential-computing-environment-v0.6.4.pdf +3 -0
  30. docs/whitepaper-tee-io-device-guide-v0-6-5.pdf +3 -0
  31. requirements.txt +8 -0
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ *.pdf filter=lfs diff=lfs merge=lfs -text
app.py ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from PyPDF2 import PdfReader
3
+ from langchain.text_splitter import RecursiveCharacterTextSplitter
4
+ import os
5
+ from langchain_google_genai import GoogleGenerativeAIEmbeddings
6
+ import google.generativeai as genai
7
+ from langchain_community.vectorstores import FAISS
8
+ from langchain_google_genai import ChatGoogleGenerativeAI
9
+ from langchain.chains.question_answering import load_qa_chain
10
+ from langchain.prompts import PromptTemplate
11
+ from dotenv import load_dotenv
12
+ import shutil
13
+ import argparse
14
+
15
+ PDF_PATH=os.path.join(os.path.dirname(__file__), "docs")
16
+
17
+ def load_pdfs():
18
+ faiss_index_path = os.path.join(os.path.dirname(__file__), "faiss_index")
19
+
20
+ if os.path.exists(faiss_index_path):
21
+ return
22
+
23
+ pdfs = [f for f in os.listdir(PDF_PATH) if os.path.isfile(os.path.join(PDF_PATH, f))]
24
+
25
+ text=""
26
+ for pdf in pdfs:
27
+ print("process PDF: %s..." % pdf)
28
+ pdf_reader= PdfReader(os.path.join(PDF_PATH, pdf))
29
+ for page in pdf_reader.pages:
30
+ text+= page.extract_text()
31
+
32
+ text_splitter = RecursiveCharacterTextSplitter(chunk_size=10000, chunk_overlap=1000)
33
+ text_chunks = text_splitter.split_text(text)
34
+
35
+ embeddings = GoogleGenerativeAIEmbeddings(model = "models/embedding-001")
36
+ vector_store = FAISS.from_texts(text_chunks, embedding=embeddings)
37
+ vector_store.save_local("faiss_index")
38
+
39
+ return text
40
+
41
+ def get_conversational_chain():
42
+
43
+ prompt_template = """
44
+ Answer the question as detailed as possible from the provided context, make sure to provide all the details, if the answer is not in
45
+ provided context just say, "answer is not available in the context", don't provide the wrong answer\n\n
46
+ Context:\n {context}?\n
47
+ Question: \n{question}\n
48
+
49
+ Answer:
50
+ """
51
+
52
+ model = ChatGoogleGenerativeAI(model="gemini-pro",
53
+ temperature=0.3)
54
+
55
+ prompt = PromptTemplate(template = prompt_template, input_variables = ["context", "question"])
56
+ chain = load_qa_chain(model, chain_type="stuff", prompt=prompt)
57
+
58
+ return chain
59
+
60
+ def user_input(user_question):
61
+ embeddings = GoogleGenerativeAIEmbeddings(model = "models/embedding-001")
62
+
63
+ new_db = FAISS.load_local("faiss_index", embeddings)
64
+ docs = new_db.similarity_search(user_question)
65
+
66
+ chain = get_conversational_chain()
67
+
68
+
69
+ response = chain(
70
+ {"input_documents":docs, "question": user_question}
71
+ , return_only_outputs=True)
72
+
73
+ print(response)
74
+ st.write("Reply: ", response["output_text"])
75
+
76
+ def main():
77
+ load_pdfs()
78
+
79
+ st.set_page_config("TDX Doctor")
80
+ st.header("Please ask questions related to TDX or UEFI")
81
+
82
+ user_question = st.text_input("Ask a Question like 'please describe xxx in 400 words'")
83
+ if user_question:
84
+ user_input(user_question)
85
+
86
+ if __name__ == "__main__":
87
+ main()
docs/24593.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6a330e406ffe39893b09f56925969cf16ac35cbbebd961f9ed9a630189a917ff
3
+ size 20303609
docs/252046-sdm-change-document.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:89f33d9582ceda2e5fec3627c880ae534d8a0df1d96ffe231a022786aa1c16b9
3
+ size 8156900
docs/325462-sdm-vol-1-2abcd-3abcd-4.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3b2551f01b4c91dc80e7f9cfb1e9790feeefe503cff15d2922ace049f4d8730f
3
+ size 25301301
docs/55766_SEV-KM_API_Specification.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7051f29f8032f7012dc9c072902a697cdbb7f29e5ad1193523ed10a657810e23
3
+ size 1167826
docs/58019.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fe84295e4dff13162819ebc7a92cfb69f44ac52df05c001c9ed61b54d9daa4cf
3
+ size 596316
docs/ACPI_Spec_6_5_Aug29.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9cbe9f1767a29eb42289fd915286c80a9d3793bccb938bd50dfbc590645f3fcc
3
+ size 6554425
docs/TDX Guest-Hypervisor Communication Interface_1.0_344426_006 - 20230311.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:970029de9a90b28f5d1cf44724f18e8fab67c57947688b4ecbe6b7d439f02da3
3
+ size 567729
docs/TDX Guest-Hypervisor Communication Interface_1.5_348552_004 - 20230317.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8533b9b6d6f1e58aa1b9f1faa9470655e56d9a0b0f6a70f4426f0cfcf34619d1
3
+ size 796471
docs/TDX Migration TD Design Guide Rev 0.8.9.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a014340764cc202df8ab2601039cf358a5659b95afd9bbe2b27954a607af81d6
3
+ size 1022107
docs/TDX-Whitepaper-February2022.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5170692d21aab2f5a8227ef5ee9b99f909aa699bbbff3e36fd3a0d1374627ae3
3
+ size 630069
docs/UEFI_PI_Spec_1_8_March3.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d62acd7bbb13546b358bdd9653a108a3b6ab16929b76dd9772035ec41f01ed6d
3
+ size 5813057
docs/UEFI_Spec_2_10_Aug29.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ad9fb298458bb89583dbbd4c876d3302abb8840cfab1b55ca4bc06738831fa75
3
+ size 16141878
docs/White Paper - Linux Stack for Intel® TDX-v0.11.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9efb4e072cc05c7689abc4e505661fc08cb500e96b429178324a0fdb44963332
3
+ size 3536526
docs/amd-sev-intel-tdx.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:333fef5829f7ad25e094c195ccce34d0cab38a429c8f9704095a22f160d4bd0c
3
+ size 745136
docs/art-amd-sev_en.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9ae562276656e5f705981d4255f340fcc1ee2f2473f229505e3ae982f4a54eb1
3
+ size 143145
docs/intel-tdx-connect-architecture-specification.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:cbd84ca511664d2345deda8477b94dbff9d87fa0a09a43ebe61ffa5e1a2decdc
3
+ size 2796778
docs/intel-tdx-cpu-architectural-specification.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0c29c794323e6608a3085f9bc52dbf93d63d7647c83dddfd25107ab4c15fcbc3
3
+ size 455522
docs/intel-tdx-module-1.5-abi-incompatibilities-354808003.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4a89484555d334fe380461c21c05b3d53c5cec1667ea23aeba10b4f565283d58
3
+ size 351430
docs/intel-tdx-module-1.5-abi-spec-348551003.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:1593fbd39521425a63705f439242c21aba988a16e5334e66da803108b9f65077
3
+ size 4695910
docs/intel-tdx-module-1.5-base-spec-348549003.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:8622eb21ed714dbd7035fac62fce69ce1cff74ce2ff851e67084cc88389e3f6a
3
+ size 2698858
docs/intel-tdx-module-1.5-td-migration-spec-348550003.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a7a3c6f3627ae193e6b7690472aedfe8ffa2088b0884ee7c13e44b597c07dae9
3
+ size 1090897
docs/intel-tdx-module-1.5-td-partitioning-spec-354807002.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ad004f5a49aa36fd23f644eda74ccffd3b3b47a49cd4e82d262b0338e45709d5
3
+ size 1034874
docs/intel-tdx-seamldr-interface-specification.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:daa7c8b37f45fda6e5019c277a6127304fdd6dae670bd84890ed6b7d138755e7
3
+ size 351705
docs/memory-encryption-white-paper.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:40d4d06ffb62b9c7973f362732b70f4cb12c77c18a35d64d19304d04d78b0cfd
3
+ size 462545
docs/software-enabling-for-tdx-tee-io-fixed.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a5aedebf37a19656abc9ec0f4884a5d113cbe59bd66307af55d443ad70246e3c
3
+ size 865337
docs/tdx-virtual-firmware-design-guide-rev-004-20231206.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:be7bf6d0bf2237735aaa957c09b0b54fdcb23f16db8d3600caca14d07146a116
3
+ size 1204456
docs/whitepaper-device-attestation-model-in-confidential-computing-environment-v0.6.4.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e332e1199da75048a1b54ae0880dbea48a606d201c763d4e64e5c8528ddc02bb
3
+ size 1293542
docs/whitepaper-tee-io-device-guide-v0-6-5.pdf ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d173233ca9fbd22fb780dfa935b7682a99d0c100a5d7baf5165e847057213111
3
+ size 1211672
requirements.txt ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ streamlit
2
+ google-generativeai
3
+ python-dotenv
4
+ langchain
5
+ PyPDF2
6
+ chromadb
7
+ faiss-cpu
8
+ langchain_google_genai