From 3acf27044b6e2778159cabe9b124694248dd8f29 Mon Sep 17 00:00:00 2001 From: Cristiano Hoshikawa Date: Thu, 10 Jul 2025 14:47:34 -0300 Subject: [PATCH] First Commit --- README.md | 12 ++++++++---- files/Extras.txt | 7 +++++++ files/main.py | 10 +--------- 3 files changed, 16 insertions(+), 13 deletions(-) create mode 100644 files/Extras.txt diff --git a/README.md b/README.md index 9897016..7c403ff 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/files/Extras.txt b/files/Extras.txt new file mode 100644 index 0000000..9c77e21 --- /dev/null +++ b/files/Extras.txt @@ -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) + diff --git a/files/main.py b/files/main.py index f8cb3c6..4b5a947 100644 --- a/files/main.py +++ b/files/main.py @@ -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() \ No newline at end of file