Add new agent tool limits to CLI

This commit is contained in:
Cyber MacGeddon 2026-02-23 20:04:34 +00:00
parent 857bbed552
commit e96760d1c7
4 changed files with 18 additions and 4 deletions

View file

@ -67,6 +67,7 @@ def set_tool(
template : str, template : str,
schema_name : str, schema_name : str,
index_name : str, index_name : str,
limit : int,
arguments : List[Argument], arguments : List[Argument],
group : List[str], group : List[str],
state : str, state : str,
@ -96,6 +97,8 @@ def set_tool(
if index_name: object["index-name"] = index_name if index_name: object["index-name"] = index_name
if limit: object["limit"] = limit
if arguments: if arguments:
object["arguments"] = [ object["arguments"] = [
{ {
@ -156,7 +159,7 @@ def main():
--type row-embeddings-query \\ --type row-embeddings-query \\
--description "Find customers by name using semantic search" \\ --description "Find customers by name using semantic search" \\
--schema-name customers --collection sales \\ --schema-name customers --collection sales \\
--index-name full_name --index-name full_name --limit 20
%(prog)s --id calc_tool --name calculate --type mcp-tool \\ %(prog)s --id calc_tool --name calculate --type mcp-tool \\
--description "Perform mathematical calculations" \\ --description "Perform mathematical calculations" \\
@ -218,6 +221,12 @@ def main():
help=f'For row-embeddings-query type: specific index to filter search (optional)', help=f'For row-embeddings-query type: specific index to filter search (optional)',
) )
parser.add_argument(
'--limit',
type=int,
help=f'For row-embeddings-query type: maximum results to return (default: 10)',
)
parser.add_argument( parser.add_argument(
'--template', '--template',
help=f'For prompt type: template ID to use', help=f'For prompt type: template ID to use',
@ -288,6 +297,7 @@ def main():
template=args.template, template=args.template,
schema_name=args.schema_name, schema_name=args.schema_name,
index_name=args.index_name, index_name=args.index_name,
limit=args.limit,
arguments=arguments, arguments=arguments,
group=args.group, group=args.group,
state=args.state, state=args.state,

View file

@ -52,6 +52,8 @@ def show_config(url, token=None):
table.append(("schema-name", data["schema-name"])) table.append(("schema-name", data["schema-name"]))
if "index-name" in data: if "index-name" in data:
table.append(("index-name", data["index-name"])) table.append(("index-name", data["index-name"]))
if "limit" in data:
table.append(("limit", data["limit"]))
if tp == "prompt": if tp == "prompt":
table.append(("template", data["template"])) table.append(("template", data["template"]))

View file

@ -173,7 +173,8 @@ class Processor(AgentService):
schema_name=data.get("schema-name"), schema_name=data.get("schema-name"),
collection=data.get("collection"), collection=data.get("collection"),
user=None, # User will be provided dynamically via context user=None, # User will be provided dynamically via context
index_name=data.get("index-name") # Optional filter index_name=data.get("index-name"), # Optional filter
limit=int(data.get("limit", 10)) # Max results
) )
arguments = RowEmbeddingsQueryImpl.get_arguments() arguments = RowEmbeddingsQueryImpl.get_arguments()
else: else:

View file

@ -130,12 +130,13 @@ class StructuredQueryImpl:
# This tool implementation knows how to query row embeddings for semantic search # This tool implementation knows how to query row embeddings for semantic search
class RowEmbeddingsQueryImpl: class RowEmbeddingsQueryImpl:
def __init__(self, context, schema_name, collection=None, user=None, index_name=None): def __init__(self, context, schema_name, collection=None, user=None, index_name=None, limit=10):
self.context = context self.context = context
self.schema_name = schema_name self.schema_name = schema_name
self.collection = collection self.collection = collection
self.user = user self.user = user
self.index_name = index_name # Optional: filter to specific index self.index_name = index_name # Optional: filter to specific index
self.limit = limit # Max results to return
@staticmethod @staticmethod
def get_arguments(): def get_arguments():
@ -168,7 +169,7 @@ class RowEmbeddingsQueryImpl:
user=user, user=user,
collection=self.collection or "default", collection=self.collection or "default",
index_name=self.index_name, index_name=self.index_name,
limit=10 limit=self.limit
) )
# Format results for agent consumption # Format results for agent consumption