Varshithdharmajv commited on
Commit
1349c00
·
verified ·
1 Parent(s): b0c6930

Upload test_calculus_pipeline.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. test_calculus_pipeline.py +53 -53
test_calculus_pipeline.py CHANGED
@@ -1,53 +1,53 @@
1
- import os
2
- import sys
3
- import time
4
-
5
- # Ensure root is in path
6
- PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__)))
7
- if PROJECT_ROOT not in sys.path:
8
- sys.path.insert(0, PROJECT_ROOT)
9
-
10
- from services.core_engine.pipeline_streamer import run_neurosymbolic_pipeline_stream
11
-
12
- def test_hard_problem():
13
- problem = "Evaluate the definite integral of x * e^x from x=0 to x=1."
14
- steps = [
15
- "Use integration by parts: integral u dv = uv - integral v du",
16
- "Let u = x, so du = dx. Let dv = e^x dx, so v = e^x.",
17
- "integral_0^1 x e^x dx = [x e^x]_0^1 - integral_0^1 e^x dx",
18
- "= (1 * e^1 - 0 * e^0) - [e^x]_0^1",
19
- "= e - (e^1 - e^0)",
20
- "= e - e + 1 = 1"
21
- ]
22
-
23
- print(f"Testing Problem: {problem}")
24
- print("Dispatching to MVM2 Ensemble...")
25
-
26
- results = None
27
- for partial_res in run_neurosymbolic_pipeline_stream(
28
- problem=problem,
29
- steps=steps,
30
- model_name="MVM2 Ensemble"
31
- ):
32
- if partial_res["type"] == "partial":
33
- agent = partial_res["agent_name"]
34
- ans = partial_res["agent_result"].get("final_answer")
35
- print(f" [OK] Agent {agent} produced answer: {ans}")
36
- elif partial_res["type"] == "final":
37
- results = partial_res
38
-
39
- if results:
40
- consensus = results.get("consensus", {})
41
- print("\n" + "="*40)
42
- print("FINAL VERIFICATION RESULT")
43
- print("="*40)
44
- print(f"Verdict: {consensus.get('final_verdict')}")
45
- print(f"Answer: {consensus.get('verified_answer')}")
46
- print(f"Score: {consensus.get('overall_confidence'):.3f}")
47
- print(f"Confidence: {consensus.get('overall_confidence', 0)*100:.1f}%")
48
- print("="*40)
49
- else:
50
- print("Failed to get results from pipeline.")
51
-
52
- if __name__ == "__main__":
53
- test_hard_problem()
 
1
+ import os
2
+ import sys
3
+ import time
4
+
5
+ # Ensure root is in path
6
+ PROJECT_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__)))
7
+ if PROJECT_ROOT not in sys.path:
8
+ sys.path.insert(0, PROJECT_ROOT)
9
+
10
+ from services.core_engine.pipeline_streamer import run_neurosymbolic_pipeline_stream
11
+
12
+ def test_hard_problem():
13
+ problem = "Evaluate the definite integral of x * e^x from x=0 to x=1."
14
+ steps = [
15
+ "Use integration by parts: integral u dv = uv - integral v du",
16
+ "Let u = x, so du = dx. Let dv = e^x dx, so v = e^x.",
17
+ "integral_0^1 x e^x dx = [x e^x]_0^1 - integral_0^1 e^x dx",
18
+ "= (1 * e^1 - 0 * e^0) - [e^x]_0^1",
19
+ "= e - (e^1 - e^0)",
20
+ "= e - e + 1 = 1"
21
+ ]
22
+
23
+ print(f"Testing Problem: {problem}")
24
+ print("Dispatching to MVM2 Ensemble...")
25
+
26
+ results = None
27
+ for partial_res in run_neurosymbolic_pipeline_stream(
28
+ problem=problem,
29
+ steps=steps,
30
+ model_name="MVM2 Ensemble"
31
+ ):
32
+ if partial_res["type"] == "partial":
33
+ agent = partial_res["agent_name"]
34
+ ans = partial_res["agent_result"].get("final_answer")
35
+ print(f" [OK] Agent {agent} produced answer: {ans}")
36
+ elif partial_res["type"] == "final":
37
+ results = partial_res
38
+
39
+ if results:
40
+ consensus = results.get("consensus", {})
41
+ print("\n" + "="*40)
42
+ print("FINAL VERIFICATION RESULT")
43
+ print("="*40)
44
+ print(f"Verdict: {consensus.get('final_verdict')}")
45
+ print(f"Answer: {consensus.get('verified_answer')}")
46
+ print(f"Score: {consensus.get('overall_confidence'):.3f}")
47
+ print(f"Confidence: {consensus.get('overall_confidence', 0)*100:.1f}%")
48
+ print("="*40)
49
+ else:
50
+ print("Failed to get results from pipeline.")
51
+
52
+ if __name__ == "__main__":
53
+ test_hard_problem()