Vitalis_Core / examples /bolt_on_hf.py
FerrellSyntheticIntelligence
Restructure as bolt-on cognitive framework
454a778
Raw
History Blame Contribute Delete
861 Bytes
from vitalis import CognitiveLayer
# Option A: No model (cognitive layer operates standalone for testing)
brain = CognitiveLayer()
result = brain.process("Hello, what is synthetic intelligence?")
print(result["response"])
# Option B: Bolt onto any callable model
def my_model(prompt):
return f"Simulated model response to: {prompt[:50]}..."
brain.bolt_to(my_model)
result = brain.process("What is the capital of France?")
print(f"[confidence={result['confidence']}] {result['response']}")
print(f"truthful={result['truthful']}, sandbox={result['sandbox_passed']}")
# Option C: Bolt onto HuggingFace pipeline
from transformers import pipeline
pipe = pipeline("text-generation", model="microsoft/phi-2")
hf_brain = CognitiveLayer(pipe)
result = hf_brain.process("Explain gravity in one sentence.")
print(f"[{result['confidence']}] {result['response']}")