classifiers.update_tool_embeddings module

Incrementally update tool embeddings in Redis.

Discovers all registered tools, compares against what already exists in Redis, generates synthetic queries for missing tools via the Gemini API (using the shared embedding key pool), and adds only the new embeddings – without touching existing ones.

Usage:

python -m classifiers.update_tool_embeddings         [--force-index] [--tools-dir tools]
Environment variables:

REDIS_URL – defaults to redis://localhost:6379/0

async classifiers.update_tool_embeddings.get_existing_redis_tools(redis_client)[source]

Return tool names already in Redis.

Return type:

set[str]

Parameters:

redis_client (redis.asyncio.Redis)

classifiers.update_tool_embeddings.discover_tools(tools_dir='tools')[source]

Auto-discover all registered tools keyed by name.

Return type:

dict[str, Any]

Parameters:

tools_dir (str)

classifiers.update_tool_embeddings.load_index_file()[source]

Load index file from the configured source.

Returns:

The result.

Return type:

dict[str, Any]

classifiers.update_tool_embeddings.save_index_file(data)[source]

Save index file.

Parameters:

data (dict[str, Any]) – Input data payload.

Return type:

None

async classifiers.update_tool_embeddings.compute_tool_embedding(embedding_client, synthetic_queries, tool_name)[source]

Compute a normalised centroid from queries.

Return type:

ndarray | None

Parameters:
async classifiers.update_tool_embeddings.update_tool_embeddings(force_index=False, tools_dir='tools')[source]

Main incremental update routine.

Return type:

bool

Parameters:
  • force_index (bool)

  • tools_dir (str)

async classifiers.update_tool_embeddings.main()[source]

Main.

Return type:

None