You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
motief/agent_tools/__init__.py

82 lines
4.4 KiB

"""Agent tools for Stemwijzer — atomic primitives for agent operation.
Import individual modules or use `list_tools()` for runtime discovery.
"""
from __future__ import annotations
from agent_tools.context import (
append_context_note,
list_recent_reports,
read_context_md,
)
from agent_tools.database import (
compute_party_positions_from_vectors,
create_motion,
delete_report,
query_compass_positions,
query_embeddings,
query_motions,
query_party_positions,
query_pipeline_status,
query_similar_motions,
query_svd_vectors,
query_votes,
update_motion,
)
from agent_tools.pipeline import (
pipeline_get_logs,
pipeline_run_stage,
)
__all__ = [
# Database
"query_motions",
"query_votes",
"query_svd_vectors",
"query_party_positions",
"compute_party_positions_from_vectors",
"query_pipeline_status",
"query_embeddings",
"query_similar_motions",
"query_compass_positions",
"create_motion",
"update_motion",
"delete_report",
# Pipeline
"pipeline_run_stage",
"pipeline_get_logs",
# Context
"list_recent_reports",
"read_context_md",
"append_context_note",
# Discovery
"list_tools",
]
def list_tools() -> list[dict[str, str]]:
"""Return a list of all available agent tools with signatures and descriptions.
Useful for runtime capability discovery and prompt injection.
"""
return [
{"name": "query_motions", "signature": "query_motions(db_path, limit=100, policy_area=None, start_date=None, end_date=None)", "description": "Query motions from the database with optional filters."},
{"name": "query_votes", "signature": "query_votes(db_path, motion_id=None, party=None)", "description": "Query vote counts or individual votes."},
{"name": "query_svd_vectors", "signature": "query_svd_vectors(db_path, window_id, entity_type='motion')", "description": "Query SVD vectors for a window and entity type."},
{"name": "query_party_positions", "signature": "query_party_positions(db_path, window_id='current_parliament')", "description": "Query party axis positions for a window."},
{"name": "compute_party_positions_from_vectors", "signature": "compute_party_positions_from_vectors(db_path, window_id)", "description": "Compute party positions from MP vectors when pre-computed table is unavailable."},
{"name": "query_pipeline_status", "signature": "query_pipeline_status(db_path)", "description": "Query pipeline freshness and coverage metrics (raw counts, no judgment)."},
{"name": "query_embeddings", "signature": "query_embeddings(db_path, motion_id=None, model=None, limit=100)", "description": "Query text/fused embeddings."},
{"name": "query_similar_motions", "signature": "query_similar_motions(db_path, motion_id, top_k=10)", "description": "Query similar motions from similarity cache."},
{"name": "query_compass_positions", "signature": "query_compass_positions(db_path, window_id='current_parliament')", "description": "Query 2D compass positions for parties/MPs."},
{"name": "create_motion", "signature": "create_motion(db_path, title, description, date, policy_area='General', voting_results='[]')", "description": "Insert a new motion into the database."},
{"name": "update_motion", "signature": "update_motion(db_path, motion_id, **fields)", "description": "Update fields of an existing motion."},
{"name": "delete_report", "signature": "delete_report(output_path)", "description": "Delete a generated report file."},
{"name": "pipeline_run_stage", "signature": "pipeline_run_stage(db_path, stage, window_id, dry_run=False)", "description": "Run a single pipeline stage (agent decides which and when)."},
{"name": "pipeline_get_logs", "signature": "pipeline_get_logs(stage, lines=50)", "description": "Retrieve recent log output for a stage."},
{"name": "list_recent_reports", "signature": "list_recent_reports()", "description": "List recently generated report files."},
{"name": "read_context_md", "signature": "read_context_md()", "description": "Read accumulated agent knowledge from context.md."},
{"name": "append_context_note", "signature": "append_context_note(note)", "description": "Append a note to the accumulated agent knowledge."},
{"name": "list_tools", "signature": "list_tools()", "description": "Return a list of all available agent tools."},
]