Skip to content

armgit / txtai

Public Imported from GitHub
0

💡 All-in-one AI framework for semantic search, LLM orchestration and language model workflows

fix(api): forward zero weights and url-encode parameters in Cluster search

serhiizghama9f7b4ddd4234
diff --git a/src/python/txtai/api/cluster.py b/src/python/txtai/api/cluster.py
index 80718186..1e18d220 100644
--- a/src/python/txtai/api/cluster.py
+++ b/src/python/txtai/api/cluster.py
@@ -56,17 +56,19 @@ class Cluster:
"""
# Build URL
- action = f"search?query={urllib.parse.quote_plus(query)}"
+ params = {"query": query}
if limit:
- action += f"&limit={limit}"
- if weights:
- action += f"&weights={weights}"
+ params["limit"] = limit
+ if weights is not None:
+ params["weights"] = weights
if index:
- action += f"&index={index}"
+ params["index"] = index
if parameters:
- action += f"&parameters={json.dumps(parameters) if isinstance(parameters, dict) else parameters}"
+ params["parameters"] = json.dumps(parameters) if isinstance(parameters, dict) else parameters
if graph is not None:
- action += f"&graph={graph}"
+ params["graph"] = graph
+
+ action = f"search?{urllib.parse.urlencode(params)}"
# Run query and flatten results into single results list
results = []
@@ -100,7 +102,7 @@ class Cluster:
params = {"queries": queries}
if limit:
params["limit"] = limit
- if weights:
+ if weights is not None:
params["weights"] = weights
if index:
params["index"] = index