Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions plugin-reversal-example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Reversal + Hermes integration example

This example shows how to normalize messy sources before they reach Hermes.

## Why

Hermes is stronger when input data is clean.
Reversal converts raw inputs (URL, PDF, Word, Excel, CSV, image, text) into a stable JSON schema.

## Install

pip install reversal-engine

Optional (only for image/dashboard parsing):
export ANTHROPIC_API_KEY=your_key_here

## Run

python plugin-reversal-example/reversal_integration.py "https://example.com"

## How to use in your Hermes flow

1. Call normalize_for_hermes(source)
2. Build prompt/tool input with build_hermes_input(...)
3. Send that normalized payload to Hermes instead of raw source content
1 change: 1 addition & 0 deletions plugin-reversal-example/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
reversal-engine>=1.0.0
52 changes: 52 additions & 0 deletions plugin-reversal-example/reversal_integration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
from __future__ import annotations
import json
import sys
from typing import Any, Dict

from reversal_engine import reverse


def normalize_for_hermes(source: str, anthropic_api_key: str | None = None) -> Dict[str, Any]:
"""
Convertit une source brute (URL, PDF, Excel, image, texte) en JSON propre
avant de la passer a Hermes.
"""
result = reverse(source, api_key=anthropic_api_key)

if result.get("status") != "ok":
return {
"status": "error",
"source": source,
"error": result.get("data", {}).get("error", "Normalization failed"),
}

data = result.get("data", {})
return {
"status": "ok",
"content_type": result.get("content_type"),
"source": result.get("source"),
"processed_in_ms": result.get("processed_in_ms"),
"title": data.get("title", ""),
"summary_hint": data.get("summary_hint", ""),
"payload": data,
}


def build_hermes_input(normalized: Dict[str, Any]) -> str:
"""
Format pret a injecter dans le prompt / tool-call Hermes.
"""
if normalized.get("status") != "ok":
return f"Normalization error: {normalized.get('error', 'unknown error')}"

return (
"You are Hermes.\n"
"Use ONLY the normalized JSON below as source of truth.\n\n"
+ json.dumps(normalized, ensure_ascii=False, indent=2)
)


if __name__ == "__main__":
source_arg = sys.argv[1] if len(sys.argv) > 1 else "https://example.com"
normalized = normalize_for_hermes(source_arg)
print(build_hermes_input(normalized))