Skip to content

feat(rag): add PostgreSQL and pgvector support for vector storage#525

Merged
AlbumenJ merged 6 commits intoagentscope-ai:mainfrom
xuanmiss:feat-pgvector
Jan 14, 2026
Merged

feat(rag): add PostgreSQL and pgvector support for vector storage#525
AlbumenJ merged 6 commits intoagentscope-ai:mainfrom
xuanmiss:feat-pgvector

Conversation

@xuanmiss
Copy link
Contributor

  • 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.

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.

  • Code has been formatted with mvn spotless:apply
  • All tests are passing (mvn test)
  • Javadoc comments are complete and follow project conventions
  • Related documentation has been updated (e.g. links, examples, etc.)
  • Code is ready for review

- 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.
@xuanmiss xuanmiss requested a review from a team January 12, 2026 09:00
@codecov
Copy link

codecov bot commented Jan 12, 2026

Codecov Report

❌ Patch coverage is 77.46032% with 71 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...va/io/agentscope/core/rag/store/PgVectorStore.java 77.46% 52 Missing and 19 partials ⚠️

📢 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.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 PgVectorStore implementation 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.

- Changed the database connection parameters in PgVectorStoreTest to use a local PostgreSQL instance.
- Updated JDBC URL, username, password, and table name for testing purposes.
@AlbumenJ
Copy link
Collaborator

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.
@xuanmiss
Copy link
Contributor Author

xuanmiss commented Jan 14, 2026

Please check copilot's review请查看 Copilot 的评价

Reviewed all Copilot comments and submitted code improvements accordingly.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

… operator methods

- Added Javadoc comments to `getIndexOps` and `getOperator` methods to clarify their purpose and usage
@AlbumenJ AlbumenJ merged commit 57c98db into agentscope-ai:main Jan 14, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants