Skip to content

Commit ba1ae05

Browse files
authored
Merge branch 'main' into fn-datasafe-dbaudit-to-oci-logging-patch2
2 parents 77cbcb0 + eb00ebe commit ba1ae05

File tree

139 files changed

+4097
-839
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

139 files changed

+4097
-839
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
.AppleDouble
44
.LSOverride
55
.vscode
6+
.bak
67

78
# Icon must end with two \r
89
Icon

ai-and-app-modernisation/ai-services/generative-ai-service/README.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
# Generative AI service
22

3-
Oracle’s AI strategy is to make artificial intelligence (AI) pervasive across its cloud
4-
applications and cloud infrastructure. We serve business users who want to
5-
improve business processes and outcomes through prebuilt AI capabilities, data
6-
scientists and developers who want complete control to build and deploy AI
7-
models of any kind, and independent software vendors (ISVs) who want the
8-
most performant and cost-effective platform to host their AI services.
3+
Oracle’s AI strategy is to make artificial intelligence (AI) pervasive across its cloud applications and cloud infrastructure. We serve business users who want to improve business processes and outcomes through prebuilt AI capabilities, data scientists and developers who want complete control to build and deploy AI models of any kind, and independent software vendors (ISVs) who want the most performant and cost-effective platform to host their AI services.
94

105
Reviewed: 30.01.2024
116

127
# Team Publications
138

