File size: 861 Bytes
454a778
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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']}")