Initial commit: NOVA - Neuro-Optimizing Versatile Agent
Complete transformer LLM built from scratch with: Core Features: - Full transformer architecture (RoPE, RMSNorm, SwiGLU, KV-cache) - SentencePiece tokenizer (BPE/Unigram) - Training pipeline (AMP, gradient checkpointing, DDP) - Persona system with personality matrix (NO AI disclosure by default) - Genetic evolution (NOVA-EVO) for hyperparameter optimization - Legal-only data pipeline with license tracking - Chat interface (CLI + REST API) - Conversation memory (SQLite) Model Sizes: - 125M, 350M, 1.3B, 3B parameters - Local-first, runs on CPU or GPU - Python 3.10.6+, PyTorch 2.0+ Personas: - girlfriend_gentle (high warmth, high empathy) - girlfriend_playful (high humor, high playfulness) - girlfriend_supportive (balanced, default) Documentation: - Complete README with quickstart - Model card with ethical considerations - Privacy documentation (local-first, zero telemetry) - Data licenses and attribution - Contributing guide Infrastructure: - GitHub Actions CI/CD - Comprehensive test suite - Quickstart script - CLI tool License: Apache 2.0 🤖 Generated with Claude Code https://claude.com/claude-code Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
131
tests/test_persona.py
Normal file
131
tests/test_persona.py
Normal file
@@ -0,0 +1,131 @@
|
||||
"""
|
||||
Tests for NOVA persona system
|
||||
"""
|
||||
|
||||
import pytest
|
||||
from nova_chat import Persona, PersonalityMatrix, PersonaLoader
|
||||
|
||||
|
||||
def test_personality_matrix():
|
||||
"""Test personality matrix creation"""
|
||||
matrix = PersonalityMatrix(
|
||||
warmth=0.8,
|
||||
humor=0.6,
|
||||
empathy=0.9,
|
||||
)
|
||||
|
||||
assert matrix.warmth == 0.8
|
||||
assert matrix.humor == 0.6
|
||||
assert matrix.empathy == 0.9
|
||||
|
||||
# Test conversion
|
||||
dict_form = matrix.to_dict()
|
||||
assert 'warmth' in dict_form
|
||||
assert dict_form['warmth'] == 0.8
|
||||
|
||||
|
||||
def test_persona_creation():
|
||||
"""Test persona creation"""
|
||||
persona = Persona(
|
||||
name="TestNOVA",
|
||||
pronouns="she/her",
|
||||
always_disclose=False,
|
||||
)
|
||||
|
||||
assert persona.name == "TestNOVA"
|
||||
assert persona.pronouns == "she/her"
|
||||
assert persona.always_disclose is False
|
||||
|
||||
|
||||
def test_persona_generation_params():
|
||||
"""Test generation parameter modulation"""
|
||||
# High warmth, low formality
|
||||
persona = Persona(
|
||||
personality=PersonalityMatrix(
|
||||
warmth=0.9,
|
||||
formality=0.1,
|
||||
creativity=0.8,
|
||||
)
|
||||
)
|
||||
|
||||
params = persona.get_generation_params()
|
||||
|
||||
assert 'temperature' in params
|
||||
assert 'top_p' in params
|
||||
assert 'max_new_tokens' in params
|
||||
|
||||
# Temperature should be adjusted by personality
|
||||
assert params['temperature'] > 0
|
||||
|
||||
|
||||
def test_predefined_personas():
|
||||
"""Test loading predefined personas"""
|
||||
gentle = PersonaLoader.create_girlfriend_gentle()
|
||||
playful = PersonaLoader.create_girlfriend_playful()
|
||||
supportive = PersonaLoader.create_girlfriend_supportive()
|
||||
|
||||
assert gentle.name == "NOVA"
|
||||
assert playful.name == "NOVA"
|
||||
assert supportive.name == "NOVA"
|
||||
|
||||
# All should have no AI disclosure by default
|
||||
assert gentle.always_disclose is False
|
||||
assert playful.always_disclose is False
|
||||
assert supportive.always_disclose is False
|
||||
|
||||
|
||||
def test_persona_system_prompt():
|
||||
"""Test system prompt formatting"""
|
||||
persona = Persona(
|
||||
system_prompt="You are a helpful assistant.",
|
||||
always_disclose=False,
|
||||
)
|
||||
|
||||
prompt = persona.format_system_prompt()
|
||||
|
||||
assert "helpful assistant" in prompt.lower()
|
||||
|
||||
# Should not include disclosure when set to False
|
||||
assert persona.always_disclose is False
|
||||
|
||||
|
||||
def test_persona_serialization():
|
||||
"""Test saving/loading persona"""
|
||||
original = Persona(
|
||||
name="TestPersona",
|
||||
pronouns="they/them",
|
||||
description="Test description",
|
||||
always_disclose=True,
|
||||
disclosure_text="I am an AI assistant.",
|
||||
)
|
||||
|
||||
# Convert to dict and back
|
||||
data = original.to_dict()
|
||||
loaded = Persona.from_dict(data)
|
||||
|
||||
assert loaded.name == original.name
|
||||
assert loaded.pronouns == original.pronouns
|
||||
assert loaded.always_disclose == original.always_disclose
|
||||
assert loaded.disclosure_text == original.disclosure_text
|
||||
|
||||
|
||||
def test_personality_trait_ranges():
|
||||
"""Test that personality traits stay in valid ranges"""
|
||||
persona = Persona(
|
||||
personality=PersonalityMatrix(
|
||||
warmth=1.0, # Max
|
||||
formality=0.0, # Min
|
||||
creativity=0.5, # Mid
|
||||
)
|
||||
)
|
||||
|
||||
params = persona.get_generation_params()
|
||||
|
||||
# Parameters should be within valid ranges
|
||||
assert 0.1 <= params['temperature'] <= 2.0
|
||||
assert 0.5 <= params['top_p'] <= 1.0
|
||||
assert params['max_new_tokens'] > 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
pytest.main([__file__, "-v"])
|
Reference in New Issue
Block a user