File size: 1,192 Bytes
6dc9d46
 
 
 
 
 
 
 
 
 
 
 
9659593
6dc9d46
 
9659593
6dc9d46
9659593
6dc9d46
 
 
9659593
6dc9d46
 
 
 
 
 
 
 
 
 
 
 
9659593
 
6dc9d46
696f787
6dc9d46
 
696f787
6dc9d46
 
 
696f787
6dc9d46
696f787
6dc9d46
 
 
 
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
"""
Quick demo script to test the chatbot with pre-defined inputs
"""

import subprocess
import sys

# Test inputs
test_cases = [
    "help",  # Show biomarker help
    "glucose 185, HbA1c 8.2, cholesterol 235, triglycerides 210, HDL 38",  # Diabetes case
    "n",  # Don't save report
    "quit",  # Exit
]

print("=" * 70)
print("CLI Chatbot Demo Test")
print("=" * 70)
print("\nThis will run the chatbot with pre-defined inputs:")
for i, case in enumerate(test_cases, 1):
    print(f"  {i}. {case}")
print("\n" + "=" * 70 + "\n")

# Prepare input string
input_str = "\n".join(test_cases) + "\n"

# Run the chatbot with piped input
try:
    result = subprocess.run(
        [sys.executable, "scripts/chat.py"],
        input=input_str,
        capture_output=True,
        text=True,
        timeout=120,
        encoding="utf-8",
        errors="replace",
    )

    print("STDOUT:")
    print(result.stdout)

    if result.stderr:
        print("\nSTDERR:")
        print(result.stderr)

    print(f"\nExit code: {result.returncode}")

except subprocess.TimeoutExpired:
    print("⚠️ Test timed out after 120 seconds")
except Exception as e:
    print(f"❌ Error running test: {e}")