Skip to content

Commit 25af306

Browse files
authored
Merge branch 'main' into alcampag/ansible-jenkins
2 parents e5b5f7d + abac334 commit 25af306

File tree

4 files changed

+124
-4
lines changed

4 files changed

+124
-4
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
Copyright (c) 2024 Oracle and/or its affiliates.
2+
3+
The Universal Permissive License (UPL), Version 1.0
4+
5+
Subject to the condition set forth below, permission is hereby granted to any
6+
person obtaining a copy of this software, associated documentation and/or data
7+
(collectively the "Software"), free of charge and under any and all copyright
8+
rights in the Software, and any and all patent rights owned or freely
9+
licensable by each licensor hereunder covering either (i) the unmodified
10+
Software as contributed to or provided by such licensor, or (ii) the Larger
11+
Works (as defined below), to deal in both
12+
13+
(a) the Software, and
14+
(b) any piece of software and/or hardware listed in the lrgrwrks.txt file if
15+
one is included with the Software (each a "Larger Work" to which the Software
16+
is contributed by such licensors),
17+
18+
without restriction, including without limitation the rights to copy, create
19+
derivative works of, display, perform, and distribute the Software and make,
20+
use, sell, offer for sale, import, export, have made, and have sold the
21+
Software and the Larger Work(s), and to sublicense the foregoing rights on
22+
either these or other terms.
23+
24+
This license is subject to the following condition:
25+
The above copyright notice and either this complete permission notice or at
26+
a minimum a reference to the UPL must be included in all copies or
27+
substantial portions of the Software.
28+
29+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
31+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
32+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
33+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
34+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
35+
SOFTWARE.
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
2+
# Creating a RAG (Retrieval-Augmented Generation) with Oracle Generative AI Service in just 21 lines of code
3+
4+
## Introduction
5+
In this article, we'll explore how to create a Retrieval-Augmented Generation (RAG) model using Oracle Gen AI, llama index, Qdrant Vector Database, and SentenceTransformerEmbeddings. This 21-line code will allow you to scrape through web pages, use llama index for indexing, Oracle Generative AI Service for question generation, and Qdrant for vector indexing.
6+
7+
<img src="./RagArchitecture.svg">
8+
</img>
9+
10+
## Limited Availability
11+
12+
Oracle Generative AI Service is in Limited Availability as of today when we are creating this repo.
13+
14+
Customers can easily enter in the LA programs. To test these functionalities you need to enrol in the LA programs and install the proper versions of software libraries.
15+
16+
Code and functionalities can change, as a result of changes and new features
17+
18+
## Prerequisites
19+
Before getting started, make sure you have the following installed:
20+
21+
- Oracle Generative AI Service
22+
- llama index
23+
- qdrant client
24+
- SentenceTransformerEmbeddings
25+
26+
## Setting up the Environment
27+
1. Install the required packages:
28+
```bash
29+
pip install oci==2.112.1+preview.1.1649 llama-index qdrant-client sentence-transformers
30+
```
31+
32+
## Loading data
33+
34+
You need to create a sitemap.xml file where you can specify or list the webpages which you want to include in your RAG.
35+
Here we have used SentenceTransformerEmbeddings to create the embeddings but you can easily use any embeddings model . In the next blog we will show how easily you can use Oracle Generative AI Service embeddings model.
36+
37+
In this example we have used some Oracle documentation pages and created a xml file for the same and have placed it in Oracle object storage.
38+
39+
sitemap used : https://objectstorage.eu-frankfurt-1.oraclecloud.com/n/frpj5kvxryk1/b/thisIsThePlace/o/combined.xml
40+
41+
## Entire code
42+
43+
```bash
44+
from genai_langchain_integration.langchain_oci import OCIGenAI
45+
from llama_index import VectorStoreIndex
46+
from llama_index import ServiceContext
47+
from llama_index.vector_stores.qdrant import QdrantVectorStore
48+
from llama_index.storage.storage_context import StorageContext
49+
from qdrant_client import qdrant_client
50+
from langchain.embeddings import SentenceTransformerEmbeddings
51+
from llama_hub.web.sitemap import SitemapReader
52+
loader = SitemapReader()
53+
documents = loader.load_data(sitemap_url='https://objectstorage.eu-frankfurt-1.oraclecloud.com/n/frpj5kvxryk1/b/thisIsThePlace/o/combined.xml')
54+
client = qdrant_client.QdrantClient(location=":memory:")
55+
embeddings = SentenceTransformerEmbeddings(model_name="all-MiniLM-L6-v2")
56+
llm = OCIGenAI(model_id="cohere.command",service_endpoint="https://generativeai.aiservice.us-chicago-1.oci.oraclecloud.com",compartment_id = "ocid1.tenancy.oc1..aaaaaaaa5hwtrus75rauufcfvtnjnz3mc4xm2bzibbigva2bw4ne7ezkvzha",temperature=0.0)
57+
system_prompt="As a support engineer, your role is to leverage the information in the context provided. Your task is to respond to queries based strictly on the information available in the provided context. Do not create new information under any circumstances. Refrain from repeating yourself. Extract your response solely from the context mentioned above. If the context does not contain relevant information for the question, respond with 'How can I assist you with questions related to the document?"
58+
service_context = ServiceContext.from_defaults(llm=llm, chunk_size=1000, chunk_overlap=100, embed_model=embeddings,system_prompt=system_prompt)
59+
vector_store = QdrantVectorStore(client=client, collection_name="ansh")
60+
storage_context = StorageContext.from_defaults(vector_store=vector_store)
61+
index = VectorStoreIndex.from_documents(documents, storage_context=storage_context, service_context=service_context)
62+
query_engine = index.as_query_engine()
63+
response = query_engine.query("can i use OCI document understanding for files in french ?")
64+
print(response)
65+
```
66+
67+
68+
69+
## Conclusion
70+
71+
In this article, we've covered the process of creating a RAG model using Oracle Generative AI Service, llama index, Qdrant, and SentenceTransformerEmbeddings. Feel free to experiment with different web pages and datasets to enhance the capabilities of your model.
72+
73+
In a future blog post, we'll explore how to integrate Oracle Vector Database and Oracle Gen AI embeddings model into this RAG setup.
74+
75+
Feel free to modify and expand upon this template according to your specific use case and preferences. Good luck with your article!

