Skip to content

Commit 6405210

Browse files
authored
Merge pull request #24 from paulparkinson/main
update to spring 3.3.1, add upload/download file functions, and add v .1 of python rag chatbot
2 parents 8dd5d5d + 29c840a commit 6405210

29 files changed

+1690
-48
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ MISSING
1515
MISSING
1616

1717
## Notes/Issues
18-
MISSING
18+
Spring Boot 3.0 requires Java 17 as a minimum version.
19+
1920

2021
## URLs
2122
https://apexapps.oracle.com/pls/apex/r/dbpm/livelabs/view-workshop?wid=3874

pom.xml

Lines changed: 8 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
44
<modelVersion>4.0.0</modelVersion>
55
<parent>
66
<groupId>org.springframework.boot</groupId>
77
<artifactId>spring-boot-starter-parent</artifactId>
8-
<version>3.1.4</version>
8+
<version>3.3.1</version>
99
<relativePath/>
1010
</parent>
1111
<groupId>oracleai</groupId>
@@ -15,26 +15,13 @@
1515
<description>Oracle AI Demos</description>
1616

1717
<properties>
18-
<spring-cloud.version>2021.0.5</spring-cloud.version>
19-
<oracle.jdbc.version>21.7.0.0</oracle.jdbc.version>
20-
<spring.boot.version>3.1.2</spring.boot.version>
21-
<snakeyaml.version>1.31</snakeyaml.version>
22-
<spring.vault.version>3.1.1</spring.vault.version>
23-
<oci.sdk.version>3.29.0</oci.sdk.version>
24-
<jib-maven-plugin.version>3.3.1</jib-maven-plugin.version>
25-
<liquibase.version>4.17.2</liquibase.version>
18+
<oci.sdk.version>3.44.2</oci.sdk.version>
2619
</properties>
2720

2821
<dependencies>
2922
<dependency>
3023
<groupId>org.springframework.boot</groupId>
3124
<artifactId>spring-boot-starter-web</artifactId>
32-
<exclusions>
33-
<exclusion>
34-
<groupId>org.yaml</groupId>
35-
<artifactId>snakeyaml</artifactId>
36-
</exclusion>
37-
</exclusions>
3825
</dependency>
3926
<dependency>
4027
<groupId>org.springframework.boot</groupId>
@@ -45,11 +32,10 @@
4532
<artifactId>json</artifactId>
4633
<version>20231013</version>
4734
</dependency>
48-
4935
<dependency>
50-
<groupId>com.oracle.oci.sdk</groupId>
51-
<artifactId>oci-java-sdk-common</artifactId>
52-
<version>${oci.sdk.version}</version>
36+
<groupId>com.oracle.cloud.spring</groupId>
37+
<artifactId>spring-cloud-oci-starter</artifactId>
38+
<version>1.0.0</version>
5339
</dependency>
5440
<dependency>
5541
<groupId>com.oracle.oci.sdk</groupId>
@@ -59,7 +45,7 @@
5945
<dependency>
6046
<groupId>com.oracle.oci.sdk</groupId>
6147
<artifactId>oci-java-sdk-generativeaiinference</artifactId>
62-
<version>3.32.1</version>
48+
<version>${oci.sdk.version}</version>
6349
</dependency>
6450
<dependency>
6551
<groupId>com.oracle.oci.sdk</groupId>
@@ -87,20 +73,6 @@
8773
<artifactId>slf4j-simple</artifactId>
8874
<version>2.0.6</version>
8975
</dependency>
90-
<dependency>
91-
<groupId>org.springframework.boot</groupId>
92-
<artifactId>spring-boot-starter-web</artifactId>
93-
<version>${spring.boot.version}</version>
94-
</dependency>
95-
<dependency>
96-
<groupId>org.springframework.boot</groupId>
97-
<artifactId>spring-boot-starter-test</artifactId>
98-
<version>${spring.boot.version}</version>
99-
<scope>test</scope>
100-
</dependency>
101-
102-
103-
10476
<dependency>
10577
<groupId>javax.xml.bind</groupId>
10678
<artifactId>jaxb-api</artifactId>
@@ -122,18 +94,7 @@
12294
<artifactId>service</artifactId>
12395
<version>0.12.0</version>
12496
</dependency>
125-
</dependencies>
126-
<dependencyManagement>
127-
<dependencies>
128-
<dependency>
129-
<groupId>org.springframework.cloud</groupId>
130-
<artifactId>spring-cloud-dependencies</artifactId>
131-
<version>${spring-cloud.version}</version>
132-
<type>pom</type>
133-
<scope>import</scope>
134-
</dependency>
135-
</dependencies>
136-
</dependencyManagement>
97+
</dependencies>
13798
<build>
13899
<plugins>
139100
<plugin>

