FerrellSyntheticIntelligence commited on
Commit ·
6e90547
1
Parent(s): 8deee89
Build real training controller and first curriculum module
Browse files
src/core/training_controller.py
CHANGED
|
@@ -1,12 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
class TrainingController:
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import json
|
| 2 |
+
import os
|
| 3 |
+
|
| 4 |
+
BASE_PATH = os.path.expanduser("~/vitalis_core")
|
| 5 |
+
|
| 6 |
class TrainingController:
|
| 7 |
+
def __init__(self):
|
| 8 |
+
self.curriculum_path = os.path.join(BASE_PATH, "storage/curriculum/modules")
|
| 9 |
+
self.log_path = os.path.join(BASE_PATH, "storage/benchmarks/training_log.txt")
|
| 10 |
+
|
| 11 |
+
def load_module(self, module_id):
|
| 12 |
+
path = os.path.join(self.curriculum_path, f"{module_id}.json")
|
| 13 |
+
if not os.path.exists(path):
|
| 14 |
+
return None
|
| 15 |
+
with open(path, 'r') as f:
|
| 16 |
+
return json.load(f)
|
| 17 |
+
|
| 18 |
+
def run_module(self, module_id, brain):
|
| 19 |
+
module = self.load_module(module_id)
|
| 20 |
+
if not module:
|
| 21 |
+
return {"status": "error", "message": f"Module {module_id} not found"}
|
| 22 |
+
results = []
|
| 23 |
+
for item in module.get("training_data", []):
|
| 24 |
+
response = brain.process(item["input"])
|
| 25 |
+
passed = item["expected"] in response
|
| 26 |
+
results.append({"input": item["input"], "response": response, "passed": passed})
|
| 27 |
+
self.log_results(module_id, results)
|
| 28 |
+
score = sum(1 for r in results if r["passed"]) / len(results) if results else 0
|
| 29 |
+
return {"status": "complete", "score": round(score, 2), "results": results}
|
| 30 |
+
|
| 31 |
+
def log_results(self, module_id, results):
|
| 32 |
+
with open(self.log_path, 'a') as f:
|
| 33 |
+
f.write(f"\nModule: {module_id}\n")
|
| 34 |
+
for r in results:
|
| 35 |
+
f.write(f" {r['input']} -> {r['response']} | {'PASS' if r['passed'] else 'FAIL'}\n")
|
storage/curriculum/modules/module_01.json
CHANGED
|
@@ -1 +1,13 @@
|
|
| 1 |
-
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"module_id": "module_01",
|
| 3 |
+
"title": "Basic Input Recognition",
|
| 4 |
+
"description": "Trains Vitalis to correctly categorize basic input types",
|
| 5 |
+
"training_data": [
|
| 6 |
+
{"input": "how do you work", "expected": "QUERY_DETECTED"},
|
| 7 |
+
{"input": "what are you", "expected": "QUERY_DETECTED"},
|
| 8 |
+
{"input": "train me on this", "expected": "TRAINING_SIGNAL"},
|
| 9 |
+
{"input": "learn from this data", "expected": "TRAINING_SIGNAL"},
|
| 10 |
+
{"input": "hello", "expected": "INPUT_RECEIVED"},
|
| 11 |
+
{"input": "build something new", "expected": "INPUT_RECEIVED"}
|
| 12 |
+
]
|
| 13 |
+
}
|