ai-and-app-modernisation/ai-services/generative-ai-service/rag-genai/RagArchitecture.svg

Lines changed: 4 additions & 0 deletions
Loading

data-platform/modernise/database-patching/README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,16 @@ Reviewed: 03.11.2023
1414
- Step by step Video demo on automating the DB System Patching of Oracle Base Database in OCI
1515
- [How to Automate Database Patching of Oracle Base Database in OCI](https://youtu.be/lzGQ0IgVbBE)
1616
- Step by step Video Demo on automating the Database Patching of Oracle Base Database in OCI
17-
- [How to apply Database Quarterly Patches on ExaDB-D/ExaDB-C@C - Part 1 - Understanding the Patching Methods](https://www.youtube.com/watch?v=3LRCR16JMBY&list=PLMQIPzhkeafSri_Jo1FEel10Y7GNO_JJS&index=2)
18-
- Video explaining the various patching methods of ExaDB-D/ExaDB-C@C, part of the larger series available [here](https://www.youtube.com/playlist?list=PLMQIPzhkeafSri_Jo1FEel10Y7GNO_JJS)
19-
- [How to apply Database Quarterly Patches on ExaDB-D/ExaDB-C@C - Part 2 - Perform in-place patching of the database](https://www.youtube.com/watch?v=pNRnwMobtfU&list=PLMQIPzhkeafSri_Jo1FEel10Y7GNO_JJS&index=3)
20-
- Video explaining in-place patching of ExaDB-D/ExaDB-C@C databases, part of the larger series available [here](https://www.youtube.com/playlist?list=PLMQIPzhkeafSri_Jo1FEel10Y7GNO_JJS)
17+
- [How to apply Database Quarterly Patches on ExaDB-D/ExaDB-C@C - Part 1 - Understanding the Patching Methods](https://youtu.be/3LRCR16JMBY?feature=shared)
18+
- Video explaining the various patching methods of ExaDB-D/ExaDB-C@C, part of the larger series available [here](https://youtu.be/mYUo0A5e178?feature=shared)
19+
- [How to apply Database Quarterly Patches on ExaDB-D/ExaDB-C@C - Part 2 - Perform in-place patching of the database](https://youtu.be/euX1r7_BGC4?feature=shared)
20+
- Video explaining in-place patching of ExaDB-D/ExaDB-C@C databases, part of the larger series available [here](https://youtu.be/mYUo0A5e178?feature=shared)
21+
- [How to apply Database Quarterly Patches on ExaDB-D/ExaDB-C@C - Part 3 - Out of Place Patching](https://youtu.be/gFnW7qpAAGw?feature=shared)
22+
- Video explaining Out of place patching of ExaDB-D/ExaDB-C@C databases, part of the larger series available [here](https://youtu.be/mYUo0A5e178?feature=shared)
23+
- [How to apply Database Quarterly Patches on ExaDB-D/ExaDB-C@C - Part 4 - Exadata Fleet Update Prep](https://youtu.be/sDvx44-TNck?feature=shared)
24+
- Video explaining Exadata Fleet Update Preparation for ExaDB-D/ExaDB-C@C databases, part of the larger series available [here](https://youtu.be/mYUo0A5e178?feature=shared)
25+
- [How to apply Database Quarterly Patches on ExaDB-D/ExaDB-C@C - Part 5 - Exadata Fleet Update](https://youtu.be/iydZdx4_5Kw?feature=shared)
26+
- Video explaining Exadata Fleet Update for ExaDB-D/ExaDB-C@C databases, part of the larger series available [here](https://youtu.be/mYUo0A5e178?feature=shared)
2127

2228
# License
2329

0 commit comments

Comments
 (0)