diff --git a/lib/edge/python/examples/mmr-query.py b/lib/edge/python/examples/mmr-query.py index d81019797c..6b740d254c 100644 --- a/lib/edge/python/examples/mmr-query.py +++ b/lib/edge/python/examples/mmr-query.py @@ -7,12 +7,10 @@ fill_dummy_data(shard) result = shard.query(QueryRequest( prefetches = [], - query = Mmr([6.0, 9.0, 4.0, 2.0], None, 0.9, 100), + query = Mmr([6.0, 9.0, 4.0, 2.0], 0.9, candidates_limit=100), filter = None, - score_threshold = None, limit = 10, offset = 0, - params = None, with_vector = True, with_payload = True, )) diff --git a/lib/edge/python/examples/qdrant-edge.py b/lib/edge/python/examples/qdrant-edge.py index 910adde3c2..ef820ac6a1 100755 --- a/lib/edge/python/examples/qdrant-edge.py +++ b/lib/edge/python/examples/qdrant-edge.py @@ -69,13 +69,8 @@ shard.update(UpdateOperation.upsert_points([ print("---- Query ----") result = shard.query(QueryRequest( - prefetches = [], query = Query.Nearest([6.0, 9.0, 4.0, 2.0]), - filter = None, - score_threshold = None, limit = 10, - offset = 0, - params = None, with_vector = True, with_payload = True, )) @@ -88,13 +83,9 @@ print("---- Search ----") points = shard.search(SearchRequest( query=Query.Nearest([1.0, 1.0, 1.0, 1.0]), - filter=None, - params=None, limit=10, - offset=0, with_vector=True, with_payload=True, - score_threshold=None, )) for point in points: @@ -119,12 +110,9 @@ search_filter = Filter( points = shard.search(SearchRequest( query=Query.Nearest([1.0, 1.0, 1.0, 1.0]), filter=search_filter, - params=None, limit=10, - offset=0, with_vector=True, with_payload=True, - score_threshold=None, )) for point in points: diff --git a/lib/edge/python/src/config/sparse_vector_data.rs b/lib/edge/python/src/config/sparse_vector_data.rs index 3c5a4dcf15..c89706108b 100644 --- a/lib/edge/python/src/config/sparse_vector_data.rs +++ b/lib/edge/python/src/config/sparse_vector_data.rs @@ -36,6 +36,7 @@ impl PySparseVectorDataConfig { #[pymethods] impl PySparseVectorDataConfig { #[new] + #[pyo3(signature = (index, storage_type, modifier = None))] pub fn new( index: PySparseIndexConfig, storage_type: PySparseVectorStorageType, @@ -98,14 +99,15 @@ pub struct PySparseIndexConfig(SparseIndexConfig); #[pymethods] impl PySparseIndexConfig { #[new] + #[pyo3(signature = (index_type, full_scan_threshold = None, datatype = None))] pub fn new( - full_scan_threshold: Option, index_type: PySparseIndexType, + full_scan_threshold: Option, datatype: Option, ) -> Self { Self(SparseIndexConfig { - full_scan_threshold, index_type: SparseIndexType::from(index_type), + full_scan_threshold, datatype: datatype.map(VectorStorageDatatype::from), }) } diff --git a/lib/edge/python/src/lib.rs b/lib/edge/python/src/lib.rs index 16156e86a3..daf67f84c0 100644 --- a/lib/edge/python/src/lib.rs +++ b/lib/edge/python/src/lib.rs @@ -87,6 +87,7 @@ pub struct PyShard(Option); #[pymethods] impl PyShard { #[new] + #[pyo3(signature = (path, config = None))] pub fn load(path: PathBuf, config: Option) -> Result { let shard = edge::Shard::load(&path, config.map(SegmentConfig::from))?; Ok(Self(Some(shard))) diff --git a/lib/edge/python/src/query.rs b/lib/edge/python/src/query.rs index 7e6827698c..8b7f8bd2ae 100644 --- a/lib/edge/python/src/query.rs +++ b/lib/edge/python/src/query.rs @@ -25,28 +25,41 @@ pub struct PyQueryRequest(ShardQueryRequest); #[pymethods] impl PyQueryRequest { #[new] + #[pyo3(signature = ( + limit, + offset = None, + query = None, + prefetches = None, + with_vector = None, + with_payload = None, + filter = None, + score_threshold = None, + params = None, + ))] #[allow(clippy::too_many_arguments)] pub fn new( - prefetches: Vec, + limit: usize, + offset: Option, query: Option, + prefetches: Option>, + with_vector: Option, + with_payload: Option, filter: Option, score_threshold: Option, - limit: usize, - offset: usize, params: Option, - with_vector: PyWithVector, - with_payload: PyWithPayload, ) -> Self { Self(ShardQueryRequest { - prefetches: PyPrefetch::peel_vec(prefetches), + prefetches: PyPrefetch::peel_vec(prefetches.unwrap_or_default()), + limit, + offset: offset.unwrap_or(0), + with_vector: with_vector.map(WithVector::from).unwrap_or_default(), + with_payload: with_payload + .map(WithPayloadInterface::from) + .unwrap_or_default(), query: query.map(ScoringQuery::from), filter: filter.map(Filter::from), score_threshold: score_threshold.map(OrderedFloat), - limit, - offset, params: params.map(SearchParams::from), - with_vector: WithVector::from(with_vector), - with_payload: WithPayloadInterface::from(with_payload), }) } @@ -128,18 +141,26 @@ pub struct PyPrefetch(ShardPrefetch); #[pymethods] impl PyPrefetch { #[new] + #[pyo3(signature = ( + limit, + query = None, + prefetches = None, + params = None, + filter = None, + score_threshold = None, + ))] pub fn new( - prefetches: Vec, - query: Option, limit: usize, + query: Option, + prefetches: Option>, params: Option, filter: Option, score_threshold: Option, ) -> Self { Self(ShardPrefetch { - prefetches: PyPrefetch::peel_vec(prefetches), - query: query.map(ScoringQuery::from), + prefetches: PyPrefetch::peel_vec(prefetches.unwrap_or_default()), limit, + query: query.map(ScoringQuery::from), params: params.map(SearchParams::from), filter: filter.map(Filter::from), score_threshold: score_threshold.map(OrderedFloat), @@ -341,6 +362,7 @@ pub struct PyOrderBy(OrderBy); #[pymethods] impl PyOrderBy { #[new] + #[pyo3(signature = (key, direction = None, start_from = None))] pub fn new( key: PyJsonPath, direction: Option, @@ -561,11 +583,12 @@ pub struct PyMmr(MmrInternal); #[pymethods] impl PyMmr { #[new] + #[pyo3(signature = (vector, lambda, candidates_limit, using = None))] pub fn new( vector: PyNamedVectorInternal, - using: Option, lambda: f32, candidates_limit: usize, + using: Option, ) -> Self { let mmr = MmrInternal { vector: VectorInternal::from(vector), diff --git a/lib/edge/python/src/search.rs b/lib/edge/python/src/search.rs index 84d34e3529..11e0b37763 100644 --- a/lib/edge/python/src/search.rs +++ b/lib/edge/python/src/search.rs @@ -16,23 +16,33 @@ pub struct PySearchRequest(CoreSearchRequest); #[pymethods] impl PySearchRequest { #[new] + #[pyo3(signature = ( + query, + limit, + offset = None, + filter = None, + params = None, + with_vector = None, + with_payload = None, + score_threshold = None, + ))] #[allow(clippy::too_many_arguments)] pub fn new( query: PyQuery, + limit: usize, + offset: Option, filter: Option, params: Option, - limit: usize, - offset: usize, with_vector: Option, with_payload: Option, score_threshold: Option, ) -> Self { Self(CoreSearchRequest { query: QueryEnum::from(query), + limit, + offset: offset.unwrap_or(0), filter: filter.map(Filter::from), params: params.map(SearchParams::from), - limit, - offset, with_vector: with_vector.map(WithVector::from), with_payload: with_payload.map(WithPayloadInterface::from), score_threshold, @@ -108,6 +118,13 @@ pub struct PySearchParams(pub SearchParams); #[pymethods] impl PySearchParams { #[new] + #[pyo3(signature = ( + hnsw_ef = None, + exact = false, + quantization = None, + indexed_only = false, + acorn = None, + ))] pub fn new( hnsw_ef: Option, exact: bool, @@ -175,6 +192,7 @@ pub struct PyQuantizationSearchParams(QuantizationSearchParams); #[pymethods] impl PyQuantizationSearchParams { #[new] + #[pyo3(signature = (ignore = false, rescore = None, oversampling = None))] pub fn new(ignore: bool, rescore: Option, oversampling: Option) -> Self { Self(QuantizationSearchParams { ignore, @@ -222,6 +240,7 @@ pub struct PyAcornSearchParams(AcornSearchParams); #[pymethods] impl PyAcornSearchParams { #[new] + #[pyo3(signature = (enable = false, max_selectivity = None))] pub fn new(enable: bool, max_selectivity: Option) -> Self { Self(AcornSearchParams { enable, diff --git a/lib/edge/python/src/types/formula/mod.rs b/lib/edge/python/src/types/formula/mod.rs index 23186e7e2b..2143aa0213 100644 --- a/lib/edge/python/src/types/formula/mod.rs +++ b/lib/edge/python/src/types/formula/mod.rs @@ -27,10 +27,14 @@ pub struct PyFormula(pub ParsedFormula); #[pymethods] impl PyFormula { #[new] - pub fn new(formula: PyExpression, defaults: HashMap) -> PyResult { + #[pyo3(signature = (formula, defaults = None))] + pub fn new( + formula: PyExpression, + defaults: Option>, + ) -> PyResult { let formula = FormulaInternal { formula: ExpressionInternal::from(formula), - defaults: PyValue::peel_map(defaults), + defaults: PyValue::peel_map(defaults.unwrap_or_default()), }; let formula = ParsedFormula::try_from(formula) diff --git a/lib/edge/python/src/types/point.rs b/lib/edge/python/src/types/point.rs index 3f9e5dd345..24b5c56b11 100644 --- a/lib/edge/python/src/types/point.rs +++ b/lib/edge/python/src/types/point.rs @@ -16,6 +16,7 @@ pub struct PyPoint(PointStructPersisted); #[pymethods] impl PyPoint { #[new] + #[pyo3(signature = (id, vector, payload = None))] pub fn new(id: PyPointId, vector: PyVector, payload: Option) -> Self { let point = PointStructPersisted { id: PointIdType::from(id),