First Commit

This commit is contained in:
2025-07-10 14:47:34 -03:00
parent 342bf55bfd
commit 3acf27044b
3 changed files with 16 additions and 13 deletions

View File

@@ -1,12 +1,12 @@
## Understanding Graph Theory and Implementing a Knowledge Graph with Oracle Autonomous Database and PGQL
## Create a Knowledge Graph with Oracle Autonomous Database and PGQL
### Introduction
This document explores the concepts of graph theory, knowledge graphs, and how they are implemented using the Oracle Autonomous Database with PGQL (Property Graph Query Language). It also explains the Python implementation used to extract relationships from documents using LLMs and store them as graph structures in Oracle.
### What is Graph Theory?
### What is Graph?
Graph theory is a field of mathematics and computer science focused on modeling relationships between objects. A graph consists of:
Graph is a field of mathematics and computer science focused on modeling relationships between objects. A graph consists of:
**Vertices** (nodes): Represent entities.
@@ -42,7 +42,11 @@ Oracle provides a fully managed environment to store and query property graphs:
![img_1.png](./images/img_1.png)
### Create Knowledge Graph
### Create a Knowledge Graph
A very common use case for Graph is to use it as one of the components working together with LLMs and a knowledge base, such as PDF files.
We will use the material Analyze PDF Documents in Natural Language with OCI Generative AI as our foundation, which uses all the mentioned components. However, for the purpose of this document, we will focus on using Oracle Autonomous Database 23ai together with Graph.
Basically, the Python code from the base material will be modified only in the parts that use the Autonomous 23ai database.
This is the processes executed on this service:

7
files/Extras.txt Normal file
View File

@@ -0,0 +1,7 @@
If you are not familiar with the process of connecting to the Autonomous Database, follow these links to understand and properly configure your code.
- [Download Database Connection Information](https://docs.oracle.com/en-us/iaas/autonomous-database-serverless/doc/connect-download-wallet.html)
- [Connect Database in Python](https://docs.oracle.com/en/cloud/paas/autonomous-database/serverless/adbsb/connecting-python-mtls.html#GUID-8A38B339-72D4-4C9F-915C-0688F0F74EDE)

View File

@@ -266,6 +266,7 @@ def query_knowledge_graph(query_text):
FETCH FIRST 20 ROWS ONLY
"""
# Show the query formulated for Graph
print(pgql)
try:
@@ -377,11 +378,6 @@ def save_indexed_docs(docs):
# Main Function
# =========================
def chat():
# pdf_paths = [
# './Manuals/SOASUITE.pdf',
# './Manuals/using-integrations-oracle-integration-3.pdf'
# ]
pdf_paths = ['AAAAAAAAAA.pdf'] # Your PDF Files as a Knowledge Base
already_indexed_docs = load_previously_indexed_docs()
@@ -494,10 +490,6 @@ def chat():
print(response)
print("\n" + "=" * 80 + "\n")
# if __name__ == "__main__":
# print("Iniciando")
# print(query_knowledge_graph("gateway"))
# 🚀 Run
if __name__ == "__main__":
chat()