Skip to content

armgit / camel

Public Imported from GitHub
0

🐫 CAMEL: The first and the best multi-agent framework. Finding the Scaling Law of Agents. https://www.camel-ai.org

Auto-update documentation after merge

camel-docs-botabce7718d950
diff --git a/docs/mintlify/docs.json b/docs/mintlify/docs.json
index 42032ad19..70c91ffe6 100644
--- a/docs/mintlify/docs.json
+++ b/docs/mintlify/docs.json
@@ -430,6 +430,7 @@
"reference/camel.storages.vectordb_storages.faiss",
"reference/camel.storages.vectordb_storages.milvus",
"reference/camel.storages.vectordb_storages.oceanbase",
+ "reference/camel.storages.vectordb_storages.pgvector",
"reference/camel.storages.vectordb_storages.qdrant",
"reference/camel.storages.vectordb_storages.tidb",
"reference/camel.storages.vectordb_storages.weaviate"
diff --git a/docs/mintlify/get_started/installation.mdx b/docs/mintlify/get_started/installation.mdx
index 775c5eb0d..1f2120c8b 100644
--- a/docs/mintlify/get_started/installation.mdx
+++ b/docs/mintlify/get_started/installation.mdx
@@ -47,7 +47,7 @@ CAMEL-AI supports multiple installation methods to suit different development wo
- `model_platforms`: OpenAI, Google, Mistral, Anthropic Claude, Cohere etc.
- `huggingface`: Transformers, Diffusers, Accelerate, Datasets, PyTorch etc.
- `rag`: Sentence Transformers, Qdrant, Milvus, TiDB, BM25, OceanBase, Weaviate, chroma etc.
- - `storage`: Neo4j, Redis, Azure Blob, Google Cloud Storage, AWS S3 etc.
+ - `storage`: Neo4j, Redis, Azure Blob, Google Cloud Storage, AWS S3 etc, Pgvector.
- `web_tools`: DuckDuckGo, Wikipedia, WolframAlpha, Google Maps, Weather API etc.
- `document_tools`: PDF, Word, OpenAPI, BeautifulSoup, Unstructured etc.
- `media_tools`: Image Processing, Audio Processing, YouTube Download, FFmpeg etc.
diff --git a/docs/mintlify/key_modules/storages.mdx b/docs/mintlify/key_modules/storages.mdx
index 35514a398..9ea733749 100644
--- a/docs/mintlify/key_modules/storages.mdx
+++ b/docs/mintlify/key_modules/storages.mdx
@@ -63,6 +63,10 @@ The <b>Storage</b> module in CAMEL-AI gives you a **unified interface for saving
**ChromaStorage**
- For [ChromaDB](https://www.trychroma.com/) (AI-native open-source embedding database)
- Simple API, scales from notebook to production
+
+ **PgVectorStorage**
+ - For [PostgreSQL with pgvector](https://github.com/pgvector/pgvector) (open-source vector engine)
+ - Leverages PostgreSQL for vector search
</Accordion>
<Accordion title="Graph Storages" icon="chart-waterfall">
diff --git a/docs/mintlify/reference/camel.storages.vectordb_storages.pgvector.mdx b/docs/mintlify/reference/camel.storages.vectordb_storages.pgvector.mdx
new file mode 100644
index 000000000..bfcfc07f1
--- /dev/null
+++ b/docs/mintlify/reference/camel.storages.vectordb_storages.pgvector.mdx
@@ -0,0 +1,185 @@
+<a id="camel.storages.vectordb_storages.pgvector"></a>
+
+<a id="camel.storages.vectordb_storages.pgvector.PgVectorStorage"></a>
+
+## PgVectorStorage
+
+```python
+class PgVectorStorage(BaseVectorStorage):
+```
+
+PgVectorStorage is an implementation of BaseVectorStorage for
+PostgreSQL with pgvector extension.
+
+This class provides methods to add, delete, query, and manage vector
+records in a PostgreSQL database using the pgvector extension.
+It supports different distance metrics for similarity search.
+
+**Parameters:**
+
+- **vector_dim** (int): The dimension of the vectors to be stored.
+- **conn_info** (Dict[str, Any]): Connection information for psycopg2.connect.
+- **table_name** (str, optional): Name of the table to store vectors. (default: :obj:`None`)
+- **distance** (VectorDistance, optional): Distance metric for vector comparison. (default: :obj:`VectorDistance.COSINE`)
+
+<a id="camel.storages.vectordb_storages.pgvector.PgVectorStorage.__init__"></a>
+
+### __init__
+
+```python
+def __init__(
+ self,
+ vector_dim: int,
+ conn_info: Dict[str, Any],
+ table_name: Optional[str] = None,
+ distance: VectorDistance = VectorDistance.COSINE,
+ **kwargs: Any
+):
+```
+
+Initialize PgVectorStorage.
+
+**Parameters:**
+
+- **vector_dim** (int): The dimension of the vectors.
+- **conn_info** (Dict[str, Any]): Connection info for psycopg2.connect.
+- **table_name** (str, optional): Table name. (default: :obj:`None`)
+- **distance** (VectorDistance, optional): Distance metric. (default: :obj:`VectorDistance.COSINE`)
+
+<a id="camel.storages.vectordb_storages.pgvector.PgVectorStorage._ensure_table"></a>
+
+### _ensure_table
+
+```python
+def _ensure_table(self):
+```
+
+Ensure the vector table exists in the database.
+Creates the table if it does not exist.
+
+<a id="camel.storages.vectordb_storages.pgvector.PgVectorStorage._ensure_index"></a>
+
+### _ensure_index
+
+```python
+def _ensure_index(self):
+```
+
+Ensure vector similarity search index exists for better
+performance.
+
+<a id="camel.storages.vectordb_storages.pgvector.PgVectorStorage.add"></a>
+
+### add
+
+```python
+def add(self, records: List[VectorRecord], **kwargs: Any):
+```
+
+Add or update vector records in the database.
+
+**Parameters:**
+
+- **records** (List[VectorRecord]): List of vector records to add or update.
+
+<a id="camel.storages.vectordb_storages.pgvector.PgVectorStorage.delete"></a>
+
+### delete
+
+```python
+def delete(self, ids: List[str], **kwargs: Any):
+```
+
+Delete vector records from the database by their IDs.
+
+**Parameters:**
+
+- **ids** (List[str]): List of record IDs to delete.
+
+<a id="camel.storages.vectordb_storages.pgvector.PgVectorStorage.query"></a>
+
+### query
+
+```python
+def query(self, query: VectorDBQuery, **kwargs: Any):
+```
+
+Query the database for the most similar vectors to the given
+query vector.
+
+**Parameters:**
+
+- **query** (VectorDBQuery): Query object containing the query vector and top_k. **kwargs (Any): Additional keyword arguments for the query.
+
+**Returns:**
+
+ List[VectorDBQueryResult]: List of query results sorted by
+similarity.
+
+<a id="camel.storages.vectordb_storages.pgvector.PgVectorStorage.status"></a>
+
+### status
+
+```python
+def status(self, **kwargs: Any):
+```
+
+Get the status of the vector database, including vector
+dimension and count.
+
+**Returns:**
+
+ VectorDBStatus: Status object with vector dimension and count.
+
+<a id="camel.storages.vectordb_storages.pgvector.PgVectorStorage.clear"></a>
+
+### clear
+
+```python
+def clear(self):
+```
+
+Remove all vectors from the storage by truncating the table.
+
+<a id="camel.storages.vectordb_storages.pgvector.PgVectorStorage.load"></a>
+
+### load
+
+```python
+def load(self):
+```
+
+Load the collection hosted on cloud service (no-op for pgvector).
+This method is provided for interface compatibility.
+
+<a id="camel.storages.vectordb_storages.pgvector.PgVectorStorage.close"></a>
+
+### close
+
+```python
+def close(self):
+```
+
+Close the database connection.
+
+<a id="camel.storages.vectordb_storages.pgvector.PgVectorStorage.__del__"></a>
+
+### __del__
+
+```python
+def __del__(self):
+```
+
+Ensure connection is closed when object is destroyed.
+
+<a id="camel.storages.vectordb_storages.pgvector.PgVectorStorage.client"></a>
+
+### client
+
+```python
+def client(self):
+```
+
+**Returns:**
+
+ Any: The underlying psycopg connection object.