-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathassistant_smoke_test.py
More file actions
86 lines (73 loc) · 2.28 KB
/
assistant_smoke_test.py
File metadata and controls
86 lines (73 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import os
import re
import sys
import json
import math
import time
import random
import hashlib
import logging
SCRIPT_PATH = r'C:\Users\User\Downloads\ForzeOS System.py'
def extract_class_src(path: str, classname: str) -> str:
src = open(path, 'r', encoding='utf-8').read()
start = src.find(f'class {classname}:')
if start == -1:
return ''
# Heuristic end marker: look for the next top-level comment marker we know follows the class
end_marker = '\n\n# --- Security helpers'
end = src.find(end_marker, start)
if end == -1:
# fallback: try to find two consecutive blank lines after start
m = re.search(r'\n\n\S', src[start:])
end = start + m.start() if m else len(src)
return src[start:end]
def main():
if not os.path.exists(SCRIPT_PATH):
print('ForzeOS System.py not found at', SCRIPT_PATH)
return
cls_src = extract_class_src(SCRIPT_PATH, 'EnhancedAssistantAI')
if not cls_src:
print('Could not extract EnhancedAssistantAI source from file')
return
# Prepare a safe globals environment with required names
g: dict = {}
logging.basicConfig(level=logging.INFO)
g['logger'] = logging.getLogger('smoke_test')
# minimal imports expected by the class
g['os'] = os
g['json'] = json
g['hashlib'] = hashlib
g['math'] = math
g['time'] = time
g['random'] = random
g['re'] = re
# Provide ASSISTANT_MEMORY_PATH default used by class signature
g['ASSISTANT_MEMORY_PATH'] = os.path.join(os.path.dirname(SCRIPT_PATH), 'assistant_memory_large.json')
try:
exec(cls_src, g)
except Exception as e:
print('Failed to exec class source:', e)
return
AIClass = g.get('EnhancedAssistantAI')
if AIClass is None:
print('EnhancedAssistantAI not found after exec')
return
mem_path = g['ASSISTANT_MEMORY_PATH']
a = AIClass(memory_path=mem_path, session_size=80)
qs = [
'merhaba',
'nasılsın',
'film öner',
'kod öğrenmek istiyorum',
'müzik aç'
]
for q in qs:
print('Q:', q)
try:
r = a.reply(q)
except Exception as e:
r = f'ERROR: {e}'
print('A:', r)
print('---')
if __name__ == '__main__':
main()