python-rag-chatbot/README.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Integrating Oracle Database 23ai RAG and OCI Generative AI with LangChain
2+
3+
[**Oracle Database 23ai**](https://www.oracle.com/database/free-1/)
4+
5+
[**OCI GenAI**](https://www.oracle.com/artificial-intelligence/generative-ai/large-language-models/)
6+
7+
[**LangChain**](https://www.langchain.com/)
8+
9+
10+
## TODO instructions
11+
12+
- setup ~/.oci/config
13+
- set yourcompartmentid
14+
- podman run -d --name 23ai -p 1521:1521 -e ORACLE_PWD=Welcome12345 -v oracle-volume:/Users/pparkins/oradata container-registry.oracle.com/database/free:latest
15+
- create/config vector tablespace and user
16+
- add oracle database info for use in init_rag_streamlit.py / init_rag_streamlit_exp.py
17+
- run run_oracle_bot.sh /run_oracle_bot_exp.sh
18+
19+
20+
## Documentation
21+
The development of the proposed integration is based on the example, from LangChain, provided [here](https://python.langchain.com/docs/modules/model_io/models/llms/custom_llm)
22+
23+
## Features
24+
* How-to build a complete, end-2-end RAG solution using LangChain and Oracle GenAI Service.
25+
* How-to load multiple pdf
26+
* How-to split pdf pages in smaller chuncks
27+
* How-to do semantic search using Embeddings
28+
* How-to use Cohere Embeddings
29+
* How-to use HF Embeddings
30+
* How-to setup a Retriever using Embeddings
31+
* How-to add Cohere reranker to the chain
32+
* How to integrate OCI GenAI Service with LangChain
33+
* How to define the LangChain
34+
* How to use the Oracle vector Db capabilities
35+
* How to use in-memory database capability
36+
37+
## Oracle BOT
38+
Using the script [run_oracle_bot_exp.sh](run_oracle_bot_exp.sh) you can launch a simple ChatBot that showcase Oracle GenAI service. The demo is based on docs from Oracle Database pdf documentation.
39+
40+
You need to put in the local directory:
41+
* Trobleshooting.pdf
42+
* globally-distributed-autonomous-database.pdf
43+
* Oracle True cache.pdf
44+
* oracle-database-23c.pdf
45+
* oracle-globally-distributed-database-guide.pdf
46+
* sharding-adg-addshard-cookbook-3610618.pdf
47+
48+
You can add more pdf. Edit [config_rag.py](config_rag.py)
49+
50+
51+
52+

python-rag-chatbot/config_rag.py

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# configurations for the RAG
2+
3+
# to enable debugging info..
4+
DEBUG = False
5+
6+
# book to use for augmentation
7+
# BOOK1 = "APISpec.pdf"
8+
BOOK1 = "pdfFiles/sharding-adg-addshard-cookbook-3610618.pdf"
9+
BOOK2 = "pdfFiles/globally-distributed-autonomous-database.pdf"
10+
# BOOK4 = "OnBoardingGuide.pdf"
11+
# BOOK5 = "CreateWorkFlow.pdf"
12+
# BOOK6 = "Team Onboarding.pdf"
13+
# BOOK7 = "workflow.pdf"
14+
BOOK3 = "pdfFiles/oracle-database-23c.pdf"
15+
BOOK4 = "pdfFiles/oracle-globally-distributed-database-guide.pdf"
16+
BOOK5 = "pdfFiles/Oracle True cache.pdf"
17+
BOOK6 = "pdfFiles/Trobleshooting.pdf"
18+
# BOOK12 = "OsdCode.pdf"
19+
20+
BOOK_LIST = [BOOK1, BOOK2, BOOK3, BOOK4, BOOK5, BOOK6]
21+
22+
23+
# to divide docs in chunks
24+
CHUNK_SIZE = 1000
25+
CHUNK_OVERLAP = 50
26+
27+
28+
#
29+
# Vector Store (Chrome or FAISS)
30+
#
31+
# VECTOR_STORE_NAME = "FAISS"
32+
# VECTOR_STORE_NAME = "ORACLEDB"
33+
VECTOR_STORE_NAME = "CHROME"
34+
35+
36+
# type of Embedding Model. The choice has been parametrized
37+
# Local means HF
38+
EMBED_TYPE = "LOCAL"
39+
# see: https://huggingface.co/spaces/mteb/leaderboard
40+
# see also: https://github.com/FlagOpen/FlagEmbedding
41+
# base seems to work better than small
42+
# EMBED_HF_MODEL_NAME = "BAAI/bge-base-en-v1.5"
43+
# EMBED_HF_MODEL_NAME = "BAAI/bge-small-en-v1.5"
44+
EMBED_HF_MODEL_NAME = "BAAI/bge-large-en-v1.5"
45+
46+
# Cohere means the embed model from Cohere site API
47+
# EMBED_TYPE = "COHERE"
48+
EMBED_COHERE_MODEL_NAME = "embed-english-v3.0"
49+
50+
# number of docs to return from Retriever
51+
MAX_DOCS_RETRIEVED = 6
52+
53+
# to add Cohere reranker to the QA chain
54+
ADD_RERANKER = False
55+
56+
#
57+
# LLM Config
58+
#
59+
# LLM_TYPE = "COHERE"
60+
LLM_TYPE = "OCI"
61+
62+
# max tokens returned from LLM for single query
63+
MAX_TOKENS = 1000
64+
# to avoid "creativity"
65+
TEMPERATURE = 0
66+
67+
#
68+
# OCI GenAI configs
69+
#
70+
TIMEOUT = 30
71+
ENDPOINT = "https://inference.generativeai.us-chicago-1.oci.oraclecloud.com"

python-rag-chatbot/copy.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
feedback_0

0 commit comments

Comments
 (0)