-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
77 lines (67 loc) · 1.96 KB
/
main.py
File metadata and controls
77 lines (67 loc) · 1.96 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
"""Example 1: Basic Python code validation using vallm's default pipeline.
Demonstrates: syntax, import, and complexity validation (Tier 1 & 2).
"""
import json
import os
from pathlib import Path
from vallm import Proposal, validate, VallmSettings
# Good code — should PASS
good_code = """
def fibonacci(n: int) -> list[int]:
if n <= 0:
return []
if n == 1:
return [0]
fib = [0, 1]
for i in range(2, n):
fib.append(fib[i - 1] + fib[i - 2])
return fib
"""
# Bad code — has syntax error, should FAIL
bad_code = """
def broken_function(x, y)
return x + y
"""
# Complex code — should get warnings
complex_code = """
def overly_complex(a, b, c, d, e, f, g):
if a > 0:
if b > 0:
if c > 0:
if d > 0:
if e > 0:
if f > 0:
if g > 0:
return a + b + c + d + e + f + g
else:
return a + b + c + d + e + f
else:
return a + b + c + d + e
else:
return a + b + c + d
else:
return a + b + c
else:
return a + b
else:
return a
else:
return 0
"""
def main():
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).parent.parent.parent))
from examples.utils import run_validation_examples, save_analysis_data
all_results = run_validation_examples(
example_name="basic_validation",
good_code=good_code,
bad_code=bad_code,
complex_code=complex_code,
)
# Save all analysis data
save_analysis_data("basic_validation", all_results)
for name, data in all_results.items():
print(f"{name}: {data['verdict']} (score: {data['score']:.2f})")
if __name__ == "__main__":
main()