feat(rag): add PostgreSQL and pgvector support for vector storage#525
feat(rag): add PostgreSQL and pgvector support for vector storage#525AlbumenJ merged 6 commits intoagentscope-ai:mainfrom
Conversation
- Introduced PgVectorStore class for managing vector data in PostgreSQL using the pgvector extension. - Updated dependencies in pom.xml files for PostgreSQL JDBC driver and pgvector SDK. - Added unit tests for PgVectorStore to ensure functionality and parameter validation. - Enhanced example projects to utilize the new PgVectorStore for vector storage operations.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
- Added PgVector RAG support details in the installation guides for both English and Chinese versions. - Updated the feature description for the `agentscope-extensions-rag-simple` module to include support for multiple RAG types including PgVector. - Included a new knowledge base example link for PgVector in the task documentation for both English and Chinese versions.
There was a problem hiding this comment.
Pull request overview
This pull request adds PostgreSQL pgvector support for vector storage in the AgentScope RAG system. The implementation introduces a new PgVectorStore class that enables users to store and search vector embeddings using PostgreSQL with the pgvector extension, providing an alternative to existing vector stores like Qdrant and Milvus.
Changes:
- Added
PgVectorStoreimplementation with support for COSINE, L2, and INNER_PRODUCT distance metrics - Updated dependency management to include PostgreSQL JDBC driver (42.7.4) and pgvector SDK (0.1.6)
- Created comprehensive unit tests with mock-based testing approach
- Added example application demonstrating PgVector integration with DashScope embeddings
- Updated documentation in both English and Chinese to include PgVector references
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
PgVectorStore.java |
New vector store implementation for PostgreSQL with pgvector extension support |
PgVectorStoreTest.java |
Comprehensive unit tests covering builder validation, CRUD operations, and payload handling |
PgVectorRAGExample.java |
Example demonstrating PgVector usage with knowledge base and Q&A agent |
agentscope-dependencies-bom/pom.xml |
Added PostgreSQL and pgvector dependency versions |
agentscope-extensions-rag-simple/pom.xml |
Added PostgreSQL and pgvector dependencies to RAG extension |
agentscope-examples/quickstart/pom.xml |
Added dependencies for PgVector example |
docs/*/task/rag.md |
Added PgVector example link to RAG documentation |
docs/*/quickstart/installation.md |
Updated dependency tables to include PgVector support |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...entscope-extensions-rag-simple/src/main/java/io/agentscope/core/rag/store/PgVectorStore.java
Show resolved
Hide resolved
...-examples/quickstart/src/main/java/io/agentscope/examples/quickstart/PgVectorRAGExample.java
Show resolved
Hide resolved
...cope-extensions-rag-simple/src/test/java/io/agentscope/core/rag/store/PgVectorStoreTest.java
Outdated
Show resolved
Hide resolved
...entscope-extensions-rag-simple/src/main/java/io/agentscope/core/rag/store/PgVectorStore.java
Show resolved
Hide resolved
...entscope-extensions-rag-simple/src/main/java/io/agentscope/core/rag/store/PgVectorStore.java
Show resolved
Hide resolved
...entscope-extensions-rag-simple/src/main/java/io/agentscope/core/rag/store/PgVectorStore.java
Show resolved
Hide resolved
...entscope-extensions-rag-simple/src/main/java/io/agentscope/core/rag/store/PgVectorStore.java
Show resolved
Hide resolved
...entscope-extensions-rag-simple/src/main/java/io/agentscope/core/rag/store/PgVectorStore.java
Show resolved
Hide resolved
...entscope-extensions-rag-simple/src/main/java/io/agentscope/core/rag/store/PgVectorStore.java
Show resolved
Hide resolved
- Changed the database connection parameters in PgVectorStoreTest to use a local PostgreSQL instance. - Updated JDBC URL, username, password, and table name for testing purposes.
|
Please check copilot's review |
- Introduced a regex pattern for validating database identifiers (schema and table names) to ensure they only contain alphanumeric characters and underscores, starting with a letter or underscore. - Added a method to validate identifiers, throwing an exception for invalid inputs. - Updated the `getFullTableName` method to include validation for schema and table names during construction, enhancing security against SQL injection attacks.
Reviewed all Copilot comments and submitted code improvements accordingly. |
...entscope-extensions-rag-simple/src/main/java/io/agentscope/core/rag/store/PgVectorStore.java
Show resolved
Hide resolved
… operator methods - Added Javadoc comments to `getIndexOps` and `getOperator` methods to clarify their purpose and usage
AgentScope-Java Version
[The version of AgentScope-Java you are working on, e.g. 1.0.6, check your pom.xml dependency version or run
mvn dependency:tree | grep agentscope-parent:pom(only mac/linux)]$ mvn dependency:tree | grep agentscope-parent:pom
[INFO] io.agentscope:agentscope-parent:pom:1.0.7-SNAPSHOT
Description
[Please describe the background, purpose, changes made, and how to test this PR]
work for #522
Checklist
Please check the following items before code is ready to be reviewed.
mvn spotless:applymvn test)