-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_all_examples.py
More file actions
52 lines (43 loc) · 1.48 KB
/
test_all_examples.py
File metadata and controls
52 lines (43 loc) · 1.48 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
# -*- coding: utf-8 -*-
from __future__ import annotations
import os
import subprocess
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parent
API_KEY = os.getenv('API_KEY_OVERRIDE', 'YOUR_API_KEY_HERE')
BASE_URL = os.getenv('BASE_URL_OVERRIDE', 'https://rahyana.ir/api/v1')
EXAMPLES = [
('chat-completions/basic_chat.py', 'Basic Chat'),
('chat-completions/streaming_chat.py', 'Streaming Chat'),
('chat-completions/json_mode.py', 'JSON Mode'),
('models/get_models.py', 'Get Models'),
('completions/legacy_completions.py', 'Legacy Completions'),
# Tools (smoke)
('ai-tools/test_generator.py', 'AI Test Generator'),
('ai-tools/performance_monitor.py', 'AI Performance Monitor'),
('ai-tools/docs_generator.py', 'AI Docs Generator'),
('ai-tools/code_reviewer.py', 'AI Code Reviewer'),
]
def run_example(rel_path: str) -> bool:
path = ROOT / rel_path
print("\n[TEST] Running:", rel_path)
env = os.environ.copy()
env['API_KEY_OVERRIDE'] = API_KEY
env['BASE_URL_OVERRIDE'] = BASE_URL
try:
subprocess.run([sys.executable, str(path)], check=True, env=env, timeout=90)
print('[OK] PASS')
return True
except Exception as e:
print('[FAIL]', e)
return False
def main() -> None:
passed = 0
for rel, _ in EXAMPLES:
if run_example(rel):
passed += 1
total = len(EXAMPLES)
print(f"\n[SUMMARY] Results: {passed}/{total} passed")
if __name__ == '__main__':
main()