Skip to content

Commit

Permalink
add fuzzy search flag
Browse files Browse the repository at this point in the history
MBueschelberger committed Feb 27, 2024
1 parent 5887b6a commit e03fca6
Showing 3 changed files with 654 additions and 144 deletions.
3 changes: 2 additions & 1 deletion dsms/core/dsms.py
Original file line number Diff line number Diff line change
@@ -84,9 +84,10 @@ def search(
ktypes: "Optional[List[KType]]" = [],
annotations: "Optional[List[str]]" = [],
limit: int = 10,
allow_fuzzy: "Optional[bool]" = True,
) -> "List[KItem]":
"""Search for KItems in the remote backend."""
return _search(query, ktypes, annotations, limit)
return _search(query, ktypes, annotations, limit, allow_fuzzy)

@property
def sparql_interface(cls) -> SparqlInterface:
8 changes: 6 additions & 2 deletions dsms/knowledge/utils.py
Original file line number Diff line number Diff line change
@@ -291,7 +291,8 @@ def _search(
query: Optional[str] = None,
ktypes: "Optional[List[KType]]" = [],
annotations: "Optional[List[str]]" = [],
limit: int = 10,
limit: "Optional[int]" = 10,
allow_fuzzy: "Optional[bool]" = True,
) -> "List[KItem]":
"""Search for KItems in the remote backend"""
from dsms import KItem # isort:skip
@@ -303,7 +304,10 @@ def _search(
"limit": limit,
}
response = _perform_request(
"api/knowledge/kitems/search", "post", json=payload
"api/knowledge/kitems/search",
"post",
json=payload,
params={"allow_fuzzy": allow_fuzzy},
)
if not response.ok:
raise RuntimeError(
787 changes: 646 additions & 141 deletions examples/basic_usage.ipynb

Large diffs are not rendered by default.

0 comments on commit e03fca6

Please sign in to comment.