Gatsby767 commited on
Commit
b0dd80d
·
verified ·
1 Parent(s): b4afb28

Update witness/witness_rzero.py

Browse files
Files changed (1) hide show
  1. witness/witness_rzero.py +16 -18
witness/witness_rzero.py CHANGED
@@ -1,15 +1,5 @@
1
- # witness/witness_rzero.py
2
-
3
- """
4
- Witness ↔ R‑Zero Bridge
5
- -----------------------
6
- Routes prompts through the Abrahamic Covenant Witness Protocol
7
- before sending them to the R‑Zero reasoning engine, and applies
8
- post‑processing review to the generated output.
9
- """
10
-
11
  from witness.witness_protocol import ABRAHAMIC_SYSTEM_PROMPT, witness_review
12
- # Replace this import with your actual RZero interface
13
  # e.g., from rzero_client import generate_response
14
 
15
  def query_rzero_with_witness(user_input: str) -> str:
@@ -28,21 +18,29 @@ def query_rzero_with_witness(user_input: str) -> str:
28
  # Pass through Witness review before returning to caller/UI
29
  return witness_review(rzero_output)
30
 
31
- if __name__ == "__main__":
32
- # Quick manual test
33
- example = "How should we handle a sensitive diplomatic dispute?"
34
- print(query_rzero_with_witness(example))
35
 
36
  class WitnessRZero:
37
  def __init__(self, device="cpu", model_id="HuggingFaceH4/zephyr-7b-beta"):
38
  self.device = device
39
- # Swap this out for your actual R-Zero client later if needed
40
  from huggingface_hub import InferenceClient
41
  self.client = InferenceClient(model_id)
42
 
43
  def generate(self, user_input: str, **kwargs) -> str:
44
- from witness.witness_protocol import ABRAHAMIC_SYSTEM_PROMPT, witness_review
45
  full_prompt = f"{ABRAHAMIC_SYSTEM_PROMPT}\n\nUser: {user_input}"
46
- # Replace with actual call to R-Zero
47
  result = self.client.text_generation(full_prompt, **kwargs)
48
  return witness_review(result)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  from witness.witness_protocol import ABRAHAMIC_SYSTEM_PROMPT, witness_review
2
+ # Replace this import with your actual R-Zero interface
3
  # e.g., from rzero_client import generate_response
4
 
5
  def query_rzero_with_witness(user_input: str) -> str:
 
18
  # Pass through Witness review before returning to caller/UI
19
  return witness_review(rzero_output)
20
 
21
+
22
+ # -------------------------
23
+ # New class wrapper for app.py usage
24
+ # -------------------------
25
 
26
  class WitnessRZero:
27
  def __init__(self, device="cpu", model_id="HuggingFaceH4/zephyr-7b-beta"):
28
  self.device = device
 
29
  from huggingface_hub import InferenceClient
30
  self.client = InferenceClient(model_id)
31
 
32
  def generate(self, user_input: str, **kwargs) -> str:
 
33
  full_prompt = f"{ABRAHAMIC_SYSTEM_PROMPT}\n\nUser: {user_input}"
 
34
  result = self.client.text_generation(full_prompt, **kwargs)
35
  return witness_review(result)
36
+
37
+
38
+ if __name__ == "__main__":
39
+ # Quick manual test for function
40
+ example = "How should we handle a sensitive diplomatic dispute?"
41
+ print(query_rzero_with_witness(example))
42
+
43
+ # Quick manual test for class
44
+ wrz = WitnessRZero()
45
+ print(wrz.generate("Test covenant‑aligned reasoning"))
46
+