sentence-transformers
English
agentweave_semantic_router
agentweave
agentic-ai
tool-routing
semantic-routing
function-calling
cpu
minilm
pre-inference-routing
Instructions to use sauravsingla08/AgentWeave-Router-MiniLM with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- sentence-transformers
How to use sauravsingla08/AgentWeave-Router-MiniLM with sentence-transformers:
from sentence_transformers import SentenceTransformer model = SentenceTransformer("sauravsingla08/AgentWeave-Router-MiniLM") sentences = [ "The weather is lovely today.", "It's so sunny outside!", "He drove to the stadium." ] embeddings = model.encode(sentences) similarities = model.similarity(embeddings, embeddings) print(similarities.shape) # [3, 3] - Notebooks
- Google Colab
- Kaggle
Publish AgentWeave Router MiniLM from 4f2a12b
Browse files
router.py
CHANGED
|
@@ -13,11 +13,12 @@ ROOT = Path(__file__).resolve().parent
|
|
| 13 |
|
| 14 |
|
| 15 |
class AgentWeaveSemanticRouter:
|
| 16 |
-
"""Prototype-based semantic capability router built on MiniLM embeddings.
|
| 17 |
|
| 18 |
This is an experimental semantic companion to AgentWeave's default
|
| 19 |
deterministic routing path. It does not replace AgentWeave policy,
|
| 20 |
-
authorization, or execution controls.
|
|
|
|
| 21 |
"""
|
| 22 |
|
| 23 |
def __init__(
|
|
@@ -29,7 +30,10 @@ class AgentWeaveSemanticRouter:
|
|
| 29 |
self.prototypes: Dict[str, List[str]] = json.loads(
|
| 30 |
Path(prototypes_path).read_text(encoding="utf-8")
|
| 31 |
)
|
| 32 |
-
|
|
|
|
|
|
|
|
|
|
| 33 |
|
| 34 |
texts: List[str] = []
|
| 35 |
labels: List[str] = []
|
|
|
|
| 13 |
|
| 14 |
|
| 15 |
class AgentWeaveSemanticRouter:
|
| 16 |
+
"""Prototype-based semantic capability router built on frozen MiniLM embeddings.
|
| 17 |
|
| 18 |
This is an experimental semantic companion to AgentWeave's default
|
| 19 |
deterministic routing path. It does not replace AgentWeave policy,
|
| 20 |
+
authorization, or execution controls. The upstream encoder is loaded as a
|
| 21 |
+
runtime dependency; this repository is not a fine-tuned MiniLM model.
|
| 22 |
"""
|
| 23 |
|
| 24 |
def __init__(
|
|
|
|
| 30 |
self.prototypes: Dict[str, List[str]] = json.loads(
|
| 31 |
Path(prototypes_path).read_text(encoding="utf-8")
|
| 32 |
)
|
| 33 |
+
encoder_model = self.config.get("encoder_model") or self.config.get("base_model")
|
| 34 |
+
if not encoder_model:
|
| 35 |
+
raise ValueError("config.json must define 'encoder_model'")
|
| 36 |
+
self.model = SentenceTransformer(str(encoder_model), device="cpu")
|
| 37 |
|
| 38 |
texts: List[str] = []
|
| 39 |
labels: List[str] = []
|