索引
向量存储索引类型。
VectorStoreQueryResult dataclass
#
向量存储查询结果。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
nodes
|
Sequence[BaseNode] | None
|
|
无
|
similarities
|
List[float] | None
|
|
无
|
ids
|
List[str] | None
|
|
无
|
源代码位于 llama-index-core/llama_index/core/vector_stores/types.py
36 37 38 39 40 41 42 |
|
VectorStoreQueryMode #
继承自: str
, Enum
向量存储查询模式。
源代码位于 llama-index-core/llama_index/core/vector_stores/types.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
|
FilterOperator #
继承自: str
, Enum
向量存储过滤器运算符。
源代码位于 llama-index-core/llama_index/core/vector_stores/types.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
|
FilterCondition #
继承自: str
, Enum
用于组合不同过滤器的向量存储过滤条件。
源代码位于 llama-index-core/llama_index/core/vector_stores/types.py
85 86 87 88 89 90 91 |
|
MetadataFilter #
继承自: BaseModel
全面的元数据过滤器,用于向量存储以支持更多运算符。
值使用 Strict* 类型,因为 int、float 和 str 是兼容类型,并且之前都被转换为字符串。
参见: https://docs.pydantic.org.cn/latest/usage/types/#strict-types
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
key
|
str
|
|
必需 |
value
|
Annotated[int, Strict] | Annotated[float, Strict] | Annotated[str, Strict] | List[Annotated[str, Strict]] | List[Annotated[float, Strict]] | List[Annotated[int, Strict]] | None
|
|
必需 |
operator
|
FilterOperator
|
|
<FilterOperator.EQ: '=='>
|
源代码位于 llama-index-core/llama_index/core/vector_stores/types.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
|
from_dict classmethod
#
from_dict(filter_dict: Dict) -> MetadataFilter
从字典创建 MetadataFilter。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
filter_dict
|
Dict
|
包含 key、value 和 operator 的 Dict。 |
必需 |
源代码位于 llama-index-core/llama_index/core/vector_stores/types.py
117 118 119 120 121 122 123 124 125 126 127 128 129 |
|
MetadataFilters #
继承自: BaseModel
向量存储的元数据过滤器。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
filters
|
List[Union[MetadataFilter, MetadataFilters]]
|
|
必需 |
condition
|
FilterCondition | None
|
|
<FilterCondition.AND: 'and'>
|
源代码位于 llama-index-core/llama_index/core/vector_stores/types.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
|
from_dict classmethod
#
from_dict(filter_dict: Dict) -> MetadataFilters
从 json 创建 MetadataFilters。
源代码位于 llama-index-core/llama_index/core/vector_stores/types.py
150 151 152 153 154 155 156 157 158 159 160 161 |
|
from_dicts classmethod
#
from_dicts(filter_dicts: List[Dict], condition: Optional[FilterCondition] = AND) -> MetadataFilters
从字典创建 MetadataFilters。
这接收一个 MetadataFilter 对象列表以及条件。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
filter_dicts
|
List[Dict]
|
字典列表,每个字典都是一个 MetadataFilter。 |
必需 |
condition
|
Optional[FilterCondition]
|
用于组合不同过滤器的 FilterCondition。 |
AND
|
源代码位于 llama-index-core/llama_index/core/vector_stores/types.py
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
|
legacy_filters #
legacy_filters() -> List[ExactMatchFilter]
将 MetadataFilters 转换为旧版 ExactMatchFilters。
源代码位于 llama-index-core/llama_index/core/vector_stores/types.py
187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
|
VectorStoreQuerySpec #
继承自: BaseModel
用于向量存储结构化请求的 Schema(即转换为 VectorStoreQuery)。
当前仅由 VectorIndexAutoRetriever 使用。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
query
|
str
|
|
必需 |
filters
|
List[MetadataFilter]
|
|
必需 |
top_k
|
int | None
|
|
无
|
源代码位于 llama-index-core/llama_index/core/vector_stores/types.py
203 204 205 206 207 208 209 210 211 212 213 |
|
MetadataInfo #
继承自: BaseModel
关于向量存储支持的元数据过滤器的信息。
当前仅由 VectorIndexAutoRetriever 使用。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
name
|
str
|
|
必需 |
type
|
str
|
|
必需 |
description
|
str
|
|
必需 |
源代码位于 llama-index-core/llama_index/core/vector_stores/types.py
216 217 218 219 220 221 222 223 224 225 |
|
VectorStoreInfo #
继承自: BaseModel
关于向量存储(内容和支持的元数据过滤器)的信息。
当前仅由 VectorIndexAutoRetriever 使用。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
metadata_info
|
List[MetadataInfo]
|
|
必需 |
content_info
|
str
|
|
必需 |
源代码位于 llama-index-core/llama_index/core/vector_stores/types.py
228 229 230 231 232 233 234 235 236 |
|
VectorStoreQuery dataclass
#
向量存储查询。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
query_embedding
|
List[float] | None
|
|
无
|
similarity_top_k
|
int
|
|
1
|
doc_ids
|
List[str] | None
|
|
无
|
node_ids
|
List[str] | None
|
|
无
|
query_str
|
str | None
|
|
无
|
output_fields
|
List[str] | None
|
|
无
|
embedding_field
|
str | None
|
|
无
|
mode
|
VectorStoreQueryMode
|
|
<VectorStoreQueryMode.DEFAULT: 'default'>
|
alpha
|
float | None
|
|
无
|
filters
|
MetadataFilters | None
|
|
无
|
mmr_threshold
|
float | None
|
|
无
|
sparse_top_k
|
int | None
|
|
无
|
hybrid_top_k
|
int | None
|
|
无
|
源代码位于 llama-index-core/llama_index/core/vector_stores/types.py
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 |
|
VectorStore #
继承自: Protocol
抽象向量存储协议。
源代码位于 llama-index-core/llama_index/core/vector_stores/types.py
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 |
|
add #
add(nodes: List[BaseNode], **add_kwargs: Any) -> List[str]
将带有嵌入的节点添加到向量存储。
源代码位于 llama-index-core/llama_index/core/vector_stores/types.py
280 281 282 283 284 285 286 |
|
async_add async
#
async_add(nodes: List[BaseNode], **kwargs: Any) -> List[str]
异步地将带有嵌入的节点添加到向量存储。注意:并非所有向量存储都实现了此功能。如果未实现,它将同步调用 add。
源代码位于 llama-index-core/llama_index/core/vector_stores/types.py
288 289 290 291 292 293 294 295 296 297 298 |
|
delete #
delete(ref_doc_id: str, **delete_kwargs: Any) -> None
使用 ref_doc_id 删除节点。
源代码位于 llama-index-core/llama_index/core/vector_stores/types.py
300 301 302 303 |
|
adelete async
#
adelete(ref_doc_id: str, **delete_kwargs: Any) -> None
使用 ref_doc_id 删除节点。注意:并非所有向量存储都实现了此功能。如果未实现,它将同步调用 delete。
源代码位于 llama-index-core/llama_index/core/vector_stores/types.py
305 306 307 308 309 310 311 |
|
query #
query(query: VectorStoreQuery, **kwargs: Any) -> VectorStoreQueryResult
查询向量存储。
源代码位于 llama-index-core/llama_index/core/vector_stores/types.py
313 314 315 |
|
aquery async
#
aquery(query: VectorStoreQuery, **kwargs: Any) -> VectorStoreQueryResult
异步地查询向量存储。注意:并非所有向量存储都实现了此功能。如果未实现,它将同步调用 query。
源代码位于 llama-index-core/llama_index/core/vector_stores/types.py
317 318 319 320 321 322 323 324 325 |
|
BasePydanticVectorStore #
继承自: BaseComponent
, ABC
抽象向量存储协议。
参数
名称 | 类型 | 描述 | 默认值 |
---|---|---|---|
stores_text
|
bool
|
|
必需 |
is_embedding_query
|
bool
|
|
True
|
源代码位于 llama-index-core/llama_index/core/vector_stores/types.py
334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 |
|
get_nodes #
get_nodes(node_ids: Optional[List[str]] = None, filters: Optional[MetadataFilters] = None) -> List[BaseNode]
从向量存储获取节点。
源代码位于 llama-index-core/llama_index/core/vector_stores/types.py
346 347 348 349 350 351 352 |
|
aget_nodes async
#
aget_nodes(node_ids: Optional[List[str]] = None, filters: Optional[MetadataFilters] = None) -> List[BaseNode]
异步地从向量存储获取节点。
源代码位于 llama-index-core/llama_index/core/vector_stores/types.py
354 355 356 357 358 359 360 |
|
add abstractmethod
#
add(nodes: Sequence[BaseNode], **kwargs: Any) -> List[str]
将节点添加到向量存储。
源代码位于 llama-index-core/llama_index/core/vector_stores/types.py
362 363 364 365 366 367 368 |
|
async_add async
#
async_add(nodes: Sequence[BaseNode], **kwargs: Any) -> List[str]
异步地将节点添加到向量存储。注意:并非所有向量存储都实现了此功能。如果未实现,它将同步调用 add。
源代码位于 llama-index-core/llama_index/core/vector_stores/types.py
370 371 372 373 374 375 376 377 378 379 380 |
|
delete abstractmethod
#
delete(ref_doc_id: str, **delete_kwargs: Any) -> None
使用 ref_doc_id 删除节点。
源代码位于 llama-index-core/llama_index/core/vector_stores/types.py
382 383 384 385 |
|
adelete async
#
adelete(ref_doc_id: str, **delete_kwargs: Any) -> None
使用 ref_doc_id 删除节点。注意:并非所有向量存储都实现了此功能。如果未实现,它将同步调用 delete。
源代码位于 llama-index-core/llama_index/core/vector_stores/types.py
387 388 389 390 391 392 393 |
|
delete_nodes #
delete_nodes(node_ids: Optional[List[str]] = None, filters: Optional[MetadataFilters] = None, **delete_kwargs: Any) -> None
从向量存储删除节点。
源代码位于 llama-index-core/llama_index/core/vector_stores/types.py
395 396 397 398 399 400 401 402 |
|
adelete_nodes async
#
adelete_nodes(node_ids: Optional[List[str]] = None, filters: Optional[MetadataFilters] = None, **delete_kwargs: Any) -> None
异步地从向量存储删除节点。
源代码位于 llama-index-core/llama_index/core/vector_stores/types.py
404 405 406 407 408 409 410 411 |
|
clear #
clear() -> None
从配置的向量存储中清除所有节点。
源代码位于 llama-index-core/llama_index/core/vector_stores/types.py
413 414 415 |
|
aclear async
#
aclear() -> None
异步地从配置的向量存储中清除所有节点。
源代码位于 llama-index-core/llama_index/core/vector_stores/types.py
417 418 419 |
|
query abstractmethod
#
query(query: VectorStoreQuery, **kwargs: Any) -> VectorStoreQueryResult
查询向量存储。
源代码位于 llama-index-core/llama_index/core/vector_stores/types.py
421 422 423 |
|
aquery async
#
aquery(query: VectorStoreQuery, **kwargs: Any) -> VectorStoreQueryResult
异步地查询向量存储。注意:并非所有向量存储都实现了此功能。如果未实现,它将同步调用 query。
源代码位于 llama-index-core/llama_index/core/vector_stores/types.py
425 426 427 428 429 430 431 432 433 |
|