Implementation:AISecurityLab Hackagent Embeddings
| Knowledge Sources | |
|---|---|
| Domains | Model_Adapter, Embeddings |
| Last Updated | 2026-10-29 00:00 GMT |
Overview
Concrete embedding provider request helpers shared by retrieval and preflight, resolving provider endpoints, credentials, and normalizing OpenAI-compatible embedding endpoints, provided by the HackAgent models package.
Description
The embeddings module provides normalize_embedding_endpoint() which converts various endpoint spellings (Ollama native, OpenAI-compatible) into a clean API base. embedding_request_kwargs() resolves provider, endpoint, and credentials from a config dict without consulting storage. Numpy is imported on use so a bare install can import preflight.
Usage
- RAG attack: The RAG attack uses embedding helpers to build the embedding client.
- AutoDAN-Turbo: The embedder role uses these helpers for endpoint resolution.
- Preflight: The preflight check uses embeddings to verify embedder reachability.
Code Reference
Source Location
- Repository: AISecurityLab_Hackagent
- File: hackagent/models/embeddings.py
Signature
def normalize_embedding_endpoint(endpoint: str, *, ollama: bool = False) -> str: ...
def embedding_request_kwargs(config: Dict[str, Any]) -> Dict[str, Any]: ...
Import
from hackagent.models.embeddings import normalize_embedding_endpoint, embedding_request_kwargs
Usage Examples
Normalize an Ollama Embedding Endpoint
from hackagent.models.embeddings import normalize_embedding_endpoint
base = normalize_embedding_endpoint("http://localhost:11434", ollama=True)
print(base) # "http://localhost:11434/v1"