Skip to content

Commit 7560402

Browse files
committed
add openai
1 parent 13cca22 commit 7560402

File tree

6 files changed

+48
-2
lines changed

6 files changed

+48
-2
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,6 @@ build/
3232
.vscode/
3333

3434
### Mac OS ###
35-
.DS_Store
35+
.DS_Store
36+
37+
.pdf-imported

compose.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
services:
2+
chroma:
3+
image: chromadb/chroma:0.6.1
4+
volumes:
5+
- chroma-data:/chroma/chroma
6+
ports:
7+
- "8000:8000"
8+
volumes:
9+
chroma-data:

pom.xml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>org.springframework.boot</groupId>
99
<artifactId>spring-boot-starter-parent</artifactId>
10-
<version>3.4.1</version>
10+
<version>3.3.7</version>
1111
<relativePath/>
1212
</parent>
1313

@@ -43,6 +43,10 @@
4343
<groupId>org.springframework.ai</groupId>
4444
<artifactId>spring-ai-ollama-spring-boot-starter</artifactId>
4545
</dependency>
46+
<dependency>
47+
<groupId>org.springframework.ai</groupId>
48+
<artifactId>spring-ai-openai-spring-boot-starter</artifactId>
49+
</dependency>
4650
<dependency>
4751
<groupId>org.springframework.ai</groupId>
4852
<artifactId>spring-ai-pdf-document-reader</artifactId>
@@ -51,6 +55,11 @@
5155
<groupId>org.springframework.boot</groupId>
5256
<artifactId>spring-boot-starter-web</artifactId>
5357
</dependency>
58+
<dependency>
59+
<groupId>org.springdoc</groupId>
60+
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
61+
<version>2.5.0</version>
62+
</dependency>
5463
</dependencies>
5564

5665
<repositories>

src/main/java/com/javaaidev/pdfqa/PDFContentLoader.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public void load(Path pdfFilePath) {
3232
public void run(String... args) throws Exception {
3333
var markerFile = Path.of(".", ".pdf-imported");
3434
if (Files.exists(markerFile)) {
35+
LOGGER.info("Marker file {} exists, skip. Delete this file to re-import.", markerFile);
3536
return;
3637
}
3738
load(Path.of(".", "content", "Understanding_Climate_Change.pdf"));
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
spring:
2+
ai:
3+
ollama:
4+
chat:
5+
enabled: false
6+
embedding:
7+
enabled: false
8+
openai:
9+
chat:
10+
enabled: true
11+
embedding:
12+
enabled: true

src/main/resources/application.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,25 @@ spring:
77
ai:
88
ollama:
99
chat:
10+
enabled: true
1011
options:
1112
model: "phi3"
1213
temperature: 0
1314
embedding:
15+
enabled: true
1416
options:
1517
model: "bge-large"
18+
openai:
19+
api-key: ${OPENAI_API_KEY:}
20+
chat:
21+
enabled: false
22+
options:
23+
model: gpt-3.5-turbo
24+
temperature: 0.0
25+
embedding:
26+
enabled: false
27+
options:
28+
model: text-embedding-3-small
1629
vectorstore:
1730
chroma:
1831
collectionName: pdf-qa

0 commit comments

Comments
 (0)