Spaces:
Sleeping
Sleeping
Update witness/witness_rzero.py
Browse files- witness/witness_rzero.py +14 -0
witness/witness_rzero.py
CHANGED
@@ -32,3 +32,17 @@ if __name__ == "__main__":
|
|
32 |
# Quick manual test
|
33 |
example = "How should we handle a sensitive diplomatic dispute?"
|
34 |
print(query_rzero_with_witness(example))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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)
|