File size: 5,041 Bytes
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
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# RagBot API - Quick Start Script (PowerShell)
# Tests all API endpoints

Write-Host "============================================================" -ForegroundColor Cyan
Write-Host "RagBot API - Quick Test Suite" -ForegroundColor Cyan
Write-Host "============================================================" -ForegroundColor Cyan
Write-Host ""

$BASE_URL = "http://localhost:8000"

# Check if API is running
Write-Host "1. Checking if API is running..." -ForegroundColor Yellow
try {
    $response = Invoke-RestMethod -Uri "$BASE_URL/" -Method Get
    Write-Host "   βœ“ API is online" -ForegroundColor Green
    Write-Host "   Version: $($response.version)" -ForegroundColor Gray
} catch {
    Write-Host "   βœ— API is not running!" -ForegroundColor Red
    Write-Host "   Start with: python -m uvicorn app.main:app --port 8000" -ForegroundColor Yellow
    exit 1
}

Write-Host ""

# Health Check
Write-Host "2. Health Check..." -ForegroundColor Yellow
try {
    $health = Invoke-RestMethod -Uri "$BASE_URL/api/v1/health" -Method Get
    Write-Host "   Status: $($health.status)" -ForegroundColor Green
    Write-Host "   Ollama: $($health.ollama_status)" -ForegroundColor Gray
    Write-Host "   Vector Store: $($health.vector_store_loaded)" -ForegroundColor Gray
} catch {
    Write-Host "   βœ— Health check failed: $_" -ForegroundColor Red
}

Write-Host ""

# List Biomarkers
Write-Host "3. Fetching Biomarkers List..." -ForegroundColor Yellow
try {
    $biomarkers = Invoke-RestMethod -Uri "$BASE_URL/api/v1/biomarkers" -Method Get
    Write-Host "   βœ“ Found $($biomarkers.total_count) biomarkers" -ForegroundColor Green
    Write-Host "   Examples: Glucose, HbA1c, Cholesterol, Hemoglobin..." -ForegroundColor Gray
} catch {
    Write-Host "   βœ— Failed to fetch biomarkers: $_" -ForegroundColor Red
}

Write-Host ""

# Test Example Endpoint
Write-Host "4. Testing Example Endpoint..." -ForegroundColor Yellow
try {
    $example = Invoke-RestMethod -Uri "$BASE_URL/api/v1/example" -Method Get
    Write-Host "   βœ“ Example analysis completed" -ForegroundColor Green
    Write-Host "   Request ID: $($example.request_id)" -ForegroundColor Gray
    Write-Host "   Prediction: $($example.prediction.disease) ($([math]::Round($example.prediction.confidence * 100))% confidence)" -ForegroundColor Gray
    Write-Host "   Processing Time: $([math]::Round($example.processing_time_ms))ms" -ForegroundColor Gray
} catch {
    Write-Host "   βœ— Example analysis failed: $_" -ForegroundColor Red
}

Write-Host ""

# Test Structured Analysis
Write-Host "5. Testing Structured Analysis..." -ForegroundColor Yellow
$structuredRequest = @{
    biomarkers = @{
        Glucose = 140
        HbA1c = 7.5
    }
    patient_context = @{
        age = 45
        gender = "female"
    }
} | ConvertTo-Json

try {
    $structured = Invoke-RestMethod -Uri "$BASE_URL/api/v1/analyze/structured" -Method Post -Body $structuredRequest -ContentType "application/json"
    Write-Host "   βœ“ Structured analysis completed" -ForegroundColor Green
    Write-Host "   Request ID: $($structured.request_id)" -ForegroundColor Gray
    Write-Host "   Prediction: $($structured.prediction.disease) ($([math]::Round($structured.prediction.confidence * 100))% confidence)" -ForegroundColor Gray
    Write-Host "   Biomarker Flags: $($structured.analysis.biomarker_flags.Count)" -ForegroundColor Gray
    Write-Host "   Safety Alerts: $($structured.analysis.safety_alerts.Count)" -ForegroundColor Gray
} catch {
    Write-Host "   βœ— Structured analysis failed: $_" -ForegroundColor Red
}

Write-Host ""

# Test Natural Language Analysis (requires Ollama)
Write-Host "6. Testing Natural Language Analysis..." -ForegroundColor Yellow
$naturalRequest = @{
    message = "My glucose is 165 and HbA1c is 7.8"
    patient_context = @{
        age = 50
        gender = "male"
    }
} | ConvertTo-Json

try {
    $natural = Invoke-RestMethod -Uri "$BASE_URL/api/v1/analyze/natural" -Method Post -Body $naturalRequest -ContentType "application/json"
    Write-Host "   βœ“ Natural language analysis completed" -ForegroundColor Green
    Write-Host "   Request ID: $($natural.request_id)" -ForegroundColor Gray
    Write-Host "   Extracted: $($natural.extracted_biomarkers.Keys -join ', ')" -ForegroundColor Gray
    Write-Host "   Prediction: $($natural.prediction.disease) ($([math]::Round($natural.prediction.confidence * 100))% confidence)" -ForegroundColor Gray
} catch {
    Write-Host "   βœ— Natural language analysis failed: $_" -ForegroundColor Red
    Write-Host "   Make sure Ollama is running: ollama serve" -ForegroundColor Yellow
}

Write-Host ""
Write-Host "============================================================" -ForegroundColor Cyan
Write-Host "βœ“ Test Suite Complete!" -ForegroundColor Green
Write-Host "============================================================" -ForegroundColor Cyan
Write-Host ""
Write-Host "API Documentation: $BASE_URL/docs" -ForegroundColor Cyan
Write-Host "ReDoc: $BASE_URL/redoc" -ForegroundColor Cyan
Write-Host ""