Pgvecto rs
PGVectoRsStore #
Bases: BasePydanticVectorStore
PGVectoRs矢量存储。
示例
pip install llama-index-vector-stores-pgvecto-rs
from llama_index.vector_stores.pgvecto_rs import PGVectoRsStore
# 设置PGVectoRs客户端
from pgvecto_rs.sdk import PGVectoRs
import os
URL = "postgresql+psycopg://{username}:{password}@{host}:{port}/{db_name}".format(
port=os.getenv("DB_PORT", "5432"),
host=os.getenv("DB_HOST", "localhost"),
username=os.getenv("DB_USER", "postgres"),
password=os.getenv("DB_PASS", "mysecretpassword"),
db_name=os.getenv("DB_NAME", "postgres"),
)
client = PGVectoRs(
db_url=URL,
collection_name="example",
dimension=1536, # 使用OpenAI的文本嵌入-ada-002
)
# 初始化PGVectoRsStore
vector_store = PGVectoRsStore(client=client)
Source code in llama_index/vector_stores/pgvecto_rs/base.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
|