Add rag module: Spring AI 2.0 RAG with pgvector, chunking, reranking and a faithfulness check
Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01B38FGKKam5SCGgwgduVAh3
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
spring:
|
||||
application:
|
||||
name: spring-ai-rag
|
||||
threads:
|
||||
virtual:
|
||||
enabled: true
|
||||
datasource:
|
||||
url: ${RAG_PG_URL:jdbc:postgresql://localhost:5432/ragdb}
|
||||
username: ${RAG_PG_USER:raguser}
|
||||
password: ${RAG_PG_PASSWORD:ragpass}
|
||||
ai:
|
||||
openai:
|
||||
api-key: ${OPENAI_API_KEY}
|
||||
# In 2.0.1 the "options" level (chat.options.model) is marked deprecated in the jars' metadata; the
|
||||
# settings now sit directly under chat: and embedding:. Spring Boot ignores keys it does not know,
|
||||
# so a misspelt key fails nothing: ConfigKeysTest checks every spring.ai key against the jars.
|
||||
chat:
|
||||
model: gpt-4o
|
||||
temperature: 0.1
|
||||
embedding:
|
||||
model: text-embedding-3-small
|
||||
vectorstore:
|
||||
pgvector:
|
||||
schema-name: rag
|
||||
table-name: document_chunks
|
||||
index-type: HNSW
|
||||
distance-type: COSINE_DISTANCE
|
||||
dimensions: 1536
|
||||
# false: the schema comes from init.sql, not from the application.
|
||||
initialize-schema: false
|
||||
|
||||
rag:
|
||||
retrieval:
|
||||
top-k: 20
|
||||
similarity-threshold: 0.0
|
||||
rerank:
|
||||
top-n: 5
|
||||
chunking:
|
||||
chunk-size: 512
|
||||
min-chunk-size-chars: 350
|
||||
|
||||
management:
|
||||
endpoints:
|
||||
web:
|
||||
exposure:
|
||||
include: health, prometheus
|
||||
Reference in New Issue
Block a user