mirror of
https://github.com/AstrBotDevs/AstrBot
synced 2026-07-17 17:51:20 +08:00
chore(core.db): 添加typings,使faiss参数能被正确识别。
This commit is contained in:
49
typings/faiss/__init__.pyi
Normal file
49
typings/faiss/__init__.pyi
Normal file
@@ -0,0 +1,49 @@
|
||||
"""Minimal type stubs for faiss used in this project.
|
||||
|
||||
This file only exposes a small subset of the faiss API that the
|
||||
project uses, including the runtime-monkeypatched signatures such as
|
||||
`Index.add_with_ids` so Pyright/Pylance stops reporting false positives.
|
||||
"""
|
||||
|
||||
from typing import Any
|
||||
|
||||
import numpy as np
|
||||
|
||||
class Index:
|
||||
d: int
|
||||
ntotal: int
|
||||
code_size: int
|
||||
nprobe: int
|
||||
|
||||
def add(self, x: np.ndarray) -> None: ...
|
||||
def add_with_ids(self, x: np.ndarray, ids: np.ndarray) -> None: ...
|
||||
def search(
|
||||
self,
|
||||
x: np.ndarray,
|
||||
k: int,
|
||||
*,
|
||||
params: Any = ...,
|
||||
D: np.ndarray | None = ...,
|
||||
I: np.ndarray | None = ...,
|
||||
) -> tuple[np.ndarray, np.ndarray]: ...
|
||||
def remove_ids(self, x: np.ndarray) -> int: ...
|
||||
def reconstruct(self, key: int, x: np.ndarray | None = ...) -> np.ndarray: ...
|
||||
def reconstruct_n(
|
||||
self, n0: int = ..., ni: int = ..., x: np.ndarray | None = ...
|
||||
) -> np.ndarray: ...
|
||||
def range_search(
|
||||
self, x: np.ndarray, thresh: float, *, params: Any = ...
|
||||
) -> tuple[np.ndarray, np.ndarray, np.ndarray]: ...
|
||||
def add_sa_codes(self, codes: np.ndarray, ids: np.ndarray | None = ...) -> None: ...
|
||||
def sa_encode(self, x: np.ndarray) -> np.ndarray: ...
|
||||
def sa_decode(self, codes: np.ndarray) -> np.ndarray: ...
|
||||
|
||||
class IndexFlatL2(Index):
|
||||
def __init__(self, d: int) -> None: ...
|
||||
|
||||
class IndexIDMap(Index):
|
||||
def __init__(self, index: Index) -> None: ...
|
||||
|
||||
def read_index(path: str) -> Index: ...
|
||||
def write_index(index: Index, path: str | None = ...) -> None: ...
|
||||
def normalize_L2(x: np.ndarray) -> None: ...
|
||||
Reference in New Issue
Block a user