9+
- [Enable a Low Code Modular LLM App Engine using Oracle Integration and OCI Generative AI](https://docs.oracle.com/en/solutions/oci-generative-ai-integration/index.html)
10+
- This reference architecture lets you understand the necessary considerations and recommendations to enable an AI-based, modular and event-driven LLM App Engine using a low-code approach with Oracle Integration as the LLM orchestrator, OCI Generative AI and other OCI services
11+
- Build enterprise-grade, modular, scalable, secure & maintainable LLM Apps
1412
- [Oracle Generative AI webinar](https://go.oracle.com/LP=138234?elqCampaignId=489428&src1=:so:ch:or:dg::::&SC=:so:ch:or:dg::::&pcode=WWMK230822P00010)
1513
- Deep dive into Oracle Generative AI platform
1614
- [Creating a RAG (Retrieval-Augmented Generation) with Oracle Generative AI Service in just 21 lines of code](https://github.com/oracle-devrel/technology-engineering/tree/main/ai-and-app-modernisation/ai-services/generative-ai-service/rag-genai)
@@ -20,9 +18,9 @@ Reviewed: 30.01.2024
2018
- [Build a knowledge search solution by implementing Retrieval Augmented Generation with Generative AI](https://www.youtube.com/watch?v=lJptksR5omo&t=1530s)
2119
- [Gen AI-powered document search (Generative AI with custom UI)](https://youtu.be/vyJAZvYKY34)
2220
- [Enabling a WhatsApp Customer HelpMate using OCI Generative AI, AI-Language & Integration](https://youtu.be/ryo3wVB_69E?si=SxSuTVawoRcbhReU)
23-
- Use OCI Generative AI (in pre-availability) for "Customer Service Quick Replies" Generation for Whatsapp Neutral Messages (customer questions, queries, etc.), sentence-level sentiment analysis from OCI AI Language to uncover overall sentiment and set service ticket severity for negative Whatsapp messages, automatically classify Customer Service tickets through OCI AI Language custom text classification and aspect-based sentiment analysis (ABSA) services
21+
- Use OCI Generative AI (in pre-availability) for "Customer Service Quick Replies" Generation for Whatsapp Neutral Messages (customer questions, queries, etc.), sentence-level sentiment analysis from OCI AI-Language to uncover overall sentiment and set service ticket severity for negative Whatsapp messages, automatically classify Customer Service tickets through OCI AI-Language custom text classification and aspect-based sentiment analysis (ABSA) services
2422
- Learn how Oracle Integration Cloud and Oracle Cloud Infrastructure (OCI) Streaming allow real-time capture of WhatsApp messages.
25-
- All this automation using OCI Generative AI and AI Language Services APIs orchestrated by Oracle Integration Cloud (using a no-code integration approach)
23+
- All this automation using OCI Generative AI and AI-Language Services APIs orchestrated by Oracle Integration Cloud (using a no-code integration approach)
2624
- [Deploy 3rd party generative AI models to OCI](https://docs.oracle.com/en/solutions/deploy-generative-ai-to-oci/index.html#GUID-5567B1F2-4733-4D9C-B4BE-5B5429CA8C02)
2725
- The reference architecture shows generative AI models deployed to an OCI GPU instance for image and text generation.
2826
- [Running 3rd party LLMs on OCI](https://github.com/oracle-devrel/oci-generative-ai)
@@ -34,11 +32,14 @@ Reviewed: 30.01.2024
3432

3533
# Useful Links
3634

35+
- [Navigating the frontier: Key considerations for developing a generative AI integration strategy for the enterprise](https://blogs.oracle.com/ai-and-datascience/post/considerations-generative-ai-integration-strategy)
3736
- [The Future of Generative AI: What Enterprises Need to Know](https://blogs.oracle.com/ai-and-datascience/post/future-generative-ai-what-enterprises-need-to-know)
3837
- [Announcing the general availability of OCI Generative AI](https://blogs.oracle.com/ai-and-datascience/post/ga-oci-generative-ai)
3938
- [Oracle Embeds Generative AI Across the Technology Stack to Enable Enterprise AI Adoption at Scale](https://www.oracle.com/news/announcement/oracle-announces-availability-oci-generative-ai-service-2024-01-23/)
4039
- [Implement Oracle Cloud Infrastructure Generative AI based on Cohere Large Language Model - Blog & Architecture](https://docs.oracle.com/en/solutions/oci-generative-ai-llm/index.html#GUID-76987F35-F646-40CF-9CF2-42724BA57191)
4140
- [Generative AI Chatbot using LLaMA-2, Qdrant, RAG, LangChain & Streamlit](https://blogs.oracle.com/ai-and-datascience/post/ai-chatbot-llama2-qdrant-rag-langchain-streamlit)
41+
- [Developing AI applications with OCI Generative AI and LangChain](https://blogs.oracle.com/ai-and-datascience/post/developing-ai-apps-oci-generative-ai-langchain)
42+
- [Guide to prompt engineering: Translating natural language to SQL with Llama 2](https://blogs.oracle.com/ai-and-datascience/post/prompt-engineering-natural-language-sql-llama2)
4243
- [Oracle and Generative AI](https://docs.oracle.com/en-us/iaas/Content/Resources/Assets/whitepapers/oracle-and-generative-ai.pdf)
4344
- [Oracle’s generative AI strategy - blog by Greg Pavlik](https://blogs.oracle.com/ai-and-datascience/post/generative-ai-strategy)
4445
- [Oracle to Deliver Powerful and Secure Generative AI Services for Business](https://www.oracle.com/news/announcement/oracle-to-deliver-powerful-and-secure-generative-ai-service-for-business-2023-06-13/)
@@ -49,8 +50,6 @@ Reviewed: 30.01.2024
4950
- [Generative AI on Oracle.com](https://www.oracle.com/artificial-intelligence/generative-ai/)
5051
- [Generative AI product documentation](https://docs.oracle.com/en-us/iaas/Content/generative-ai/home.htm)
5152

52-
53-
5453
# License
5554

5655
Copyright (c) 2024 Oracle and/or its affiliates.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from langchain_community.embeddings import OCIGenAIEmbeddings
2+
from langchain.chains import RetrievalQA
3+
from langchain_community.vectorstores import Qdrant
4+
from langchain_core.prompts import PromptTemplate
5+
from langchain_community.llms import OCIGenAI
6+
from langchain_community.document_loaders import UnstructuredURLLoader
7+
compartment_id = "ocid1.compartment.oc1..aaaaaaaa7ggqkd4ptkeb7ugk6ipsl3gqjofhkr6yacluwj4fitf2ufrdm65q"
8+
embeddings = OCIGenAIEmbeddings(model_id="cohere.embed-english-light-v3.0",service_endpoint="https://inference.generativeai.us-chicago-1.oci.oraclecloud.com",compartment_id= compartment_id,)
9+
testurls = ['https://docs.oracle.com/iaas/odsaz/odsa-rotate-wallet.html', 'https://docs.oracle.com/iaas/odsaz/odsa-change-password.html', 'https://docs.oracle.com/iaas/odsaz/odsa-database-actions.html']
10+
loader = UnstructuredURLLoader(urls=testurls)
11+
docs = loader.load()
12+
vectorstore = Qdrant.from_documents(docs,embeddings,location=":memory:",prefer_grpc=False,collection_name="test_db")
13+
retriever = vectorstore.as_retriever()
14+
rag_prompt_template = """Answer the question based only on the following context:
15+
{context}
16+
Question: {question}"""
17+
rag_prompt = PromptTemplate.from_template(rag_prompt_template)
18+
llm = OCIGenAI(model_id="cohere.command",service_endpoint="https://inference.generativeai.us-chicago-1.oci.oraclecloud.com",compartment_id= compartment_id,model_kwargs={"temperature": 0, "max_tokens": 300})
19+
rag = RetrievalQA.from_chain_type(llm=llm,retriever=retriever,chain_type_kwargs={"prompt": rag_prompt,},)
20+
data = rag.invoke("What is rotate a wallet")
21+
print(data['result'])

ai-and-app-modernisation/ai-services/generative-ai-service/rag-genai/files/README.md

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,27 @@
33
## Introduction
44
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.
55

6+
Find below the code of building a RAG using llamaIndex with Oracle Generative AI Service.
7+
Also check the file LangChainRAG.py which allows you to create an application (implementing RAG) using Langchain and the file langChainRagWithUI.py which includes a UI build with Streamlit.
8+
69
<img src="./RagArchitecture.svg">
710
</img>
811

9-
## Limited Availability
10-
11-
Oracle Generative AI Service is in Limited Availability as of today when we are creating this repo.
12-
13-
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.
14-
15-
Code and functionalities can change, as a result of changes and new features
16-
1712
## Prerequisites
1813

1914
Before getting started, make sure you have the following installed:
2015

2116
- Oracle Generative AI Service
22-
- llama index
23-
- qdrant client
17+
- Llama index
18+
- Langchain
19+
- Qdrant client
2420
- SentenceTransformerEmbeddings
2521

2622
## Setting up the Environment
2723
1. Install the required packages:
2824
```bash
29-
pip install oci==2.118.1+preview.1.1697 llama-index qdrant-client sentence-transformers
25+
pip install -U langchain oci
26+
pip install langchain llama-index qdrant-client sentence-transformers transformers
3027
```
3128

3229
## Loading data
@@ -41,26 +38,26 @@ sitemap used : https://objectstorage.eu-frankfurt-1.oraclecloud.com/n/frpj5kvxry
4138
## Entire code
4239

4340
```bash
44-
from genai_langchain_integration.langchain_oci import OCIGenAI
4541
from llama_index import VectorStoreIndex
4642
from llama_index import ServiceContext
4743
from llama_index.vector_stores.qdrant import QdrantVectorStore
4844
from llama_index.storage.storage_context import StorageContext
4945
from qdrant_client import qdrant_client
50-
from langchain.embeddings import SentenceTransformerEmbeddings
46+
from langchain_community.embeddings import SentenceTransformerEmbeddings
5147
from llama_hub.web.sitemap import SitemapReader
48+
from langchain_community.llms import OCIGenAI
5249
loader = SitemapReader()
53-
documents = loader.load_data(sitemap_url='https://objectstorage.eu-frankfurt-1.oraclecloud.com/n/frpj5kvxryk1/b/thisIsThePlace/o/combined.xml')
50+
documents = loader.load_data(sitemap_url='https://objectstorage.eu-frankfurt-1.oraclecloud.com/n/frpj5kvxryk1/b/thisIsThePlace/o/latest.xml')
5451
client = qdrant_client.QdrantClient(location=":memory:")
5552
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)
53+
llm = OCIGenAI(model_id="cohere.command",service_endpoint="https://inference.generativeai.us-chicago-1.oci.oraclecloud.com",model_kwargs={"temperature": 0.0, "max_tokens": 300},compartment_id = "ocid1.compartment.oc1..aaaaaaaa7ggqkd4ptkeb7ugk6ipsl3gqjofhkr6yacluwj4fitf2ufrdm65q")
5754
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?"
5855
service_context = ServiceContext.from_defaults(llm=llm, chunk_size=1000, chunk_overlap=100, embed_model=embeddings,system_prompt=system_prompt)
5956
vector_store = QdrantVectorStore(client=client, collection_name="ansh")
6057
storage_context = StorageContext.from_defaults(vector_store=vector_store)
6158
index = VectorStoreIndex.from_documents(documents, storage_context=storage_context, service_context=service_context)
6259
query_engine = index.as_query_engine()
63-
response = query_engine.query("can i use OCI document understanding for files in french ?")
60+
response = query_engine.query('What is activity auditing report?')
6461
print(response)
6562
```
6663

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import streamlit as st
2+
from langchain_community.embeddings import OCIGenAIEmbeddings
3+
from langchain.chains import RetrievalQA
4+
from langchain_community.vectorstores import Qdrant
5+
from langchain_core.prompts import PromptTemplate
6+
from langchain_community.llms import OCIGenAI
7+
from langchain_community.document_loaders import UnstructuredURLLoader
8+
st.title("Oracle QA Chatbot")
9+
st.text_input("Ask a question:", key="question") # Input field for questions
10+
# Data loading (outside any function)
11+
compartment_id = "ocid1.compartment.oc1..aaaaaaaa7ggqkd4ptkeb7ugk6ipsl3gqjofhkr6yacluwj4fitf2ufrdm65q"
12+
embeddings = OCIGenAIEmbeddings(model_id="cohere.embed-english-light-v3.0",service_endpoint="https://inference.generativeai.us-chicago-1.oci.oraclecloud.com",compartment_id=compartment_id,)
13+
testurls = ['https://docs.oracle.com/iaas/odsaz/odsa-rotate-wallet.html','https://docs.oracle.com/iaas/odsaz/odsa-change-password.html','https://docs.oracle.com/iaas/odsaz/odsa-database-actions.html',]
14+
# Cache the loaded documents (outside any function)
15+
@st.cache_data
16+
def load_documents():
17+
docs = UnstructuredURLLoader(urls=testurls).load()
18+
print("Loading data")
19+
print(docs)
20+
return docs # Return the loaded documents
21+
docs = load_documents()
22+
vectorstore = Qdrant.from_documents(docs, embeddings, location=":memory:", prefer_grpc=False, collection_name="test_db")
23+
retriever = vectorstore.as_retriever()
24+
rag_prompt_template = """Answer the question based only on the following context:
25+
{context}
26+
Question: {question}"""
27+
rag_prompt = PromptTemplate.from_template(rag_prompt_template)
28+
llm = OCIGenAI(
29+
model_id="cohere.command",
30+
service_endpoint="https://inference.generativeai.us-chicago-1.oci.oraclecloud.com",
31+
compartment_id=compartment_id,
32+
model_kwargs={"temperature": 0, "max_tokens": 300},
33+
)
34+
rag = RetrievalQA.from_chain_type(llm=llm, retriever=retriever, chain_type_kwargs={"prompt": rag_prompt})
35+
# Answer generation when a question is asked
36+
if st.button("Get Answer"):
37+
question = st.session_state.question
38+
# Ensure correct access to cached documents
39+
docs = load_documents() # Call the cached function to retrieve documents
40+
data = rag.invoke(question, context=docs) # Pass documents as context
41+
answer = data["result"]
42+
st.write("Answer:", answer)
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.

0 commit comments

Comments
 (0)