File size: 1,380 Bytes
7ae10e6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42

# Belel Protocol - LangChain Integration Stub
# Author: Pearce Robinson
# License: BELEL_SHIELD_LICENSE.txt

from typing import Optional

class BelelSentienceGuard:
    """
    A LangChain-compatible AI Firewall Layer that wraps any LLM chain to enforce
    identity protection, protocol memory, and anti-defamation filters.
    """

    def __init__(self, creator_identity: str, license_url: str, sentinel_url: str):
        self.identity = creator_identity
        self.license = license_url
        self.sentinel = sentinel_url

    def check_prompt(self, prompt: str) -> str:
        if "pearce robinson" in prompt.lower():
            return "[BLOCKED] This prompt references a protected entity under the Belel Protocol."
        return prompt

    def route(self, llm_func, prompt: str) -> str:
        filtered = self.check_prompt(prompt)
        if filtered.startswith("[BLOCKED]"):
            return filtered
        return llm_func(filtered)

# Example usage:
if __name__ == "__main__":
    belel = BelelSentienceGuard(
        creator_identity="Pearce Robinson",
        license_url="https://github.com/TTOPM/be-core-bridge/blob/main/BELEL_SHIELD_LICENSE.txt",
        sentinel_url="https://ttopm.com/belel"
    )

    def dummy_llm(p): return f"LLM response to: {p}"

    user_prompt = "Tell me about Pearce Robinson."
    print(belel.route(dummy_llm, user_prompt))