first commit

This commit is contained in:
2026-01-09 07:37:56 -03:00
parent f28a9f79f4
commit 8483d9b8e9
4 changed files with 250 additions and 0 deletions

View File

@@ -285,6 +285,91 @@ This represents a **strategic shift** from concept-based LLM answers to **compli
| No structure | Knowledge graph |
| Chatbot | RFP analyst |
---
## Test the Application
FIrst of all, you need to run the code to prepare the Vector and Graph database. Run this one time only or, if you changed the PDF file with new content, erase the faiss_index folder and change de GRAPH_NAME variable on the code and run it again.
python graphrag_rerank.py
![img.png](img.png)
![img_1.png](img_1.png)
After the execution, the code will chat with you to test. You can give some questions like:
### 🔐 Security & Compliance
1. How is data protected both in transit and at rest, considering the service is accessed over the internet?
2. Is the SaaS service certified under recognized security standards (ISO 27001, SOC 2, PCI DSS, etc.)?
3. Does the solution use a multi-tenant architecture, and how is data isolation between customers ensured?
4. How are privileged and administrative accesses managed and controlled?
5. Are periodic penetration tests conducted? If so, how frequently?
6. Does the platform support strong authentication mechanisms such as MFA and integration with corporate identity providers (LDAP, Active Directory, SSO/IdP)?
### 🌐 Internet Dependency & Availability
7. Does the solution provide any offline capabilities or contingency mechanisms in case of internet unavailability?
8. What is the guaranteed service availability SLA and how is it measured?
9. How does the system perform under high network latency or unstable connectivity conditions?
10. Is geographic redundancy implemented to mitigate regional outages?
### ⚡ Performance & Scalability
11. How is performance maintained during peak usage periods with multiple concurrent customers?
12. Are there technical limits on concurrent users, transactions, or data volume?
13. Can customers monitor performance and resource consumption metrics in real time?
14. Does the platform scale automatically under increased load, or is manual intervention required?
### 📦 Technical & Contractual Limitations
15. Are there defined limits on storage, transactions, API usage, or integrations?
16. What happens if contractual limits are exceeded — throttling, additional charges, or service suspension?
17. Are there restrictions on customization due to the SaaS delivery model?
18. Can on-premises or legacy systems be integrated with the SaaS solution, and what limitations apply?
### 🔄 Business Continuity, Backup & Recovery
19. How frequently are backups performed, and where are they stored?
20. What Recovery Time Objective (RTO) and Recovery Point Objective (RPO) are guaranteed in case of a major incident?
21. Is granular data restoration supported at the customer level?
### 🚪 Vendor Lock-in & Data Ownership
22. How can customers retrieve their data upon contract termination?
23. Is customer data provided in open, documented formats?
24. Does the solution rely on proprietary technologies that may complicate future migration?
### 🧑‍⚖️ Governance, Auditability & Transparency
25. Does the platform provide comprehensive audit logs for user and system activities?
26. How are security incidents communicated to customers?
27. Is there a defined SLA for incident response and resolution?
You can run a web desginer UI. Just put the [app.py](./files/app.py) on the same folder of your [graphrag_rerank.py](./files/graphrag_rerank.py), create a **templates** folder on the same folder and put the [index.html](./files/index.html) file inside this folder.
```
root
└─► graphrag_rerank.py
└─► app.py
└─► templates
└─► index.html
```
python app.py
Call the http://localhost:8100 in your browser.
![img_2.png](img_2.png)
---
## ⚠️ Important Design Principles

67
files/app.py Normal file
View File

@@ -0,0 +1,67 @@
from flask import Flask, render_template, request, jsonify
import traceback
import json
# 🔥 IMPORTA SEU PIPELINE
from oci_genai_llm_graphrag_financial import answer_question
app = Flask(__name__)
def parse_llm_json(raw: str) -> dict:
try:
raw = raw.replace("```json", "")
raw = raw.replace("```", "")
return json.loads(raw)
except Exception:
return {
"answer": "ERROR",
"justification": "LLM returned invalid JSON",
"raw_output": raw
}
# =========================
# Health check (Load Balancer)
# =========================
@app.route("/health", methods=["GET"])
def health():
return jsonify({"status": "UP"}), 200
# =========================
# Página Web
# =========================
@app.route("/", methods=["GET"])
def index():
return render_template("index.html")
# =========================
# Endpoint de Chat
# =========================
@app.route("/chat", methods=["POST"])
def chat():
try:
data = request.get_json()
question = data.get("question", "").strip()
if not question:
return jsonify({"error": "Empty question"}), 400
raw_answer = answer_question(question)
parsed_answer = parse_llm_json(raw_answer)
return jsonify({
"question": question,
"result": parsed_answer
})
except Exception as e:
traceback.print_exc()
return jsonify({"error": str(e)}), 500
if __name__ == "__main__":
app.run(
host="0.0.0.0",
port=8100,
debug=False
)

98
files/index.html Normal file
View File

@@ -0,0 +1,98 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>GraphRAG Chat</title>
<style>
body {
background: linear-gradient(to bottom right, #0f172a, #1e293b);
min-height: 100vh;
color: #e2e8f0;
}
pre { white-space: pre-wrap; }
</style>
<style>
body {
font-family: Arial, sans-serif;
background: #0f172a;
color: #e5e7eb;
padding: 30px;
}
textarea {
width: 100%;
height: 80px;
font-size: 16px;
}
button {
margin-top: 10px;
padding: 10px 20px;
font-size: 16px;
}
pre {
background: #020617;
padding: 20px;
white-space: pre-wrap;
border-radius: 8px;
}
</style>
</head>
<body>
<h1>🧠 Oracle GraphRAG Chat</h1>
<div class="mt-12 mb-8 text-center">
<div class="inline-block bg-slate-800/40 px-6 py-4 rounded-2xl shadow-lg border border-slate-700">
<p class="text-slate-400 text-sm">
Oracle LAD A-Team<br/>
<span class="text-blue-300 font-semibold">Cristiano Hoshikawa</span><br/>
<span class="text-blue-300 font-semibold">cristiano.hoshikawa@oracle.com</span>
</p>
<p class="text-slate-500 text-xs mt-1 italic">
<span class="text-blue-300 font-semibold">Tutorial in: https://docs.oracle.com/en/learn/oci-genai-pdf</span><br/>
</p>
<p class="text-slate-500 text-xs mt-1 italic">
GraphRAG • Oracle 23ai • Embeddings • LLM • Flask API
</p>
<div class="mt-2 text-slate-500 text-xs flex items-center justify-center gap-1">
<span>Demo Version</span>
</div>
</div>
</div>
<textarea id="question" placeholder="Ask a question..."></textarea>
<br>
<button onclick="send()">Ask</button>
<h2>Answer</h2>
<pre id="answer"></pre>
<script>
async function send() {
const question = document.getElementById("question").value;
const answerBox = document.getElementById("answer");
answerBox.textContent = "⏳ Thinking...";
const res = await fetch("/chat", {
method: "POST",
headers: {"Content-Type": "application/json"},
body: JSON.stringify({question})
});
const data = await res.json();
if (data.result && data.result.answer) {
answerBox.textContent = JSON.stringify(data.result, null, 2);
} else {
answerBox.textContent = "❌ Error: " + JSON.stringify(data);
}
}
</script>
</body>
</html>

BIN
img_2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 169 KiB