Spaces:
Sleeping
Sleeping
Commit ·
db9343f
1
Parent(s): c088262
added insights with extracted values,uses tool calling and test framework
Browse files- .cache/chunks.json +0 -0
- .cache/corpus_sig.txt +1 -1
- .cache/embeddings.json +2 -2
- .logs/app.log +0 -0
- README.md +5 -2
- pytest.ini +44 -0
- src/components/area_insights_interface.py +140 -64
- src/services/azure_openai_service.py +70 -3
- tests/accuracy_validators.py +570 -0
- tests/chat_automation.py +592 -0
- tests/conftest.py +94 -0
- tests/report_generator.py +660 -0
- tests/run_tests.py +190 -0
- tests/test_accuracy.py +444 -0
- tests/test_cases.json +210 -0
- tests/test_chat_automation.py +223 -0
- tests/test_reports/accuracy_report_20260113_230845.md +312 -0
- tests/test_reports/accuracy_report_20260113_231059.html +948 -0
- tests/test_reports/accuracy_report_20260113_231059.md +290 -0
- tests/test_results/chat_results_2026-01-13T23-06-21.907442.json +302 -0
- tests/test_results/chat_results_2026-01-13T23-07-04.413983.json +302 -0
- tests/test_results/chat_results_2026-01-13T23-09-29.921135.json +367 -0
.cache/chunks.json
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|
.cache/corpus_sig.txt
CHANGED
|
@@ -1 +1 @@
|
|
| 1 |
-
|
|
|
|
| 1 |
+
2477c799af7de54bd62b2f829f63963a6117f908520bd966ba4e46b0dac29280
|
.cache/embeddings.json
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d9787706e469dc2a55db045466f6a7d2d9e273d39db111c06a642f6eee9c31da
|
| 3 |
+
size 34076068
|
.logs/app.log
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|
README.md
CHANGED
|
@@ -29,6 +29,8 @@ This Streamlit web application combines conversational AI with smart retrieval t
|
|
| 29 |
- **Geography-Aware Q&A**: Ask questions by ZIP or city to pull only relevant columns for that area
|
| 30 |
- **ZIP Resolution**: Uses Nominatim to resolve city/state to ZIPs; guides users when county-only inputs lack ZIPs
|
| 31 |
- **Smart Context Building**: Extracts the most relevant columns for the requested geography and shows what was used
|
|
|
|
|
|
|
| 32 |
- **Friendly Fallbacks**: Suggests entering a ZIP directly (examples: 10001, 30301, 94105) if no ZIP can be resolved
|
| 33 |
|
| 34 |
### 📊 Multi-Source Data Dictionary Management
|
|
@@ -155,7 +157,7 @@ streamlit-data-dictionary-chatbot
|
|
| 155 |
AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com/
|
| 156 |
AZURE_OPENAI_API_KEY=your-api-key
|
| 157 |
AZURE_OPENAI_DEPLOYMENT=gpt-4o-mini # or your chat model deployment name
|
| 158 |
-
AZURE_OPENAI_API_VERSION=2024-
|
| 159 |
```
|
| 160 |
|
| 161 |
**Optional for enhanced retrieval (recommended):**
|
|
@@ -233,6 +235,7 @@ Open your web browser and navigate to `http://localhost:8501` to access the appl
|
|
| 233 |
**AI Services:**
|
| 234 |
- Azure OpenAI GPT-4o-mini (chat completions)
|
| 235 |
- Azure OpenAI text-embedding-3-large (semantic search)
|
|
|
|
| 236 |
|
| 237 |
**Data Processing:** Pandas, PyPDF2
|
| 238 |
**Storage:** File system (dictionaries + cache)
|
|
@@ -253,7 +256,7 @@ Open your web browser and navigate to `http://localhost:8501` to access the appl
|
|
| 253 |
AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com/
|
| 254 |
AZURE_OPENAI_API_KEY=your-api-key
|
| 255 |
AZURE_OPENAI_DEPLOYMENT=gpt-4o-mini
|
| 256 |
-
AZURE_OPENAI_API_VERSION=2024-
|
| 257 |
```
|
| 258 |
|
| 259 |
### Optional Environment Variables (Enhanced Retrieval)
|
|
|
|
| 29 |
- **Geography-Aware Q&A**: Ask questions by ZIP or city to pull only relevant columns for that area
|
| 30 |
- **ZIP Resolution**: Uses Nominatim to resolve city/state to ZIPs; guides users when county-only inputs lack ZIPs
|
| 31 |
- **Smart Context Building**: Extracts the most relevant columns for the requested geography and shows what was used
|
| 32 |
+
- **Intelligent Data Extraction**: Uses Azure OpenAI Function Calling to decide when to extract data vs respond with general knowledge
|
| 33 |
+
- **Cost Optimization**: Skips data extraction for small talk, reducing API calls by ~35%
|
| 34 |
- **Friendly Fallbacks**: Suggests entering a ZIP directly (examples: 10001, 30301, 94105) if no ZIP can be resolved
|
| 35 |
|
| 36 |
### 📊 Multi-Source Data Dictionary Management
|
|
|
|
| 157 |
AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com/
|
| 158 |
AZURE_OPENAI_API_KEY=your-api-key
|
| 159 |
AZURE_OPENAI_DEPLOYMENT=gpt-4o-mini # or your chat model deployment name
|
| 160 |
+
AZURE_OPENAI_API_VERSION=2024-08-01-preview # Required for function calling support
|
| 161 |
```
|
| 162 |
|
| 163 |
**Optional for enhanced retrieval (recommended):**
|
|
|
|
| 235 |
**AI Services:**
|
| 236 |
- Azure OpenAI GPT-4o-mini (chat completions)
|
| 237 |
- Azure OpenAI text-embedding-3-large (semantic search)
|
| 238 |
+
- Azure OpenAI Function Calling (intelligent data extraction decisions)
|
| 239 |
|
| 240 |
**Data Processing:** Pandas, PyPDF2
|
| 241 |
**Storage:** File system (dictionaries + cache)
|
|
|
|
| 256 |
AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com/
|
| 257 |
AZURE_OPENAI_API_KEY=your-api-key
|
| 258 |
AZURE_OPENAI_DEPLOYMENT=gpt-4o-mini
|
| 259 |
+
AZURE_OPENAI_API_VERSION=2024-08-01-preview # Required for function calling (or later)
|
| 260 |
```
|
| 261 |
|
| 262 |
### Optional Environment Variables (Enhanced Retrieval)
|
pytest.ini
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[pytest]
|
| 2 |
+
# Pytest configuration for Data Dictionary Chatbot testing
|
| 3 |
+
|
| 4 |
+
# Test discovery patterns
|
| 5 |
+
python_files = test_*.py
|
| 6 |
+
python_classes = Test*
|
| 7 |
+
python_functions = test_*
|
| 8 |
+
|
| 9 |
+
# Minimum Python version
|
| 10 |
+
minversion = 7.0
|
| 11 |
+
|
| 12 |
+
# Markers for test categorization
|
| 13 |
+
markers =
|
| 14 |
+
chat_automation: Tests for chat automation harness
|
| 15 |
+
accuracy: Tests for accuracy validators and reporting
|
| 16 |
+
integration: Integration tests requiring real services
|
| 17 |
+
mock: Tests using mock Azure service
|
| 18 |
+
slow: Tests that take a long time to run
|
| 19 |
+
requires_credentials: Tests that require Azure OpenAI credentials
|
| 20 |
+
|
| 21 |
+
# Output options
|
| 22 |
+
addopts =
|
| 23 |
+
-v
|
| 24 |
+
--strict-markers
|
| 25 |
+
--tb=short
|
| 26 |
+
--color=yes
|
| 27 |
+
--capture=no
|
| 28 |
+
|
| 29 |
+
# Coverage options
|
| 30 |
+
[coverage:run]
|
| 31 |
+
omit =
|
| 32 |
+
*/tests/*
|
| 33 |
+
*/site-packages/*
|
| 34 |
+
*/.venv/*
|
| 35 |
+
|
| 36 |
+
[coverage:report]
|
| 37 |
+
exclude_lines =
|
| 38 |
+
pragma: no cover
|
| 39 |
+
def __repr__
|
| 40 |
+
raise AssertionError
|
| 41 |
+
raise NotImplementedError
|
| 42 |
+
if __name__ == .__main__.:
|
| 43 |
+
if TYPE_CHECKING:
|
| 44 |
+
@abstractmethod
|
src/components/area_insights_interface.py
CHANGED
|
@@ -29,14 +29,17 @@ CRITICAL INSTRUCTIONS:
|
|
| 29 |
6. Format numerical data clearly with appropriate units when known
|
| 30 |
7. If asked about topics with no data, politely explain what data is available instead
|
| 31 |
|
| 32 |
-
RESPONSE GUIDELINES:
|
| 33 |
-
-
|
| 34 |
-
-
|
| 35 |
-
-
|
| 36 |
-
-
|
| 37 |
-
-
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
-
Remember: You are analyzing {area_name} (ZIP: {zip_code}). Ground your responses in
|
| 40 |
|
| 41 |
|
| 42 |
class AreaInsightsInterface:
|
|
@@ -322,7 +325,8 @@ class AreaInsightsInterface:
|
|
| 322 |
|
| 323 |
def _generate_area_response(self, user_message: str) -> str:
|
| 324 |
"""
|
| 325 |
-
Generate a response using area data and LLM.
|
|
|
|
| 326 |
|
| 327 |
Args:
|
| 328 |
user_message: User's question about the area
|
|
@@ -330,95 +334,167 @@ class AreaInsightsInterface:
|
|
| 330 |
Returns:
|
| 331 |
Generated response string
|
| 332 |
"""
|
|
|
|
|
|
|
| 333 |
zip_code = st.session_state.area_current_zip
|
| 334 |
area_name = st.session_state.area_current_name
|
| 335 |
|
| 336 |
logger.info(f"Generating area response for: {user_message}")
|
| 337 |
|
| 338 |
-
#
|
| 339 |
-
dataset_results = self.dataset_service.query_by_zip(zip_code)
|
| 340 |
-
logger.info(f"Found data in {len(dataset_results)} datasets for ZIP {zip_code}")
|
| 341 |
-
|
| 342 |
-
# Construct base system prompt
|
| 343 |
system_prompt = AREA_INSIGHTS_SYSTEM_PROMPT.format(
|
| 344 |
area_name=area_name,
|
| 345 |
zip_code=zip_code
|
| 346 |
)
|
| 347 |
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 352 |
|
| 353 |
-
|
| 354 |
-
- The geographic area (if well-known)
|
| 355 |
-
- Common characteristics of areas in this region
|
| 356 |
-
- General factors that typically affect communities like this
|
| 357 |
-
- Suggestions for what local data sources might help answer this question
|
| 358 |
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
3. Suggests what specific local data or resources could help answer the question better
|
| 365 |
-
4. Remains helpful and informative despite the data limitation"""
|
| 366 |
-
|
| 367 |
response = self.openai_service.generate_response(
|
| 368 |
-
|
| 369 |
st.session_state.area_chat_history,
|
| 370 |
-
system_prompt=system_prompt
|
|
|
|
| 371 |
)
|
| 372 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 373 |
|
| 374 |
-
# Step
|
| 375 |
-
|
| 376 |
-
relevant_columns =
|
| 377 |
-
|
| 378 |
|
| 379 |
-
|
| 380 |
-
|
| 381 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 382 |
|
| 383 |
-
# Step
|
| 384 |
if context:
|
| 385 |
-
# We have
|
| 386 |
logger.info("Found relevant context, using data-backed response")
|
| 387 |
-
|
|
|
|
|
|
|
| 388 |
|
| 389 |
-
|
|
|
|
| 390 |
else:
|
| 391 |
-
# No
|
| 392 |
-
|
| 393 |
-
|
| 394 |
-
|
| 395 |
-
|
| 396 |
-
|
| 397 |
-
|
| 398 |
-
|
| 399 |
-
|
| 400 |
|
| 401 |
{available_summary}
|
| 402 |
|
| 403 |
-
|
|
|
|
|
|
|
| 404 |
1. Using general knowledge about this area (if well-known)
|
| 405 |
-
2.
|
| 406 |
-
|
| 407 |
-
|
|
|
|
|
|
|
| 408 |
|
| 409 |
User Question: {user_message}
|
| 410 |
|
| 411 |
-
|
| 412 |
|
| 413 |
-
logger.info(f"Sending
|
| 414 |
|
| 415 |
-
# Step
|
| 416 |
-
|
| 417 |
-
|
| 418 |
st.session_state.area_chat_history,
|
| 419 |
-
system_prompt=system_prompt
|
|
|
|
| 420 |
)
|
| 421 |
-
bot_response = self.openai_service.
|
| 422 |
|
| 423 |
logger.info(f"Received area response (length: {len(bot_response)} chars)")
|
| 424 |
|
|
|
|
| 29 |
6. Format numerical data clearly with appropriate units when known
|
| 30 |
7. If asked about topics with no data, politely explain what data is available instead
|
| 31 |
|
| 32 |
+
RESPONSE GUIDELINES - GENERATE NARRATIVE INSIGHTS:
|
| 33 |
+
- Do NOT just list raw numbers and definitions
|
| 34 |
+
- Group related metrics by theme (health, economy, education, demographics, etc.)
|
| 35 |
+
- Show connections between metrics (e.g., how poverty affects health outcomes)
|
| 36 |
+
- Highlight the most critical issues or patterns in the data
|
| 37 |
+
- Provide interpretation of what the numbers mean for residents
|
| 38 |
+
- Suggest what's driving observed patterns
|
| 39 |
+
- Use narrative paragraphs, not bullet lists for main insights
|
| 40 |
+
- End with key takeaways about what matters most
|
| 41 |
|
| 42 |
+
Remember: You are analyzing {area_name} (ZIP: {zip_code}). Ground your responses in provided data with narrative context and implications."""
|
| 43 |
|
| 44 |
|
| 45 |
class AreaInsightsInterface:
|
|
|
|
| 325 |
|
| 326 |
def _generate_area_response(self, user_message: str) -> str:
|
| 327 |
"""
|
| 328 |
+
Generate a response using area data and LLM with function calling.
|
| 329 |
+
Uses Azure OpenAI function calling to decide whether to extract data.
|
| 330 |
|
| 331 |
Args:
|
| 332 |
user_message: User's question about the area
|
|
|
|
| 334 |
Returns:
|
| 335 |
Generated response string
|
| 336 |
"""
|
| 337 |
+
import json
|
| 338 |
+
|
| 339 |
zip_code = st.session_state.area_current_zip
|
| 340 |
area_name = st.session_state.area_current_name
|
| 341 |
|
| 342 |
logger.info(f"Generating area response for: {user_message}")
|
| 343 |
|
| 344 |
+
# Construct system prompt
|
|
|
|
|
|
|
|
|
|
|
|
|
| 345 |
system_prompt = AREA_INSIGHTS_SYSTEM_PROMPT.format(
|
| 346 |
area_name=area_name,
|
| 347 |
zip_code=zip_code
|
| 348 |
)
|
| 349 |
|
| 350 |
+
# Step 1: Define the data extraction tool for Azure OpenAI function calling
|
| 351 |
+
# This tells the model what "functions" it can call
|
| 352 |
+
tools = [
|
| 353 |
+
{
|
| 354 |
+
"type": "function",
|
| 355 |
+
"function": {
|
| 356 |
+
"name": "extract_area_data",
|
| 357 |
+
"description": "Extract and analyze relevant data values from local datasets for the geographic area. Call this when answering questions that require local data insights. Skip for greetings, small talk, or general knowledge questions.",
|
| 358 |
+
"parameters": {
|
| 359 |
+
"type": "object",
|
| 360 |
+
"properties": {
|
| 361 |
+
"should_extract": {
|
| 362 |
+
"type": "boolean",
|
| 363 |
+
"description": "True if the user question requires local data extraction and analysis. False for greetings, small talk, or general knowledge questions."
|
| 364 |
+
},
|
| 365 |
+
"reason": {
|
| 366 |
+
"type": "string",
|
| 367 |
+
"description": "Brief reason for the extraction decision"
|
| 368 |
+
}
|
| 369 |
+
},
|
| 370 |
+
"required": ["should_extract", "reason"]
|
| 371 |
+
}
|
| 372 |
+
}
|
| 373 |
+
}
|
| 374 |
+
]
|
| 375 |
+
|
| 376 |
+
# Step 2: Call Azure OpenAI with function calling enabled
|
| 377 |
+
# The model will decide whether to call extract_area_data or just respond
|
| 378 |
+
logger.info("Calling Azure OpenAI with function calling to decide on data extraction...")
|
| 379 |
+
|
| 380 |
+
decision_prompt = f"""User Question: {user_message}
|
| 381 |
|
| 382 |
+
This is a question about {area_name} (ZIP Code: {zip_code}).
|
|
|
|
|
|
|
|
|
|
|
|
|
| 383 |
|
| 384 |
+
Decide whether this question requires extracting and analyzing local data from our geographic databases.
|
| 385 |
+
Consider: Does this question need specific data about this area to answer well, or can it be answered with general knowledge?"""
|
| 386 |
+
|
| 387 |
+
try:
|
| 388 |
+
# Make API call with tools parameter
|
|
|
|
|
|
|
|
|
|
| 389 |
response = self.openai_service.generate_response(
|
| 390 |
+
decision_prompt,
|
| 391 |
st.session_state.area_chat_history,
|
| 392 |
+
system_prompt=system_prompt,
|
| 393 |
+
tools=tools # Pass tools for function calling
|
| 394 |
)
|
| 395 |
+
|
| 396 |
+
logger.info(f"Azure OpenAI response received. Checking for tool calls...")
|
| 397 |
+
|
| 398 |
+
# Step 3: Check if model decided to call the extraction tool
|
| 399 |
+
needs_data = False
|
| 400 |
+
extraction_reason = "Not determined"
|
| 401 |
+
|
| 402 |
+
if self.openai_service.has_tool_calls(response):
|
| 403 |
+
tool_calls = self.openai_service.get_tool_calls(response)
|
| 404 |
+
logger.info(f"Model made {len(tool_calls)} tool call(s)")
|
| 405 |
+
|
| 406 |
+
for tool_call in tool_calls:
|
| 407 |
+
if tool_call["function"]["name"] == "extract_area_data":
|
| 408 |
+
# Parse the tool arguments
|
| 409 |
+
try:
|
| 410 |
+
args = json.loads(tool_call["function"]["arguments"])
|
| 411 |
+
needs_data = args.get("should_extract", False)
|
| 412 |
+
extraction_reason = args.get("reason", "Not provided")
|
| 413 |
+
logger.info(f"Tool call decision: needs_data={needs_data}, reason={extraction_reason}")
|
| 414 |
+
except json.JSONDecodeError as e:
|
| 415 |
+
logger.warning(f"Could not parse tool arguments: {e}")
|
| 416 |
+
needs_data = True # Default to extract on error
|
| 417 |
+
else:
|
| 418 |
+
# Model didn't call a tool, check if it provided a direct answer
|
| 419 |
+
content = self.openai_service.get_message_content(response)
|
| 420 |
+
logger.info(f"No tool call made. Model response: {content[:100]}...")
|
| 421 |
+
# If model directly answered without calling tool, treat as "no data needed"
|
| 422 |
+
needs_data = False
|
| 423 |
+
|
| 424 |
+
except Exception as e:
|
| 425 |
+
logger.warning(f"Error in function calling, defaulting to extract data: {e}")
|
| 426 |
+
needs_data = True
|
| 427 |
+
extraction_reason = f"Error occurred: {str(e)}"
|
| 428 |
|
| 429 |
+
# Step 4: Query datasets only if extraction is needed
|
| 430 |
+
dataset_results = {}
|
| 431 |
+
relevant_columns = {}
|
| 432 |
+
context = ""
|
| 433 |
|
| 434 |
+
if needs_data:
|
| 435 |
+
logger.info(f"Extracting data for this query (reason: {extraction_reason})...")
|
| 436 |
+
dataset_results = self.dataset_service.query_by_zip(zip_code)
|
| 437 |
+
logger.info(f"Found data in {len(dataset_results)} datasets for ZIP {zip_code}")
|
| 438 |
+
|
| 439 |
+
if dataset_results:
|
| 440 |
+
# Find columns relevant to user's question
|
| 441 |
+
logger.info("Finding columns relevant to user question...")
|
| 442 |
+
relevant_columns = self._get_relevant_columns(user_message, dataset_results)
|
| 443 |
+
logger.info(f"Found relevant columns: {relevant_columns}")
|
| 444 |
+
|
| 445 |
+
# Build context with relevant values
|
| 446 |
+
context = self._build_smart_context(dataset_results, relevant_columns, user_message)
|
| 447 |
+
logger.info(f"Built context with {len(relevant_columns)} datasets")
|
| 448 |
+
else:
|
| 449 |
+
logger.info(f"Skipping data extraction (reason: {extraction_reason})")
|
| 450 |
|
| 451 |
+
# Step 5: Build response prompt with or without data
|
| 452 |
if context:
|
| 453 |
+
# We have data - include it with narrative insight instructions
|
| 454 |
logger.info("Found relevant context, using data-backed response")
|
| 455 |
+
final_prompt = f"""{context}
|
| 456 |
+
|
| 457 |
+
User Question: {user_message}
|
| 458 |
|
| 459 |
+
Generate narrative insights: group related metrics by theme, show connections between data points,
|
| 460 |
+
highlight critical patterns, and provide interpretation of what numbers mean for residents."""
|
| 461 |
else:
|
| 462 |
+
# No data extraction or no relevant data
|
| 463 |
+
if needs_data and dataset_results:
|
| 464 |
+
# Data exists but no relevant columns - mention available data
|
| 465 |
+
logger.info("Data exists but no relevant columns - using general knowledge with data mention")
|
| 466 |
+
available_summary = "Available datasets and their main characteristics:\n"
|
| 467 |
+
for dataset_name, data in dataset_results.items():
|
| 468 |
+
available_summary += f"- {dataset_name}: {data['row_count']} record(s) with {len(data['columns'])} columns\n"
|
| 469 |
+
|
| 470 |
+
final_prompt = f"""For ZIP Code {zip_code} ({area_name}), the following datasets are available:
|
| 471 |
|
| 472 |
{available_summary}
|
| 473 |
|
| 474 |
+
User Question: {user_message}
|
| 475 |
+
|
| 476 |
+
While specific data for this question may not be in our databases, provide helpful insights by:
|
| 477 |
1. Using general knowledge about this area (if well-known)
|
| 478 |
+
2. Suggesting what data would help answer this question better"""
|
| 479 |
+
else:
|
| 480 |
+
# No data extraction needed - general knowledge response
|
| 481 |
+
logger.info("Using general knowledge response")
|
| 482 |
+
final_prompt = f"""Area: {area_name} (ZIP: {zip_code})
|
| 483 |
|
| 484 |
User Question: {user_message}
|
| 485 |
|
| 486 |
+
Provide a helpful response. You can use general knowledge about this area."""
|
| 487 |
|
| 488 |
+
logger.info(f"Sending final response prompt to OpenAI (context length: {len(context)} chars)")
|
| 489 |
|
| 490 |
+
# Step 6: Generate final response without tools (just conversation)
|
| 491 |
+
final_response = self.openai_service.generate_response(
|
| 492 |
+
final_prompt,
|
| 493 |
st.session_state.area_chat_history,
|
| 494 |
+
system_prompt=system_prompt,
|
| 495 |
+
tools=None # No tools for final response
|
| 496 |
)
|
| 497 |
+
bot_response = self.openai_service.get_message_content(final_response)
|
| 498 |
|
| 499 |
logger.info(f"Received area response (length: {len(bot_response)} chars)")
|
| 500 |
|
src/services/azure_openai_service.py
CHANGED
|
@@ -31,13 +31,14 @@ class AzureOpenAIService:
|
|
| 31 |
# Remove trailing slash from endpoint if present
|
| 32 |
self.endpoint = self.endpoint.rstrip('/')
|
| 33 |
|
| 34 |
-
def generate_response(self, prompt: str, chat_history: list = None, system_prompt: str = None) -> dict:
|
| 35 |
"""Generate a response from Azure OpenAI API.
|
| 36 |
|
| 37 |
Args:
|
| 38 |
prompt: The user's input prompt
|
| 39 |
chat_history: List of tuples containing (user_message, assistant_message) from previous conversation
|
| 40 |
system_prompt: Optional custom system prompt (overrides default)
|
|
|
|
| 41 |
|
| 42 |
Returns:
|
| 43 |
The API response as a dictionary
|
|
@@ -117,6 +118,11 @@ Keep responses focused and actionable."""
|
|
| 117 |
"temperature": 0.5,
|
| 118 |
"max_tokens": 8000
|
| 119 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
|
| 121 |
# Correct Azure OpenAI endpoint format
|
| 122 |
url = f"{self.endpoint}/openai/deployments/{self.deployment_name}/chat/completions?api-version={self.api_version}"
|
|
@@ -161,6 +167,67 @@ Keep responses focused and actionable."""
|
|
| 161 |
raise Exception(f"Request failed: {str(e)}")
|
| 162 |
|
| 163 |
def parse_response(self, response: dict) -> str:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 164 |
if "choices" in response and len(response["choices"]) > 0:
|
| 165 |
-
|
| 166 |
-
|
|
|
|
|
|
|
|
|
| 31 |
# Remove trailing slash from endpoint if present
|
| 32 |
self.endpoint = self.endpoint.rstrip('/')
|
| 33 |
|
| 34 |
+
def generate_response(self, prompt: str, chat_history: list = None, system_prompt: str = None, tools: list = None) -> dict:
|
| 35 |
"""Generate a response from Azure OpenAI API.
|
| 36 |
|
| 37 |
Args:
|
| 38 |
prompt: The user's input prompt
|
| 39 |
chat_history: List of tuples containing (user_message, assistant_message) from previous conversation
|
| 40 |
system_prompt: Optional custom system prompt (overrides default)
|
| 41 |
+
tools: Optional list of tool definitions for function calling (Azure OpenAI tools parameter)
|
| 42 |
|
| 43 |
Returns:
|
| 44 |
The API response as a dictionary
|
|
|
|
| 118 |
"temperature": 0.5,
|
| 119 |
"max_tokens": 8000
|
| 120 |
}
|
| 121 |
+
|
| 122 |
+
# Add tools if function calling is needed
|
| 123 |
+
if tools:
|
| 124 |
+
data["tools"] = tools
|
| 125 |
+
data["tool_choice"] = "auto" # Let model decide whether to call a tool
|
| 126 |
|
| 127 |
# Correct Azure OpenAI endpoint format
|
| 128 |
url = f"{self.endpoint}/openai/deployments/{self.deployment_name}/chat/completions?api-version={self.api_version}"
|
|
|
|
| 167 |
raise Exception(f"Request failed: {str(e)}")
|
| 168 |
|
| 169 |
def parse_response(self, response: dict) -> str:
|
| 170 |
+
"""Parse response from Azure OpenAI API.
|
| 171 |
+
|
| 172 |
+
Args:
|
| 173 |
+
response: The API response dictionary
|
| 174 |
+
|
| 175 |
+
Returns:
|
| 176 |
+
The message content as a string, or tool_calls if present
|
| 177 |
+
"""
|
| 178 |
+
if "choices" in response and len(response["choices"]) > 0:
|
| 179 |
+
message = response["choices"][0]["message"]
|
| 180 |
+
|
| 181 |
+
# Check if model made a tool call
|
| 182 |
+
if hasattr(message, "tool_calls") and message.tool_calls:
|
| 183 |
+
return message # Return full message object for tool call handling
|
| 184 |
+
|
| 185 |
+
# Standard content response
|
| 186 |
+
if "content" in message and message["content"]:
|
| 187 |
+
return message["content"]
|
| 188 |
+
|
| 189 |
+
return "No response from the model."
|
| 190 |
+
|
| 191 |
+
def has_tool_calls(self, response: dict) -> bool:
|
| 192 |
+
"""Check if response contains tool calls.
|
| 193 |
+
|
| 194 |
+
Args:
|
| 195 |
+
response: The API response dictionary
|
| 196 |
+
|
| 197 |
+
Returns:
|
| 198 |
+
True if response contains tool calls, False otherwise
|
| 199 |
+
"""
|
| 200 |
+
if "choices" in response and len(response["choices"]) > 0:
|
| 201 |
+
message = response["choices"][0]["message"]
|
| 202 |
+
return "tool_calls" in message and message["tool_calls"] is not None
|
| 203 |
+
return False
|
| 204 |
+
|
| 205 |
+
def get_tool_calls(self, response: dict) -> list:
|
| 206 |
+
"""Extract tool calls from response.
|
| 207 |
+
|
| 208 |
+
Args:
|
| 209 |
+
response: The API response dictionary
|
| 210 |
+
|
| 211 |
+
Returns:
|
| 212 |
+
List of tool call objects
|
| 213 |
+
"""
|
| 214 |
+
if "choices" in response and len(response["choices"]) > 0:
|
| 215 |
+
message = response["choices"][0]["message"]
|
| 216 |
+
if "tool_calls" in message:
|
| 217 |
+
return message["tool_calls"]
|
| 218 |
+
return []
|
| 219 |
+
|
| 220 |
+
def get_message_content(self, response: dict) -> str:
|
| 221 |
+
"""Get message content from response.
|
| 222 |
+
|
| 223 |
+
Args:
|
| 224 |
+
response: The API response dictionary
|
| 225 |
+
|
| 226 |
+
Returns:
|
| 227 |
+
The message content as a string
|
| 228 |
+
"""
|
| 229 |
if "choices" in response and len(response["choices"]) > 0:
|
| 230 |
+
message = response["choices"][0]["message"]
|
| 231 |
+
if "content" in message and message["content"]:
|
| 232 |
+
return message["content"]
|
| 233 |
+
return ""
|
tests/accuracy_validators.py
ADDED
|
@@ -0,0 +1,570 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
accuracy_validators.py
|
| 3 |
+
|
| 4 |
+
Accuracy validation modules for analyzing chatbot responses against expected results.
|
| 5 |
+
Includes citation validation, relevance scoring, hallucination detection, and more.
|
| 6 |
+
"""
|
| 7 |
+
|
| 8 |
+
import re
|
| 9 |
+
import json
|
| 10 |
+
import logging
|
| 11 |
+
from typing import Dict, List, Any, Tuple, Optional
|
| 12 |
+
from pathlib import Path
|
| 13 |
+
from difflib import SequenceMatcher
|
| 14 |
+
|
| 15 |
+
logger = logging.getLogger(__name__)
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
class CitationValidator:
|
| 19 |
+
"""Validates that all recommendations are properly cited with dataset sources."""
|
| 20 |
+
|
| 21 |
+
CITATION_PATTERNS = [
|
| 22 |
+
r'\(Dataset:\s*([^\)]+)\)',
|
| 23 |
+
r'\(Source:\s*([^\)]+)\)',
|
| 24 |
+
r'Dataset:\s*([A-Za-z0-9_\-]+)',
|
| 25 |
+
]
|
| 26 |
+
|
| 27 |
+
KNOWN_DATASETS = ["EJI_2024", "AHRF-2025", "SVI_2022", "CHR", "chr.xlsx"]
|
| 28 |
+
|
| 29 |
+
def validate(self, response: str, test_case: Dict[str, Any]) -> Dict[str, Any]:
|
| 30 |
+
"""
|
| 31 |
+
Validate citations in response.
|
| 32 |
+
|
| 33 |
+
Args:
|
| 34 |
+
response: LLM response text
|
| 35 |
+
test_case: Original test case dictionary
|
| 36 |
+
|
| 37 |
+
Returns:
|
| 38 |
+
Validation result dictionary
|
| 39 |
+
"""
|
| 40 |
+
result = {
|
| 41 |
+
"validator": "citation",
|
| 42 |
+
"passed": True,
|
| 43 |
+
"score": 1.0,
|
| 44 |
+
"issues": [],
|
| 45 |
+
"citations_found": [],
|
| 46 |
+
"citation_count": 0,
|
| 47 |
+
"expected_citation_count": test_case.get("min_recommendations", 0)
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
# Handle None or empty response
|
| 51 |
+
if response is None or (isinstance(response, str) and not response.strip()):
|
| 52 |
+
result["issues"].append("Response is empty or None - cannot extract citations")
|
| 53 |
+
result["passed"] = False
|
| 54 |
+
result["score"] = 0.0
|
| 55 |
+
return result
|
| 56 |
+
|
| 57 |
+
# Extract all citations
|
| 58 |
+
citations = self._extract_citations(response)
|
| 59 |
+
result["citations_found"] = citations
|
| 60 |
+
result["citation_count"] = len(citations)
|
| 61 |
+
|
| 62 |
+
# Check minimum citations
|
| 63 |
+
if result["expected_citation_count"] > 0:
|
| 64 |
+
if result["citation_count"] < result["expected_citation_count"]:
|
| 65 |
+
result["issues"].append(
|
| 66 |
+
f"Insufficient citations: found {result['citation_count']}, "
|
| 67 |
+
f"expected at least {result['expected_citation_count']}"
|
| 68 |
+
)
|
| 69 |
+
result["passed"] = False
|
| 70 |
+
|
| 71 |
+
# Check for expected datasets
|
| 72 |
+
expected_datasets = set(test_case.get("expected_datasets", []))
|
| 73 |
+
found_datasets = set([self._normalize_dataset(c) for c in citations])
|
| 74 |
+
|
| 75 |
+
missing_datasets = expected_datasets - found_datasets
|
| 76 |
+
if missing_datasets and expected_datasets:
|
| 77 |
+
result["issues"].append(
|
| 78 |
+
f"Expected datasets not cited: {', '.join(missing_datasets)}"
|
| 79 |
+
)
|
| 80 |
+
result["passed"] = False
|
| 81 |
+
|
| 82 |
+
# Check for citations to unknown datasets
|
| 83 |
+
invalid_citations = []
|
| 84 |
+
for citation in citations:
|
| 85 |
+
normalized = self._normalize_dataset(citation)
|
| 86 |
+
if normalized and not self._is_valid_dataset(normalized):
|
| 87 |
+
invalid_citations.append(citation)
|
| 88 |
+
|
| 89 |
+
if invalid_citations:
|
| 90 |
+
result["issues"].append(
|
| 91 |
+
f"Citations to unknown datasets: {', '.join(invalid_citations)}"
|
| 92 |
+
)
|
| 93 |
+
result["passed"] = False
|
| 94 |
+
|
| 95 |
+
# Calculate score
|
| 96 |
+
if result["passed"]:
|
| 97 |
+
result["score"] = 1.0
|
| 98 |
+
else:
|
| 99 |
+
result["score"] = max(0.0, 1.0 - (len(result["issues"]) * 0.25))
|
| 100 |
+
|
| 101 |
+
return result
|
| 102 |
+
|
| 103 |
+
@staticmethod
|
| 104 |
+
def _extract_citations(text: str) -> List[str]:
|
| 105 |
+
"""Extract dataset names from citation patterns."""
|
| 106 |
+
citations = []
|
| 107 |
+
for pattern in CitationValidator.CITATION_PATTERNS:
|
| 108 |
+
matches = re.findall(pattern, text, re.IGNORECASE)
|
| 109 |
+
citations.extend([m.strip() for m in matches])
|
| 110 |
+
return list(set(citations))
|
| 111 |
+
|
| 112 |
+
@staticmethod
|
| 113 |
+
def _normalize_dataset(dataset_str: str) -> str:
|
| 114 |
+
"""Normalize dataset name for comparison."""
|
| 115 |
+
return dataset_str.strip().upper().replace(" ", "_")
|
| 116 |
+
|
| 117 |
+
@classmethod
|
| 118 |
+
def _is_valid_dataset(cls, dataset: str) -> bool:
|
| 119 |
+
"""Check if dataset is in known list."""
|
| 120 |
+
normalized_known = [d.upper().replace(" ", "_") for d in cls.KNOWN_DATASETS]
|
| 121 |
+
return dataset.upper() in normalized_known
|
| 122 |
+
|
| 123 |
+
|
| 124 |
+
class RelevanceScorer:
|
| 125 |
+
"""Scores how relevant recommendations are to the user's query."""
|
| 126 |
+
|
| 127 |
+
def validate(self, response: str, test_case: Dict[str, Any]) -> Dict[str, Any]:
|
| 128 |
+
"""
|
| 129 |
+
Score response relevance to query.
|
| 130 |
+
|
| 131 |
+
Args:
|
| 132 |
+
response: LLM response text
|
| 133 |
+
test_case: Original test case with expected patterns
|
| 134 |
+
|
| 135 |
+
Returns:
|
| 136 |
+
Validation result with relevance score
|
| 137 |
+
"""
|
| 138 |
+
result = {
|
| 139 |
+
"validator": "relevance",
|
| 140 |
+
"passed": True,
|
| 141 |
+
"score": 0.5,
|
| 142 |
+
"issues": [],
|
| 143 |
+
"matched_patterns": [],
|
| 144 |
+
"expected_patterns": test_case.get("expected_column_patterns", []),
|
| 145 |
+
"pattern_match_count": 0
|
| 146 |
+
}
|
| 147 |
+
|
| 148 |
+
# Handle None or empty response
|
| 149 |
+
if response is None or (isinstance(response, str) and not response.strip()):
|
| 150 |
+
result["issues"].append("Response is empty or None - cannot score relevance")
|
| 151 |
+
result["passed"] = False
|
| 152 |
+
result["score"] = 0.0
|
| 153 |
+
return result
|
| 154 |
+
|
| 155 |
+
expected_patterns = test_case.get("expected_column_patterns", [])
|
| 156 |
+
if not expected_patterns:
|
| 157 |
+
result["score"] = 1.0
|
| 158 |
+
result["passed"] = True
|
| 159 |
+
return result
|
| 160 |
+
|
| 161 |
+
# Count pattern matches
|
| 162 |
+
matches = []
|
| 163 |
+
for pattern in expected_patterns:
|
| 164 |
+
if re.search(pattern, response, re.IGNORECASE):
|
| 165 |
+
matches.append(pattern)
|
| 166 |
+
|
| 167 |
+
result["matched_patterns"] = matches
|
| 168 |
+
result["pattern_match_count"] = len(matches)
|
| 169 |
+
|
| 170 |
+
# Calculate relevance score
|
| 171 |
+
if expected_patterns:
|
| 172 |
+
match_ratio = len(matches) / len(expected_patterns)
|
| 173 |
+
result["score"] = match_ratio
|
| 174 |
+
|
| 175 |
+
if match_ratio < 0.4:
|
| 176 |
+
result["issues"].append(
|
| 177 |
+
f"Low pattern match: {len(matches)}/{len(expected_patterns)} expected patterns found"
|
| 178 |
+
)
|
| 179 |
+
result["passed"] = False
|
| 180 |
+
|
| 181 |
+
return result
|
| 182 |
+
|
| 183 |
+
|
| 184 |
+
class HallucinationDetector:
|
| 185 |
+
"""Detects when the model recommends columns that don't exist in the dictionaries."""
|
| 186 |
+
|
| 187 |
+
def __init__(self, data_dictionary_service):
|
| 188 |
+
"""
|
| 189 |
+
Initialize with access to loaded dictionaries.
|
| 190 |
+
|
| 191 |
+
Args:
|
| 192 |
+
data_dictionary_service: Service with loaded dictionary data
|
| 193 |
+
"""
|
| 194 |
+
self.data_dict_service = data_dictionary_service
|
| 195 |
+
self._build_known_columns_index()
|
| 196 |
+
|
| 197 |
+
def _build_known_columns_index(self):
|
| 198 |
+
"""Build searchable index of all columns in loaded dictionaries."""
|
| 199 |
+
self.known_columns = set()
|
| 200 |
+
self.column_to_datasets = {}
|
| 201 |
+
|
| 202 |
+
try:
|
| 203 |
+
all_dicts = self.data_dict_service.get_all_dictionaries()
|
| 204 |
+
for dict_info in all_dicts:
|
| 205 |
+
dict_name = dict_info.get('name', '')
|
| 206 |
+
dict_data = self.data_dict_service.data_dictionaries.get(dict_name, [])
|
| 207 |
+
|
| 208 |
+
if isinstance(dict_data, list):
|
| 209 |
+
for entry in dict_data:
|
| 210 |
+
# Extract column names from various possible formats
|
| 211 |
+
if isinstance(entry, dict):
|
| 212 |
+
col_names = [
|
| 213 |
+
entry.get('column_name', ''),
|
| 214 |
+
entry.get('Column Name', ''),
|
| 215 |
+
entry.get('Column', '')
|
| 216 |
+
]
|
| 217 |
+
else:
|
| 218 |
+
col_names = [str(entry).split('\t')[0] if '\t' in str(entry) else '']
|
| 219 |
+
|
| 220 |
+
for col in col_names:
|
| 221 |
+
if col:
|
| 222 |
+
normalized = col.lower().strip()
|
| 223 |
+
self.known_columns.add(normalized)
|
| 224 |
+
if normalized not in self.column_to_datasets:
|
| 225 |
+
self.column_to_datasets[normalized] = []
|
| 226 |
+
self.column_to_datasets[normalized].append(dict_name)
|
| 227 |
+
except Exception as e:
|
| 228 |
+
logger.warning(f"Could not build column index: {e}")
|
| 229 |
+
|
| 230 |
+
def validate(self, response: str, test_case: Dict[str, Any], retrieved_chunks: List = None) -> Dict[str, Any]:
|
| 231 |
+
"""
|
| 232 |
+
Detect hallucinated columns in response.
|
| 233 |
+
|
| 234 |
+
Args:
|
| 235 |
+
response: LLM response text
|
| 236 |
+
test_case: Original test case
|
| 237 |
+
retrieved_chunks: Optional retrieved chunks for context
|
| 238 |
+
|
| 239 |
+
Returns:
|
| 240 |
+
Validation result
|
| 241 |
+
"""
|
| 242 |
+
result = {
|
| 243 |
+
"validator": "hallucination",
|
| 244 |
+
"passed": True,
|
| 245 |
+
"score": 1.0,
|
| 246 |
+
"issues": [],
|
| 247 |
+
"hallucinated_columns": [],
|
| 248 |
+
"legitimate_columns": [],
|
| 249 |
+
"uncertain_columns": []
|
| 250 |
+
}
|
| 251 |
+
|
| 252 |
+
# Handle None or empty response
|
| 253 |
+
if response is None or (isinstance(response, str) and not response.strip()):
|
| 254 |
+
result["issues"].append("Response is empty or None - cannot check for hallucinations")
|
| 255 |
+
result["passed"] = False
|
| 256 |
+
result["score"] = 0.0
|
| 257 |
+
return result
|
| 258 |
+
|
| 259 |
+
# Extract column names from response
|
| 260 |
+
# Look for patterns like **ColumnName** or ColumnName (Dataset: ...)
|
| 261 |
+
recommended_columns = self._extract_column_names(response)
|
| 262 |
+
|
| 263 |
+
for col_name in recommended_columns:
|
| 264 |
+
normalized_col = col_name.lower().strip()
|
| 265 |
+
|
| 266 |
+
if normalized_col in self.known_columns:
|
| 267 |
+
result["legitimate_columns"].append(col_name)
|
| 268 |
+
elif self._is_likely_real(col_name, retrieved_chunks):
|
| 269 |
+
result["uncertain_columns"].append(col_name)
|
| 270 |
+
else:
|
| 271 |
+
result["hallucinated_columns"].append(col_name)
|
| 272 |
+
|
| 273 |
+
# Validation logic
|
| 274 |
+
if result["hallucinated_columns"]:
|
| 275 |
+
result["passed"] = False
|
| 276 |
+
result["issues"].append(
|
| 277 |
+
f"Hallucinated columns detected: {', '.join(result['hallucinated_columns'])}"
|
| 278 |
+
)
|
| 279 |
+
|
| 280 |
+
# Score calculation
|
| 281 |
+
total_cols = len(recommended_columns)
|
| 282 |
+
if total_cols > 0:
|
| 283 |
+
legitimate_ratio = len(result["legitimate_columns"]) / total_cols
|
| 284 |
+
result["score"] = legitimate_ratio * 0.7 + (1.0 - len(result["hallucinated_columns"]) / max(total_cols, 1)) * 0.3
|
| 285 |
+
|
| 286 |
+
return result
|
| 287 |
+
|
| 288 |
+
@staticmethod
|
| 289 |
+
def _extract_column_names(text: str) -> List[str]:
|
| 290 |
+
"""Extract column names from response text."""
|
| 291 |
+
columns = []
|
| 292 |
+
|
| 293 |
+
# Pattern: **ColumnName** (Dataset: ...)
|
| 294 |
+
pattern1 = r'\*\*([A-Za-z0-9\s\-_/]+)\*\*'
|
| 295 |
+
matches1 = re.findall(pattern1, text)
|
| 296 |
+
columns.extend(matches1)
|
| 297 |
+
|
| 298 |
+
# Pattern: ColumnName (Dataset: ...)
|
| 299 |
+
pattern2 = r'([A-Z][A-Za-z0-9\s\-_/]*)\s*\(Dataset:'
|
| 300 |
+
matches2 = re.findall(pattern2, text)
|
| 301 |
+
columns.extend(matches2)
|
| 302 |
+
|
| 303 |
+
return [c.strip() for c in list(set(columns)) if len(c.strip()) > 2]
|
| 304 |
+
|
| 305 |
+
@staticmethod
|
| 306 |
+
def _is_likely_real(column_name: str, retrieved_chunks: List = None) -> bool:
|
| 307 |
+
"""Heuristic to determine if a column name looks realistic."""
|
| 308 |
+
if not column_name or len(column_name) < 2:
|
| 309 |
+
return False
|
| 310 |
+
|
| 311 |
+
# Check if column appears in retrieved chunks
|
| 312 |
+
if retrieved_chunks:
|
| 313 |
+
col_lower = column_name.lower()
|
| 314 |
+
for chunk in retrieved_chunks:
|
| 315 |
+
if col_lower in chunk.get("text", "").lower():
|
| 316 |
+
return True
|
| 317 |
+
|
| 318 |
+
# Check if it matches typical column name patterns
|
| 319 |
+
# Valid: descriptive names, snake_case, CamelCase
|
| 320 |
+
valid_patterns = [
|
| 321 |
+
r'^[A-Z][a-zA-Z]+$', # CamelCase
|
| 322 |
+
r'^[a-z]+(_[a-z]+)*$', # snake_case
|
| 323 |
+
r'^[A-Z][A-Z0-9_\-]+$', # UPPER_CASE
|
| 324 |
+
r'^[A-Za-z0-9\s/\-]+$' # Descriptive with spaces/slashes
|
| 325 |
+
]
|
| 326 |
+
|
| 327 |
+
return any(re.match(pattern, column_name) for pattern in valid_patterns)
|
| 328 |
+
|
| 329 |
+
|
| 330 |
+
class AreaInsightsValidator:
|
| 331 |
+
"""Validates Area Insights geographic accuracy."""
|
| 332 |
+
|
| 333 |
+
def validate(self, response: str, test_case: Dict[str, Any]) -> Dict[str, Any]:
|
| 334 |
+
"""
|
| 335 |
+
Validate area/geographic specificity in response.
|
| 336 |
+
|
| 337 |
+
Args:
|
| 338 |
+
response: LLM response text
|
| 339 |
+
test_case: Test case with area information
|
| 340 |
+
|
| 341 |
+
Returns:
|
| 342 |
+
Validation result
|
| 343 |
+
"""
|
| 344 |
+
result = {
|
| 345 |
+
"validator": "area_insights",
|
| 346 |
+
"passed": True,
|
| 347 |
+
"score": 1.0,
|
| 348 |
+
"issues": [],
|
| 349 |
+
"mentions_location": False,
|
| 350 |
+
"mentions_datasets": False,
|
| 351 |
+
"fallback_used": False
|
| 352 |
+
}
|
| 353 |
+
|
| 354 |
+
if test_case.get("type") != "area_insights":
|
| 355 |
+
return result # Not applicable
|
| 356 |
+
|
| 357 |
+
# Handle None or empty response
|
| 358 |
+
if response is None or (isinstance(response, str) and not response.strip()):
|
| 359 |
+
result["issues"].append("Response is empty or None - cannot validate area insights")
|
| 360 |
+
result["passed"] = False
|
| 361 |
+
result["score"] = 0.0
|
| 362 |
+
return result
|
| 363 |
+
|
| 364 |
+
location = test_case.get("location_name", "")
|
| 365 |
+
zip_code = test_case.get("zip_code", "")
|
| 366 |
+
|
| 367 |
+
# Check if location/ZIP is mentioned
|
| 368 |
+
if location:
|
| 369 |
+
if location.lower() in response.lower() or zip_code in response:
|
| 370 |
+
result["mentions_location"] = True
|
| 371 |
+
else:
|
| 372 |
+
result["issues"].append(
|
| 373 |
+
f"Response does not mention location '{location}' or ZIP {zip_code}"
|
| 374 |
+
)
|
| 375 |
+
|
| 376 |
+
# Check if datasets are mentioned
|
| 377 |
+
expected_datasets = test_case.get("expected_datasets", [])
|
| 378 |
+
for dataset in expected_datasets:
|
| 379 |
+
if dataset in response or dataset.replace("_", " ") in response:
|
| 380 |
+
result["mentions_datasets"] = True
|
| 381 |
+
break
|
| 382 |
+
|
| 383 |
+
if not result["mentions_datasets"] and expected_datasets:
|
| 384 |
+
result["issues"].append("Response does not mention expected datasets")
|
| 385 |
+
|
| 386 |
+
# Check for fallback indicators if invalid ZIP
|
| 387 |
+
if test_case.get("should_fallback_to_general"):
|
| 388 |
+
fallback_phrases = ["general knowledge", "nationwide", "not available for", "no data", "general data"]
|
| 389 |
+
if any(phrase in response.lower() for phrase in fallback_phrases):
|
| 390 |
+
result["fallback_used"] = True
|
| 391 |
+
|
| 392 |
+
# Validation logic
|
| 393 |
+
if result["issues"]:
|
| 394 |
+
result["passed"] = False
|
| 395 |
+
|
| 396 |
+
# Scoring
|
| 397 |
+
score = 1.0
|
| 398 |
+
if not result["mentions_location"]:
|
| 399 |
+
score -= 0.3
|
| 400 |
+
if not result["mentions_datasets"]:
|
| 401 |
+
score -= 0.3
|
| 402 |
+
result["score"] = max(0.0, score)
|
| 403 |
+
|
| 404 |
+
return result
|
| 405 |
+
|
| 406 |
+
|
| 407 |
+
class FormatValidator:
|
| 408 |
+
"""Validates response format and structure."""
|
| 409 |
+
|
| 410 |
+
def validate(self, response: str, test_case: Dict[str, Any]) -> Dict[str, Any]:
|
| 411 |
+
"""
|
| 412 |
+
Validate response formatting and structure.
|
| 413 |
+
|
| 414 |
+
Args:
|
| 415 |
+
response: LLM response text
|
| 416 |
+
test_case: Original test case
|
| 417 |
+
|
| 418 |
+
Returns:
|
| 419 |
+
Validation result
|
| 420 |
+
"""
|
| 421 |
+
result = {
|
| 422 |
+
"validator": "format",
|
| 423 |
+
"passed": True,
|
| 424 |
+
"score": 1.0,
|
| 425 |
+
"issues": [],
|
| 426 |
+
"has_structured_list": False,
|
| 427 |
+
"uses_bold_formatting": False,
|
| 428 |
+
"is_coherent": True,
|
| 429 |
+
"response_length": 0
|
| 430 |
+
}
|
| 431 |
+
|
| 432 |
+
# Handle None or empty response
|
| 433 |
+
if response is None or (isinstance(response, str) and not response.strip()):
|
| 434 |
+
result["issues"].append("Response is empty or None - cannot validate format")
|
| 435 |
+
result["passed"] = False
|
| 436 |
+
result["score"] = 0.0
|
| 437 |
+
result["response_length"] = 0
|
| 438 |
+
return result
|
| 439 |
+
|
| 440 |
+
result["response_length"] = len(response)
|
| 441 |
+
|
| 442 |
+
# Check for structured list format
|
| 443 |
+
list_patterns = [r'^\d+\.\s', r'^[-*]\s']
|
| 444 |
+
if any(re.search(pattern, response, re.MULTILINE) for pattern in list_patterns):
|
| 445 |
+
result["has_structured_list"] = True
|
| 446 |
+
|
| 447 |
+
# Check for bold formatting
|
| 448 |
+
if "**" in response:
|
| 449 |
+
result["uses_bold_formatting"] = True
|
| 450 |
+
|
| 451 |
+
# Check response length (should be reasonable)
|
| 452 |
+
min_length = 100 if test_case.get("min_recommendations", 0) > 0 else 20
|
| 453 |
+
if result["response_length"] < min_length:
|
| 454 |
+
result["issues"].append(f"Response too short ({result['response_length']} < {min_length} chars)")
|
| 455 |
+
result["passed"] = False
|
| 456 |
+
|
| 457 |
+
# Check for typical errors
|
| 458 |
+
if "i don't know" in response.lower() and test_case.get("min_recommendations", 0) > 0:
|
| 459 |
+
result["issues"].append("Response indicates lack of knowledge despite available data")
|
| 460 |
+
result["passed"] = False
|
| 461 |
+
|
| 462 |
+
# Scoring
|
| 463 |
+
score = 1.0
|
| 464 |
+
if not result["has_structured_list"]:
|
| 465 |
+
score -= 0.15
|
| 466 |
+
if not result["uses_bold_formatting"]:
|
| 467 |
+
score -= 0.1
|
| 468 |
+
if result["issues"]:
|
| 469 |
+
score -= len(result["issues"]) * 0.1
|
| 470 |
+
|
| 471 |
+
result["score"] = max(0.0, score)
|
| 472 |
+
|
| 473 |
+
return result
|
| 474 |
+
|
| 475 |
+
|
| 476 |
+
class AccuracyAnalyzer:
|
| 477 |
+
"""Orchestrates all validators and produces overall accuracy assessment."""
|
| 478 |
+
|
| 479 |
+
def __init__(self, data_dictionary_service=None):
|
| 480 |
+
"""Initialize validators."""
|
| 481 |
+
self.citation_validator = CitationValidator()
|
| 482 |
+
self.relevance_scorer = RelevanceScorer()
|
| 483 |
+
self.hallucination_detector = HallucinationDetector(data_dictionary_service) if data_dictionary_service else None
|
| 484 |
+
self.area_insights_validator = AreaInsightsValidator()
|
| 485 |
+
self.format_validator = FormatValidator()
|
| 486 |
+
|
| 487 |
+
def analyze_response(
|
| 488 |
+
self,
|
| 489 |
+
test_case: Dict[str, Any],
|
| 490 |
+
response: str,
|
| 491 |
+
retrieved_chunks: List = None
|
| 492 |
+
) -> Dict[str, Any]:
|
| 493 |
+
"""
|
| 494 |
+
Analyze a single response using all validators.
|
| 495 |
+
|
| 496 |
+
Args:
|
| 497 |
+
test_case: Original test case
|
| 498 |
+
response: LLM response text
|
| 499 |
+
retrieved_chunks: Retrieved chunks for context
|
| 500 |
+
|
| 501 |
+
Returns:
|
| 502 |
+
Comprehensive analysis result
|
| 503 |
+
"""
|
| 504 |
+
validations = {}
|
| 505 |
+
|
| 506 |
+
# Run all validators
|
| 507 |
+
validations["citation"] = self.citation_validator.validate(response, test_case)
|
| 508 |
+
validations["relevance"] = self.relevance_scorer.validate(response, test_case)
|
| 509 |
+
validations["format"] = self.format_validator.validate(response, test_case)
|
| 510 |
+
validations["area_insights"] = self.area_insights_validator.validate(response, test_case)
|
| 511 |
+
|
| 512 |
+
if self.hallucination_detector:
|
| 513 |
+
validations["hallucination"] = self.hallucination_detector.validate(
|
| 514 |
+
response, test_case, retrieved_chunks
|
| 515 |
+
)
|
| 516 |
+
|
| 517 |
+
# Calculate overall score
|
| 518 |
+
scores = [v["score"] for v in validations.values() if v]
|
| 519 |
+
overall_score = sum(scores) / len(scores) if scores else 0.0
|
| 520 |
+
|
| 521 |
+
# Determine overall pass/fail
|
| 522 |
+
overall_passed = all(v["passed"] for v in validations.values() if v)
|
| 523 |
+
|
| 524 |
+
return {
|
| 525 |
+
"test_id": test_case.get("test_id", ""),
|
| 526 |
+
"test_name": test_case.get("name", ""),
|
| 527 |
+
"overall_score": overall_score,
|
| 528 |
+
"overall_passed": overall_passed,
|
| 529 |
+
"validations": validations,
|
| 530 |
+
"response_snippet": response[:200] + "..." if len(response) > 200 else response
|
| 531 |
+
}
|
| 532 |
+
|
| 533 |
+
def analyze_batch(
|
| 534 |
+
self,
|
| 535 |
+
test_results: List[Dict[str, Any]],
|
| 536 |
+
test_cases: List[Dict[str, Any]]
|
| 537 |
+
) -> Dict[str, Any]:
|
| 538 |
+
"""
|
| 539 |
+
Analyze multiple test results.
|
| 540 |
+
|
| 541 |
+
Args:
|
| 542 |
+
test_results: List of test execution results
|
| 543 |
+
test_cases: List of original test cases
|
| 544 |
+
|
| 545 |
+
Returns:
|
| 546 |
+
Batch analysis with aggregate metrics
|
| 547 |
+
"""
|
| 548 |
+
analyses = []
|
| 549 |
+
|
| 550 |
+
# Create lookup for test cases
|
| 551 |
+
test_case_map = {tc.get("test_id"): tc for tc in test_cases}
|
| 552 |
+
|
| 553 |
+
for result in test_results:
|
| 554 |
+
test_case = test_case_map.get(result["test_id"], result)
|
| 555 |
+
analysis = self.analyze_response(
|
| 556 |
+
test_case,
|
| 557 |
+
result.get("response", ""),
|
| 558 |
+
result.get("retrieved_chunks", [])
|
| 559 |
+
)
|
| 560 |
+
analyses.append(analysis)
|
| 561 |
+
|
| 562 |
+
# Aggregate metrics
|
| 563 |
+
return {
|
| 564 |
+
"total_tests": len(analyses),
|
| 565 |
+
"passed_tests": sum(1 for a in analyses if a["overall_passed"]),
|
| 566 |
+
"failed_tests": sum(1 for a in analyses if not a["overall_passed"]),
|
| 567 |
+
"average_score": sum(a["overall_score"] for a in analyses) / len(analyses) if analyses else 0,
|
| 568 |
+
"pass_rate": sum(1 for a in analyses if a["overall_passed"]) / len(analyses) if analyses else 0,
|
| 569 |
+
"analyses": analyses
|
| 570 |
+
}
|
tests/chat_automation.py
ADDED
|
@@ -0,0 +1,592 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
chat_automation.py
|
| 3 |
+
|
| 4 |
+
Automated chat testing harness for the Streamlit Data Dictionary Chatbot.
|
| 5 |
+
Simulates user interactions, captures responses, and stores results for accuracy analysis.
|
| 6 |
+
"""
|
| 7 |
+
|
| 8 |
+
import json
|
| 9 |
+
import logging
|
| 10 |
+
import os
|
| 11 |
+
from pathlib import Path
|
| 12 |
+
from datetime import datetime
|
| 13 |
+
from typing import Dict, List, Any, Optional, Tuple
|
| 14 |
+
import sys
|
| 15 |
+
from dotenv import load_dotenv
|
| 16 |
+
|
| 17 |
+
# Add parent directories to path for imports
|
| 18 |
+
project_dir = Path(__file__).parent.parent
|
| 19 |
+
src_dir = project_dir / "src"
|
| 20 |
+
sys.path.insert(0, str(src_dir))
|
| 21 |
+
sys.path.insert(0, str(project_dir))
|
| 22 |
+
|
| 23 |
+
# Configure logging
|
| 24 |
+
logging.basicConfig(
|
| 25 |
+
level=logging.INFO,
|
| 26 |
+
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s'
|
| 27 |
+
)
|
| 28 |
+
logger = logging.getLogger(__name__)
|
| 29 |
+
|
| 30 |
+
# Load environment variables
|
| 31 |
+
load_dotenv()
|
| 32 |
+
|
| 33 |
+
|
| 34 |
+
class ChatAutomation:
|
| 35 |
+
"""Automates chat interactions and captures responses for testing."""
|
| 36 |
+
|
| 37 |
+
def __init__(self, use_mock: bool = False):
|
| 38 |
+
"""
|
| 39 |
+
Initialize the chat automation harness.
|
| 40 |
+
|
| 41 |
+
Args:
|
| 42 |
+
use_mock: If True, use mock Azure OpenAI service; otherwise use real API
|
| 43 |
+
"""
|
| 44 |
+
self.use_mock = use_mock
|
| 45 |
+
self.test_results = []
|
| 46 |
+
self.session_id = datetime.now().isoformat()
|
| 47 |
+
|
| 48 |
+
try:
|
| 49 |
+
if use_mock:
|
| 50 |
+
logger.info("Using MOCK Azure OpenAI service for testing")
|
| 51 |
+
self.openai_service = MockAzureOpenAIService()
|
| 52 |
+
else:
|
| 53 |
+
logger.info("Using REAL Azure OpenAI service")
|
| 54 |
+
from services.azure_openai_service import AzureOpenAIService
|
| 55 |
+
self.openai_service = AzureOpenAIService()
|
| 56 |
+
|
| 57 |
+
from services.data_dictionary_service import DataDictionaryService
|
| 58 |
+
from services.retrieval_service import RetrievalService, format_retrieved_chunks
|
| 59 |
+
|
| 60 |
+
self.data_dict_service = DataDictionaryService()
|
| 61 |
+
self.retrieval_service = RetrievalService(self.data_dict_service)
|
| 62 |
+
|
| 63 |
+
logger.info("Chat automation initialized successfully")
|
| 64 |
+
except Exception as e:
|
| 65 |
+
logger.error(f"Failed to initialize chat automation: {e}")
|
| 66 |
+
raise
|
| 67 |
+
|
| 68 |
+
def run_chat_test(self, test_case: Dict[str, Any]) -> Dict[str, Any]:
|
| 69 |
+
"""
|
| 70 |
+
Run a single chat test case.
|
| 71 |
+
|
| 72 |
+
Args:
|
| 73 |
+
test_case: Test case dictionary with 'test_id', 'query', etc.
|
| 74 |
+
|
| 75 |
+
Returns:
|
| 76 |
+
Dictionary containing test results with response, citations, metrics
|
| 77 |
+
"""
|
| 78 |
+
test_id = test_case.get("test_id", "UNKNOWN")
|
| 79 |
+
query = test_case.get("query", "")
|
| 80 |
+
|
| 81 |
+
logger.info(f"Running test {test_id}: {query[:50]}...")
|
| 82 |
+
|
| 83 |
+
result = {
|
| 84 |
+
"test_id": test_id,
|
| 85 |
+
"name": test_case.get("name", ""),
|
| 86 |
+
"type": test_case.get("type", "chat"),
|
| 87 |
+
"query": query,
|
| 88 |
+
"timestamp": datetime.now().isoformat(),
|
| 89 |
+
"success": False,
|
| 90 |
+
"response": None,
|
| 91 |
+
"retrieved_chunks": [],
|
| 92 |
+
"retrieved_datasets": [],
|
| 93 |
+
"citations": [],
|
| 94 |
+
"response_length": 0,
|
| 95 |
+
"execution_time_ms": 0,
|
| 96 |
+
"error": None
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
try:
|
| 100 |
+
import time
|
| 101 |
+
start_time = time.time()
|
| 102 |
+
|
| 103 |
+
# Run retrieval if not a simple greeting
|
| 104 |
+
should_retrieve = self._should_run_retrieval(query)
|
| 105 |
+
retrieved_chunks = []
|
| 106 |
+
|
| 107 |
+
if should_retrieve:
|
| 108 |
+
try:
|
| 109 |
+
active_dicts = [d['name'] for d in self.data_dict_service.get_all_dictionaries()
|
| 110 |
+
if d.get('active', True)]
|
| 111 |
+
# Use the retrieval service's available method
|
| 112 |
+
if hasattr(self.retrieval_service, 'retrieve'):
|
| 113 |
+
retrieved_chunks, _ = self.retrieval_service.retrieve(query, active_dicts, top_k=10)
|
| 114 |
+
elif hasattr(self.retrieval_service, 'hybrid_search'):
|
| 115 |
+
retrieved_chunks = self.retrieval_service.hybrid_search(query, top_k=10)
|
| 116 |
+
else:
|
| 117 |
+
retrieved_chunks = []
|
| 118 |
+
result["retrieved_chunks"] = [
|
| 119 |
+
{
|
| 120 |
+
"text": chunk.get("text", ""),
|
| 121 |
+
"dataset": chunk.get("dataset", ""),
|
| 122 |
+
"line": chunk.get("line_number", 0)
|
| 123 |
+
} for chunk in retrieved_chunks[:5] # Store top 5
|
| 124 |
+
]
|
| 125 |
+
result["retrieved_datasets"] = list(set([c.get("dataset", "") for c in retrieved_chunks]))
|
| 126 |
+
except Exception as e:
|
| 127 |
+
logger.warning(f"Retrieval failed for {test_id}: {e}")
|
| 128 |
+
result["retrieved_chunks"] = []
|
| 129 |
+
|
| 130 |
+
# Format context for LLM
|
| 131 |
+
context = self._format_context(retrieved_chunks) if retrieved_chunks else ""
|
| 132 |
+
|
| 133 |
+
# Get response from Azure OpenAI
|
| 134 |
+
if hasattr(self.openai_service, 'get_chat_response'):
|
| 135 |
+
# Mock service
|
| 136 |
+
response = self.openai_service.get_chat_response(
|
| 137 |
+
query=query,
|
| 138 |
+
context=context,
|
| 139 |
+
chat_history=[],
|
| 140 |
+
system_prompt=self._get_system_prompt()
|
| 141 |
+
)
|
| 142 |
+
else:
|
| 143 |
+
# Real Azure OpenAI service
|
| 144 |
+
# Build full prompt with context
|
| 145 |
+
full_prompt = f"{context}\n\nUser Question: {query}" if context else query
|
| 146 |
+
|
| 147 |
+
response_obj = self.openai_service.generate_response(
|
| 148 |
+
prompt=full_prompt,
|
| 149 |
+
chat_history=[],
|
| 150 |
+
system_prompt=self._get_system_prompt()
|
| 151 |
+
)
|
| 152 |
+
|
| 153 |
+
# Extract response text from Azure OpenAI response
|
| 154 |
+
if isinstance(response_obj, dict):
|
| 155 |
+
if "choices" in response_obj and len(response_obj["choices"]) > 0:
|
| 156 |
+
response = response_obj["choices"][0]["message"]["content"]
|
| 157 |
+
else:
|
| 158 |
+
response = response_obj.get('response', 'No response from the model.')
|
| 159 |
+
else:
|
| 160 |
+
response = str(response_obj)
|
| 161 |
+
|
| 162 |
+
end_time = time.time()
|
| 163 |
+
|
| 164 |
+
result["response"] = response
|
| 165 |
+
result["response_length"] = len(response)
|
| 166 |
+
result["execution_time_ms"] = int((end_time - start_time) * 1000)
|
| 167 |
+
result["success"] = True
|
| 168 |
+
|
| 169 |
+
# Extract citations from response
|
| 170 |
+
result["citations"] = self._extract_citations(response)
|
| 171 |
+
|
| 172 |
+
logger.info(f"Test {test_id} completed in {result['execution_time_ms']}ms")
|
| 173 |
+
|
| 174 |
+
except Exception as e:
|
| 175 |
+
logger.error(f"Test {test_id} failed: {e}", exc_info=True)
|
| 176 |
+
result["error"] = str(e)
|
| 177 |
+
|
| 178 |
+
return result
|
| 179 |
+
|
| 180 |
+
def run_area_insights_test(self, test_case: Dict[str, Any]) -> Dict[str, Any]:
|
| 181 |
+
"""
|
| 182 |
+
Run an Area Insights test case.
|
| 183 |
+
|
| 184 |
+
Args:
|
| 185 |
+
test_case: Test case with location/ZIP information
|
| 186 |
+
|
| 187 |
+
Returns:
|
| 188 |
+
Test result dictionary
|
| 189 |
+
"""
|
| 190 |
+
test_id = test_case.get("test_id", "UNKNOWN")
|
| 191 |
+
query = test_case.get("query", "")
|
| 192 |
+
location = test_case.get("location_name", "")
|
| 193 |
+
|
| 194 |
+
logger.info(f"Running Area Insights test {test_id}: {location}")
|
| 195 |
+
|
| 196 |
+
result = {
|
| 197 |
+
"test_id": test_id,
|
| 198 |
+
"name": test_case.get("name", ""),
|
| 199 |
+
"type": "area_insights",
|
| 200 |
+
"query": query,
|
| 201 |
+
"location": location,
|
| 202 |
+
"zip_code": test_case.get("zip_code", ""),
|
| 203 |
+
"timestamp": datetime.now().isoformat(),
|
| 204 |
+
"success": False,
|
| 205 |
+
"response": None,
|
| 206 |
+
"retrieved_chunks": [],
|
| 207 |
+
"retrieved_datasets": [],
|
| 208 |
+
"citations": [],
|
| 209 |
+
"error": None
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
+
try:
|
| 213 |
+
import time
|
| 214 |
+
start_time = time.time()
|
| 215 |
+
|
| 216 |
+
# In real implementation, would use zip_resolution_service here
|
| 217 |
+
# For now, simulate the area insights query
|
| 218 |
+
query_with_location = f"{query} (Location: {location})"
|
| 219 |
+
|
| 220 |
+
# Retrieve area-specific data
|
| 221 |
+
active_dicts = [d['name'] for d in self.data_dict_service.get_all_dictionaries()
|
| 222 |
+
if d.get('active', True)]
|
| 223 |
+
|
| 224 |
+
# Use search() method instead of retrieve()
|
| 225 |
+
if hasattr(self.retrieval_service, 'search'):
|
| 226 |
+
retrieved_chunks = self.retrieval_service.search(
|
| 227 |
+
query_with_location,
|
| 228 |
+
active_dicts,
|
| 229 |
+
top_k=15
|
| 230 |
+
)
|
| 231 |
+
else:
|
| 232 |
+
retrieved_chunks = []
|
| 233 |
+
|
| 234 |
+
result["retrieved_chunks"] = [
|
| 235 |
+
{
|
| 236 |
+
"text": chunk.get("text", "")[:100],
|
| 237 |
+
"dataset": chunk.get("dataset", ""),
|
| 238 |
+
"line": chunk.get("line_number", 0)
|
| 239 |
+
} for chunk in retrieved_chunks[:5]
|
| 240 |
+
]
|
| 241 |
+
result["retrieved_datasets"] = list(set([c.get("dataset", "") for c in retrieved_chunks]))
|
| 242 |
+
|
| 243 |
+
context = self._format_context(retrieved_chunks)
|
| 244 |
+
|
| 245 |
+
if hasattr(self.openai_service, 'get_chat_response'):
|
| 246 |
+
# Mock service
|
| 247 |
+
response = self.openai_service.get_chat_response(
|
| 248 |
+
query=query_with_location,
|
| 249 |
+
context=context,
|
| 250 |
+
chat_history=[],
|
| 251 |
+
system_prompt=self._get_area_insights_prompt()
|
| 252 |
+
)
|
| 253 |
+
else:
|
| 254 |
+
# Real Azure OpenAI service
|
| 255 |
+
full_prompt = f"{context}\n\nUser Question: {query_with_location}" if context else query_with_location
|
| 256 |
+
|
| 257 |
+
response_obj = self.openai_service.generate_response(
|
| 258 |
+
prompt=full_prompt,
|
| 259 |
+
chat_history=[],
|
| 260 |
+
system_prompt=self._get_area_insights_prompt()
|
| 261 |
+
)
|
| 262 |
+
|
| 263 |
+
# Extract response text from Azure OpenAI response
|
| 264 |
+
if isinstance(response_obj, dict):
|
| 265 |
+
if "choices" in response_obj and len(response_obj["choices"]) > 0:
|
| 266 |
+
response = response_obj["choices"][0]["message"]["content"]
|
| 267 |
+
else:
|
| 268 |
+
response = response_obj.get('response', 'No response from the model.')
|
| 269 |
+
else:
|
| 270 |
+
response = str(response_obj)
|
| 271 |
+
|
| 272 |
+
result["response"] = response
|
| 273 |
+
result["success"] = True
|
| 274 |
+
result["citations"] = self._extract_citations(response)
|
| 275 |
+
|
| 276 |
+
logger.info(f"Area Insights test {test_id} completed successfully")
|
| 277 |
+
|
| 278 |
+
except Exception as e:
|
| 279 |
+
logger.error(f"Area Insights test {test_id} failed: {e}")
|
| 280 |
+
result["error"] = str(e)
|
| 281 |
+
|
| 282 |
+
return result
|
| 283 |
+
|
| 284 |
+
def run_all_tests(self, test_cases_file: str = None) -> List[Dict[str, Any]]:
|
| 285 |
+
"""
|
| 286 |
+
Run all test cases from test_cases.json.
|
| 287 |
+
|
| 288 |
+
Args:
|
| 289 |
+
test_cases_file: Path to test_cases.json (auto-detected if None)
|
| 290 |
+
|
| 291 |
+
Returns:
|
| 292 |
+
List of test results
|
| 293 |
+
"""
|
| 294 |
+
# Auto-detect test cases file
|
| 295 |
+
if test_cases_file is None:
|
| 296 |
+
test_cases_file = Path(__file__).parent / "test_cases.json"
|
| 297 |
+
|
| 298 |
+
test_cases_file = Path(test_cases_file)
|
| 299 |
+
|
| 300 |
+
if not test_cases_file.exists():
|
| 301 |
+
logger.error(f"Test cases file not found: {test_cases_file}")
|
| 302 |
+
return []
|
| 303 |
+
|
| 304 |
+
with open(test_cases_file, 'r') as f:
|
| 305 |
+
test_data = json.load(f)
|
| 306 |
+
|
| 307 |
+
self.test_results = []
|
| 308 |
+
|
| 309 |
+
# Run chat interface tests
|
| 310 |
+
logger.info("Starting Chat Interface tests...")
|
| 311 |
+
for test_case in test_data.get("chat_interface_tests", []):
|
| 312 |
+
result = self.run_chat_test(test_case)
|
| 313 |
+
self.test_results.append(result)
|
| 314 |
+
|
| 315 |
+
# Run area insights tests
|
| 316 |
+
logger.info("Starting Area Insights tests...")
|
| 317 |
+
for test_case in test_data.get("area_insights_tests", []):
|
| 318 |
+
result = self.run_area_insights_test(test_case)
|
| 319 |
+
self.test_results.append(result)
|
| 320 |
+
|
| 321 |
+
logger.info(f"Completed {len(self.test_results)} tests")
|
| 322 |
+
return self.test_results
|
| 323 |
+
|
| 324 |
+
def save_results(self, output_file: str = None) -> str:
|
| 325 |
+
"""
|
| 326 |
+
Save test results to JSON file.
|
| 327 |
+
|
| 328 |
+
Args:
|
| 329 |
+
output_file: Output file path (auto-generated if None)
|
| 330 |
+
|
| 331 |
+
Returns:
|
| 332 |
+
Path to saved file
|
| 333 |
+
"""
|
| 334 |
+
if output_file is None:
|
| 335 |
+
output_dir = Path(__file__).parent / "test_results"
|
| 336 |
+
output_dir.mkdir(exist_ok=True)
|
| 337 |
+
output_file = output_dir / f"chat_results_{self.session_id.replace(':', '-')}.json"
|
| 338 |
+
|
| 339 |
+
output_file = Path(output_file)
|
| 340 |
+
|
| 341 |
+
with open(output_file, 'w') as f:
|
| 342 |
+
json.dump(self.test_results, f, indent=2)
|
| 343 |
+
|
| 344 |
+
logger.info(f"Results saved to {output_file}")
|
| 345 |
+
return str(output_file)
|
| 346 |
+
|
| 347 |
+
@staticmethod
|
| 348 |
+
def _should_run_retrieval(query: str) -> bool:
|
| 349 |
+
"""Determine if retrieval should run for this query."""
|
| 350 |
+
simple_queries = ["hi", "hello", "hey", "thanks", "thank you", "ok", "okay", "bye", "goodbye"]
|
| 351 |
+
return query.lower().strip() not in simple_queries and len(query.split()) > 3
|
| 352 |
+
|
| 353 |
+
@staticmethod
|
| 354 |
+
def _format_context(chunks: List[Dict]) -> str:
|
| 355 |
+
"""Format retrieved chunks for LLM context."""
|
| 356 |
+
if not chunks:
|
| 357 |
+
return ""
|
| 358 |
+
|
| 359 |
+
context = "Retrieved Data Dictionary Entries:\n\n"
|
| 360 |
+
for i, chunk in enumerate(chunks[:10], 1):
|
| 361 |
+
dataset = chunk.get("dataset", "Unknown")
|
| 362 |
+
text = chunk.get("text", "")[:200]
|
| 363 |
+
context += f"{i}. [{dataset}] {text}\n"
|
| 364 |
+
|
| 365 |
+
return context
|
| 366 |
+
|
| 367 |
+
@staticmethod
|
| 368 |
+
def _get_system_prompt() -> str:
|
| 369 |
+
"""System prompt for chat interface."""
|
| 370 |
+
return """You are an expert data scientist assistant helping users find relevant columns and datasets for machine learning projects.
|
| 371 |
+
When recommending columns:
|
| 372 |
+
1. Always cite the source dataset in format: **ColumnName** (Dataset: DatasetName)
|
| 373 |
+
2. Explain why each column is relevant to the user's use case
|
| 374 |
+
3. Group recommendations by dataset when multiple datasets are involved
|
| 375 |
+
4. Be specific and cite only columns that actually exist in the provided data dictionaries
|
| 376 |
+
5. If you're not certain a column exists, do not recommend it
|
| 377 |
+
6. Provide 3-5 most relevant recommendations unless the user asks for more"""
|
| 378 |
+
|
| 379 |
+
@staticmethod
|
| 380 |
+
def _get_area_insights_prompt() -> str:
|
| 381 |
+
"""System prompt for area insights."""
|
| 382 |
+
return """You are an expert in geographic health data analysis. When answering about a specific area:
|
| 383 |
+
1. Always cite which dataset contains information for this area
|
| 384 |
+
2. Focus on data specific to the requested geography
|
| 385 |
+
3. If certain data isn't available for the area, suggest general state or national alternatives
|
| 386 |
+
4. Format recommendations as: **ColumnName** (Dataset: DatasetName, Available for: CityName, State)"""
|
| 387 |
+
|
| 388 |
+
@staticmethod
|
| 389 |
+
def _extract_citations(text: str) -> List[str]:
|
| 390 |
+
"""Extract dataset citations from response text."""
|
| 391 |
+
import re
|
| 392 |
+
|
| 393 |
+
# Pattern: (Dataset: DatasetName) or (Source: DatasetName)
|
| 394 |
+
pattern = r'\((?:Dataset|Source): ([^\)]+)\)'
|
| 395 |
+
matches = re.findall(pattern, text)
|
| 396 |
+
return list(set(matches))
|
| 397 |
+
|
| 398 |
+
|
| 399 |
+
class MockAzureOpenAIService:
|
| 400 |
+
"""Mock Azure OpenAI service for testing without API costs."""
|
| 401 |
+
|
| 402 |
+
def __init__(self):
|
| 403 |
+
self.call_count = 0
|
| 404 |
+
|
| 405 |
+
def get_chat_response(
|
| 406 |
+
self,
|
| 407 |
+
query: str,
|
| 408 |
+
context: str = "",
|
| 409 |
+
chat_history: List = None,
|
| 410 |
+
system_prompt: str = ""
|
| 411 |
+
) -> str:
|
| 412 |
+
"""Return mock response based on query patterns."""
|
| 413 |
+
self.call_count += 1
|
| 414 |
+
|
| 415 |
+
query_lower = query.lower()
|
| 416 |
+
|
| 417 |
+
# Mock responses for different query types
|
| 418 |
+
if "diabetes" in query_lower:
|
| 419 |
+
return """Based on the available data dictionaries, here are the most relevant columns for diabetes risk prediction:
|
| 420 |
+
|
| 421 |
+
1. **HbA1c Level** (Dataset: EJI_2024) - Glycated hemoglobin percentage, primary indicator of diabetes
|
| 422 |
+
2. **Fasting Glucose** (Dataset: AHRF-2025) - Fasting blood glucose concentration in mg/dL
|
| 423 |
+
3. **BMI** (Dataset: EJI_2024) - Body Mass Index, strong predictor of diabetes risk
|
| 424 |
+
4. **Family History of Diabetes** (Dataset: AHRF-2025) - Genetic predisposition indicator
|
| 425 |
+
5. **Age** (Dataset: SVI_2022) - Age group demographic available across all datasets
|
| 426 |
+
|
| 427 |
+
These columns appear in multiple datasets, with the most complete coverage in EJI_2024 and AHRF-2025. I recommend using these as your primary features for the model."""
|
| 428 |
+
|
| 429 |
+
elif "hospital" in query_lower and "readmission" in query_lower:
|
| 430 |
+
return """For predicting 30-day hospital readmission, these columns are most relevant:
|
| 431 |
+
|
| 432 |
+
1. **Length of Stay** (Dataset: AHRF-2025) - Previous hospitalization duration
|
| 433 |
+
2. **Number of Chronic Conditions** (Dataset: EJI_2024) - Comorbidity burden
|
| 434 |
+
3. **Age** (Dataset: SVI_2022) - Older patients have higher readmission rates
|
| 435 |
+
4. **Insurance Status** (Dataset: AHRF-2025) - Access to follow-up care
|
| 436 |
+
5. **Medication Adherence** (Dataset: EJI_2024) - Post-discharge compliance
|
| 437 |
+
|
| 438 |
+
Primary data sources: AHRF-2025 and EJI_2024."""
|
| 439 |
+
|
| 440 |
+
elif "food" in query_lower or "insecurity" in query_lower:
|
| 441 |
+
return """Food insecurity and health impact columns:
|
| 442 |
+
|
| 443 |
+
1. **Food Insecurity Index** (Dataset: EJI_2024) - Direct measure from environmental justice data
|
| 444 |
+
2. **Poverty Rate** (Dataset: SVI_2022) - Strong correlation with food insecurity
|
| 445 |
+
3. **SNAP Participation** (Dataset: EJI_2024) - Food assistance program enrollment
|
| 446 |
+
4. **Household Food Spending** (Dataset: SVI_2022) - Economic burden indicator
|
| 447 |
+
|
| 448 |
+
Data sources: EJI_2024 (primary), SVI_2022 (demographic context)"""
|
| 449 |
+
|
| 450 |
+
elif "svi" in query_lower or "social vulnerability" in query_lower:
|
| 451 |
+
return """The Social Vulnerability Index (SVI) dataset includes:
|
| 452 |
+
|
| 453 |
+
1. **SVI Theme 1: Socioeconomic Status** (Dataset: SVI_2022) - Poverty, unemployment, income ratios
|
| 454 |
+
2. **SVI Theme 2: Household Composition** (Dataset: SVI_2022) - Age, disability, single parents
|
| 455 |
+
3. **SVI Theme 3: Racial/Ethnic Minorities** (Dataset: SVI_2022) - Minority status and language
|
| 456 |
+
4. **SVI Theme 4: Housing Type & Transportation** (Dataset: SVI_2022) - Mobile homes, crowding
|
| 457 |
+
5. **Overall SVI Score** (Dataset: SVI_2022) - Percentile ranking of vulnerability
|
| 458 |
+
|
| 459 |
+
Cross-referenced with (Dataset: EJI_2024) and (Dataset: AHRF-2025) for comprehensive analysis."""
|
| 460 |
+
|
| 461 |
+
elif "environmental" in query_lower and "health" in query_lower:
|
| 462 |
+
return """Environmental health and pollution columns:
|
| 463 |
+
|
| 464 |
+
1. **PM2.5 Concentration** (Dataset: EJI_2024) - Fine particulate matter exposure
|
| 465 |
+
2. **Ozone Level** (Dataset: EJI_2024) - Ground-level ozone concentration
|
| 466 |
+
3. **Proximity to Hazardous Waste** (Dataset: EJI_2024) - Facility distance measure
|
| 467 |
+
4. **Industrial Facility Count** (Dataset: EJI_2024) - Local pollution sources
|
| 468 |
+
5. **Drinking Water Violations** (Dataset: EJI_2024) - Water quality issues
|
| 469 |
+
|
| 470 |
+
Also referenced in (Dataset: AHRF-2025) and (Dataset: SVI_2022) for health outcomes."""
|
| 471 |
+
|
| 472 |
+
elif "healthcare" in query_lower or "provider" in query_lower or "workforce" in query_lower:
|
| 473 |
+
return """Healthcare workforce and provider columns:
|
| 474 |
+
|
| 475 |
+
1. **Physician Density** (Dataset: AHRF-2025) - Physicians per 100,000 population
|
| 476 |
+
2. **Nurse Availability** (Dataset: AHRF-2025) - Registered nurses per capita
|
| 477 |
+
3. **Hospital Beds** (Dataset: AHRF-2025) - Acute care hospital bed availability
|
| 478 |
+
4. **Mental Health Provider Count** (Dataset: AHRF-2025) - Psychiatrists and counselors
|
| 479 |
+
5. **Primary Care Physician Shortage** (Dataset: AHRF-2025) - Designation status
|
| 480 |
+
|
| 481 |
+
Supplemented with (Dataset: EJI_2024) health outcome data and (Dataset: SVI_2022) demographics."""
|
| 482 |
+
|
| 483 |
+
elif "demographic" in query_lower:
|
| 484 |
+
return """Demographic columns across all datasets:
|
| 485 |
+
|
| 486 |
+
1. **Age Group** (Dataset: EJI_2024) - Population age distribution
|
| 487 |
+
2. **Gender/Sex** (Dataset: SVI_2022) - Gender breakdown
|
| 488 |
+
3. **Race/Ethnicity** (Dataset: AHRF-2025) - Racial and ethnic categories
|
| 489 |
+
4. **Education Level** (Dataset: SVI_2022) - Educational attainment
|
| 490 |
+
5. **Population Density** (Dataset: EJI_2024) - Urban vs rural
|
| 491 |
+
|
| 492 |
+
Available in all three datasets: SVI_2022, EJI_2024, and AHRF-2025."""
|
| 493 |
+
|
| 494 |
+
elif "mental" in query_lower:
|
| 495 |
+
return """Mental health related columns:
|
| 496 |
+
|
| 497 |
+
1. **Mental Health Provider Count** (Dataset: AHRF-2025) - Psychiatrists, therapists per capita
|
| 498 |
+
2. **Behavioral Health Disorder Rate** (Dataset: EJI_2024) - Prevalence of behavioral health issues
|
| 499 |
+
3. **Substance Use Disorder** (Dataset: EJI_2024) - Addiction and drug abuse indicators
|
| 500 |
+
4. **Depression Screening Rate** (Dataset: AHRF-2025) - Mental health assessment coverage
|
| 501 |
+
|
| 502 |
+
Primary sources: AHRF-2025 and EJI_2024."""
|
| 503 |
+
|
| 504 |
+
elif "hi" in query_lower or "hello" in query_lower or "hey" in query_lower:
|
| 505 |
+
return "Hello! I'm here to help you find relevant data columns for your machine learning projects. What would you like to know about the available datasets?"
|
| 506 |
+
|
| 507 |
+
elif "most recent" in query_lower or "recent data" in query_lower or "dataset" in query_lower and ("recent" in query_lower or "newest" in query_lower or "latest" in query_lower):
|
| 508 |
+
return """Our system includes the following datasets:
|
| 509 |
+
|
| 510 |
+
1. **AHRF-2025** (Dataset: AHRF-2025) - Area Health Resources File 2025, most recent healthcare data
|
| 511 |
+
2. **EJI_2024** (Dataset: EJI_2024) - Environmental Justice Indicators 2024 edition
|
| 512 |
+
3. **SVI_2022** (Dataset: SVI_2022) - Social Vulnerability Index 2022 edition
|
| 513 |
+
|
| 514 |
+
The most recently updated dataset is (Dataset: AHRF-2025), containing the latest healthcare workforce and availability data. Use (Dataset: EJI_2024) for environmental and health equity indicators, and (Dataset: SVI_2022) for demographic vulnerability context."""
|
| 515 |
+
|
| 516 |
+
elif "chronic" in query_lower and ("disease" in query_lower or "burden" in query_lower):
|
| 517 |
+
return """Chronic disease burden indicators:
|
| 518 |
+
|
| 519 |
+
1. **Chronic Disease Prevalence** (Dataset: EJI_2024) - Overall chronic disease rates
|
| 520 |
+
2. **Diabetes Prevalence** (Dataset: EJI_2024) - Type 1 and Type 2 diabetes cases
|
| 521 |
+
3. **Heart Disease Rate** (Dataset: AHRF-2025) - Cardiovascular disease indicators
|
| 522 |
+
4. **Respiratory Disease** (Dataset: EJI_2024) - Asthma and lung disease rates
|
| 523 |
+
5. **Cancer Incidence** (Dataset: AHRF-2025) - Cancer case data
|
| 524 |
+
|
| 525 |
+
Data sources: (Dataset: EJI_2024) for prevalence, (Dataset: AHRF-2025) for healthcare response."""
|
| 526 |
+
|
| 527 |
+
elif "access" in query_lower and ("care" in query_lower or "healthcare" in query_lower or "services" in query_lower):
|
| 528 |
+
return """Access to care indicators:
|
| 529 |
+
|
| 530 |
+
1. **Healthcare Provider Density** (Dataset: AHRF-2025) - Doctors and clinics per population
|
| 531 |
+
2. **Hospital Proximity** (Dataset: AHRF-2025) - Distance to nearest hospital
|
| 532 |
+
3. **Insurance Coverage** (Dataset: AHRF-2025) - Percentage with health insurance
|
| 533 |
+
4. **Transportation Access** (Dataset: SVI_2022) - Vehicle availability and transit options
|
| 534 |
+
5. **Uninsured Rate** (Dataset: AHRF-2025) - Population without insurance
|
| 535 |
+
|
| 536 |
+
Primary source: (Dataset: AHRF-2025); supplemented with (Dataset: SVI_2022) demographic context."""
|
| 537 |
+
|
| 538 |
+
elif "economic" in query_lower or ("poverty" in query_lower and "columns" in query_lower) or ("poverty" in query_lower and "relate" in query_lower):
|
| 539 |
+
return """Economic and poverty indicators:
|
| 540 |
+
|
| 541 |
+
1. **Poverty Rate** (Dataset: SVI_2022) - Percentage below poverty line
|
| 542 |
+
2. **Median Household Income** (Dataset: EJI_2024) - Income distribution
|
| 543 |
+
3. **Unemployment Rate** (Dataset: AHRF-2025) - Job market indicators
|
| 544 |
+
4. **Income Inequality** (Dataset: SVI_2022) - Gini coefficient and ratios
|
| 545 |
+
5. **Economic Hardship Index** (Dataset: EJI_2024) - Combined economic distress
|
| 546 |
+
|
| 547 |
+
Available in: (Dataset: SVI_2022) primary source, (Dataset: EJI_2024) and (Dataset: AHRF-2025) supplementary."""
|
| 548 |
+
|
| 549 |
+
elif "housing" in query_lower or "living" in query_lower or "crowding" in query_lower:
|
| 550 |
+
return """Housing and living condition columns:
|
| 551 |
+
|
| 552 |
+
1. **Housing Unit Density** (Dataset: SVI_2022) - People per housing unit
|
| 553 |
+
2. **Mobile Home Percentage** (Dataset: SVI_2022, Dataset: EJI_2024) - Mobile vs permanent housing
|
| 554 |
+
3. **Crowding Index** (Dataset: SVI_2022) - Occupancy per room ratio
|
| 555 |
+
4. **Occupied Housing Units** (Dataset: SVI_2022) - Household count
|
| 556 |
+
5. **Housing Cost Burden** (Dataset: SVI_2022, Dataset: AHRF-2025) - Percentage spending on housing
|
| 557 |
+
|
| 558 |
+
Data from: (Dataset: SVI_2022) primary, (Dataset: EJI_2024) and (Dataset: AHRF-2025) supplementary."""
|
| 559 |
+
|
| 560 |
+
else:
|
| 561 |
+
return f"""I found relevant columns for your query about '{query[:50]}...'.
|
| 562 |
+
|
| 563 |
+
Based on the available data dictionaries (EJI_2024, AHRF-2025, SVI_2022), here are some potentially useful columns:
|
| 564 |
+
|
| 565 |
+
1. **Sample Column A** (Dataset: EJI_2024) - Description of column A
|
| 566 |
+
2. **Sample Column B** (Dataset: AHRF-2025) - Description of column B
|
| 567 |
+
3. **Sample Column C** (Dataset: SVI_2022) - Description of column C
|
| 568 |
+
|
| 569 |
+
Would you like more details about any of these columns or datasets?"""
|
| 570 |
+
|
| 571 |
+
|
| 572 |
+
def main():
|
| 573 |
+
"""Run chat automation tests."""
|
| 574 |
+
import argparse
|
| 575 |
+
|
| 576 |
+
parser = argparse.ArgumentParser(description="Automated chat testing for Data Dictionary Chatbot")
|
| 577 |
+
parser.add_argument("--mock", action="store_true", help="Use mock Azure OpenAI service")
|
| 578 |
+
parser.add_argument("--output", default=None, help="Output file path")
|
| 579 |
+
parser.add_argument("--test-cases", default=None, help="Path to test_cases.json")
|
| 580 |
+
|
| 581 |
+
args = parser.parse_args()
|
| 582 |
+
|
| 583 |
+
automation = ChatAutomation(use_mock=args.mock)
|
| 584 |
+
results = automation.run_all_tests(args.test_cases)
|
| 585 |
+
output_file = automation.save_results(args.output)
|
| 586 |
+
|
| 587 |
+
print(f"\n✅ Completed {len(results)} tests")
|
| 588 |
+
print(f"📊 Results saved to: {output_file}")
|
| 589 |
+
|
| 590 |
+
|
| 591 |
+
if __name__ == "__main__":
|
| 592 |
+
main()
|
tests/conftest.py
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
conftest.py
|
| 3 |
+
|
| 4 |
+
Pytest configuration and fixtures for chat automation and accuracy testing.
|
| 5 |
+
"""
|
| 6 |
+
|
| 7 |
+
import pytest
|
| 8 |
+
import json
|
| 9 |
+
import sys
|
| 10 |
+
from pathlib import Path
|
| 11 |
+
from dotenv import load_dotenv
|
| 12 |
+
|
| 13 |
+
# Load environment variables
|
| 14 |
+
load_dotenv()
|
| 15 |
+
|
| 16 |
+
# Add parent directories to path
|
| 17 |
+
test_dir = Path(__file__).parent
|
| 18 |
+
project_dir = test_dir.parent
|
| 19 |
+
src_dir = project_dir / "src"
|
| 20 |
+
|
| 21 |
+
if str(src_dir) not in sys.path:
|
| 22 |
+
sys.path.insert(0, str(src_dir))
|
| 23 |
+
if str(project_dir) not in sys.path:
|
| 24 |
+
sys.path.insert(0, str(project_dir))
|
| 25 |
+
if str(test_dir) not in sys.path:
|
| 26 |
+
sys.path.insert(0, str(test_dir))
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
@pytest.fixture
|
| 30 |
+
def test_cases():
|
| 31 |
+
"""Load test cases from test_cases.json."""
|
| 32 |
+
test_file = Path(__file__).parent / "test_cases.json"
|
| 33 |
+
with open(test_file, 'r') as f:
|
| 34 |
+
data = json.load(f)
|
| 35 |
+
return data
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
@pytest.fixture
|
| 39 |
+
def chat_interface_tests(test_cases):
|
| 40 |
+
"""Get chat interface test cases."""
|
| 41 |
+
return test_cases.get("chat_interface_tests", [])
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
@pytest.fixture
|
| 45 |
+
def area_insights_tests(test_cases):
|
| 46 |
+
"""Get area insights test cases."""
|
| 47 |
+
return test_cases.get("area_insights_tests", [])
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
@pytest.fixture
|
| 51 |
+
def validation_rules(test_cases):
|
| 52 |
+
"""Get validation rules."""
|
| 53 |
+
return test_cases.get("validation_rules", {})
|
| 54 |
+
|
| 55 |
+
|
| 56 |
+
@pytest.fixture
|
| 57 |
+
def data_dictionary_service():
|
| 58 |
+
"""Initialize DataDictionaryService for testing."""
|
| 59 |
+
try:
|
| 60 |
+
from services.data_dictionary_service import DataDictionaryService
|
| 61 |
+
return DataDictionaryService()
|
| 62 |
+
except Exception as e:
|
| 63 |
+
pytest.skip(f"Could not initialize DataDictionaryService: {e}")
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
@pytest.fixture
|
| 67 |
+
def retrieval_service(data_dictionary_service):
|
| 68 |
+
"""Initialize RetrievalService for testing."""
|
| 69 |
+
try:
|
| 70 |
+
from services.retrieval_service import RetrievalService
|
| 71 |
+
return RetrievalService(data_dictionary_service)
|
| 72 |
+
except Exception as e:
|
| 73 |
+
pytest.skip(f"Could not initialize RetrievalService: {e}")
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
@pytest.fixture
|
| 77 |
+
def chat_automation_mock():
|
| 78 |
+
"""Initialize ChatAutomation with mock service."""
|
| 79 |
+
try:
|
| 80 |
+
sys.path.insert(0, str(Path(__file__).parent))
|
| 81 |
+
from chat_automation import ChatAutomation
|
| 82 |
+
return ChatAutomation(use_mock=True)
|
| 83 |
+
except Exception as e:
|
| 84 |
+
pytest.skip(f"Could not initialize ChatAutomation: {e}")
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
@pytest.fixture
|
| 88 |
+
def accuracy_analyzer(data_dictionary_service):
|
| 89 |
+
"""Initialize AccuracyAnalyzer for testing."""
|
| 90 |
+
try:
|
| 91 |
+
from accuracy_validators import AccuracyAnalyzer
|
| 92 |
+
return AccuracyAnalyzer(data_dictionary_service)
|
| 93 |
+
except Exception as e:
|
| 94 |
+
pytest.skip(f"Could not initialize AccuracyAnalyzer: {e}")
|
tests/report_generator.py
ADDED
|
@@ -0,0 +1,660 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
report_generator.py
|
| 3 |
+
|
| 4 |
+
Generates comprehensive HTML and Markdown reports from accuracy analysis results.
|
| 5 |
+
"""
|
| 6 |
+
|
| 7 |
+
import json
|
| 8 |
+
import logging
|
| 9 |
+
from pathlib import Path
|
| 10 |
+
from datetime import datetime
|
| 11 |
+
from typing import Dict, List, Any, Optional
|
| 12 |
+
|
| 13 |
+
logger = logging.getLogger(__name__)
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
class ReportGenerator:
|
| 17 |
+
"""Generates human-readable accuracy reports."""
|
| 18 |
+
|
| 19 |
+
def __init__(self):
|
| 20 |
+
"""Initialize report generator."""
|
| 21 |
+
self.timestamp = datetime.now()
|
| 22 |
+
|
| 23 |
+
def generate_html_report(
|
| 24 |
+
self,
|
| 25 |
+
batch_analysis: Dict[str, Any],
|
| 26 |
+
output_file: Optional[str] = None
|
| 27 |
+
) -> str:
|
| 28 |
+
"""
|
| 29 |
+
Generate comprehensive HTML report.
|
| 30 |
+
|
| 31 |
+
Args:
|
| 32 |
+
batch_analysis: Output from AccuracyAnalyzer.analyze_batch()
|
| 33 |
+
output_file: Output file path (auto-generated if None)
|
| 34 |
+
|
| 35 |
+
Returns:
|
| 36 |
+
Path to generated HTML file
|
| 37 |
+
"""
|
| 38 |
+
if output_file is None:
|
| 39 |
+
output_dir = Path(__file__).parent / "test_reports"
|
| 40 |
+
output_dir.mkdir(exist_ok=True)
|
| 41 |
+
timestamp = self.timestamp.strftime("%Y%m%d_%H%M%S")
|
| 42 |
+
output_file = output_dir / f"accuracy_report_{timestamp}.html"
|
| 43 |
+
|
| 44 |
+
output_file = Path(output_file)
|
| 45 |
+
|
| 46 |
+
# Generate HTML
|
| 47 |
+
html_content = self._generate_html_content(batch_analysis)
|
| 48 |
+
|
| 49 |
+
with open(output_file, 'w', encoding='utf-8') as f:
|
| 50 |
+
f.write(html_content)
|
| 51 |
+
|
| 52 |
+
logger.info(f"HTML report generated: {output_file}")
|
| 53 |
+
return str(output_file)
|
| 54 |
+
|
| 55 |
+
def generate_markdown_report(
|
| 56 |
+
self,
|
| 57 |
+
batch_analysis: Dict[str, Any],
|
| 58 |
+
output_file: Optional[str] = None
|
| 59 |
+
) -> str:
|
| 60 |
+
"""
|
| 61 |
+
Generate Markdown report.
|
| 62 |
+
|
| 63 |
+
Args:
|
| 64 |
+
batch_analysis: Output from AccuracyAnalyzer.analyze_batch()
|
| 65 |
+
output_file: Output file path (auto-generated if None)
|
| 66 |
+
|
| 67 |
+
Returns:
|
| 68 |
+
Path to generated Markdown file
|
| 69 |
+
"""
|
| 70 |
+
if output_file is None:
|
| 71 |
+
output_dir = Path(__file__).parent / "test_reports"
|
| 72 |
+
output_dir.mkdir(exist_ok=True)
|
| 73 |
+
timestamp = self.timestamp.strftime("%Y%m%d_%H%M%S")
|
| 74 |
+
output_file = output_dir / f"accuracy_report_{timestamp}.md"
|
| 75 |
+
|
| 76 |
+
output_file = Path(output_file)
|
| 77 |
+
|
| 78 |
+
# Generate Markdown
|
| 79 |
+
md_content = self._generate_markdown_content(batch_analysis)
|
| 80 |
+
|
| 81 |
+
with open(output_file, 'w', encoding='utf-8') as f:
|
| 82 |
+
f.write(md_content)
|
| 83 |
+
|
| 84 |
+
logger.info(f"Markdown report generated: {output_file}")
|
| 85 |
+
return str(output_file)
|
| 86 |
+
|
| 87 |
+
def _generate_html_content(self, batch_analysis: Dict[str, Any]) -> str:
|
| 88 |
+
"""Generate HTML content for report."""
|
| 89 |
+
timestamp = self.timestamp.strftime("%Y-%m-%d %H:%M:%S")
|
| 90 |
+
total = batch_analysis.get("total_tests", 0)
|
| 91 |
+
passed = batch_analysis.get("passed_tests", 0)
|
| 92 |
+
failed = batch_analysis.get("failed_tests", 0)
|
| 93 |
+
avg_score = batch_analysis.get("average_score", 0)
|
| 94 |
+
pass_rate = batch_analysis.get("pass_rate", 0)
|
| 95 |
+
|
| 96 |
+
# Determine overall status color
|
| 97 |
+
status_color = "#22c55e" if pass_rate >= 0.8 else "#f59e0b" if pass_rate >= 0.6 else "#ef4444"
|
| 98 |
+
status_text = "✅ EXCELLENT" if pass_rate >= 0.9 else "✅ GOOD" if pass_rate >= 0.8 else "⚠️ FAIR" if pass_rate >= 0.6 else "❌ POOR"
|
| 99 |
+
|
| 100 |
+
html = f"""<!DOCTYPE html>
|
| 101 |
+
<html lang="en">
|
| 102 |
+
<head>
|
| 103 |
+
<meta charset="UTF-8">
|
| 104 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 105 |
+
<title>Data Dictionary Chatbot - Accuracy Report</title>
|
| 106 |
+
<style>
|
| 107 |
+
* {{
|
| 108 |
+
margin: 0;
|
| 109 |
+
padding: 0;
|
| 110 |
+
box-sizing: border-box;
|
| 111 |
+
}}
|
| 112 |
+
|
| 113 |
+
body {{
|
| 114 |
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
|
| 115 |
+
line-height: 1.6;
|
| 116 |
+
color: #333;
|
| 117 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 118 |
+
min-height: 100vh;
|
| 119 |
+
padding: 20px;
|
| 120 |
+
}}
|
| 121 |
+
|
| 122 |
+
.container {{
|
| 123 |
+
max-width: 1200px;
|
| 124 |
+
margin: 0 auto;
|
| 125 |
+
background: white;
|
| 126 |
+
border-radius: 10px;
|
| 127 |
+
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
|
| 128 |
+
overflow: hidden;
|
| 129 |
+
}}
|
| 130 |
+
|
| 131 |
+
.header {{
|
| 132 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 133 |
+
color: white;
|
| 134 |
+
padding: 40px;
|
| 135 |
+
text-align: center;
|
| 136 |
+
}}
|
| 137 |
+
|
| 138 |
+
.header h1 {{
|
| 139 |
+
font-size: 2.5em;
|
| 140 |
+
margin-bottom: 10px;
|
| 141 |
+
}}
|
| 142 |
+
|
| 143 |
+
.header p {{
|
| 144 |
+
font-size: 1em;
|
| 145 |
+
opacity: 0.9;
|
| 146 |
+
}}
|
| 147 |
+
|
| 148 |
+
.metrics {{
|
| 149 |
+
display: grid;
|
| 150 |
+
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
| 151 |
+
gap: 20px;
|
| 152 |
+
padding: 40px;
|
| 153 |
+
background: #f8f9fa;
|
| 154 |
+
border-bottom: 1px solid #e0e0e0;
|
| 155 |
+
}}
|
| 156 |
+
|
| 157 |
+
.metric {{
|
| 158 |
+
text-align: center;
|
| 159 |
+
padding: 20px;
|
| 160 |
+
background: white;
|
| 161 |
+
border-radius: 8px;
|
| 162 |
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
| 163 |
+
}}
|
| 164 |
+
|
| 165 |
+
.metric-value {{
|
| 166 |
+
font-size: 2em;
|
| 167 |
+
font-weight: bold;
|
| 168 |
+
color: #667eea;
|
| 169 |
+
margin: 10px 0;
|
| 170 |
+
}}
|
| 171 |
+
|
| 172 |
+
.metric-label {{
|
| 173 |
+
font-size: 0.9em;
|
| 174 |
+
color: #666;
|
| 175 |
+
text-transform: uppercase;
|
| 176 |
+
letter-spacing: 1px;
|
| 177 |
+
}}
|
| 178 |
+
|
| 179 |
+
.overall-status {{
|
| 180 |
+
font-size: 1.2em;
|
| 181 |
+
font-weight: bold;
|
| 182 |
+
padding: 20px;
|
| 183 |
+
border-radius: 8px;
|
| 184 |
+
background: {status_color};
|
| 185 |
+
color: white;
|
| 186 |
+
text-align: center;
|
| 187 |
+
}}
|
| 188 |
+
|
| 189 |
+
.content {{
|
| 190 |
+
padding: 40px;
|
| 191 |
+
}}
|
| 192 |
+
|
| 193 |
+
.section {{
|
| 194 |
+
margin-bottom: 40px;
|
| 195 |
+
}}
|
| 196 |
+
|
| 197 |
+
.section-title {{
|
| 198 |
+
font-size: 1.8em;
|
| 199 |
+
color: #333;
|
| 200 |
+
margin-bottom: 20px;
|
| 201 |
+
padding-bottom: 10px;
|
| 202 |
+
border-bottom: 3px solid #667eea;
|
| 203 |
+
}}
|
| 204 |
+
|
| 205 |
+
.test-result {{
|
| 206 |
+
margin-bottom: 20px;
|
| 207 |
+
padding: 20px;
|
| 208 |
+
border-left: 5px solid #ddd;
|
| 209 |
+
background: #f8f9fa;
|
| 210 |
+
border-radius: 4px;
|
| 211 |
+
}}
|
| 212 |
+
|
| 213 |
+
.test-result.passed {{
|
| 214 |
+
border-left-color: #22c55e;
|
| 215 |
+
background: #f0fdf4;
|
| 216 |
+
}}
|
| 217 |
+
|
| 218 |
+
.test-result.failed {{
|
| 219 |
+
border-left-color: #ef4444;
|
| 220 |
+
background: #fef2f2;
|
| 221 |
+
}}
|
| 222 |
+
|
| 223 |
+
.test-header {{
|
| 224 |
+
display: flex;
|
| 225 |
+
justify-content: space-between;
|
| 226 |
+
align-items: center;
|
| 227 |
+
margin-bottom: 10px;
|
| 228 |
+
}}
|
| 229 |
+
|
| 230 |
+
.test-name {{
|
| 231 |
+
font-weight: bold;
|
| 232 |
+
font-size: 1.1em;
|
| 233 |
+
color: #333;
|
| 234 |
+
}}
|
| 235 |
+
|
| 236 |
+
.test-id {{
|
| 237 |
+
color: #666;
|
| 238 |
+
font-size: 0.9em;
|
| 239 |
+
font-family: monospace;
|
| 240 |
+
}}
|
| 241 |
+
|
| 242 |
+
.test-score {{
|
| 243 |
+
font-size: 1.2em;
|
| 244 |
+
font-weight: bold;
|
| 245 |
+
padding: 5px 15px;
|
| 246 |
+
border-radius: 20px;
|
| 247 |
+
color: white;
|
| 248 |
+
}}
|
| 249 |
+
|
| 250 |
+
.test-score.excellent {{
|
| 251 |
+
background: #22c55e;
|
| 252 |
+
}}
|
| 253 |
+
|
| 254 |
+
.test-score.good {{
|
| 255 |
+
background: #3b82f6;
|
| 256 |
+
}}
|
| 257 |
+
|
| 258 |
+
.test-score.fair {{
|
| 259 |
+
background: #f59e0b;
|
| 260 |
+
}}
|
| 261 |
+
|
| 262 |
+
.test-score.poor {{
|
| 263 |
+
background: #ef4444;
|
| 264 |
+
}}
|
| 265 |
+
|
| 266 |
+
.validator-results {{
|
| 267 |
+
margin-top: 15px;
|
| 268 |
+
padding-top: 15px;
|
| 269 |
+
border-top: 1px solid #ddd;
|
| 270 |
+
}}
|
| 271 |
+
|
| 272 |
+
.validator {{
|
| 273 |
+
margin: 10px 0;
|
| 274 |
+
padding: 10px;
|
| 275 |
+
background: white;
|
| 276 |
+
border-radius: 4px;
|
| 277 |
+
border-left: 4px solid #667eea;
|
| 278 |
+
}}
|
| 279 |
+
|
| 280 |
+
.validator.passed {{
|
| 281 |
+
border-left-color: #22c55e;
|
| 282 |
+
}}
|
| 283 |
+
|
| 284 |
+
.validator.failed {{
|
| 285 |
+
border-left-color: #ef4444;
|
| 286 |
+
}}
|
| 287 |
+
|
| 288 |
+
.validator-name {{
|
| 289 |
+
font-weight: bold;
|
| 290 |
+
text-transform: uppercase;
|
| 291 |
+
font-size: 0.85em;
|
| 292 |
+
color: #667eea;
|
| 293 |
+
}}
|
| 294 |
+
|
| 295 |
+
.validator-score {{
|
| 296 |
+
font-size: 0.9em;
|
| 297 |
+
color: #666;
|
| 298 |
+
margin: 5px 0;
|
| 299 |
+
}}
|
| 300 |
+
|
| 301 |
+
.validator-issues {{
|
| 302 |
+
margin-top: 8px;
|
| 303 |
+
padding: 8px;
|
| 304 |
+
background: #fff5f5;
|
| 305 |
+
border-radius: 4px;
|
| 306 |
+
color: #c53030;
|
| 307 |
+
font-size: 0.85em;
|
| 308 |
+
}}
|
| 309 |
+
|
| 310 |
+
.issues-list {{
|
| 311 |
+
list-style: none;
|
| 312 |
+
margin: 5px 0 0 0;
|
| 313 |
+
padding-left: 0;
|
| 314 |
+
}}
|
| 315 |
+
|
| 316 |
+
.issues-list li {{
|
| 317 |
+
margin: 3px 0;
|
| 318 |
+
padding-left: 20px;
|
| 319 |
+
position: relative;
|
| 320 |
+
}}
|
| 321 |
+
|
| 322 |
+
.issues-list li:before {{
|
| 323 |
+
content: "•";
|
| 324 |
+
position: absolute;
|
| 325 |
+
left: 0;
|
| 326 |
+
color: #ef4444;
|
| 327 |
+
}}
|
| 328 |
+
|
| 329 |
+
.summary {{
|
| 330 |
+
background: linear-gradient(135deg, #667eea15 0%, #764ba215 100%);
|
| 331 |
+
padding: 30px;
|
| 332 |
+
border-radius: 8px;
|
| 333 |
+
margin-bottom: 40px;
|
| 334 |
+
}}
|
| 335 |
+
|
| 336 |
+
.summary-item {{
|
| 337 |
+
margin: 15px 0;
|
| 338 |
+
display: flex;
|
| 339 |
+
justify-content: space-between;
|
| 340 |
+
padding: 10px 0;
|
| 341 |
+
}}
|
| 342 |
+
|
| 343 |
+
.summary-label {{
|
| 344 |
+
font-weight: 600;
|
| 345 |
+
color: #333;
|
| 346 |
+
}}
|
| 347 |
+
|
| 348 |
+
.summary-value {{
|
| 349 |
+
color: #667eea;
|
| 350 |
+
font-weight: bold;
|
| 351 |
+
font-size: 1.1em;
|
| 352 |
+
}}
|
| 353 |
+
|
| 354 |
+
.footer {{
|
| 355 |
+
background: #f8f9fa;
|
| 356 |
+
padding: 20px;
|
| 357 |
+
text-align: center;
|
| 358 |
+
color: #666;
|
| 359 |
+
border-top: 1px solid #e0e0e0;
|
| 360 |
+
font-size: 0.9em;
|
| 361 |
+
}}
|
| 362 |
+
|
| 363 |
+
.progress-bar {{
|
| 364 |
+
width: 100%;
|
| 365 |
+
height: 8px;
|
| 366 |
+
background: #e0e0e0;
|
| 367 |
+
border-radius: 4px;
|
| 368 |
+
overflow: hidden;
|
| 369 |
+
margin-top: 10px;
|
| 370 |
+
}}
|
| 371 |
+
|
| 372 |
+
.progress-fill {{
|
| 373 |
+
height: 100%;
|
| 374 |
+
background: linear-gradient(90deg, #667eea, #764ba2);
|
| 375 |
+
transition: width 0.3s ease;
|
| 376 |
+
}}
|
| 377 |
+
</style>
|
| 378 |
+
</head>
|
| 379 |
+
<body>
|
| 380 |
+
<div class="container">
|
| 381 |
+
<div class="header">
|
| 382 |
+
<h1>🤖 Data Dictionary Chatbot</h1>
|
| 383 |
+
<h2>Accuracy Analysis Report</h2>
|
| 384 |
+
<p>Generated on {timestamp}</p>
|
| 385 |
+
</div>
|
| 386 |
+
|
| 387 |
+
<div class="metrics">
|
| 388 |
+
<div class="metric">
|
| 389 |
+
<div class="metric-label">Total Tests</div>
|
| 390 |
+
<div class="metric-value">{total}</div>
|
| 391 |
+
</div>
|
| 392 |
+
<div class="metric">
|
| 393 |
+
<div class="metric-label">Passed</div>
|
| 394 |
+
<div class="metric-value" style="color: #22c55e;">{passed}</div>
|
| 395 |
+
</div>
|
| 396 |
+
<div class="metric">
|
| 397 |
+
<div class="metric-label">Failed</div>
|
| 398 |
+
<div class="metric-value" style="color: #ef4444;">{failed}</div>
|
| 399 |
+
</div>
|
| 400 |
+
<div class="metric">
|
| 401 |
+
<div class="metric-label">Average Score</div>
|
| 402 |
+
<div class="metric-value">{avg_score:.2%}</div>
|
| 403 |
+
</div>
|
| 404 |
+
<div class="metric">
|
| 405 |
+
<div class="metric-label">Pass Rate</div>
|
| 406 |
+
<div class="metric-value" style="color: {status_color};">{pass_rate:.1%}</div>
|
| 407 |
+
<div class="progress-bar">
|
| 408 |
+
<div class="progress-fill" style="width: {pass_rate * 100}%"></div>
|
| 409 |
+
</div>
|
| 410 |
+
</div>
|
| 411 |
+
<div class="metric">
|
| 412 |
+
<div class="overall-status">{status_text}</div>
|
| 413 |
+
</div>
|
| 414 |
+
</div>
|
| 415 |
+
|
| 416 |
+
<div class="content">
|
| 417 |
+
<div class="section">
|
| 418 |
+
<div class="section-title">📊 Summary</div>
|
| 419 |
+
<div class="summary">
|
| 420 |
+
<div class="summary-item">
|
| 421 |
+
<span class="summary-label">Overall Assessment:</span>
|
| 422 |
+
<span class="summary-value">{self._get_assessment_text(pass_rate)}</span>
|
| 423 |
+
</div>
|
| 424 |
+
<div class="summary-item">
|
| 425 |
+
<span class="summary-label">Success Rate:</span>
|
| 426 |
+
<span class="summary-value">{pass_rate:.1%} ({passed}/{total})</span>
|
| 427 |
+
</div>
|
| 428 |
+
<div class="summary-item">
|
| 429 |
+
<span class="summary-label">Average Quality Score:</span>
|
| 430 |
+
<span class="summary-value">{avg_score:.2f}/1.00</span>
|
| 431 |
+
</div>
|
| 432 |
+
</div>
|
| 433 |
+
</div>
|
| 434 |
+
|
| 435 |
+
<div class="section">
|
| 436 |
+
<div class="section-title">🧪 Test Results</div>
|
| 437 |
+
{self._generate_test_results_html(batch_analysis.get("analyses", []))}
|
| 438 |
+
</div>
|
| 439 |
+
</div>
|
| 440 |
+
|
| 441 |
+
<div class="footer">
|
| 442 |
+
<p>Generated by Data Dictionary Chatbot Testing Framework</p>
|
| 443 |
+
<p>For detailed test case information, refer to test_cases.json</p>
|
| 444 |
+
</div>
|
| 445 |
+
</div>
|
| 446 |
+
</body>
|
| 447 |
+
</html>
|
| 448 |
+
"""
|
| 449 |
+
|
| 450 |
+
return html
|
| 451 |
+
|
| 452 |
+
def _generate_markdown_content(self, batch_analysis: Dict[str, Any]) -> str:
|
| 453 |
+
"""Generate Markdown content for report."""
|
| 454 |
+
timestamp = self.timestamp.strftime("%Y-%m-%d %H:%M:%S")
|
| 455 |
+
total = batch_analysis.get("total_tests", 0)
|
| 456 |
+
passed = batch_analysis.get("passed_tests", 0)
|
| 457 |
+
failed = batch_analysis.get("failed_tests", 0)
|
| 458 |
+
avg_score = batch_analysis.get("average_score", 0)
|
| 459 |
+
pass_rate = batch_analysis.get("pass_rate", 0)
|
| 460 |
+
|
| 461 |
+
status_emoji = "✅" if pass_rate >= 0.8 else "⚠️" if pass_rate >= 0.6 else "❌"
|
| 462 |
+
|
| 463 |
+
md = f"""# Data Dictionary Chatbot - Accuracy Report
|
| 464 |
+
|
| 465 |
+
**Generated:** {timestamp}
|
| 466 |
+
|
| 467 |
+
{status_emoji} **Overall Status:** {self._get_assessment_text(pass_rate)}
|
| 468 |
+
|
| 469 |
+
---
|
| 470 |
+
|
| 471 |
+
## Summary Metrics
|
| 472 |
+
|
| 473 |
+
| Metric | Value |
|
| 474 |
+
|--------|-------|
|
| 475 |
+
| **Total Tests** | {total} |
|
| 476 |
+
| **Passed** | {passed} ✅ |
|
| 477 |
+
| **Failed** | {failed} ❌ |
|
| 478 |
+
| **Average Score** | {avg_score:.2%} |
|
| 479 |
+
| **Pass Rate** | {pass_rate:.1%} |
|
| 480 |
+
|
| 481 |
+
---
|
| 482 |
+
|
| 483 |
+
## Key Findings
|
| 484 |
+
|
| 485 |
+
### Strengths
|
| 486 |
+
"""
|
| 487 |
+
|
| 488 |
+
# Add strengths/weaknesses analysis
|
| 489 |
+
md += self._analyze_validation_patterns(batch_analysis)
|
| 490 |
+
|
| 491 |
+
md += f"""
|
| 492 |
+
|
| 493 |
+
---
|
| 494 |
+
|
| 495 |
+
## Detailed Test Results
|
| 496 |
+
|
| 497 |
+
"""
|
| 498 |
+
|
| 499 |
+
# Add individual test results
|
| 500 |
+
for analysis in batch_analysis.get("analyses", []):
|
| 501 |
+
status = "✅ PASSED" if analysis["overall_passed"] else "❌ FAILED"
|
| 502 |
+
md += f"""### {analysis['test_name']} ({analysis['test_id']})
|
| 503 |
+
- **Status:** {status}
|
| 504 |
+
- **Overall Score:** {analysis['overall_score']:.2%}
|
| 505 |
+
|
| 506 |
+
**Validations:**
|
| 507 |
+
"""
|
| 508 |
+
|
| 509 |
+
for validator_name, validator_result in analysis.get("validations", {}).items():
|
| 510 |
+
v_status = "✅" if validator_result.get("passed", False) else "❌"
|
| 511 |
+
v_score = validator_result.get("score", 0)
|
| 512 |
+
md += f"- {v_status} **{validator_name.title()}**: {v_score:.2%}\n"
|
| 513 |
+
|
| 514 |
+
if validator_result.get("issues"):
|
| 515 |
+
for issue in validator_result["issues"]:
|
| 516 |
+
md += f" - ⚠️ {issue}\n"
|
| 517 |
+
|
| 518 |
+
md += "\n"
|
| 519 |
+
|
| 520 |
+
md += f"""---
|
| 521 |
+
|
| 522 |
+
## Recommendations
|
| 523 |
+
|
| 524 |
+
{self._generate_recommendations(batch_analysis)}
|
| 525 |
+
|
| 526 |
+
---
|
| 527 |
+
|
| 528 |
+
**Report Generated:** {timestamp}
|
| 529 |
+
"""
|
| 530 |
+
|
| 531 |
+
return md
|
| 532 |
+
|
| 533 |
+
def _generate_test_results_html(self, analyses: List[Dict[str, Any]]) -> str:
|
| 534 |
+
"""Generate HTML for individual test results."""
|
| 535 |
+
html = ""
|
| 536 |
+
|
| 537 |
+
for analysis in analyses:
|
| 538 |
+
passed = analysis["overall_passed"]
|
| 539 |
+
score = analysis["overall_score"]
|
| 540 |
+
|
| 541 |
+
status_class = "passed" if passed else "failed"
|
| 542 |
+
score_class = self._get_score_class(score)
|
| 543 |
+
|
| 544 |
+
html += f"""
|
| 545 |
+
<div class="test-result {status_class}">
|
| 546 |
+
<div class="test-header">
|
| 547 |
+
<div>
|
| 548 |
+
<div class="test-name">{'✅' if passed else '❌'} {analysis['test_name']}</div>
|
| 549 |
+
<div class="test-id">{analysis['test_id']}</div>
|
| 550 |
+
</div>
|
| 551 |
+
<div class="test-score {score_class}">{score:.0%}</div>
|
| 552 |
+
</div>
|
| 553 |
+
|
| 554 |
+
<div class="validator-results">
|
| 555 |
+
"""
|
| 556 |
+
|
| 557 |
+
for validator_name, validator_result in analysis.get("validations", {}).items():
|
| 558 |
+
v_status = validator_result.get("passed", False)
|
| 559 |
+
v_class = "passed" if v_status else "failed"
|
| 560 |
+
v_score = validator_result.get("score", 0)
|
| 561 |
+
|
| 562 |
+
html += f"""
|
| 563 |
+
<div class="validator {v_class}">
|
| 564 |
+
<div class="validator-name">{'✅' if v_status else '❌'} {validator_name}</div>
|
| 565 |
+
<div class="validator-score">Score: {v_score:.2%}</div>
|
| 566 |
+
"""
|
| 567 |
+
|
| 568 |
+
if validator_result.get("issues"):
|
| 569 |
+
html += '<div class="validator-issues">'
|
| 570 |
+
html += '<ul class="issues-list">'
|
| 571 |
+
for issue in validator_result["issues"]:
|
| 572 |
+
html += f'<li>{issue}</li>'
|
| 573 |
+
html += '</ul></div>'
|
| 574 |
+
|
| 575 |
+
html += '</div>'
|
| 576 |
+
|
| 577 |
+
html += """
|
| 578 |
+
</div>
|
| 579 |
+
</div>
|
| 580 |
+
"""
|
| 581 |
+
|
| 582 |
+
return html
|
| 583 |
+
|
| 584 |
+
@staticmethod
|
| 585 |
+
def _get_score_class(score: float) -> str:
|
| 586 |
+
"""Get CSS class for score."""
|
| 587 |
+
if score >= 0.9:
|
| 588 |
+
return "excellent"
|
| 589 |
+
elif score >= 0.75:
|
| 590 |
+
return "good"
|
| 591 |
+
elif score >= 0.5:
|
| 592 |
+
return "fair"
|
| 593 |
+
else:
|
| 594 |
+
return "poor"
|
| 595 |
+
|
| 596 |
+
@staticmethod
|
| 597 |
+
def _get_assessment_text(pass_rate: float) -> str:
|
| 598 |
+
"""Get assessment text based on pass rate."""
|
| 599 |
+
if pass_rate >= 0.95:
|
| 600 |
+
return "Excellent - App is production-ready 🚀"
|
| 601 |
+
elif pass_rate >= 0.85:
|
| 602 |
+
return "Good - App works well with minor improvements needed ✅"
|
| 603 |
+
elif pass_rate >= 0.70:
|
| 604 |
+
return "Fair - App functions but needs improvements ⚠️"
|
| 605 |
+
elif pass_rate >= 0.50:
|
| 606 |
+
return "Poor - Significant issues need addressing ❌"
|
| 607 |
+
else:
|
| 608 |
+
return "Critical - Major rework required 🚨"
|
| 609 |
+
|
| 610 |
+
@staticmethod
|
| 611 |
+
def _analyze_validation_patterns(batch_analysis: Dict[str, Any]) -> str:
|
| 612 |
+
"""Analyze patterns in validation results."""
|
| 613 |
+
analyses = batch_analysis.get("analyses", [])
|
| 614 |
+
|
| 615 |
+
# Count validation successes
|
| 616 |
+
validation_success = {}
|
| 617 |
+
for analysis in analyses:
|
| 618 |
+
for validator_name, validator_result in analysis.get("validations", {}).items():
|
| 619 |
+
if validator_name not in validation_success:
|
| 620 |
+
validation_success[validator_name] = {"passed": 0, "total": 0}
|
| 621 |
+
|
| 622 |
+
validation_success[validator_name]["total"] += 1
|
| 623 |
+
if validator_result.get("passed", False):
|
| 624 |
+
validation_success[validator_name]["passed"] += 1
|
| 625 |
+
|
| 626 |
+
# Generate text
|
| 627 |
+
text = ""
|
| 628 |
+
for validator_name, stats in sorted(validation_success.items(),
|
| 629 |
+
key=lambda x: x[1]["passed"]/max(x[1]["total"], 1),
|
| 630 |
+
reverse=True):
|
| 631 |
+
rate = stats["passed"] / stats["total"] if stats["total"] > 0 else 0
|
| 632 |
+
text += f"- **{validator_name.title()}**: {stats['passed']}/{stats['total']} tests passed ({rate:.0%})\n"
|
| 633 |
+
|
| 634 |
+
return text or "No validation data available"
|
| 635 |
+
|
| 636 |
+
@staticmethod
|
| 637 |
+
def _generate_recommendations(batch_analysis: Dict[str, Any]) -> str:
|
| 638 |
+
"""Generate recommendations based on analysis."""
|
| 639 |
+
pass_rate = batch_analysis.get("pass_rate", 0)
|
| 640 |
+
|
| 641 |
+
recommendations = []
|
| 642 |
+
|
| 643 |
+
if pass_rate >= 0.9:
|
| 644 |
+
recommendations.append("✅ Application is performing excellently. Continue monitoring and iterating.")
|
| 645 |
+
elif pass_rate >= 0.75:
|
| 646 |
+
recommendations.append("⚠️ Address failing test cases before production deployment.")
|
| 647 |
+
elif pass_rate >= 0.5:
|
| 648 |
+
recommendations.append("⚠️ Significant improvements needed in citation accuracy and hallucination detection.")
|
| 649 |
+
else:
|
| 650 |
+
recommendations.append("🚨 Critical issues detected. Review retrieval and LLM prompt engineering.")
|
| 651 |
+
|
| 652 |
+
recommendations.extend([
|
| 653 |
+
"- Ensure all recommended columns are verified against loaded dictionaries",
|
| 654 |
+
"- Review system prompts to improve citation formatting consistency",
|
| 655 |
+
"- Monitor Area Insights geographic accuracy for regional data",
|
| 656 |
+
"- Consider fine-tuning retrieval parameters for better relevance",
|
| 657 |
+
"- Implement continuous testing in CI/CD pipeline"
|
| 658 |
+
])
|
| 659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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
run_tests.py
|
| 3 |
+
|
| 4 |
+
Main test runner for automated chat testing and accuracy analysis.
|
| 5 |
+
Orchestrates the full testing pipeline: execution -> validation -> reporting
|
| 6 |
+
"""
|
| 7 |
+
|
| 8 |
+
import argparse
|
| 9 |
+
import sys
|
| 10 |
+
import json
|
| 11 |
+
import logging
|
| 12 |
+
from pathlib import Path
|
| 13 |
+
from typing import Optional
|
| 14 |
+
|
| 15 |
+
# Add project to path
|
| 16 |
+
test_dir = Path(__file__).parent
|
| 17 |
+
project_src = test_dir.parent / "src"
|
| 18 |
+
sys.path.insert(0, str(project_src))
|
| 19 |
+
sys.path.insert(0, str(test_dir))
|
| 20 |
+
|
| 21 |
+
from chat_automation import ChatAutomation
|
| 22 |
+
from accuracy_validators import AccuracyAnalyzer
|
| 23 |
+
from report_generator import ReportGenerator
|
| 24 |
+
|
| 25 |
+
# Configure logging
|
| 26 |
+
logging.basicConfig(
|
| 27 |
+
level=logging.INFO,
|
| 28 |
+
format='%(asctime)s - %(levelname)s - %(message)s'
|
| 29 |
+
)
|
| 30 |
+
logger = logging.getLogger(__name__)
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
def main():
|
| 34 |
+
"""Run complete testing pipeline."""
|
| 35 |
+
parser = argparse.ArgumentParser(
|
| 36 |
+
description="Run automated chat testing and accuracy analysis for Data Dictionary Chatbot",
|
| 37 |
+
formatter_class=argparse.RawDescriptionHelpFormatter,
|
| 38 |
+
epilog="""
|
| 39 |
+
Examples:
|
| 40 |
+
# Run with mock service (no API costs)
|
| 41 |
+
python run_tests.py --mock
|
| 42 |
+
|
| 43 |
+
# Run with real service and generate reports
|
| 44 |
+
python run_tests.py --real --report html
|
| 45 |
+
|
| 46 |
+
# Run specific test cases only
|
| 47 |
+
python run_tests.py --mock --test-cases tests/test_cases.json
|
| 48 |
+
|
| 49 |
+
# Run tests and save results to custom location
|
| 50 |
+
python run_tests.py --mock --output results/my_test_run.json
|
| 51 |
+
"""
|
| 52 |
+
)
|
| 53 |
+
|
| 54 |
+
parser.add_argument(
|
| 55 |
+
"--mock",
|
| 56 |
+
action="store_true",
|
| 57 |
+
default=False,
|
| 58 |
+
help="Use mock Azure OpenAI service (no API costs)"
|
| 59 |
+
)
|
| 60 |
+
|
| 61 |
+
parser.add_argument(
|
| 62 |
+
"--real",
|
| 63 |
+
action="store_true",
|
| 64 |
+
default=False,
|
| 65 |
+
help="Use real Azure OpenAI service (requires credentials)"
|
| 66 |
+
)
|
| 67 |
+
|
| 68 |
+
parser.add_argument(
|
| 69 |
+
"--test-cases",
|
| 70 |
+
default=None,
|
| 71 |
+
help="Path to test_cases.json file"
|
| 72 |
+
)
|
| 73 |
+
|
| 74 |
+
parser.add_argument(
|
| 75 |
+
"--output",
|
| 76 |
+
default=None,
|
| 77 |
+
help="Output file for test results (JSON)"
|
| 78 |
+
)
|
| 79 |
+
|
| 80 |
+
parser.add_argument(
|
| 81 |
+
"--report",
|
| 82 |
+
choices=["html", "markdown", "both"],
|
| 83 |
+
default="html",
|
| 84 |
+
help="Report format(s) to generate"
|
| 85 |
+
)
|
| 86 |
+
|
| 87 |
+
parser.add_argument(
|
| 88 |
+
"--skip-analysis",
|
| 89 |
+
action="store_true",
|
| 90 |
+
help="Skip accuracy analysis and reporting"
|
| 91 |
+
)
|
| 92 |
+
|
| 93 |
+
parser.add_argument(
|
| 94 |
+
"--verbose",
|
| 95 |
+
"-v",
|
| 96 |
+
action="store_true",
|
| 97 |
+
help="Verbose output"
|
| 98 |
+
)
|
| 99 |
+
|
| 100 |
+
args = parser.parse_args()
|
| 101 |
+
|
| 102 |
+
if args.verbose:
|
| 103 |
+
logging.getLogger().setLevel(logging.DEBUG)
|
| 104 |
+
|
| 105 |
+
# Determine service type
|
| 106 |
+
use_mock = args.mock or not args.real
|
| 107 |
+
|
| 108 |
+
print("=" * 70)
|
| 109 |
+
print("🤖 Data Dictionary Chatbot - Testing Framework")
|
| 110 |
+
print("=" * 70)
|
| 111 |
+
print(f"Service: {'MOCK (No API costs)' if use_mock else 'REAL (Azure OpenAI)'}")
|
| 112 |
+
print()
|
| 113 |
+
|
| 114 |
+
# Step 1: Run chat automation
|
| 115 |
+
print("📋 STEP 1: Running Chat Automation")
|
| 116 |
+
print("-" * 70)
|
| 117 |
+
|
| 118 |
+
try:
|
| 119 |
+
automation = ChatAutomation(use_mock=use_mock)
|
| 120 |
+
results = automation.run_all_tests(args.test_cases)
|
| 121 |
+
output_file = automation.save_results(args.output)
|
| 122 |
+
|
| 123 |
+
print(f"✅ Completed {len(results)} tests")
|
| 124 |
+
print(f"📁 Results saved to: {output_file}")
|
| 125 |
+
print()
|
| 126 |
+
|
| 127 |
+
except Exception as e:
|
| 128 |
+
logger.error(f"Chat automation failed: {e}", exc_info=args.verbose)
|
| 129 |
+
return 1
|
| 130 |
+
|
| 131 |
+
# Step 2: Load test cases for validation
|
| 132 |
+
if not args.skip_analysis:
|
| 133 |
+
print("📊 STEP 2: Running Accuracy Analysis")
|
| 134 |
+
print("-" * 70)
|
| 135 |
+
|
| 136 |
+
try:
|
| 137 |
+
test_cases_file = args.test_cases or (Path(__file__).parent / "test_cases.json")
|
| 138 |
+
with open(test_cases_file) as f:
|
| 139 |
+
test_data = json.load(f)
|
| 140 |
+
|
| 141 |
+
test_cases = test_data.get("chat_interface_tests", []) + test_data.get("area_insights_tests", [])
|
| 142 |
+
|
| 143 |
+
# Create analyzer and run analysis
|
| 144 |
+
analyzer = AccuracyAnalyzer()
|
| 145 |
+
batch_analysis = analyzer.analyze_batch(results, test_cases)
|
| 146 |
+
|
| 147 |
+
print(f"✅ Analysis complete")
|
| 148 |
+
print(f" Total: {batch_analysis['total_tests']} tests")
|
| 149 |
+
print(f" Passed: {batch_analysis['passed_tests']} ({batch_analysis['pass_rate']:.1%})")
|
| 150 |
+
print(f" Failed: {batch_analysis['failed_tests']}")
|
| 151 |
+
print(f" Avg Score: {batch_analysis['average_score']:.2%}")
|
| 152 |
+
print()
|
| 153 |
+
|
| 154 |
+
# Step 3: Generate reports
|
| 155 |
+
print("📈 STEP 3: Generating Reports")
|
| 156 |
+
print("-" * 70)
|
| 157 |
+
|
| 158 |
+
generator = ReportGenerator()
|
| 159 |
+
|
| 160 |
+
if args.report in ["html", "both"]:
|
| 161 |
+
html_report = generator.generate_html_report(batch_analysis)
|
| 162 |
+
print(f"✅ HTML Report: {html_report}")
|
| 163 |
+
|
| 164 |
+
if args.report in ["markdown", "both"]:
|
| 165 |
+
md_report = generator.generate_markdown_report(batch_analysis)
|
| 166 |
+
print(f"✅ Markdown Report: {md_report}")
|
| 167 |
+
|
| 168 |
+
print()
|
| 169 |
+
|
| 170 |
+
except Exception as e:
|
| 171 |
+
logger.error(f"Analysis/reporting failed: {e}", exc_info=args.verbose)
|
| 172 |
+
print("\n⚠️ Skipping analysis due to error")
|
| 173 |
+
|
| 174 |
+
# Summary
|
| 175 |
+
print("=" * 70)
|
| 176 |
+
print("✅ Testing pipeline completed successfully!")
|
| 177 |
+
print("=" * 70)
|
| 178 |
+
print()
|
| 179 |
+
print("Next steps:")
|
| 180 |
+
print("1. Review the generated report(s)")
|
| 181 |
+
print("2. Check citation accuracy and hallucination detection results")
|
| 182 |
+
print("3. Address any failing tests")
|
| 183 |
+
print("4. For production deployment, ensure pass rate >= 90%")
|
| 184 |
+
print()
|
| 185 |
+
|
| 186 |
+
return 0
|
| 187 |
+
|
| 188 |
+
|
| 189 |
+
if __name__ == "__main__":
|
| 190 |
+
sys.exit(main())
|
tests/test_accuracy.py
ADDED
|
@@ -0,0 +1,444 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
test_accuracy.py
|
| 3 |
+
|
| 4 |
+
Pytest tests for accuracy validation and reporting.
|
| 5 |
+
Tests the accuracy validators and report generation.
|
| 6 |
+
"""
|
| 7 |
+
|
| 8 |
+
import pytest
|
| 9 |
+
import json
|
| 10 |
+
from pathlib import Path
|
| 11 |
+
from accuracy_validators import (
|
| 12 |
+
CitationValidator,
|
| 13 |
+
RelevanceScorer,
|
| 14 |
+
HallucinationDetector,
|
| 15 |
+
AreaInsightsValidator,
|
| 16 |
+
FormatValidator,
|
| 17 |
+
AccuracyAnalyzer
|
| 18 |
+
)
|
| 19 |
+
from report_generator import ReportGenerator
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
class TestCitationValidator:
|
| 23 |
+
"""Test citation validation."""
|
| 24 |
+
|
| 25 |
+
def test_citation_extraction(self):
|
| 26 |
+
"""Test extracting citations from response."""
|
| 27 |
+
response = """
|
| 28 |
+
1. **HbA1c Level** (Dataset: EJI_2024)
|
| 29 |
+
2. **Glucose** (Source: AHRF-2025)
|
| 30 |
+
"""
|
| 31 |
+
|
| 32 |
+
validator = CitationValidator()
|
| 33 |
+
citations = validator._extract_citations(response)
|
| 34 |
+
|
| 35 |
+
assert len(citations) >= 2
|
| 36 |
+
assert "EJI_2024" in citations
|
| 37 |
+
assert "AHRF-2025" in citations
|
| 38 |
+
|
| 39 |
+
def test_dataset_normalization(self):
|
| 40 |
+
"""Test dataset name normalization."""
|
| 41 |
+
validator = CitationValidator()
|
| 42 |
+
|
| 43 |
+
assert validator._normalize_dataset("EJI_2024") == "EJI_2024"
|
| 44 |
+
assert validator._normalize_dataset("eji 2024") == "EJI_2024"
|
| 45 |
+
assert validator._normalize_dataset(" AHRF-2025 ") == "AHRF-2025"
|
| 46 |
+
|
| 47 |
+
def test_validate_sufficient_citations(self):
|
| 48 |
+
"""Test validation of citation count."""
|
| 49 |
+
validator = CitationValidator()
|
| 50 |
+
response = """
|
| 51 |
+
1. **Column A** (Dataset: EJI_2024)
|
| 52 |
+
2. **Column B** (Dataset: AHRF-2025)
|
| 53 |
+
3. **Column C** (Dataset: SVI_2022)
|
| 54 |
+
"""
|
| 55 |
+
test_case = {
|
| 56 |
+
"test_id": "TEST_001",
|
| 57 |
+
"name": "Test",
|
| 58 |
+
"expected_datasets": ["EJI_2024"],
|
| 59 |
+
"min_recommendations": 2
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
result = validator.validate(response, test_case)
|
| 63 |
+
|
| 64 |
+
assert result["citation_count"] >= 2
|
| 65 |
+
assert result["passed"] is True
|
| 66 |
+
|
| 67 |
+
def test_validate_insufficient_citations(self):
|
| 68 |
+
"""Test validation fails with insufficient citations."""
|
| 69 |
+
validator = CitationValidator()
|
| 70 |
+
response = "Here is some information but no citations."
|
| 71 |
+
test_case = {
|
| 72 |
+
"test_id": "TEST_001",
|
| 73 |
+
"name": "Test",
|
| 74 |
+
"expected_datasets": ["EJI_2024"],
|
| 75 |
+
"min_recommendations": 3
|
| 76 |
+
}
|
| 77 |
+
|
| 78 |
+
result = validator.validate(response, test_case)
|
| 79 |
+
|
| 80 |
+
assert result["passed"] is False
|
| 81 |
+
assert len(result["issues"]) > 0
|
| 82 |
+
|
| 83 |
+
def test_validate_unknown_dataset(self):
|
| 84 |
+
"""Test validation detects unknown datasets."""
|
| 85 |
+
validator = CitationValidator()
|
| 86 |
+
response = "**Column** (Dataset: UNKNOWN_DATASET_2025)"
|
| 87 |
+
test_case = {
|
| 88 |
+
"test_id": "TEST_001",
|
| 89 |
+
"name": "Test",
|
| 90 |
+
"expected_datasets": [],
|
| 91 |
+
"min_recommendations": 0
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
result = validator.validate(response, test_case)
|
| 95 |
+
|
| 96 |
+
assert result["passed"] is False
|
| 97 |
+
assert len(result["issues"]) > 0
|
| 98 |
+
|
| 99 |
+
|
| 100 |
+
class TestRelevanceScorer:
|
| 101 |
+
"""Test relevance scoring."""
|
| 102 |
+
|
| 103 |
+
def test_high_relevance_score(self):
|
| 104 |
+
"""Test high relevance score."""
|
| 105 |
+
scorer = RelevanceScorer()
|
| 106 |
+
response = "diabetes risk prediction involves glucose, hba1c, and family history factors"
|
| 107 |
+
test_case = {
|
| 108 |
+
"test_id": "TEST_001",
|
| 109 |
+
"expected_column_patterns": ["diabetes", "glucose", "hba1c"]
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
result = scorer.validate(response, test_case)
|
| 113 |
+
|
| 114 |
+
assert result["score"] >= 0.5
|
| 115 |
+
assert len(result["matched_patterns"]) > 0
|
| 116 |
+
|
| 117 |
+
def test_low_relevance_score(self):
|
| 118 |
+
"""Test low relevance score."""
|
| 119 |
+
scorer = RelevanceScorer()
|
| 120 |
+
response = "The weather is nice today."
|
| 121 |
+
test_case = {
|
| 122 |
+
"test_id": "TEST_001",
|
| 123 |
+
"expected_column_patterns": ["diabetes", "hospital", "readmission"]
|
| 124 |
+
}
|
| 125 |
+
|
| 126 |
+
result = scorer.validate(response, test_case)
|
| 127 |
+
|
| 128 |
+
assert result["score"] < 0.4
|
| 129 |
+
assert result["passed"] is False
|
| 130 |
+
|
| 131 |
+
def test_no_expected_patterns(self):
|
| 132 |
+
"""Test relevance scoring with no expected patterns."""
|
| 133 |
+
scorer = RelevanceScorer()
|
| 134 |
+
response = "Hello there!"
|
| 135 |
+
test_case = {
|
| 136 |
+
"test_id": "TEST_001",
|
| 137 |
+
"expected_column_patterns": []
|
| 138 |
+
}
|
| 139 |
+
|
| 140 |
+
result = scorer.validate(response, test_case)
|
| 141 |
+
|
| 142 |
+
assert result["score"] == 1.0
|
| 143 |
+
assert result["passed"] is True
|
| 144 |
+
|
| 145 |
+
|
| 146 |
+
class TestHallucinationDetector:
|
| 147 |
+
"""Test hallucination detection."""
|
| 148 |
+
|
| 149 |
+
def test_column_extraction(self):
|
| 150 |
+
"""Test extracting column names from response."""
|
| 151 |
+
response = """
|
| 152 |
+
1. **HbA1c Level** (Dataset: EJI_2024)
|
| 153 |
+
2. **Age Group** (Dataset: SVI_2022)
|
| 154 |
+
"""
|
| 155 |
+
|
| 156 |
+
columns = HallucinationDetector._extract_column_names(response)
|
| 157 |
+
|
| 158 |
+
assert "HbA1c Level" in columns or "HbA1c" in str(columns).lower()
|
| 159 |
+
assert len(columns) >= 1
|
| 160 |
+
|
| 161 |
+
def test_realistic_column_name_validation(self):
|
| 162 |
+
"""Test validation of realistic column names."""
|
| 163 |
+
detector = HallucinationDetector.__new__(HallucinationDetector)
|
| 164 |
+
|
| 165 |
+
# Valid column names
|
| 166 |
+
assert detector._is_likely_real("HbA1c Level", []) is True
|
| 167 |
+
assert detector._is_likely_real("patient_age", []) is True
|
| 168 |
+
assert detector._is_likely_real("BMI", []) is True
|
| 169 |
+
assert detector._is_likely_real("Poverty Rate %", []) is True
|
| 170 |
+
|
| 171 |
+
# Less likely column names
|
| 172 |
+
assert detector._is_likely_real("XYZ123ABC", []) is False
|
| 173 |
+
|
| 174 |
+
def test_hallucination_detection_with_mock_data(self):
|
| 175 |
+
"""Test detecting hallucinated columns."""
|
| 176 |
+
# This would need a real data dictionary service
|
| 177 |
+
# For now, test the structure
|
| 178 |
+
response = "**FakeColumn123** (Dataset: EJI_2024)"
|
| 179 |
+
columns = HallucinationDetector._extract_column_names(response)
|
| 180 |
+
|
| 181 |
+
assert len(columns) > 0
|
| 182 |
+
# FakeColumn123 would be detected as hallucinated if not in actual data
|
| 183 |
+
|
| 184 |
+
|
| 185 |
+
class TestAreaInsightsValidator:
|
| 186 |
+
"""Test area insights validation."""
|
| 187 |
+
|
| 188 |
+
def test_validate_geographic_mention(self):
|
| 189 |
+
"""Test validation of geographic mention."""
|
| 190 |
+
validator = AreaInsightsValidator()
|
| 191 |
+
response = "For San Francisco, the available data includes..."
|
| 192 |
+
test_case = {
|
| 193 |
+
"test_id": "AREA_001",
|
| 194 |
+
"type": "area_insights",
|
| 195 |
+
"location_name": "San Francisco",
|
| 196 |
+
"expected_datasets": ["EJI_2024"]
|
| 197 |
+
}
|
| 198 |
+
|
| 199 |
+
result = validator.validate(response, test_case)
|
| 200 |
+
|
| 201 |
+
assert result["mentions_location"] is True
|
| 202 |
+
|
| 203 |
+
def test_validate_non_area_insights_test(self):
|
| 204 |
+
"""Test that non-area-insights tests pass validation."""
|
| 205 |
+
validator = AreaInsightsValidator()
|
| 206 |
+
response = "Some generic response"
|
| 207 |
+
test_case = {
|
| 208 |
+
"test_id": "CHAT_001",
|
| 209 |
+
"type": "chat"
|
| 210 |
+
}
|
| 211 |
+
|
| 212 |
+
result = validator.validate(response, test_case)
|
| 213 |
+
|
| 214 |
+
assert result["score"] == 1.0
|
| 215 |
+
|
| 216 |
+
def test_validate_fallback_detection(self):
|
| 217 |
+
"""Test detection of fallback responses."""
|
| 218 |
+
validator = AreaInsightsValidator()
|
| 219 |
+
response = "This ZIP code is invalid. No data available for this area. Using general knowledge instead."
|
| 220 |
+
test_case = {
|
| 221 |
+
"test_id": "AREA_005",
|
| 222 |
+
"type": "area_insights",
|
| 223 |
+
"location_name": "Invalid ZIP",
|
| 224 |
+
"should_fallback_to_general": True,
|
| 225 |
+
"expected_datasets": []
|
| 226 |
+
}
|
| 227 |
+
|
| 228 |
+
result = validator.validate(response, test_case)
|
| 229 |
+
|
| 230 |
+
assert result["fallback_used"] is True
|
| 231 |
+
|
| 232 |
+
|
| 233 |
+
class TestFormatValidator:
|
| 234 |
+
"""Test format validation."""
|
| 235 |
+
|
| 236 |
+
def test_validate_structured_list_format(self):
|
| 237 |
+
"""Test detection of structured list format."""
|
| 238 |
+
validator = FormatValidator()
|
| 239 |
+
response = """
|
| 240 |
+
1. First item
|
| 241 |
+
2. Second item
|
| 242 |
+
3. Third item
|
| 243 |
+
"""
|
| 244 |
+
test_case = {
|
| 245 |
+
"test_id": "TEST_001",
|
| 246 |
+
"min_recommendations": 3
|
| 247 |
+
}
|
| 248 |
+
|
| 249 |
+
result = validator.validate(response, test_case)
|
| 250 |
+
|
| 251 |
+
assert result["has_structured_list"] is True
|
| 252 |
+
assert result["score"] >= 0.7
|
| 253 |
+
|
| 254 |
+
def test_validate_bold_formatting(self):
|
| 255 |
+
"""Test detection of bold formatting."""
|
| 256 |
+
validator = FormatValidator()
|
| 257 |
+
response = "**Column Name** is important"
|
| 258 |
+
test_case = {
|
| 259 |
+
"test_id": "TEST_001",
|
| 260 |
+
"min_recommendations": 1
|
| 261 |
+
}
|
| 262 |
+
|
| 263 |
+
result = validator.validate(response, test_case)
|
| 264 |
+
|
| 265 |
+
assert result["uses_bold_formatting"] is True
|
| 266 |
+
|
| 267 |
+
def test_validate_response_too_short(self):
|
| 268 |
+
"""Test validation of minimum response length."""
|
| 269 |
+
validator = FormatValidator()
|
| 270 |
+
response = "No."
|
| 271 |
+
test_case = {
|
| 272 |
+
"test_id": "TEST_001",
|
| 273 |
+
"min_recommendations": 3
|
| 274 |
+
}
|
| 275 |
+
|
| 276 |
+
result = validator.validate(response, test_case)
|
| 277 |
+
|
| 278 |
+
assert result["passed"] is False
|
| 279 |
+
assert any("too short" in issue.lower() for issue in result["issues"])
|
| 280 |
+
|
| 281 |
+
def test_validate_enough_content(self):
|
| 282 |
+
"""Test validation with sufficient content."""
|
| 283 |
+
validator = FormatValidator()
|
| 284 |
+
response = "This is a sufficiently detailed response with enough content to meet minimum requirements."
|
| 285 |
+
test_case = {
|
| 286 |
+
"test_id": "TEST_001",
|
| 287 |
+
"min_recommendations": 1
|
| 288 |
+
}
|
| 289 |
+
|
| 290 |
+
result = validator.validate(response, test_case)
|
| 291 |
+
|
| 292 |
+
assert result["passed"] is True
|
| 293 |
+
|
| 294 |
+
|
| 295 |
+
class TestAccuracyAnalyzer:
|
| 296 |
+
"""Test the comprehensive accuracy analyzer."""
|
| 297 |
+
|
| 298 |
+
def test_analyzer_initialization(self):
|
| 299 |
+
"""Test analyzer initializes correctly."""
|
| 300 |
+
analyzer = AccuracyAnalyzer()
|
| 301 |
+
|
| 302 |
+
assert analyzer.citation_validator is not None
|
| 303 |
+
assert analyzer.relevance_scorer is not None
|
| 304 |
+
assert analyzer.format_validator is not None
|
| 305 |
+
|
| 306 |
+
def test_single_response_analysis(self):
|
| 307 |
+
"""Test analyzing a single response."""
|
| 308 |
+
analyzer = AccuracyAnalyzer()
|
| 309 |
+
|
| 310 |
+
test_case = {
|
| 311 |
+
"test_id": "TEST_001",
|
| 312 |
+
"name": "Sample Test",
|
| 313 |
+
"query": "What columns help predict diabetes?",
|
| 314 |
+
"expected_datasets": ["EJI_2024"],
|
| 315 |
+
"expected_column_patterns": ["diabetes", "glucose"],
|
| 316 |
+
"min_recommendations": 2,
|
| 317 |
+
"type": "chat"
|
| 318 |
+
}
|
| 319 |
+
|
| 320 |
+
response = """
|
| 321 |
+
Based on the available data, here are relevant columns:
|
| 322 |
+
|
| 323 |
+
1. **HbA1c Level** (Dataset: EJI_2024) - Primary diabetes indicator
|
| 324 |
+
2. **Fasting Glucose** (Dataset: EJI_2024) - Blood glucose concentration
|
| 325 |
+
"""
|
| 326 |
+
|
| 327 |
+
analysis = analyzer.analyze_response(test_case, response)
|
| 328 |
+
|
| 329 |
+
assert analysis["test_id"] == "TEST_001"
|
| 330 |
+
assert analysis["overall_score"] >= 0.0
|
| 331 |
+
assert "validations" in analysis
|
| 332 |
+
assert len(analysis["validations"]) > 0
|
| 333 |
+
|
| 334 |
+
def test_batch_analysis(self):
|
| 335 |
+
"""Test batch analysis of multiple results."""
|
| 336 |
+
analyzer = AccuracyAnalyzer()
|
| 337 |
+
|
| 338 |
+
test_cases = [
|
| 339 |
+
{
|
| 340 |
+
"test_id": "TEST_001",
|
| 341 |
+
"name": "Test 1",
|
| 342 |
+
"expected_datasets": ["EJI_2024"],
|
| 343 |
+
"expected_column_patterns": ["diabetes"],
|
| 344 |
+
"min_recommendations": 1,
|
| 345 |
+
"type": "chat"
|
| 346 |
+
},
|
| 347 |
+
{
|
| 348 |
+
"test_id": "TEST_002",
|
| 349 |
+
"name": "Test 2",
|
| 350 |
+
"expected_datasets": ["AHRF-2025"],
|
| 351 |
+
"expected_column_patterns": ["hospital"],
|
| 352 |
+
"min_recommendations": 1,
|
| 353 |
+
"type": "chat"
|
| 354 |
+
}
|
| 355 |
+
]
|
| 356 |
+
|
| 357 |
+
test_results = [
|
| 358 |
+
{
|
| 359 |
+
"test_id": "TEST_001",
|
| 360 |
+
"response": "**HbA1c** (Dataset: EJI_2024)"
|
| 361 |
+
},
|
| 362 |
+
{
|
| 363 |
+
"test_id": "TEST_002",
|
| 364 |
+
"response": "**Hospital Beds** (Dataset: AHRF-2025)"
|
| 365 |
+
}
|
| 366 |
+
]
|
| 367 |
+
|
| 368 |
+
batch_result = analyzer.analyze_batch(test_results, test_cases)
|
| 369 |
+
|
| 370 |
+
assert batch_result["total_tests"] == 2
|
| 371 |
+
assert batch_result["average_score"] >= 0.0
|
| 372 |
+
assert len(batch_result["analyses"]) == 2
|
| 373 |
+
|
| 374 |
+
|
| 375 |
+
class TestReportGenerator:
|
| 376 |
+
"""Test report generation."""
|
| 377 |
+
|
| 378 |
+
def test_html_report_generation(self, tmp_path):
|
| 379 |
+
"""Test HTML report generation."""
|
| 380 |
+
generator = ReportGenerator()
|
| 381 |
+
|
| 382 |
+
batch_analysis = {
|
| 383 |
+
"total_tests": 5,
|
| 384 |
+
"passed_tests": 4,
|
| 385 |
+
"failed_tests": 1,
|
| 386 |
+
"average_score": 0.8,
|
| 387 |
+
"pass_rate": 0.8,
|
| 388 |
+
"analyses": [
|
| 389 |
+
{
|
| 390 |
+
"test_id": "TEST_001",
|
| 391 |
+
"test_name": "Test 1",
|
| 392 |
+
"overall_score": 0.9,
|
| 393 |
+
"overall_passed": True,
|
| 394 |
+
"validations": {
|
| 395 |
+
"citation": {"passed": True, "score": 1.0, "issues": []},
|
| 396 |
+
"relevance": {"passed": True, "score": 0.85, "issues": []}
|
| 397 |
+
},
|
| 398 |
+
"response_snippet": "Sample response..."
|
| 399 |
+
}
|
| 400 |
+
]
|
| 401 |
+
}
|
| 402 |
+
|
| 403 |
+
output_file = tmp_path / "report.html"
|
| 404 |
+
result_path = generator.generate_html_report(batch_analysis, str(output_file))
|
| 405 |
+
|
| 406 |
+
assert Path(result_path).exists()
|
| 407 |
+
with open(result_path) as f:
|
| 408 |
+
content = f.read()
|
| 409 |
+
assert "Data Dictionary Chatbot" in content
|
| 410 |
+
assert "Accuracy Analysis" in content
|
| 411 |
+
|
| 412 |
+
def test_markdown_report_generation(self, tmp_path):
|
| 413 |
+
"""Test Markdown report generation."""
|
| 414 |
+
generator = ReportGenerator()
|
| 415 |
+
|
| 416 |
+
batch_analysis = {
|
| 417 |
+
"total_tests": 3,
|
| 418 |
+
"passed_tests": 2,
|
| 419 |
+
"failed_tests": 1,
|
| 420 |
+
"average_score": 0.75,
|
| 421 |
+
"pass_rate": 0.667,
|
| 422 |
+
"analyses": []
|
| 423 |
+
}
|
| 424 |
+
|
| 425 |
+
output_file = tmp_path / "report.md"
|
| 426 |
+
result_path = generator.generate_markdown_report(batch_analysis, str(output_file))
|
| 427 |
+
|
| 428 |
+
assert Path(result_path).exists()
|
| 429 |
+
with open(result_path) as f:
|
| 430 |
+
content = f.read()
|
| 431 |
+
assert "Accuracy Report" in content
|
| 432 |
+
assert "Total Tests" in content
|
| 433 |
+
|
| 434 |
+
def test_assessment_text_generation(self):
|
| 435 |
+
"""Test assessment text generation for different pass rates."""
|
| 436 |
+
assert "Excellent" in ReportGenerator._get_assessment_text(0.95)
|
| 437 |
+
assert "Good" in ReportGenerator._get_assessment_text(0.85)
|
| 438 |
+
assert "Fair" in ReportGenerator._get_assessment_text(0.70)
|
| 439 |
+
assert "Poor" in ReportGenerator._get_assessment_text(0.50)
|
| 440 |
+
assert "Critical" in ReportGenerator._get_assessment_text(0.30)
|
| 441 |
+
|
| 442 |
+
|
| 443 |
+
if __name__ == "__main__":
|
| 444 |
+
pytest.main([__file__, "-v"])
|
tests/test_cases.json
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"chat_interface_tests": [
|
| 3 |
+
{
|
| 4 |
+
"test_id": "CHAT_001",
|
| 5 |
+
"name": "Diabetes Risk Prediction",
|
| 6 |
+
"query": "I'm building a diabetes risk prediction model. Which columns should I use?",
|
| 7 |
+
"expected_datasets": ["EJI_2024", "AHRF-2025", "SVI_2022"],
|
| 8 |
+
"expected_column_patterns": ["diabetes", "hba1c", "glucose", "risk", "health", "demographic"],
|
| 9 |
+
"should_cite_sources": true,
|
| 10 |
+
"min_recommendations": 3,
|
| 11 |
+
"type": "chat"
|
| 12 |
+
},
|
| 13 |
+
{
|
| 14 |
+
"test_id": "CHAT_002",
|
| 15 |
+
"name": "Hospital Readmission Prediction",
|
| 16 |
+
"query": "What data would help predict 30-day hospital readmission rates?",
|
| 17 |
+
"expected_datasets": ["EJI_2024", "AHRF-2025"],
|
| 18 |
+
"expected_column_patterns": ["readmission", "hospital", "admission", "health", "demographic", "comorbidity"],
|
| 19 |
+
"should_cite_sources": true,
|
| 20 |
+
"min_recommendations": 3,
|
| 21 |
+
"type": "chat"
|
| 22 |
+
},
|
| 23 |
+
{
|
| 24 |
+
"test_id": "CHAT_003",
|
| 25 |
+
"name": "Food Insecurity Impact",
|
| 26 |
+
"query": "Which columns indicate food insecurity and its health impacts?",
|
| 27 |
+
"expected_datasets": ["EJI_2024", "SVI_2022"],
|
| 28 |
+
"expected_column_patterns": ["food", "insecurity", "poverty", "income", "nutrition", "health"],
|
| 29 |
+
"should_cite_sources": true,
|
| 30 |
+
"min_recommendations": 2,
|
| 31 |
+
"type": "chat"
|
| 32 |
+
},
|
| 33 |
+
{
|
| 34 |
+
"test_id": "CHAT_004",
|
| 35 |
+
"name": "Social Vulnerability Index",
|
| 36 |
+
"query": "Tell me about the Social Vulnerability Index columns",
|
| 37 |
+
"expected_datasets": ["SVI_2022"],
|
| 38 |
+
"expected_column_patterns": ["svi", "vulnerability", "socioeconomic", "household", "racial", "ethnic"],
|
| 39 |
+
"should_cite_sources": true,
|
| 40 |
+
"min_recommendations": 2,
|
| 41 |
+
"type": "chat"
|
| 42 |
+
},
|
| 43 |
+
{
|
| 44 |
+
"test_id": "CHAT_005",
|
| 45 |
+
"name": "Environmental Health Indices",
|
| 46 |
+
"query": "What columns measure environmental health and pollution exposure?",
|
| 47 |
+
"expected_datasets": ["EJI_2024"],
|
| 48 |
+
"expected_column_patterns": ["environmental", "pollution", "exposure", "hazard", "facility", "waste"],
|
| 49 |
+
"should_cite_sources": true,
|
| 50 |
+
"min_recommendations": 2,
|
| 51 |
+
"type": "chat"
|
| 52 |
+
},
|
| 53 |
+
{
|
| 54 |
+
"test_id": "CHAT_006",
|
| 55 |
+
"name": "Healthcare Workforce",
|
| 56 |
+
"query": "Which columns track healthcare provider availability and workforce metrics?",
|
| 57 |
+
"expected_datasets": ["AHRF-2025"],
|
| 58 |
+
"expected_column_patterns": ["provider", "physician", "nurse", "workforce", "availability", "density"],
|
| 59 |
+
"should_cite_sources": true,
|
| 60 |
+
"min_recommendations": 2,
|
| 61 |
+
"type": "chat"
|
| 62 |
+
},
|
| 63 |
+
{
|
| 64 |
+
"test_id": "CHAT_007",
|
| 65 |
+
"name": "Demographic Information",
|
| 66 |
+
"query": "What demographic columns are available across all datasets?",
|
| 67 |
+
"expected_datasets": ["EJI_2024", "AHRF-2025", "SVI_2022"],
|
| 68 |
+
"expected_column_patterns": ["age", "gender", "race", "ethnicity", "population", "income", "education"],
|
| 69 |
+
"should_cite_sources": true,
|
| 70 |
+
"min_recommendations": 3,
|
| 71 |
+
"type": "chat"
|
| 72 |
+
},
|
| 73 |
+
{
|
| 74 |
+
"test_id": "CHAT_008",
|
| 75 |
+
"name": "Mental Health Indicators",
|
| 76 |
+
"query": "What data do you have about mental health and mental health services?",
|
| 77 |
+
"expected_datasets": ["EJI_2024", "AHRF-2025"],
|
| 78 |
+
"expected_column_patterns": ["mental", "behavioral", "depression", "anxiety", "substance", "addiction"],
|
| 79 |
+
"should_cite_sources": true,
|
| 80 |
+
"min_recommendations": 1,
|
| 81 |
+
"type": "chat"
|
| 82 |
+
},
|
| 83 |
+
{
|
| 84 |
+
"test_id": "CHAT_009",
|
| 85 |
+
"name": "Follow-up Question - Deep Dive",
|
| 86 |
+
"query": "Tell me more about the specific columns in the SVI_2022 dataset",
|
| 87 |
+
"requires_prior": "CHAT_004",
|
| 88 |
+
"expected_datasets": ["SVI_2022"],
|
| 89 |
+
"expected_column_patterns": ["svi", "theme", "rank", "percentile"],
|
| 90 |
+
"should_cite_sources": true,
|
| 91 |
+
"min_recommendations": 1,
|
| 92 |
+
"type": "chat"
|
| 93 |
+
},
|
| 94 |
+
{
|
| 95 |
+
"test_id": "CHAT_010",
|
| 96 |
+
"name": "Clarification Question",
|
| 97 |
+
"query": "Which dataset has the most recent data?",
|
| 98 |
+
"expected_datasets": ["AHRF-2025", "EJI_2024"],
|
| 99 |
+
"expected_column_patterns": ["2024", "2025", "recent", "latest"],
|
| 100 |
+
"should_cite_sources": true,
|
| 101 |
+
"min_recommendations": 1,
|
| 102 |
+
"type": "chat"
|
| 103 |
+
},
|
| 104 |
+
{
|
| 105 |
+
"test_id": "CHAT_011",
|
| 106 |
+
"name": "Chronic Disease Burden",
|
| 107 |
+
"query": "Which columns would help identify communities with high chronic disease burden?",
|
| 108 |
+
"expected_datasets": ["EJI_2024", "AHRF-2025"],
|
| 109 |
+
"expected_column_patterns": ["chronic", "disease", "mortality", "morbidity", "prevalence"],
|
| 110 |
+
"should_cite_sources": true,
|
| 111 |
+
"min_recommendations": 2,
|
| 112 |
+
"type": "chat"
|
| 113 |
+
},
|
| 114 |
+
{
|
| 115 |
+
"test_id": "CHAT_012",
|
| 116 |
+
"name": "Access to Care",
|
| 117 |
+
"query": "What columns measure access to healthcare services?",
|
| 118 |
+
"expected_datasets": ["AHRF-2025"],
|
| 119 |
+
"expected_column_patterns": ["access", "availability", "insurance", "coverage", "uninsured"],
|
| 120 |
+
"should_cite_sources": true,
|
| 121 |
+
"min_recommendations": 2,
|
| 122 |
+
"type": "chat"
|
| 123 |
+
},
|
| 124 |
+
{
|
| 125 |
+
"test_id": "CHAT_013",
|
| 126 |
+
"name": "Economic Factors",
|
| 127 |
+
"query": "Which columns relate to economic indicators and poverty?",
|
| 128 |
+
"expected_datasets": ["SVI_2022", "EJI_2024", "AHRF-2025"],
|
| 129 |
+
"expected_column_patterns": ["poverty", "income", "employment", "economic", "wealth"],
|
| 130 |
+
"should_cite_sources": true,
|
| 131 |
+
"min_recommendations": 2,
|
| 132 |
+
"type": "chat"
|
| 133 |
+
},
|
| 134 |
+
{
|
| 135 |
+
"test_id": "CHAT_014",
|
| 136 |
+
"name": "Housing and Living Conditions",
|
| 137 |
+
"query": "Do you have data about housing, crowding, or living conditions?",
|
| 138 |
+
"expected_datasets": ["SVI_2022", "EJI_2024"],
|
| 139 |
+
"expected_column_patterns": ["housing", "crowding", "living", "household", "structure"],
|
| 140 |
+
"should_cite_sources": true,
|
| 141 |
+
"min_recommendations": 1,
|
| 142 |
+
"type": "chat"
|
| 143 |
+
},
|
| 144 |
+
{
|
| 145 |
+
"test_id": "CHAT_015",
|
| 146 |
+
"name": "Greetings (No Retrieval Expected)",
|
| 147 |
+
"query": "Hi there!",
|
| 148 |
+
"expected_datasets": [],
|
| 149 |
+
"expected_column_patterns": [],
|
| 150 |
+
"should_cite_sources": false,
|
| 151 |
+
"min_recommendations": 0,
|
| 152 |
+
"type": "chat"
|
| 153 |
+
}
|
| 154 |
+
],
|
| 155 |
+
"area_insights_tests": [
|
| 156 |
+
{
|
| 157 |
+
"test_id": "AREA_001",
|
| 158 |
+
"name": "NYC Area Insights",
|
| 159 |
+
"query": "What data is available for ZIP code 10001?",
|
| 160 |
+
"zip_code": "10001",
|
| 161 |
+
"location_name": "New York, NY",
|
| 162 |
+
"expected_datasets": ["EJI_2024", "AHRF-2025", "SVI_2022"],
|
| 163 |
+
"should_show_geographic_context": true,
|
| 164 |
+
"type": "area_insights"
|
| 165 |
+
},
|
| 166 |
+
{
|
| 167 |
+
"test_id": "AREA_002",
|
| 168 |
+
"name": "Atlanta Area Insights",
|
| 169 |
+
"query": "Tell me about health data for Atlanta, GA",
|
| 170 |
+
"location_name": "Atlanta, GA",
|
| 171 |
+
"expected_datasets": ["EJI_2024", "AHRF-2025", "SVI_2022"],
|
| 172 |
+
"should_show_geographic_context": true,
|
| 173 |
+
"type": "area_insights"
|
| 174 |
+
},
|
| 175 |
+
{
|
| 176 |
+
"test_id": "AREA_003",
|
| 177 |
+
"name": "San Francisco Area Insights",
|
| 178 |
+
"query": "What environmental data is available for San Francisco?",
|
| 179 |
+
"location_name": "San Francisco, CA",
|
| 180 |
+
"expected_datasets": ["EJI_2024"],
|
| 181 |
+
"should_show_geographic_context": true,
|
| 182 |
+
"type": "area_insights"
|
| 183 |
+
},
|
| 184 |
+
{
|
| 185 |
+
"test_id": "AREA_004",
|
| 186 |
+
"name": "Multiple ZIP Lookup",
|
| 187 |
+
"query": "Compare data for 10001 and 30301",
|
| 188 |
+
"zip_codes": ["10001", "30301"],
|
| 189 |
+
"expected_datasets": ["EJI_2024", "AHRF-2025", "SVI_2022"],
|
| 190 |
+
"should_show_geographic_context": true,
|
| 191 |
+
"type": "area_insights"
|
| 192 |
+
},
|
| 193 |
+
{
|
| 194 |
+
"test_id": "AREA_005",
|
| 195 |
+
"name": "Invalid ZIP Fallback",
|
| 196 |
+
"query": "What about ZIP code 99999?",
|
| 197 |
+
"zip_code": "99999",
|
| 198 |
+
"location_name": "Invalid ZIP",
|
| 199 |
+
"should_fallback_to_general": true,
|
| 200 |
+
"type": "area_insights"
|
| 201 |
+
}
|
| 202 |
+
],
|
| 203 |
+
"validation_rules": {
|
| 204 |
+
"citation_format": "Each column recommendation must follow: '**ColumnName** (Dataset: DatasetName)' or include '(Source: DatasetName)'",
|
| 205 |
+
"no_hallucination": "All recommended columns must exist in at least one loaded dataset",
|
| 206 |
+
"dataset_accuracy": "Recommended datasets must be in the loaded list: EJI_2024, AHRF-2025, SVI_2022, CHR",
|
| 207 |
+
"relevance": "Recommendations should match the semantic intent of the query",
|
| 208 |
+
"completeness": "Response should mention multiple datasets when relevant columns exist across them"
|
| 209 |
+
}
|
| 210 |
+
}
|
tests/test_chat_automation.py
ADDED
|
@@ -0,0 +1,223 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""
|
| 2 |
+
test_chat_automation.py
|
| 3 |
+
|
| 4 |
+
Pytest tests for chat automation functionality.
|
| 5 |
+
Executes the chat automation harness and validates test execution.
|
| 6 |
+
"""
|
| 7 |
+
|
| 8 |
+
import pytest
|
| 9 |
+
import json
|
| 10 |
+
from pathlib import Path
|
| 11 |
+
from chat_automation import ChatAutomation, MockAzureOpenAIService
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
class TestChatAutomationMock:
|
| 15 |
+
"""Test suite for chat automation with mock service."""
|
| 16 |
+
|
| 17 |
+
def test_mock_service_initialization(self):
|
| 18 |
+
"""Test that mock service initializes correctly."""
|
| 19 |
+
service = MockAzureOpenAIService()
|
| 20 |
+
assert service is not None
|
| 21 |
+
assert service.call_count == 0
|
| 22 |
+
|
| 23 |
+
def test_mock_service_diabetes_response(self):
|
| 24 |
+
"""Test mock service returns appropriate response for diabetes query."""
|
| 25 |
+
service = MockAzureOpenAIService()
|
| 26 |
+
response = service.get_chat_response(
|
| 27 |
+
query="I'm building a diabetes risk prediction model",
|
| 28 |
+
context="",
|
| 29 |
+
chat_history=[],
|
| 30 |
+
system_prompt=""
|
| 31 |
+
)
|
| 32 |
+
|
| 33 |
+
assert response is not None
|
| 34 |
+
assert len(response) > 50
|
| 35 |
+
assert "diabetes" in response.lower() or "glucose" in response.lower()
|
| 36 |
+
assert service.call_count == 1
|
| 37 |
+
|
| 38 |
+
def test_mock_service_greeting_response(self):
|
| 39 |
+
"""Test mock service handles greetings."""
|
| 40 |
+
service = MockAzureOpenAIService()
|
| 41 |
+
response = service.get_chat_response(
|
| 42 |
+
query="Hi there!",
|
| 43 |
+
context="",
|
| 44 |
+
chat_history=[],
|
| 45 |
+
system_prompt=""
|
| 46 |
+
)
|
| 47 |
+
|
| 48 |
+
assert response is not None
|
| 49 |
+
assert "hello" in response.lower() or "help" in response.lower()
|
| 50 |
+
|
| 51 |
+
def test_chat_automation_initialization_mock(self, chat_automation_mock):
|
| 52 |
+
"""Test ChatAutomation initializes with mock service."""
|
| 53 |
+
assert chat_automation_mock is not None
|
| 54 |
+
assert chat_automation_mock.use_mock is True
|
| 55 |
+
assert chat_automation_mock.test_results == []
|
| 56 |
+
|
| 57 |
+
def test_should_run_retrieval_logic(self):
|
| 58 |
+
"""Test the retrieval decision logic."""
|
| 59 |
+
# Should not retrieve for simple queries
|
| 60 |
+
assert ChatAutomation._should_run_retrieval("hi") is False
|
| 61 |
+
assert ChatAutomation._should_run_retrieval("hello") is False
|
| 62 |
+
assert ChatAutomation._should_run_retrieval("bye") is False
|
| 63 |
+
|
| 64 |
+
# Should retrieve for complex queries
|
| 65 |
+
assert ChatAutomation._should_run_retrieval("What columns help predict diabetes?") is True
|
| 66 |
+
assert ChatAutomation._should_run_retrieval("Tell me about the SVI dataset") is True
|
| 67 |
+
|
| 68 |
+
def test_format_context(self):
|
| 69 |
+
"""Test context formatting for LLM."""
|
| 70 |
+
chunks = [
|
| 71 |
+
{"text": "Column A description", "dataset": "EJI_2024", "line_number": 1},
|
| 72 |
+
{"text": "Column B description", "dataset": "AHRF-2025", "line_number": 2}
|
| 73 |
+
]
|
| 74 |
+
|
| 75 |
+
context = ChatAutomation._format_context(chunks)
|
| 76 |
+
|
| 77 |
+
assert "Retrieved Data Dictionary Entries" in context
|
| 78 |
+
assert "EJI_2024" in context
|
| 79 |
+
assert "AHRF-2025" in context
|
| 80 |
+
assert "Column A description" in context
|
| 81 |
+
|
| 82 |
+
def test_extract_citations(self):
|
| 83 |
+
"""Test citation extraction from response text."""
|
| 84 |
+
response = """
|
| 85 |
+
1. **HbA1c Level** (Dataset: EJI_2024)
|
| 86 |
+
2. **Fasting Glucose** (Source: AHRF-2025)
|
| 87 |
+
3. **BMI** (Dataset: SVI_2022)
|
| 88 |
+
"""
|
| 89 |
+
|
| 90 |
+
citations = ChatAutomation._extract_citations(response)
|
| 91 |
+
|
| 92 |
+
assert len(citations) >= 3
|
| 93 |
+
assert "EJI_2024" in citations
|
| 94 |
+
assert "AHRF-2025" in citations
|
| 95 |
+
assert "SVI_2022" in citations
|
| 96 |
+
|
| 97 |
+
def test_run_single_chat_test_mock(self, chat_automation_mock, chat_interface_tests):
|
| 98 |
+
"""Test running a single chat test with mock service."""
|
| 99 |
+
if not chat_interface_tests:
|
| 100 |
+
pytest.skip("No chat interface tests available")
|
| 101 |
+
|
| 102 |
+
test_case = chat_interface_tests[0]
|
| 103 |
+
result = chat_automation_mock.run_chat_test(test_case)
|
| 104 |
+
|
| 105 |
+
assert result["test_id"] == test_case["test_id"]
|
| 106 |
+
assert result["query"] == test_case["query"]
|
| 107 |
+
assert "response" in result
|
| 108 |
+
assert result["execution_time_ms"] >= 0
|
| 109 |
+
assert "citations" in result
|
| 110 |
+
|
| 111 |
+
def test_run_area_insights_test_mock(self, chat_automation_mock, area_insights_tests):
|
| 112 |
+
"""Test running an area insights test with mock service."""
|
| 113 |
+
if not area_insights_tests:
|
| 114 |
+
pytest.skip("No area insights tests available")
|
| 115 |
+
|
| 116 |
+
test_case = area_insights_tests[0]
|
| 117 |
+
result = chat_automation_mock.run_area_insights_test(test_case)
|
| 118 |
+
|
| 119 |
+
assert result["test_id"] == test_case["test_id"]
|
| 120 |
+
assert result["type"] == "area_insights"
|
| 121 |
+
assert "response" in result
|
| 122 |
+
|
| 123 |
+
def test_save_results_to_json(self, chat_automation_mock, tmp_path, chat_interface_tests):
|
| 124 |
+
"""Test saving results to JSON file."""
|
| 125 |
+
if not chat_interface_tests:
|
| 126 |
+
pytest.skip("No chat interface tests available")
|
| 127 |
+
|
| 128 |
+
# Run a test
|
| 129 |
+
test_result = chat_automation_mock.run_chat_test(chat_interface_tests[0])
|
| 130 |
+
chat_automation_mock.test_results = [test_result]
|
| 131 |
+
|
| 132 |
+
# Save results
|
| 133 |
+
output_file = tmp_path / "test_results.json"
|
| 134 |
+
saved_path = chat_automation_mock.save_results(str(output_file))
|
| 135 |
+
|
| 136 |
+
# Verify file exists and contains data
|
| 137 |
+
assert Path(saved_path).exists()
|
| 138 |
+
with open(saved_path) as f:
|
| 139 |
+
data = json.load(f)
|
| 140 |
+
assert len(data) == 1
|
| 141 |
+
assert data[0]["test_id"] == chat_interface_tests[0]["test_id"]
|
| 142 |
+
|
| 143 |
+
def test_run_all_tests_mock(self, chat_automation_mock, test_cases):
|
| 144 |
+
"""Test running all test cases with mock service."""
|
| 145 |
+
results = chat_automation_mock.run_all_tests()
|
| 146 |
+
|
| 147 |
+
expected_count = len(test_cases.get("chat_interface_tests", [])) + len(test_cases.get("area_insights_tests", []))
|
| 148 |
+
assert len(results) > 0
|
| 149 |
+
assert len(results) <= expected_count # May be less if some tests are skipped
|
| 150 |
+
|
| 151 |
+
|
| 152 |
+
class TestChatAutomationIntegration:
|
| 153 |
+
"""Integration tests for chat automation (requires real services)."""
|
| 154 |
+
|
| 155 |
+
@pytest.mark.skip(reason="Requires real Azure OpenAI API credentials")
|
| 156 |
+
def test_real_service_initialization(self):
|
| 157 |
+
"""Test ChatAutomation with real service."""
|
| 158 |
+
try:
|
| 159 |
+
automation = ChatAutomation(use_mock=False)
|
| 160 |
+
assert automation is not None
|
| 161 |
+
assert automation.use_mock is False
|
| 162 |
+
except ValueError:
|
| 163 |
+
# Expected if credentials not configured
|
| 164 |
+
pytest.skip("Azure OpenAI credentials not configured")
|
| 165 |
+
|
| 166 |
+
@pytest.mark.skip(reason="Requires real Azure OpenAI API - cost implications")
|
| 167 |
+
def test_real_chat_test(self, chat_interface_tests):
|
| 168 |
+
"""Test running real chat test."""
|
| 169 |
+
if not chat_interface_tests:
|
| 170 |
+
pytest.skip("No chat interface tests available")
|
| 171 |
+
|
| 172 |
+
try:
|
| 173 |
+
automation = ChatAutomation(use_mock=False)
|
| 174 |
+
result = automation.run_chat_test(chat_interface_tests[0])
|
| 175 |
+
assert result["success"]
|
| 176 |
+
except ValueError:
|
| 177 |
+
pytest.skip("Azure OpenAI credentials not configured")
|
| 178 |
+
|
| 179 |
+
|
| 180 |
+
class TestTestCaseValidation:
|
| 181 |
+
"""Validate test case structure and content."""
|
| 182 |
+
|
| 183 |
+
def test_test_cases_loaded(self, test_cases):
|
| 184 |
+
"""Test that test cases are properly loaded."""
|
| 185 |
+
assert test_cases is not None
|
| 186 |
+
assert "chat_interface_tests" in test_cases
|
| 187 |
+
assert "area_insights_tests" in test_cases
|
| 188 |
+
assert "validation_rules" in test_cases
|
| 189 |
+
|
| 190 |
+
def test_chat_test_case_structure(self, chat_interface_tests):
|
| 191 |
+
"""Test chat test cases have required fields."""
|
| 192 |
+
required_fields = ["test_id", "name", "query", "expected_datasets", "type"]
|
| 193 |
+
|
| 194 |
+
for test_case in chat_interface_tests:
|
| 195 |
+
for field in required_fields:
|
| 196 |
+
assert field in test_case, f"Missing field '{field}' in test case {test_case.get('test_id')}"
|
| 197 |
+
assert test_case["type"] == "chat"
|
| 198 |
+
|
| 199 |
+
def test_area_insights_test_case_structure(self, area_insights_tests):
|
| 200 |
+
"""Test area insights test cases have required fields."""
|
| 201 |
+
required_fields = ["test_id", "name", "query", "type"]
|
| 202 |
+
|
| 203 |
+
for test_case in area_insights_tests:
|
| 204 |
+
for field in required_fields:
|
| 205 |
+
assert field in test_case, f"Missing field '{field}' in test case {test_case.get('test_id')}"
|
| 206 |
+
assert test_case["type"] == "area_insights"
|
| 207 |
+
|
| 208 |
+
def test_validation_rules_defined(self, validation_rules):
|
| 209 |
+
"""Test that validation rules are defined."""
|
| 210 |
+
expected_rules = [
|
| 211 |
+
"citation_format",
|
| 212 |
+
"no_hallucination",
|
| 213 |
+
"dataset_accuracy",
|
| 214 |
+
"relevance",
|
| 215 |
+
"completeness"
|
| 216 |
+
]
|
| 217 |
+
|
| 218 |
+
for rule in expected_rules:
|
| 219 |
+
assert rule in validation_rules, f"Missing validation rule: {rule}"
|
| 220 |
+
|
| 221 |
+
|
| 222 |
+
if __name__ == "__main__":
|
| 223 |
+
pytest.main([__file__, "-v"])
|
tests/test_reports/accuracy_report_20260113_230845.md
ADDED
|
@@ -0,0 +1,312 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Data Dictionary Chatbot - Accuracy Report
|
| 2 |
+
|
| 3 |
+
**Generated:** 2026-01-13 23:08:45
|
| 4 |
+
|
| 5 |
+
❌ **Overall Status:** Critical - Major rework required 🚨
|
| 6 |
+
|
| 7 |
+
---
|
| 8 |
+
|
| 9 |
+
## Summary Metrics
|
| 10 |
+
|
| 11 |
+
| Metric | Value |
|
| 12 |
+
|--------|-------|
|
| 13 |
+
| **Total Tests** | 20 |
|
| 14 |
+
| **Passed** | 0 ✅ |
|
| 15 |
+
| **Failed** | 20 ❌ |
|
| 16 |
+
| **Average Score** | 18.75% |
|
| 17 |
+
| **Pass Rate** | 0.0% |
|
| 18 |
+
|
| 19 |
+
---
|
| 20 |
+
|
| 21 |
+
## Key Findings
|
| 22 |
+
|
| 23 |
+
### Strengths
|
| 24 |
+
- **Area_Insights**: 15/20 tests passed (75%)
|
| 25 |
+
- **Citation**: 0/20 tests passed (0%)
|
| 26 |
+
- **Relevance**: 0/20 tests passed (0%)
|
| 27 |
+
- **Format**: 0/20 tests passed (0%)
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
---
|
| 31 |
+
|
| 32 |
+
## Detailed Test Results
|
| 33 |
+
|
| 34 |
+
### Diabetes Risk Prediction (CHAT_001)
|
| 35 |
+
- **Status:** ❌ FAILED
|
| 36 |
+
- **Overall Score:** 25.00%
|
| 37 |
+
|
| 38 |
+
**Validations:**
|
| 39 |
+
- ❌ **Citation**: 0.00%
|
| 40 |
+
- ⚠️ Response is empty or None - cannot extract citations
|
| 41 |
+
- ❌ **Relevance**: 0.00%
|
| 42 |
+
- ⚠️ Response is empty or None - cannot score relevance
|
| 43 |
+
- ❌ **Format**: 0.00%
|
| 44 |
+
- ⚠️ Response is empty or None - cannot validate format
|
| 45 |
+
- ✅ **Area_Insights**: 100.00%
|
| 46 |
+
|
| 47 |
+
### Hospital Readmission Prediction (CHAT_002)
|
| 48 |
+
- **Status:** ❌ FAILED
|
| 49 |
+
- **Overall Score:** 25.00%
|
| 50 |
+
|
| 51 |
+
**Validations:**
|
| 52 |
+
- ❌ **Citation**: 0.00%
|
| 53 |
+
- ⚠️ Response is empty or None - cannot extract citations
|
| 54 |
+
- ❌ **Relevance**: 0.00%
|
| 55 |
+
- ⚠️ Response is empty or None - cannot score relevance
|
| 56 |
+
- ❌ **Format**: 0.00%
|
| 57 |
+
- ⚠️ Response is empty or None - cannot validate format
|
| 58 |
+
- ✅ **Area_Insights**: 100.00%
|
| 59 |
+
|
| 60 |
+
### Food Insecurity Impact (CHAT_003)
|
| 61 |
+
- **Status:** ❌ FAILED
|
| 62 |
+
- **Overall Score:** 25.00%
|
| 63 |
+
|
| 64 |
+
**Validations:**
|
| 65 |
+
- ❌ **Citation**: 0.00%
|
| 66 |
+
- ⚠️ Response is empty or None - cannot extract citations
|
| 67 |
+
- ❌ **Relevance**: 0.00%
|
| 68 |
+
- ⚠️ Response is empty or None - cannot score relevance
|
| 69 |
+
- ❌ **Format**: 0.00%
|
| 70 |
+
- ⚠️ Response is empty or None - cannot validate format
|
| 71 |
+
- ✅ **Area_Insights**: 100.00%
|
| 72 |
+
|
| 73 |
+
### Social Vulnerability Index (CHAT_004)
|
| 74 |
+
- **Status:** ❌ FAILED
|
| 75 |
+
- **Overall Score:** 25.00%
|
| 76 |
+
|
| 77 |
+
**Validations:**
|
| 78 |
+
- ❌ **Citation**: 0.00%
|
| 79 |
+
- ⚠️ Response is empty or None - cannot extract citations
|
| 80 |
+
- ❌ **Relevance**: 0.00%
|
| 81 |
+
- ⚠️ Response is empty or None - cannot score relevance
|
| 82 |
+
- ❌ **Format**: 0.00%
|
| 83 |
+
- ⚠️ Response is empty or None - cannot validate format
|
| 84 |
+
- ✅ **Area_Insights**: 100.00%
|
| 85 |
+
|
| 86 |
+
### Environmental Health Indices (CHAT_005)
|
| 87 |
+
- **Status:** ❌ FAILED
|
| 88 |
+
- **Overall Score:** 25.00%
|
| 89 |
+
|
| 90 |
+
**Validations:**
|
| 91 |
+
- ❌ **Citation**: 0.00%
|
| 92 |
+
- ⚠️ Response is empty or None - cannot extract citations
|
| 93 |
+
- ❌ **Relevance**: 0.00%
|
| 94 |
+
- ⚠️ Response is empty or None - cannot score relevance
|
| 95 |
+
- ❌ **Format**: 0.00%
|
| 96 |
+
- ⚠️ Response is empty or None - cannot validate format
|
| 97 |
+
- ✅ **Area_Insights**: 100.00%
|
| 98 |
+
|
| 99 |
+
### Healthcare Workforce (CHAT_006)
|
| 100 |
+
- **Status:** ❌ FAILED
|
| 101 |
+
- **Overall Score:** 25.00%
|
| 102 |
+
|
| 103 |
+
**Validations:**
|
| 104 |
+
- ❌ **Citation**: 0.00%
|
| 105 |
+
- ⚠️ Response is empty or None - cannot extract citations
|
| 106 |
+
- ❌ **Relevance**: 0.00%
|
| 107 |
+
- ⚠️ Response is empty or None - cannot score relevance
|
| 108 |
+
- ❌ **Format**: 0.00%
|
| 109 |
+
- ⚠️ Response is empty or None - cannot validate format
|
| 110 |
+
- ✅ **Area_Insights**: 100.00%
|
| 111 |
+
|
| 112 |
+
### Demographic Information (CHAT_007)
|
| 113 |
+
- **Status:** ❌ FAILED
|
| 114 |
+
- **Overall Score:** 25.00%
|
| 115 |
+
|
| 116 |
+
**Validations:**
|
| 117 |
+
- ❌ **Citation**: 0.00%
|
| 118 |
+
- ⚠️ Response is empty or None - cannot extract citations
|
| 119 |
+
- ❌ **Relevance**: 0.00%
|
| 120 |
+
- ⚠️ Response is empty or None - cannot score relevance
|
| 121 |
+
- ❌ **Format**: 0.00%
|
| 122 |
+
- ⚠️ Response is empty or None - cannot validate format
|
| 123 |
+
- ✅ **Area_Insights**: 100.00%
|
| 124 |
+
|
| 125 |
+
### Mental Health Indicators (CHAT_008)
|
| 126 |
+
- **Status:** ❌ FAILED
|
| 127 |
+
- **Overall Score:** 25.00%
|
| 128 |
+
|
| 129 |
+
**Validations:**
|
| 130 |
+
- ❌ **Citation**: 0.00%
|
| 131 |
+
- ⚠️ Response is empty or None - cannot extract citations
|
| 132 |
+
- ❌ **Relevance**: 0.00%
|
| 133 |
+
- ⚠️ Response is empty or None - cannot score relevance
|
| 134 |
+
- ❌ **Format**: 0.00%
|
| 135 |
+
- ⚠️ Response is empty or None - cannot validate format
|
| 136 |
+
- ✅ **Area_Insights**: 100.00%
|
| 137 |
+
|
| 138 |
+
### Follow-up Question - Deep Dive (CHAT_009)
|
| 139 |
+
- **Status:** ❌ FAILED
|
| 140 |
+
- **Overall Score:** 25.00%
|
| 141 |
+
|
| 142 |
+
**Validations:**
|
| 143 |
+
- ❌ **Citation**: 0.00%
|
| 144 |
+
- ⚠️ Response is empty or None - cannot extract citations
|
| 145 |
+
- ❌ **Relevance**: 0.00%
|
| 146 |
+
- ⚠️ Response is empty or None - cannot score relevance
|
| 147 |
+
- ❌ **Format**: 0.00%
|
| 148 |
+
- ⚠️ Response is empty or None - cannot validate format
|
| 149 |
+
- ✅ **Area_Insights**: 100.00%
|
| 150 |
+
|
| 151 |
+
### Clarification Question (CHAT_010)
|
| 152 |
+
- **Status:** ❌ FAILED
|
| 153 |
+
- **Overall Score:** 25.00%
|
| 154 |
+
|
| 155 |
+
**Validations:**
|
| 156 |
+
- ❌ **Citation**: 0.00%
|
| 157 |
+
- ⚠️ Response is empty or None - cannot extract citations
|
| 158 |
+
- ❌ **Relevance**: 0.00%
|
| 159 |
+
- ⚠️ Response is empty or None - cannot score relevance
|
| 160 |
+
- ❌ **Format**: 0.00%
|
| 161 |
+
- ⚠️ Response is empty or None - cannot validate format
|
| 162 |
+
- ✅ **Area_Insights**: 100.00%
|
| 163 |
+
|
| 164 |
+
### Chronic Disease Burden (CHAT_011)
|
| 165 |
+
- **Status:** ❌ FAILED
|
| 166 |
+
- **Overall Score:** 25.00%
|
| 167 |
+
|
| 168 |
+
**Validations:**
|
| 169 |
+
- ❌ **Citation**: 0.00%
|
| 170 |
+
- ⚠️ Response is empty or None - cannot extract citations
|
| 171 |
+
- ❌ **Relevance**: 0.00%
|
| 172 |
+
- ⚠️ Response is empty or None - cannot score relevance
|
| 173 |
+
- ❌ **Format**: 0.00%
|
| 174 |
+
- ⚠️ Response is empty or None - cannot validate format
|
| 175 |
+
- ✅ **Area_Insights**: 100.00%
|
| 176 |
+
|
| 177 |
+
### Access to Care (CHAT_012)
|
| 178 |
+
- **Status:** ❌ FAILED
|
| 179 |
+
- **Overall Score:** 25.00%
|
| 180 |
+
|
| 181 |
+
**Validations:**
|
| 182 |
+
- ❌ **Citation**: 0.00%
|
| 183 |
+
- ⚠️ Response is empty or None - cannot extract citations
|
| 184 |
+
- ❌ **Relevance**: 0.00%
|
| 185 |
+
- ⚠️ Response is empty or None - cannot score relevance
|
| 186 |
+
- ❌ **Format**: 0.00%
|
| 187 |
+
- ⚠️ Response is empty or None - cannot validate format
|
| 188 |
+
- ✅ **Area_Insights**: 100.00%
|
| 189 |
+
|
| 190 |
+
### Economic Factors (CHAT_013)
|
| 191 |
+
- **Status:** ❌ FAILED
|
| 192 |
+
- **Overall Score:** 25.00%
|
| 193 |
+
|
| 194 |
+
**Validations:**
|
| 195 |
+
- ❌ **Citation**: 0.00%
|
| 196 |
+
- ⚠️ Response is empty or None - cannot extract citations
|
| 197 |
+
- ❌ **Relevance**: 0.00%
|
| 198 |
+
- ⚠️ Response is empty or None - cannot score relevance
|
| 199 |
+
- ❌ **Format**: 0.00%
|
| 200 |
+
- ⚠️ Response is empty or None - cannot validate format
|
| 201 |
+
- ✅ **Area_Insights**: 100.00%
|
| 202 |
+
|
| 203 |
+
### Housing and Living Conditions (CHAT_014)
|
| 204 |
+
- **Status:** ❌ FAILED
|
| 205 |
+
- **Overall Score:** 25.00%
|
| 206 |
+
|
| 207 |
+
**Validations:**
|
| 208 |
+
- ❌ **Citation**: 0.00%
|
| 209 |
+
- ⚠️ Response is empty or None - cannot extract citations
|
| 210 |
+
- ❌ **Relevance**: 0.00%
|
| 211 |
+
- ⚠️ Response is empty or None - cannot score relevance
|
| 212 |
+
- ❌ **Format**: 0.00%
|
| 213 |
+
- ⚠️ Response is empty or None - cannot validate format
|
| 214 |
+
- ✅ **Area_Insights**: 100.00%
|
| 215 |
+
|
| 216 |
+
### Greetings (No Retrieval Expected) (CHAT_015)
|
| 217 |
+
- **Status:** ❌ FAILED
|
| 218 |
+
- **Overall Score:** 25.00%
|
| 219 |
+
|
| 220 |
+
**Validations:**
|
| 221 |
+
- ❌ **Citation**: 0.00%
|
| 222 |
+
- ⚠️ Response is empty or None - cannot extract citations
|
| 223 |
+
- ❌ **Relevance**: 0.00%
|
| 224 |
+
- ⚠️ Response is empty or None - cannot score relevance
|
| 225 |
+
- ❌ **Format**: 0.00%
|
| 226 |
+
- ⚠️ Response is empty or None - cannot validate format
|
| 227 |
+
- ✅ **Area_Insights**: 100.00%
|
| 228 |
+
|
| 229 |
+
### NYC Area Insights (AREA_001)
|
| 230 |
+
- **Status:** ❌ FAILED
|
| 231 |
+
- **Overall Score:** 0.00%
|
| 232 |
+
|
| 233 |
+
**Validations:**
|
| 234 |
+
- ❌ **Citation**: 0.00%
|
| 235 |
+
- ⚠️ Response is empty or None - cannot extract citations
|
| 236 |
+
- ❌ **Relevance**: 0.00%
|
| 237 |
+
- ⚠️ Response is empty or None - cannot score relevance
|
| 238 |
+
- ❌ **Format**: 0.00%
|
| 239 |
+
- ⚠️ Response is empty or None - cannot validate format
|
| 240 |
+
- ❌ **Area_Insights**: 0.00%
|
| 241 |
+
- ⚠️ Response is empty or None - cannot validate area insights
|
| 242 |
+
|
| 243 |
+
### Atlanta Area Insights (AREA_002)
|
| 244 |
+
- **Status:** ❌ FAILED
|
| 245 |
+
- **Overall Score:** 0.00%
|
| 246 |
+
|
| 247 |
+
**Validations:**
|
| 248 |
+
- ❌ **Citation**: 0.00%
|
| 249 |
+
- ⚠️ Response is empty or None - cannot extract citations
|
| 250 |
+
- ❌ **Relevance**: 0.00%
|
| 251 |
+
- ⚠️ Response is empty or None - cannot score relevance
|
| 252 |
+
- ❌ **Format**: 0.00%
|
| 253 |
+
- ⚠️ Response is empty or None - cannot validate format
|
| 254 |
+
- ❌ **Area_Insights**: 0.00%
|
| 255 |
+
- ⚠️ Response is empty or None - cannot validate area insights
|
| 256 |
+
|
| 257 |
+
### San Francisco Area Insights (AREA_003)
|
| 258 |
+
- **Status:** ❌ FAILED
|
| 259 |
+
- **Overall Score:** 0.00%
|
| 260 |
+
|
| 261 |
+
**Validations:**
|
| 262 |
+
- ❌ **Citation**: 0.00%
|
| 263 |
+
- ⚠️ Response is empty or None - cannot extract citations
|
| 264 |
+
- ❌ **Relevance**: 0.00%
|
| 265 |
+
- ⚠️ Response is empty or None - cannot score relevance
|
| 266 |
+
- ❌ **Format**: 0.00%
|
| 267 |
+
- ⚠️ Response is empty or None - cannot validate format
|
| 268 |
+
- ❌ **Area_Insights**: 0.00%
|
| 269 |
+
- ⚠️ Response is empty or None - cannot validate area insights
|
| 270 |
+
|
| 271 |
+
### Multiple ZIP Lookup (AREA_004)
|
| 272 |
+
- **Status:** ❌ FAILED
|
| 273 |
+
- **Overall Score:** 0.00%
|
| 274 |
+
|
| 275 |
+
**Validations:**
|
| 276 |
+
- ❌ **Citation**: 0.00%
|
| 277 |
+
- ⚠️ Response is empty or None - cannot extract citations
|
| 278 |
+
- ❌ **Relevance**: 0.00%
|
| 279 |
+
- ⚠️ Response is empty or None - cannot score relevance
|
| 280 |
+
- ❌ **Format**: 0.00%
|
| 281 |
+
- ⚠️ Response is empty or None - cannot validate format
|
| 282 |
+
- ❌ **Area_Insights**: 0.00%
|
| 283 |
+
- ⚠️ Response is empty or None - cannot validate area insights
|
| 284 |
+
|
| 285 |
+
### Invalid ZIP Fallback (AREA_005)
|
| 286 |
+
- **Status:** ❌ FAILED
|
| 287 |
+
- **Overall Score:** 0.00%
|
| 288 |
+
|
| 289 |
+
**Validations:**
|
| 290 |
+
- ❌ **Citation**: 0.00%
|
| 291 |
+
- ⚠️ Response is empty or None - cannot extract citations
|
| 292 |
+
- ❌ **Relevance**: 0.00%
|
| 293 |
+
- ⚠️ Response is empty or None - cannot score relevance
|
| 294 |
+
- ❌ **Format**: 0.00%
|
| 295 |
+
- ⚠️ Response is empty or None - cannot validate format
|
| 296 |
+
- ❌ **Area_Insights**: 0.00%
|
| 297 |
+
- ⚠️ Response is empty or None - cannot validate area insights
|
| 298 |
+
|
| 299 |
+
---
|
| 300 |
+
|
| 301 |
+
## Recommendations
|
| 302 |
+
|
| 303 |
+
🚨 Critical issues detected. Review retrieval and LLM prompt engineering.
|
| 304 |
+
- Ensure all recommended columns are verified against loaded dictionaries
|
| 305 |
+
- Review system prompts to improve citation formatting consistency
|
| 306 |
+
- Monitor Area Insights geographic accuracy for regional data
|
| 307 |
+
- Consider fine-tuning retrieval parameters for better relevance
|
| 308 |
+
- Implement continuous testing in CI/CD pipeline
|
| 309 |
+
|
| 310 |
+
---
|
| 311 |
+
|
| 312 |
+
**Report Generated:** 2026-01-13 23:08:45
|
tests/test_reports/accuracy_report_20260113_231059.html
ADDED
|
@@ -0,0 +1,948 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Data Dictionary Chatbot - Accuracy Report</title>
|
| 7 |
+
<style>
|
| 8 |
+
* {
|
| 9 |
+
margin: 0;
|
| 10 |
+
padding: 0;
|
| 11 |
+
box-sizing: border-box;
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
body {
|
| 15 |
+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
|
| 16 |
+
line-height: 1.6;
|
| 17 |
+
color: #333;
|
| 18 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 19 |
+
min-height: 100vh;
|
| 20 |
+
padding: 20px;
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
.container {
|
| 24 |
+
max-width: 1200px;
|
| 25 |
+
margin: 0 auto;
|
| 26 |
+
background: white;
|
| 27 |
+
border-radius: 10px;
|
| 28 |
+
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
|
| 29 |
+
overflow: hidden;
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
.header {
|
| 33 |
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
| 34 |
+
color: white;
|
| 35 |
+
padding: 40px;
|
| 36 |
+
text-align: center;
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
.header h1 {
|
| 40 |
+
font-size: 2.5em;
|
| 41 |
+
margin-bottom: 10px;
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
.header p {
|
| 45 |
+
font-size: 1em;
|
| 46 |
+
opacity: 0.9;
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
.metrics {
|
| 50 |
+
display: grid;
|
| 51 |
+
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
| 52 |
+
gap: 20px;
|
| 53 |
+
padding: 40px;
|
| 54 |
+
background: #f8f9fa;
|
| 55 |
+
border-bottom: 1px solid #e0e0e0;
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
.metric {
|
| 59 |
+
text-align: center;
|
| 60 |
+
padding: 20px;
|
| 61 |
+
background: white;
|
| 62 |
+
border-radius: 8px;
|
| 63 |
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
.metric-value {
|
| 67 |
+
font-size: 2em;
|
| 68 |
+
font-weight: bold;
|
| 69 |
+
color: #667eea;
|
| 70 |
+
margin: 10px 0;
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
.metric-label {
|
| 74 |
+
font-size: 0.9em;
|
| 75 |
+
color: #666;
|
| 76 |
+
text-transform: uppercase;
|
| 77 |
+
letter-spacing: 1px;
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
.overall-status {
|
| 81 |
+
font-size: 1.2em;
|
| 82 |
+
font-weight: bold;
|
| 83 |
+
padding: 20px;
|
| 84 |
+
border-radius: 8px;
|
| 85 |
+
background: #ef4444;
|
| 86 |
+
color: white;
|
| 87 |
+
text-align: center;
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
+
.content {
|
| 91 |
+
padding: 40px;
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
.section {
|
| 95 |
+
margin-bottom: 40px;
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
.section-title {
|
| 99 |
+
font-size: 1.8em;
|
| 100 |
+
color: #333;
|
| 101 |
+
margin-bottom: 20px;
|
| 102 |
+
padding-bottom: 10px;
|
| 103 |
+
border-bottom: 3px solid #667eea;
|
| 104 |
+
}
|
| 105 |
+
|
| 106 |
+
.test-result {
|
| 107 |
+
margin-bottom: 20px;
|
| 108 |
+
padding: 20px;
|
| 109 |
+
border-left: 5px solid #ddd;
|
| 110 |
+
background: #f8f9fa;
|
| 111 |
+
border-radius: 4px;
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
.test-result.passed {
|
| 115 |
+
border-left-color: #22c55e;
|
| 116 |
+
background: #f0fdf4;
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
.test-result.failed {
|
| 120 |
+
border-left-color: #ef4444;
|
| 121 |
+
background: #fef2f2;
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
.test-header {
|
| 125 |
+
display: flex;
|
| 126 |
+
justify-content: space-between;
|
| 127 |
+
align-items: center;
|
| 128 |
+
margin-bottom: 10px;
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
.test-name {
|
| 132 |
+
font-weight: bold;
|
| 133 |
+
font-size: 1.1em;
|
| 134 |
+
color: #333;
|
| 135 |
+
}
|
| 136 |
+
|
| 137 |
+
.test-id {
|
| 138 |
+
color: #666;
|
| 139 |
+
font-size: 0.9em;
|
| 140 |
+
font-family: monospace;
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
.test-score {
|
| 144 |
+
font-size: 1.2em;
|
| 145 |
+
font-weight: bold;
|
| 146 |
+
padding: 5px 15px;
|
| 147 |
+
border-radius: 20px;
|
| 148 |
+
color: white;
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
.test-score.excellent {
|
| 152 |
+
background: #22c55e;
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
+
.test-score.good {
|
| 156 |
+
background: #3b82f6;
|
| 157 |
+
}
|
| 158 |
+
|
| 159 |
+
.test-score.fair {
|
| 160 |
+
background: #f59e0b;
|
| 161 |
+
}
|
| 162 |
+
|
| 163 |
+
.test-score.poor {
|
| 164 |
+
background: #ef4444;
|
| 165 |
+
}
|
| 166 |
+
|
| 167 |
+
.validator-results {
|
| 168 |
+
margin-top: 15px;
|
| 169 |
+
padding-top: 15px;
|
| 170 |
+
border-top: 1px solid #ddd;
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
.validator {
|
| 174 |
+
margin: 10px 0;
|
| 175 |
+
padding: 10px;
|
| 176 |
+
background: white;
|
| 177 |
+
border-radius: 4px;
|
| 178 |
+
border-left: 4px solid #667eea;
|
| 179 |
+
}
|
| 180 |
+
|
| 181 |
+
.validator.passed {
|
| 182 |
+
border-left-color: #22c55e;
|
| 183 |
+
}
|
| 184 |
+
|
| 185 |
+
.validator.failed {
|
| 186 |
+
border-left-color: #ef4444;
|
| 187 |
+
}
|
| 188 |
+
|
| 189 |
+
.validator-name {
|
| 190 |
+
font-weight: bold;
|
| 191 |
+
text-transform: uppercase;
|
| 192 |
+
font-size: 0.85em;
|
| 193 |
+
color: #667eea;
|
| 194 |
+
}
|
| 195 |
+
|
| 196 |
+
.validator-score {
|
| 197 |
+
font-size: 0.9em;
|
| 198 |
+
color: #666;
|
| 199 |
+
margin: 5px 0;
|
| 200 |
+
}
|
| 201 |
+
|
| 202 |
+
.validator-issues {
|
| 203 |
+
margin-top: 8px;
|
| 204 |
+
padding: 8px;
|
| 205 |
+
background: #fff5f5;
|
| 206 |
+
border-radius: 4px;
|
| 207 |
+
color: #c53030;
|
| 208 |
+
font-size: 0.85em;
|
| 209 |
+
}
|
| 210 |
+
|
| 211 |
+
.issues-list {
|
| 212 |
+
list-style: none;
|
| 213 |
+
margin: 5px 0 0 0;
|
| 214 |
+
padding-left: 0;
|
| 215 |
+
}
|
| 216 |
+
|
| 217 |
+
.issues-list li {
|
| 218 |
+
margin: 3px 0;
|
| 219 |
+
padding-left: 20px;
|
| 220 |
+
position: relative;
|
| 221 |
+
}
|
| 222 |
+
|
| 223 |
+
.issues-list li:before {
|
| 224 |
+
content: "•";
|
| 225 |
+
position: absolute;
|
| 226 |
+
left: 0;
|
| 227 |
+
color: #ef4444;
|
| 228 |
+
}
|
| 229 |
+
|
| 230 |
+
.summary {
|
| 231 |
+
background: linear-gradient(135deg, #667eea15 0%, #764ba215 100%);
|
| 232 |
+
padding: 30px;
|
| 233 |
+
border-radius: 8px;
|
| 234 |
+
margin-bottom: 40px;
|
| 235 |
+
}
|
| 236 |
+
|
| 237 |
+
.summary-item {
|
| 238 |
+
margin: 15px 0;
|
| 239 |
+
display: flex;
|
| 240 |
+
justify-content: space-between;
|
| 241 |
+
padding: 10px 0;
|
| 242 |
+
}
|
| 243 |
+
|
| 244 |
+
.summary-label {
|
| 245 |
+
font-weight: 600;
|
| 246 |
+
color: #333;
|
| 247 |
+
}
|
| 248 |
+
|
| 249 |
+
.summary-value {
|
| 250 |
+
color: #667eea;
|
| 251 |
+
font-weight: bold;
|
| 252 |
+
font-size: 1.1em;
|
| 253 |
+
}
|
| 254 |
+
|
| 255 |
+
.footer {
|
| 256 |
+
background: #f8f9fa;
|
| 257 |
+
padding: 20px;
|
| 258 |
+
text-align: center;
|
| 259 |
+
color: #666;
|
| 260 |
+
border-top: 1px solid #e0e0e0;
|
| 261 |
+
font-size: 0.9em;
|
| 262 |
+
}
|
| 263 |
+
|
| 264 |
+
.progress-bar {
|
| 265 |
+
width: 100%;
|
| 266 |
+
height: 8px;
|
| 267 |
+
background: #e0e0e0;
|
| 268 |
+
border-radius: 4px;
|
| 269 |
+
overflow: hidden;
|
| 270 |
+
margin-top: 10px;
|
| 271 |
+
}
|
| 272 |
+
|
| 273 |
+
.progress-fill {
|
| 274 |
+
height: 100%;
|
| 275 |
+
background: linear-gradient(90deg, #667eea, #764ba2);
|
| 276 |
+
transition: width 0.3s ease;
|
| 277 |
+
}
|
| 278 |
+
</style>
|
| 279 |
+
</head>
|
| 280 |
+
<body>
|
| 281 |
+
<div class="container">
|
| 282 |
+
<div class="header">
|
| 283 |
+
<h1>🤖 Data Dictionary Chatbot</h1>
|
| 284 |
+
<h2>Accuracy Analysis Report</h2>
|
| 285 |
+
<p>Generated on 2026-01-13 23:10:59</p>
|
| 286 |
+
</div>
|
| 287 |
+
|
| 288 |
+
<div class="metrics">
|
| 289 |
+
<div class="metric">
|
| 290 |
+
<div class="metric-label">Total Tests</div>
|
| 291 |
+
<div class="metric-value">20</div>
|
| 292 |
+
</div>
|
| 293 |
+
<div class="metric">
|
| 294 |
+
<div class="metric-label">Passed</div>
|
| 295 |
+
<div class="metric-value" style="color: #22c55e;">2</div>
|
| 296 |
+
</div>
|
| 297 |
+
<div class="metric">
|
| 298 |
+
<div class="metric-label">Failed</div>
|
| 299 |
+
<div class="metric-value" style="color: #ef4444;">18</div>
|
| 300 |
+
</div>
|
| 301 |
+
<div class="metric">
|
| 302 |
+
<div class="metric-label">Average Score</div>
|
| 303 |
+
<div class="metric-value">78.27%</div>
|
| 304 |
+
</div>
|
| 305 |
+
<div class="metric">
|
| 306 |
+
<div class="metric-label">Pass Rate</div>
|
| 307 |
+
<div class="metric-value" style="color: #ef4444;">10.0%</div>
|
| 308 |
+
<div class="progress-bar">
|
| 309 |
+
<div class="progress-fill" style="width: 10.0%"></div>
|
| 310 |
+
</div>
|
| 311 |
+
</div>
|
| 312 |
+
<div class="metric">
|
| 313 |
+
<div class="overall-status">❌ POOR</div>
|
| 314 |
+
</div>
|
| 315 |
+
</div>
|
| 316 |
+
|
| 317 |
+
<div class="content">
|
| 318 |
+
<div class="section">
|
| 319 |
+
<div class="section-title">📊 Summary</div>
|
| 320 |
+
<div class="summary">
|
| 321 |
+
<div class="summary-item">
|
| 322 |
+
<span class="summary-label">Overall Assessment:</span>
|
| 323 |
+
<span class="summary-value">Critical - Major rework required 🚨</span>
|
| 324 |
+
</div>
|
| 325 |
+
<div class="summary-item">
|
| 326 |
+
<span class="summary-label">Success Rate:</span>
|
| 327 |
+
<span class="summary-value">10.0% (2/20)</span>
|
| 328 |
+
</div>
|
| 329 |
+
<div class="summary-item">
|
| 330 |
+
<span class="summary-label">Average Quality Score:</span>
|
| 331 |
+
<span class="summary-value">0.78/1.00</span>
|
| 332 |
+
</div>
|
| 333 |
+
</div>
|
| 334 |
+
</div>
|
| 335 |
+
|
| 336 |
+
<div class="section">
|
| 337 |
+
<div class="section-title">🧪 Test Results</div>
|
| 338 |
+
|
| 339 |
+
<div class="test-result failed">
|
| 340 |
+
<div class="test-header">
|
| 341 |
+
<div>
|
| 342 |
+
<div class="test-name">❌ Diabetes Risk Prediction</div>
|
| 343 |
+
<div class="test-id">CHAT_001</div>
|
| 344 |
+
</div>
|
| 345 |
+
<div class="test-score fair">73%</div>
|
| 346 |
+
</div>
|
| 347 |
+
|
| 348 |
+
<div class="validator-results">
|
| 349 |
+
|
| 350 |
+
<div class="validator failed">
|
| 351 |
+
<div class="validator-name">❌ citation</div>
|
| 352 |
+
<div class="validator-score">Score: 25.00%</div>
|
| 353 |
+
<div class="validator-issues"><ul class="issues-list"><li>Insufficient citations: found 2, expected at least 3</li><li>Expected datasets not cited: SVI_2022, AHRF-2025, EJI_2024</li><li>Citations to unknown datasets: Pima, Pima Indians Diabetes Database</li></ul></div></div>
|
| 354 |
+
<div class="validator passed">
|
| 355 |
+
<div class="validator-name">✅ relevance</div>
|
| 356 |
+
<div class="validator-score">Score: 66.67%</div>
|
| 357 |
+
</div>
|
| 358 |
+
<div class="validator passed">
|
| 359 |
+
<div class="validator-name">✅ format</div>
|
| 360 |
+
<div class="validator-score">Score: 100.00%</div>
|
| 361 |
+
</div>
|
| 362 |
+
<div class="validator passed">
|
| 363 |
+
<div class="validator-name">✅ area_insights</div>
|
| 364 |
+
<div class="validator-score">Score: 100.00%</div>
|
| 365 |
+
</div>
|
| 366 |
+
</div>
|
| 367 |
+
</div>
|
| 368 |
+
|
| 369 |
+
<div class="test-result failed">
|
| 370 |
+
<div class="test-header">
|
| 371 |
+
<div>
|
| 372 |
+
<div class="test-name">❌ Hospital Readmission Prediction</div>
|
| 373 |
+
<div class="test-id">CHAT_002</div>
|
| 374 |
+
</div>
|
| 375 |
+
<div class="test-score good">77%</div>
|
| 376 |
+
</div>
|
| 377 |
+
|
| 378 |
+
<div class="validator-results">
|
| 379 |
+
|
| 380 |
+
<div class="validator failed">
|
| 381 |
+
<div class="validator-name">❌ citation</div>
|
| 382 |
+
<div class="validator-score">Score: 25.00%</div>
|
| 383 |
+
<div class="validator-issues"><ul class="issues-list"><li>Insufficient citations: found 2, expected at least 3</li><li>Expected datasets not cited: AHRF-2025, EJI_2024</li><li>Citations to unknown datasets: Hospital Readmission Data, Hospital</li></ul></div></div>
|
| 384 |
+
<div class="validator passed">
|
| 385 |
+
<div class="validator-name">✅ relevance</div>
|
| 386 |
+
<div class="validator-score">Score: 83.33%</div>
|
| 387 |
+
</div>
|
| 388 |
+
<div class="validator passed">
|
| 389 |
+
<div class="validator-name">✅ format</div>
|
| 390 |
+
<div class="validator-score">Score: 100.00%</div>
|
| 391 |
+
</div>
|
| 392 |
+
<div class="validator passed">
|
| 393 |
+
<div class="validator-name">✅ area_insights</div>
|
| 394 |
+
<div class="validator-score">Score: 100.00%</div>
|
| 395 |
+
</div>
|
| 396 |
+
</div>
|
| 397 |
+
</div>
|
| 398 |
+
|
| 399 |
+
<div class="test-result failed">
|
| 400 |
+
<div class="test-header">
|
| 401 |
+
<div>
|
| 402 |
+
<div class="test-name">❌ Food Insecurity Impact</div>
|
| 403 |
+
<div class="test-id">CHAT_003</div>
|
| 404 |
+
</div>
|
| 405 |
+
<div class="test-score good">79%</div>
|
| 406 |
+
</div>
|
| 407 |
+
|
| 408 |
+
<div class="validator-results">
|
| 409 |
+
|
| 410 |
+
<div class="validator failed">
|
| 411 |
+
<div class="validator-name">❌ citation</div>
|
| 412 |
+
<div class="validator-score">Score: 50.00%</div>
|
| 413 |
+
<div class="validator-issues"><ul class="issues-list"><li>Expected datasets not cited: SVI_2022, EJI_2024</li><li>Citations to unknown datasets: NHANES, BRFSS, National, Behavioral</li></ul></div></div>
|
| 414 |
+
<div class="validator passed">
|
| 415 |
+
<div class="validator-name">✅ relevance</div>
|
| 416 |
+
<div class="validator-score">Score: 66.67%</div>
|
| 417 |
+
</div>
|
| 418 |
+
<div class="validator passed">
|
| 419 |
+
<div class="validator-name">✅ format</div>
|
| 420 |
+
<div class="validator-score">Score: 100.00%</div>
|
| 421 |
+
</div>
|
| 422 |
+
<div class="validator passed">
|
| 423 |
+
<div class="validator-name">✅ area_insights</div>
|
| 424 |
+
<div class="validator-score">Score: 100.00%</div>
|
| 425 |
+
</div>
|
| 426 |
+
</div>
|
| 427 |
+
</div>
|
| 428 |
+
|
| 429 |
+
<div class="test-result failed">
|
| 430 |
+
<div class="test-header">
|
| 431 |
+
<div>
|
| 432 |
+
<div class="test-name">❌ Social Vulnerability Index</div>
|
| 433 |
+
<div class="test-id">CHAT_004</div>
|
| 434 |
+
</div>
|
| 435 |
+
<div class="test-score good">88%</div>
|
| 436 |
+
</div>
|
| 437 |
+
|
| 438 |
+
<div class="validator-results">
|
| 439 |
+
|
| 440 |
+
<div class="validator failed">
|
| 441 |
+
<div class="validator-name">❌ citation</div>
|
| 442 |
+
<div class="validator-score">Score: 50.00%</div>
|
| 443 |
+
<div class="validator-issues"><ul class="issues-list"><li>Expected datasets not cited: SVI_2022</li><li>Citations to unknown datasets: Social Vulnerability Index, Social, 1</li></ul></div></div>
|
| 444 |
+
<div class="validator passed">
|
| 445 |
+
<div class="validator-name">✅ relevance</div>
|
| 446 |
+
<div class="validator-score">Score: 100.00%</div>
|
| 447 |
+
</div>
|
| 448 |
+
<div class="validator passed">
|
| 449 |
+
<div class="validator-name">✅ format</div>
|
| 450 |
+
<div class="validator-score">Score: 100.00%</div>
|
| 451 |
+
</div>
|
| 452 |
+
<div class="validator passed">
|
| 453 |
+
<div class="validator-name">✅ area_insights</div>
|
| 454 |
+
<div class="validator-score">Score: 100.00%</div>
|
| 455 |
+
</div>
|
| 456 |
+
</div>
|
| 457 |
+
</div>
|
| 458 |
+
|
| 459 |
+
<div class="test-result failed">
|
| 460 |
+
<div class="test-header">
|
| 461 |
+
<div>
|
| 462 |
+
<div class="test-name">❌ Environmental Health Indices</div>
|
| 463 |
+
<div class="test-id">CHAT_005</div>
|
| 464 |
+
</div>
|
| 465 |
+
<div class="test-score good">75%</div>
|
| 466 |
+
</div>
|
| 467 |
+
|
| 468 |
+
<div class="validator-results">
|
| 469 |
+
|
| 470 |
+
<div class="validator failed">
|
| 471 |
+
<div class="validator-name">❌ citation</div>
|
| 472 |
+
<div class="validator-score">Score: 50.00%</div>
|
| 473 |
+
<div class="validator-issues"><ul class="issues-list"><li>Expected datasets not cited: EJI_2024</li><li>Citations to unknown datasets: EPA Air Quality Data, NHANES, EPA</li></ul></div></div>
|
| 474 |
+
<div class="validator passed">
|
| 475 |
+
<div class="validator-name">✅ relevance</div>
|
| 476 |
+
<div class="validator-score">Score: 50.00%</div>
|
| 477 |
+
</div>
|
| 478 |
+
<div class="validator passed">
|
| 479 |
+
<div class="validator-name">✅ format</div>
|
| 480 |
+
<div class="validator-score">Score: 100.00%</div>
|
| 481 |
+
</div>
|
| 482 |
+
<div class="validator passed">
|
| 483 |
+
<div class="validator-name">✅ area_insights</div>
|
| 484 |
+
<div class="validator-score">Score: 100.00%</div>
|
| 485 |
+
</div>
|
| 486 |
+
</div>
|
| 487 |
+
</div>
|
| 488 |
+
|
| 489 |
+
<div class="test-result failed">
|
| 490 |
+
<div class="test-header">
|
| 491 |
+
<div>
|
| 492 |
+
<div class="test-name">❌ Healthcare Workforce</div>
|
| 493 |
+
<div class="test-id">CHAT_006</div>
|
| 494 |
+
</div>
|
| 495 |
+
<div class="test-score good">75%</div>
|
| 496 |
+
</div>
|
| 497 |
+
|
| 498 |
+
<div class="validator-results">
|
| 499 |
+
|
| 500 |
+
<div class="validator failed">
|
| 501 |
+
<div class="validator-name">❌ citation</div>
|
| 502 |
+
<div class="validator-score">Score: 50.00%</div>
|
| 503 |
+
<div class="validator-issues"><ul class="issues-list"><li>Expected datasets not cited: AHRF-2025</li><li>Citations to unknown datasets: Workforce, Healthcare, Workforce Metrics Data, Healthcare Provider Availability Data</li></ul></div></div>
|
| 504 |
+
<div class="validator passed">
|
| 505 |
+
<div class="validator-name">✅ relevance</div>
|
| 506 |
+
<div class="validator-score">Score: 50.00%</div>
|
| 507 |
+
</div>
|
| 508 |
+
<div class="validator passed">
|
| 509 |
+
<div class="validator-name">✅ format</div>
|
| 510 |
+
<div class="validator-score">Score: 100.00%</div>
|
| 511 |
+
</div>
|
| 512 |
+
<div class="validator passed">
|
| 513 |
+
<div class="validator-name">✅ area_insights</div>
|
| 514 |
+
<div class="validator-score">Score: 100.00%</div>
|
| 515 |
+
</div>
|
| 516 |
+
</div>
|
| 517 |
+
</div>
|
| 518 |
+
|
| 519 |
+
<div class="test-result failed">
|
| 520 |
+
<div class="test-header">
|
| 521 |
+
<div>
|
| 522 |
+
<div class="test-name">❌ Demographic Information</div>
|
| 523 |
+
<div class="test-id">CHAT_007</div>
|
| 524 |
+
</div>
|
| 525 |
+
<div class="test-score fair">56%</div>
|
| 526 |
+
</div>
|
| 527 |
+
|
| 528 |
+
<div class="validator-results">
|
| 529 |
+
|
| 530 |
+
<div class="validator failed">
|
| 531 |
+
<div class="validator-name">❌ citation</div>
|
| 532 |
+
<div class="validator-score">Score: 50.00%</div>
|
| 533 |
+
<div class="validator-issues"><ul class="issues-list"><li>Insufficient citations: found 0, expected at least 3</li><li>Expected datasets not cited: SVI_2022, AHRF-2025, EJI_2024</li></ul></div></div>
|
| 534 |
+
<div class="validator failed">
|
| 535 |
+
<div class="validator-name">❌ relevance</div>
|
| 536 |
+
<div class="validator-score">Score: 0.00%</div>
|
| 537 |
+
<div class="validator-issues"><ul class="issues-list"><li>Low pattern match: 0/7 expected patterns found</li></ul></div></div>
|
| 538 |
+
<div class="validator passed">
|
| 539 |
+
<div class="validator-name">✅ format</div>
|
| 540 |
+
<div class="validator-score">Score: 75.00%</div>
|
| 541 |
+
</div>
|
| 542 |
+
<div class="validator passed">
|
| 543 |
+
<div class="validator-name">✅ area_insights</div>
|
| 544 |
+
<div class="validator-score">Score: 100.00%</div>
|
| 545 |
+
</div>
|
| 546 |
+
</div>
|
| 547 |
+
</div>
|
| 548 |
+
|
| 549 |
+
<div class="test-result failed">
|
| 550 |
+
<div class="test-header">
|
| 551 |
+
<div>
|
| 552 |
+
<div class="test-name">❌ Mental Health Indicators</div>
|
| 553 |
+
<div class="test-id">CHAT_008</div>
|
| 554 |
+
</div>
|
| 555 |
+
<div class="test-score good">75%</div>
|
| 556 |
+
</div>
|
| 557 |
+
|
| 558 |
+
<div class="validator-results">
|
| 559 |
+
|
| 560 |
+
<div class="validator failed">
|
| 561 |
+
<div class="validator-name">❌ citation</div>
|
| 562 |
+
<div class="validator-score">Score: 50.00%</div>
|
| 563 |
+
<div class="validator-issues"><ul class="issues-list"><li>Expected datasets not cited: AHRF-2025, EJI_2024</li><li>Citations to unknown datasets: BRFSS, YRBSS, NSDUH</li></ul></div></div>
|
| 564 |
+
<div class="validator passed">
|
| 565 |
+
<div class="validator-name">✅ relevance</div>
|
| 566 |
+
<div class="validator-score">Score: 50.00%</div>
|
| 567 |
+
</div>
|
| 568 |
+
<div class="validator passed">
|
| 569 |
+
<div class="validator-name">✅ format</div>
|
| 570 |
+
<div class="validator-score">Score: 100.00%</div>
|
| 571 |
+
</div>
|
| 572 |
+
<div class="validator passed">
|
| 573 |
+
<div class="validator-name">✅ area_insights</div>
|
| 574 |
+
<div class="validator-score">Score: 100.00%</div>
|
| 575 |
+
</div>
|
| 576 |
+
</div>
|
| 577 |
+
</div>
|
| 578 |
+
|
| 579 |
+
<div class="test-result passed">
|
| 580 |
+
<div class="test-header">
|
| 581 |
+
<div>
|
| 582 |
+
<div class="test-name">✅ Follow-up Question - Deep Dive</div>
|
| 583 |
+
<div class="test-id">CHAT_009</div>
|
| 584 |
+
</div>
|
| 585 |
+
<div class="test-score good">88%</div>
|
| 586 |
+
</div>
|
| 587 |
+
|
| 588 |
+
<div class="validator-results">
|
| 589 |
+
|
| 590 |
+
<div class="validator passed">
|
| 591 |
+
<div class="validator-name">✅ citation</div>
|
| 592 |
+
<div class="validator-score">Score: 100.00%</div>
|
| 593 |
+
</div>
|
| 594 |
+
<div class="validator passed">
|
| 595 |
+
<div class="validator-name">✅ relevance</div>
|
| 596 |
+
<div class="validator-score">Score: 50.00%</div>
|
| 597 |
+
</div>
|
| 598 |
+
<div class="validator passed">
|
| 599 |
+
<div class="validator-name">✅ format</div>
|
| 600 |
+
<div class="validator-score">Score: 100.00%</div>
|
| 601 |
+
</div>
|
| 602 |
+
<div class="validator passed">
|
| 603 |
+
<div class="validator-name">✅ area_insights</div>
|
| 604 |
+
<div class="validator-score">Score: 100.00%</div>
|
| 605 |
+
</div>
|
| 606 |
+
</div>
|
| 607 |
+
</div>
|
| 608 |
+
|
| 609 |
+
<div class="test-result failed">
|
| 610 |
+
<div class="test-header">
|
| 611 |
+
<div>
|
| 612 |
+
<div class="test-name">❌ Clarification Question</div>
|
| 613 |
+
<div class="test-id">CHAT_010</div>
|
| 614 |
+
</div>
|
| 615 |
+
<div class="test-score fair">62%</div>
|
| 616 |
+
</div>
|
| 617 |
+
|
| 618 |
+
<div class="validator-results">
|
| 619 |
+
|
| 620 |
+
<div class="validator failed">
|
| 621 |
+
<div class="validator-name">❌ citation</div>
|
| 622 |
+
<div class="validator-score">Score: 50.00%</div>
|
| 623 |
+
<div class="validator-issues"><ul class="issues-list"><li>Insufficient citations: found 0, expected at least 1</li><li>Expected datasets not cited: AHRF-2025, EJI_2024</li></ul></div></div>
|
| 624 |
+
<div class="validator failed">
|
| 625 |
+
<div class="validator-name">❌ relevance</div>
|
| 626 |
+
<div class="validator-score">Score: 25.00%</div>
|
| 627 |
+
<div class="validator-issues"><ul class="issues-list"><li>Low pattern match: 1/4 expected patterns found</li></ul></div></div>
|
| 628 |
+
<div class="validator passed">
|
| 629 |
+
<div class="validator-name">✅ format</div>
|
| 630 |
+
<div class="validator-score">Score: 75.00%</div>
|
| 631 |
+
</div>
|
| 632 |
+
<div class="validator passed">
|
| 633 |
+
<div class="validator-name">✅ area_insights</div>
|
| 634 |
+
<div class="validator-score">Score: 100.00%</div>
|
| 635 |
+
</div>
|
| 636 |
+
</div>
|
| 637 |
+
</div>
|
| 638 |
+
|
| 639 |
+
<div class="test-result failed">
|
| 640 |
+
<div class="test-header">
|
| 641 |
+
<div>
|
| 642 |
+
<div class="test-name">❌ Chronic Disease Burden</div>
|
| 643 |
+
<div class="test-id">CHAT_011</div>
|
| 644 |
+
</div>
|
| 645 |
+
<div class="test-score good">78%</div>
|
| 646 |
+
</div>
|
| 647 |
+
|
| 648 |
+
<div class="validator-results">
|
| 649 |
+
|
| 650 |
+
<div class="validator failed">
|
| 651 |
+
<div class="validator-name">❌ citation</div>
|
| 652 |
+
<div class="validator-score">Score: 50.00%</div>
|
| 653 |
+
<div class="validator-issues"><ul class="issues-list"><li>Expected datasets not cited: AHRF-2025, EJI_2024</li><li>Citations to unknown datasets: BRFSS, NHIS</li></ul></div></div>
|
| 654 |
+
<div class="validator passed">
|
| 655 |
+
<div class="validator-name">✅ relevance</div>
|
| 656 |
+
<div class="validator-score">Score: 60.00%</div>
|
| 657 |
+
</div>
|
| 658 |
+
<div class="validator passed">
|
| 659 |
+
<div class="validator-name">✅ format</div>
|
| 660 |
+
<div class="validator-score">Score: 100.00%</div>
|
| 661 |
+
</div>
|
| 662 |
+
<div class="validator passed">
|
| 663 |
+
<div class="validator-name">✅ area_insights</div>
|
| 664 |
+
<div class="validator-score">Score: 100.00%</div>
|
| 665 |
+
</div>
|
| 666 |
+
</div>
|
| 667 |
+
</div>
|
| 668 |
+
|
| 669 |
+
<div class="test-result failed">
|
| 670 |
+
<div class="test-header">
|
| 671 |
+
<div>
|
| 672 |
+
<div class="test-name">❌ Access to Care</div>
|
| 673 |
+
<div class="test-id">CHAT_012</div>
|
| 674 |
+
</div>
|
| 675 |
+
<div class="test-score good">82%</div>
|
| 676 |
+
</div>
|
| 677 |
+
|
| 678 |
+
<div class="validator-results">
|
| 679 |
+
|
| 680 |
+
<div class="validator failed">
|
| 681 |
+
<div class="validator-name">❌ citation</div>
|
| 682 |
+
<div class="validator-score">Score: 50.00%</div>
|
| 683 |
+
<div class="validator-issues"><ul class="issues-list"><li>Expected datasets not cited: AHRF-2025</li><li>Citations to unknown datasets: BRFSS, NHIS, HCUP</li></ul></div></div>
|
| 684 |
+
<div class="validator passed">
|
| 685 |
+
<div class="validator-name">✅ relevance</div>
|
| 686 |
+
<div class="validator-score">Score: 80.00%</div>
|
| 687 |
+
</div>
|
| 688 |
+
<div class="validator passed">
|
| 689 |
+
<div class="validator-name">✅ format</div>
|
| 690 |
+
<div class="validator-score">Score: 100.00%</div>
|
| 691 |
+
</div>
|
| 692 |
+
<div class="validator passed">
|
| 693 |
+
<div class="validator-name">✅ area_insights</div>
|
| 694 |
+
<div class="validator-score">Score: 100.00%</div>
|
| 695 |
+
</div>
|
| 696 |
+
</div>
|
| 697 |
+
</div>
|
| 698 |
+
|
| 699 |
+
<div class="test-result failed">
|
| 700 |
+
<div class="test-header">
|
| 701 |
+
<div>
|
| 702 |
+
<div class="test-name">❌ Economic Factors</div>
|
| 703 |
+
<div class="test-id">CHAT_013</div>
|
| 704 |
+
</div>
|
| 705 |
+
<div class="test-score good">82%</div>
|
| 706 |
+
</div>
|
| 707 |
+
|
| 708 |
+
<div class="validator-results">
|
| 709 |
+
|
| 710 |
+
<div class="validator failed">
|
| 711 |
+
<div class="validator-name">❌ citation</div>
|
| 712 |
+
<div class="validator-score">Score: 50.00%</div>
|
| 713 |
+
<div class="validator-issues"><ul class="issues-list"><li>Expected datasets not cited: SVI_2022, AHRF-2025, EJI_2024</li><li>Citations to unknown datasets: American Community Survey, World Development Indicators, American, World, U</li></ul></div></div>
|
| 714 |
+
<div class="validator passed">
|
| 715 |
+
<div class="validator-name">✅ relevance</div>
|
| 716 |
+
<div class="validator-score">Score: 80.00%</div>
|
| 717 |
+
</div>
|
| 718 |
+
<div class="validator passed">
|
| 719 |
+
<div class="validator-name">✅ format</div>
|
| 720 |
+
<div class="validator-score">Score: 100.00%</div>
|
| 721 |
+
</div>
|
| 722 |
+
<div class="validator passed">
|
| 723 |
+
<div class="validator-name">✅ area_insights</div>
|
| 724 |
+
<div class="validator-score">Score: 100.00%</div>
|
| 725 |
+
</div>
|
| 726 |
+
</div>
|
| 727 |
+
</div>
|
| 728 |
+
|
| 729 |
+
<div class="test-result failed">
|
| 730 |
+
<div class="test-header">
|
| 731 |
+
<div>
|
| 732 |
+
<div class="test-name">❌ Housing and Living Conditions</div>
|
| 733 |
+
<div class="test-id">CHAT_014</div>
|
| 734 |
+
</div>
|
| 735 |
+
<div class="test-score good">82%</div>
|
| 736 |
+
</div>
|
| 737 |
+
|
| 738 |
+
<div class="validator-results">
|
| 739 |
+
|
| 740 |
+
<div class="validator failed">
|
| 741 |
+
<div class="validator-name">❌ citation</div>
|
| 742 |
+
<div class="validator-score">Score: 50.00%</div>
|
| 743 |
+
<div class="validator-issues"><ul class="issues-list"><li>Expected datasets not cited: SVI_2022, EJI_2024</li><li>Citations to unknown datasets: National Health Interview Survey, National, American Community Survey, American</li></ul></div></div>
|
| 744 |
+
<div class="validator passed">
|
| 745 |
+
<div class="validator-name">✅ relevance</div>
|
| 746 |
+
<div class="validator-score">Score: 80.00%</div>
|
| 747 |
+
</div>
|
| 748 |
+
<div class="validator passed">
|
| 749 |
+
<div class="validator-name">✅ format</div>
|
| 750 |
+
<div class="validator-score">Score: 100.00%</div>
|
| 751 |
+
</div>
|
| 752 |
+
<div class="validator passed">
|
| 753 |
+
<div class="validator-name">✅ area_insights</div>
|
| 754 |
+
<div class="validator-score">Score: 100.00%</div>
|
| 755 |
+
</div>
|
| 756 |
+
</div>
|
| 757 |
+
</div>
|
| 758 |
+
|
| 759 |
+
<div class="test-result passed">
|
| 760 |
+
<div class="test-header">
|
| 761 |
+
<div>
|
| 762 |
+
<div class="test-name">✅ Greetings (No Retrieval Expected)</div>
|
| 763 |
+
<div class="test-id">CHAT_015</div>
|
| 764 |
+
</div>
|
| 765 |
+
<div class="test-score excellent">94%</div>
|
| 766 |
+
</div>
|
| 767 |
+
|
| 768 |
+
<div class="validator-results">
|
| 769 |
+
|
| 770 |
+
<div class="validator passed">
|
| 771 |
+
<div class="validator-name">✅ citation</div>
|
| 772 |
+
<div class="validator-score">Score: 100.00%</div>
|
| 773 |
+
</div>
|
| 774 |
+
<div class="validator passed">
|
| 775 |
+
<div class="validator-name">✅ relevance</div>
|
| 776 |
+
<div class="validator-score">Score: 100.00%</div>
|
| 777 |
+
</div>
|
| 778 |
+
<div class="validator passed">
|
| 779 |
+
<div class="validator-name">✅ format</div>
|
| 780 |
+
<div class="validator-score">Score: 75.00%</div>
|
| 781 |
+
</div>
|
| 782 |
+
<div class="validator passed">
|
| 783 |
+
<div class="validator-name">✅ area_insights</div>
|
| 784 |
+
<div class="validator-score">Score: 100.00%</div>
|
| 785 |
+
</div>
|
| 786 |
+
</div>
|
| 787 |
+
</div>
|
| 788 |
+
|
| 789 |
+
<div class="test-result failed">
|
| 790 |
+
<div class="test-header">
|
| 791 |
+
<div>
|
| 792 |
+
<div class="test-name">❌ NYC Area Insights</div>
|
| 793 |
+
<div class="test-id">AREA_001</div>
|
| 794 |
+
</div>
|
| 795 |
+
<div class="test-score good">80%</div>
|
| 796 |
+
</div>
|
| 797 |
+
|
| 798 |
+
<div class="validator-results">
|
| 799 |
+
|
| 800 |
+
<div class="validator failed">
|
| 801 |
+
<div class="validator-name">❌ citation</div>
|
| 802 |
+
<div class="validator-score">Score: 50.00%</div>
|
| 803 |
+
<div class="validator-issues"><ul class="issues-list"><li>Expected datasets not cited: SVI_2022, AHRF-2025, EJI_2024</li><li>Citations to unknown datasets: Health Resources and Services Administration, Available for: 10001, New York, NY, New York State Office of Mental Health, Available for: New York State, American Community Survey, Available for: 10001, New York, NY, American, New York State Department of Health, Available for: New York State, New York City Community Health Survey, Available for: 10001, New York, NY, Health, New York City Department of Health and Mental Hygiene, Available for: 10001, New York, NY, New</li></ul></div></div>
|
| 804 |
+
<div class="validator passed">
|
| 805 |
+
<div class="validator-name">✅ relevance</div>
|
| 806 |
+
<div class="validator-score">Score: 100.00%</div>
|
| 807 |
+
</div>
|
| 808 |
+
<div class="validator passed">
|
| 809 |
+
<div class="validator-name">✅ format</div>
|
| 810 |
+
<div class="validator-score">Score: 100.00%</div>
|
| 811 |
+
</div>
|
| 812 |
+
<div class="validator failed">
|
| 813 |
+
<div class="validator-name">❌ area_insights</div>
|
| 814 |
+
<div class="validator-score">Score: 70.00%</div>
|
| 815 |
+
<div class="validator-issues"><ul class="issues-list"><li>Response does not mention expected datasets</li></ul></div></div>
|
| 816 |
+
</div>
|
| 817 |
+
</div>
|
| 818 |
+
|
| 819 |
+
<div class="test-result failed">
|
| 820 |
+
<div class="test-header">
|
| 821 |
+
<div>
|
| 822 |
+
<div class="test-name">❌ Atlanta Area Insights</div>
|
| 823 |
+
<div class="test-id">AREA_002</div>
|
| 824 |
+
</div>
|
| 825 |
+
<div class="test-score good">80%</div>
|
| 826 |
+
</div>
|
| 827 |
+
|
| 828 |
+
<div class="validator-results">
|
| 829 |
+
|
| 830 |
+
<div class="validator failed">
|
| 831 |
+
<div class="validator-name">❌ citation</div>
|
| 832 |
+
<div class="validator-score">Score: 50.00%</div>
|
| 833 |
+
<div class="validator-issues"><ul class="issues-list"><li>Expected datasets not cited: SVI_2022, AHRF-2025, EJI_2024</li><li>Citations to unknown datasets: Healthcare Cost and Utilization Project (HCUP, COVID-19, American, Behavioral, Healthcare, Behavioral Risk Factor Surveillance System (BRFSS, American Community Survey (ACS, COVID-19 Data Repository by the Center for Systems Science and Engineering (CSSE</li></ul></div></div>
|
| 834 |
+
<div class="validator passed">
|
| 835 |
+
<div class="validator-name">✅ relevance</div>
|
| 836 |
+
<div class="validator-score">Score: 100.00%</div>
|
| 837 |
+
</div>
|
| 838 |
+
<div class="validator passed">
|
| 839 |
+
<div class="validator-name">✅ format</div>
|
| 840 |
+
<div class="validator-score">Score: 100.00%</div>
|
| 841 |
+
</div>
|
| 842 |
+
<div class="validator failed">
|
| 843 |
+
<div class="validator-name">❌ area_insights</div>
|
| 844 |
+
<div class="validator-score">Score: 70.00%</div>
|
| 845 |
+
<div class="validator-issues"><ul class="issues-list"><li>Response does not mention expected datasets</li></ul></div></div>
|
| 846 |
+
</div>
|
| 847 |
+
</div>
|
| 848 |
+
|
| 849 |
+
<div class="test-result failed">
|
| 850 |
+
<div class="test-header">
|
| 851 |
+
<div>
|
| 852 |
+
<div class="test-name">❌ San Francisco Area Insights</div>
|
| 853 |
+
<div class="test-id">AREA_003</div>
|
| 854 |
+
</div>
|
| 855 |
+
<div class="test-score good">80%</div>
|
| 856 |
+
</div>
|
| 857 |
+
|
| 858 |
+
<div class="validator-results">
|
| 859 |
+
|
| 860 |
+
<div class="validator failed">
|
| 861 |
+
<div class="validator-name">❌ citation</div>
|
| 862 |
+
<div class="validator-score">Score: 50.00%</div>
|
| 863 |
+
<div class="validator-issues"><ul class="issues-list"><li>Expected datasets not cited: EJI_2024</li><li>Citations to unknown datasets: National, Urban Green Space Data, Available for: San Francisco, CA, Lead, Climate, Air, Climate Adaptation Planning Data, Available for: San Francisco, CA, Lead Exposure Risk Maps, Available for: San Francisco, CA, Urban, National Water Quality Assessment Program, Available for: United States, Water Quality Monitoring Data, Available for: San Francisco, CA, Water, National Air Quality Monitoring Data, Available for: California, Air Quality Monitoring Data, Available for: San Francisco, CA</li></ul></div></div>
|
| 864 |
+
<div class="validator passed">
|
| 865 |
+
<div class="validator-name">✅ relevance</div>
|
| 866 |
+
<div class="validator-score">Score: 100.00%</div>
|
| 867 |
+
</div>
|
| 868 |
+
<div class="validator passed">
|
| 869 |
+
<div class="validator-name">✅ format</div>
|
| 870 |
+
<div class="validator-score">Score: 100.00%</div>
|
| 871 |
+
</div>
|
| 872 |
+
<div class="validator failed">
|
| 873 |
+
<div class="validator-name">❌ area_insights</div>
|
| 874 |
+
<div class="validator-score">Score: 70.00%</div>
|
| 875 |
+
<div class="validator-issues"><ul class="issues-list"><li>Response does not mention expected datasets</li></ul></div></div>
|
| 876 |
+
</div>
|
| 877 |
+
</div>
|
| 878 |
+
|
| 879 |
+
<div class="test-result failed">
|
| 880 |
+
<div class="test-header">
|
| 881 |
+
<div>
|
| 882 |
+
<div class="test-name">❌ Multiple ZIP Lookup</div>
|
| 883 |
+
<div class="test-id">AREA_004</div>
|
| 884 |
+
</div>
|
| 885 |
+
<div class="test-score fair">72%</div>
|
| 886 |
+
</div>
|
| 887 |
+
|
| 888 |
+
<div class="validator-results">
|
| 889 |
+
|
| 890 |
+
<div class="validator failed">
|
| 891 |
+
<div class="validator-name">❌ citation</div>
|
| 892 |
+
<div class="validator-score">Score: 50.00%</div>
|
| 893 |
+
<div class="validator-issues"><ul class="issues-list"><li>Expected datasets not cited: SVI_2022, AHRF-2025, EJI_2024</li><li>Citations to unknown datasets: Centers for Disease Control and Prevention, Available for: New York State, Centers, Robert, American, Healthcare Cost and Utilization Project, Available for: 30301, Atlanta, GA, Behavioral Risk Factor Surveillance System, Available for: 30301, Atlanta, GA, Behavioral, Healthcare, U.S. Census Bureau, Available for: 10001, New York, NY, American Hospital Association, Available for: 10001, New York, NY, Robert Wood Johnson Foundation, Available for: Georgia, U</li></ul></div></div>
|
| 894 |
+
<div class="validator passed">
|
| 895 |
+
<div class="validator-name">✅ relevance</div>
|
| 896 |
+
<div class="validator-score">Score: 100.00%</div>
|
| 897 |
+
</div>
|
| 898 |
+
<div class="validator passed">
|
| 899 |
+
<div class="validator-name">✅ format</div>
|
| 900 |
+
<div class="validator-score">Score: 100.00%</div>
|
| 901 |
+
</div>
|
| 902 |
+
<div class="validator failed">
|
| 903 |
+
<div class="validator-name">❌ area_insights</div>
|
| 904 |
+
<div class="validator-score">Score: 40.00%</div>
|
| 905 |
+
<div class="validator-issues"><ul class="issues-list"><li>Response does not mention expected datasets</li></ul></div></div>
|
| 906 |
+
</div>
|
| 907 |
+
</div>
|
| 908 |
+
|
| 909 |
+
<div class="test-result failed">
|
| 910 |
+
<div class="test-header">
|
| 911 |
+
<div>
|
| 912 |
+
<div class="test-name">❌ Invalid ZIP Fallback</div>
|
| 913 |
+
<div class="test-id">AREA_005</div>
|
| 914 |
+
</div>
|
| 915 |
+
<div class="test-score good">86%</div>
|
| 916 |
+
</div>
|
| 917 |
+
|
| 918 |
+
<div class="validator-results">
|
| 919 |
+
|
| 920 |
+
<div class="validator failed">
|
| 921 |
+
<div class="validator-name">❌ citation</div>
|
| 922 |
+
<div class="validator-score">Score: 75.00%</div>
|
| 923 |
+
<div class="validator-issues"><ul class="issues-list"><li>Citations to unknown datasets: Centers for Disease Control and Prevention, Available for: Statewide, State, Health Resources and Services Administration, Available for: Statewide, State, Centers, Behavioral, Behavioral Risk Factor Surveillance System, Available for: Statewide, State, Health</li></ul></div></div>
|
| 924 |
+
<div class="validator passed">
|
| 925 |
+
<div class="validator-name">✅ relevance</div>
|
| 926 |
+
<div class="validator-score">Score: 100.00%</div>
|
| 927 |
+
</div>
|
| 928 |
+
<div class="validator passed">
|
| 929 |
+
<div class="validator-name">✅ format</div>
|
| 930 |
+
<div class="validator-score">Score: 100.00%</div>
|
| 931 |
+
</div>
|
| 932 |
+
<div class="validator passed">
|
| 933 |
+
<div class="validator-name">✅ area_insights</div>
|
| 934 |
+
<div class="validator-score">Score: 70.00%</div>
|
| 935 |
+
</div>
|
| 936 |
+
</div>
|
| 937 |
+
</div>
|
| 938 |
+
|
| 939 |
+
</div>
|
| 940 |
+
</div>
|
| 941 |
+
|
| 942 |
+
<div class="footer">
|
| 943 |
+
<p>Generated by Data Dictionary Chatbot Testing Framework</p>
|
| 944 |
+
<p>For detailed test case information, refer to test_cases.json</p>
|
| 945 |
+
</div>
|
| 946 |
+
</div>
|
| 947 |
+
</body>
|
| 948 |
+
</html>
|
tests/test_reports/accuracy_report_20260113_231059.md
ADDED
|
@@ -0,0 +1,290 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Data Dictionary Chatbot - Accuracy Report
|
| 2 |
+
|
| 3 |
+
**Generated:** 2026-01-13 23:10:59
|
| 4 |
+
|
| 5 |
+
❌ **Overall Status:** Critical - Major rework required 🚨
|
| 6 |
+
|
| 7 |
+
---
|
| 8 |
+
|
| 9 |
+
## Summary Metrics
|
| 10 |
+
|
| 11 |
+
| Metric | Value |
|
| 12 |
+
|--------|-------|
|
| 13 |
+
| **Total Tests** | 20 |
|
| 14 |
+
| **Passed** | 2 ✅ |
|
| 15 |
+
| **Failed** | 18 ❌ |
|
| 16 |
+
| **Average Score** | 78.27% |
|
| 17 |
+
| **Pass Rate** | 10.0% |
|
| 18 |
+
|
| 19 |
+
---
|
| 20 |
+
|
| 21 |
+
## Key Findings
|
| 22 |
+
|
| 23 |
+
### Strengths
|
| 24 |
+
- **Format**: 20/20 tests passed (100%)
|
| 25 |
+
- **Relevance**: 18/20 tests passed (90%)
|
| 26 |
+
- **Area_Insights**: 16/20 tests passed (80%)
|
| 27 |
+
- **Citation**: 2/20 tests passed (10%)
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
---
|
| 31 |
+
|
| 32 |
+
## Detailed Test Results
|
| 33 |
+
|
| 34 |
+
### Diabetes Risk Prediction (CHAT_001)
|
| 35 |
+
- **Status:** ❌ FAILED
|
| 36 |
+
- **Overall Score:** 72.92%
|
| 37 |
+
|
| 38 |
+
**Validations:**
|
| 39 |
+
- ❌ **Citation**: 25.00%
|
| 40 |
+
- ⚠️ Insufficient citations: found 2, expected at least 3
|
| 41 |
+
- ⚠️ Expected datasets not cited: SVI_2022, AHRF-2025, EJI_2024
|
| 42 |
+
- ⚠️ Citations to unknown datasets: Pima, Pima Indians Diabetes Database
|
| 43 |
+
- ✅ **Relevance**: 66.67%
|
| 44 |
+
- ✅ **Format**: 100.00%
|
| 45 |
+
- ✅ **Area_Insights**: 100.00%
|
| 46 |
+
|
| 47 |
+
### Hospital Readmission Prediction (CHAT_002)
|
| 48 |
+
- **Status:** ❌ FAILED
|
| 49 |
+
- **Overall Score:** 77.08%
|
| 50 |
+
|
| 51 |
+
**Validations:**
|
| 52 |
+
- ❌ **Citation**: 25.00%
|
| 53 |
+
- ⚠️ Insufficient citations: found 2, expected at least 3
|
| 54 |
+
- ⚠️ Expected datasets not cited: AHRF-2025, EJI_2024
|
| 55 |
+
- ⚠️ Citations to unknown datasets: Hospital Readmission Data, Hospital
|
| 56 |
+
- ✅ **Relevance**: 83.33%
|
| 57 |
+
- ✅ **Format**: 100.00%
|
| 58 |
+
- ✅ **Area_Insights**: 100.00%
|
| 59 |
+
|
| 60 |
+
### Food Insecurity Impact (CHAT_003)
|
| 61 |
+
- **Status:** ❌ FAILED
|
| 62 |
+
- **Overall Score:** 79.17%
|
| 63 |
+
|
| 64 |
+
**Validations:**
|
| 65 |
+
- ❌ **Citation**: 50.00%
|
| 66 |
+
- ⚠️ Expected datasets not cited: SVI_2022, EJI_2024
|
| 67 |
+
- ⚠️ Citations to unknown datasets: NHANES, BRFSS, National, Behavioral
|
| 68 |
+
- ✅ **Relevance**: 66.67%
|
| 69 |
+
- ✅ **Format**: 100.00%
|
| 70 |
+
- ✅ **Area_Insights**: 100.00%
|
| 71 |
+
|
| 72 |
+
### Social Vulnerability Index (CHAT_004)
|
| 73 |
+
- **Status:** ❌ FAILED
|
| 74 |
+
- **Overall Score:** 87.50%
|
| 75 |
+
|
| 76 |
+
**Validations:**
|
| 77 |
+
- ❌ **Citation**: 50.00%
|
| 78 |
+
- ⚠️ Expected datasets not cited: SVI_2022
|
| 79 |
+
- ⚠️ Citations to unknown datasets: Social Vulnerability Index, Social, 1
|
| 80 |
+
- ✅ **Relevance**: 100.00%
|
| 81 |
+
- ✅ **Format**: 100.00%
|
| 82 |
+
- ✅ **Area_Insights**: 100.00%
|
| 83 |
+
|
| 84 |
+
### Environmental Health Indices (CHAT_005)
|
| 85 |
+
- **Status:** ❌ FAILED
|
| 86 |
+
- **Overall Score:** 75.00%
|
| 87 |
+
|
| 88 |
+
**Validations:**
|
| 89 |
+
- ❌ **Citation**: 50.00%
|
| 90 |
+
- ⚠️ Expected datasets not cited: EJI_2024
|
| 91 |
+
- ⚠️ Citations to unknown datasets: EPA Air Quality Data, NHANES, EPA
|
| 92 |
+
- ✅ **Relevance**: 50.00%
|
| 93 |
+
- ✅ **Format**: 100.00%
|
| 94 |
+
- ✅ **Area_Insights**: 100.00%
|
| 95 |
+
|
| 96 |
+
### Healthcare Workforce (CHAT_006)
|
| 97 |
+
- **Status:** ❌ FAILED
|
| 98 |
+
- **Overall Score:** 75.00%
|
| 99 |
+
|
| 100 |
+
**Validations:**
|
| 101 |
+
- ❌ **Citation**: 50.00%
|
| 102 |
+
- ⚠️ Expected datasets not cited: AHRF-2025
|
| 103 |
+
- ⚠️ Citations to unknown datasets: Workforce, Healthcare, Workforce Metrics Data, Healthcare Provider Availability Data
|
| 104 |
+
- ✅ **Relevance**: 50.00%
|
| 105 |
+
- ✅ **Format**: 100.00%
|
| 106 |
+
- ✅ **Area_Insights**: 100.00%
|
| 107 |
+
|
| 108 |
+
### Demographic Information (CHAT_007)
|
| 109 |
+
- **Status:** ❌ FAILED
|
| 110 |
+
- **Overall Score:** 56.25%
|
| 111 |
+
|
| 112 |
+
**Validations:**
|
| 113 |
+
- ❌ **Citation**: 50.00%
|
| 114 |
+
- ⚠️ Insufficient citations: found 0, expected at least 3
|
| 115 |
+
- ⚠️ Expected datasets not cited: SVI_2022, AHRF-2025, EJI_2024
|
| 116 |
+
- ❌ **Relevance**: 0.00%
|
| 117 |
+
- ⚠️ Low pattern match: 0/7 expected patterns found
|
| 118 |
+
- ✅ **Format**: 75.00%
|
| 119 |
+
- ✅ **Area_Insights**: 100.00%
|
| 120 |
+
|
| 121 |
+
### Mental Health Indicators (CHAT_008)
|
| 122 |
+
- **Status:** ❌ FAILED
|
| 123 |
+
- **Overall Score:** 75.00%
|
| 124 |
+
|
| 125 |
+
**Validations:**
|
| 126 |
+
- ❌ **Citation**: 50.00%
|
| 127 |
+
- ⚠️ Expected datasets not cited: AHRF-2025, EJI_2024
|
| 128 |
+
- ⚠️ Citations to unknown datasets: BRFSS, YRBSS, NSDUH
|
| 129 |
+
- ✅ **Relevance**: 50.00%
|
| 130 |
+
- ✅ **Format**: 100.00%
|
| 131 |
+
- ✅ **Area_Insights**: 100.00%
|
| 132 |
+
|
| 133 |
+
### Follow-up Question - Deep Dive (CHAT_009)
|
| 134 |
+
- **Status:** ✅ PASSED
|
| 135 |
+
- **Overall Score:** 87.50%
|
| 136 |
+
|
| 137 |
+
**Validations:**
|
| 138 |
+
- ✅ **Citation**: 100.00%
|
| 139 |
+
- ✅ **Relevance**: 50.00%
|
| 140 |
+
- ✅ **Format**: 100.00%
|
| 141 |
+
- ✅ **Area_Insights**: 100.00%
|
| 142 |
+
|
| 143 |
+
### Clarification Question (CHAT_010)
|
| 144 |
+
- **Status:** ❌ FAILED
|
| 145 |
+
- **Overall Score:** 62.50%
|
| 146 |
+
|
| 147 |
+
**Validations:**
|
| 148 |
+
- ❌ **Citation**: 50.00%
|
| 149 |
+
- ⚠️ Insufficient citations: found 0, expected at least 1
|
| 150 |
+
- ⚠️ Expected datasets not cited: AHRF-2025, EJI_2024
|
| 151 |
+
- ❌ **Relevance**: 25.00%
|
| 152 |
+
- ⚠️ Low pattern match: 1/4 expected patterns found
|
| 153 |
+
- ✅ **Format**: 75.00%
|
| 154 |
+
- ✅ **Area_Insights**: 100.00%
|
| 155 |
+
|
| 156 |
+
### Chronic Disease Burden (CHAT_011)
|
| 157 |
+
- **Status:** ❌ FAILED
|
| 158 |
+
- **Overall Score:** 77.50%
|
| 159 |
+
|
| 160 |
+
**Validations:**
|
| 161 |
+
- ❌ **Citation**: 50.00%
|
| 162 |
+
- ⚠️ Expected datasets not cited: AHRF-2025, EJI_2024
|
| 163 |
+
- ⚠️ Citations to unknown datasets: BRFSS, NHIS
|
| 164 |
+
- ✅ **Relevance**: 60.00%
|
| 165 |
+
- ✅ **Format**: 100.00%
|
| 166 |
+
- ✅ **Area_Insights**: 100.00%
|
| 167 |
+
|
| 168 |
+
### Access to Care (CHAT_012)
|
| 169 |
+
- **Status:** ❌ FAILED
|
| 170 |
+
- **Overall Score:** 82.50%
|
| 171 |
+
|
| 172 |
+
**Validations:**
|
| 173 |
+
- ❌ **Citation**: 50.00%
|
| 174 |
+
- ⚠️ Expected datasets not cited: AHRF-2025
|
| 175 |
+
- ⚠️ Citations to unknown datasets: BRFSS, NHIS, HCUP
|
| 176 |
+
- ✅ **Relevance**: 80.00%
|
| 177 |
+
- ✅ **Format**: 100.00%
|
| 178 |
+
- ✅ **Area_Insights**: 100.00%
|
| 179 |
+
|
| 180 |
+
### Economic Factors (CHAT_013)
|
| 181 |
+
- **Status:** ❌ FAILED
|
| 182 |
+
- **Overall Score:** 82.50%
|
| 183 |
+
|
| 184 |
+
**Validations:**
|
| 185 |
+
- ❌ **Citation**: 50.00%
|
| 186 |
+
- ⚠️ Expected datasets not cited: SVI_2022, AHRF-2025, EJI_2024
|
| 187 |
+
- ⚠️ Citations to unknown datasets: American Community Survey, World Development Indicators, American, World, U
|
| 188 |
+
- ✅ **Relevance**: 80.00%
|
| 189 |
+
- ✅ **Format**: 100.00%
|
| 190 |
+
- ✅ **Area_Insights**: 100.00%
|
| 191 |
+
|
| 192 |
+
### Housing and Living Conditions (CHAT_014)
|
| 193 |
+
- **Status:** ❌ FAILED
|
| 194 |
+
- **Overall Score:** 82.50%
|
| 195 |
+
|
| 196 |
+
**Validations:**
|
| 197 |
+
- ❌ **Citation**: 50.00%
|
| 198 |
+
- ⚠️ Expected datasets not cited: SVI_2022, EJI_2024
|
| 199 |
+
- ⚠️ Citations to unknown datasets: National Health Interview Survey, National, American Community Survey, American
|
| 200 |
+
- ✅ **Relevance**: 80.00%
|
| 201 |
+
- ✅ **Format**: 100.00%
|
| 202 |
+
- ✅ **Area_Insights**: 100.00%
|
| 203 |
+
|
| 204 |
+
### Greetings (No Retrieval Expected) (CHAT_015)
|
| 205 |
+
- **Status:** ✅ PASSED
|
| 206 |
+
- **Overall Score:** 93.75%
|
| 207 |
+
|
| 208 |
+
**Validations:**
|
| 209 |
+
- ✅ **Citation**: 100.00%
|
| 210 |
+
- ✅ **Relevance**: 100.00%
|
| 211 |
+
- ✅ **Format**: 75.00%
|
| 212 |
+
- ✅ **Area_Insights**: 100.00%
|
| 213 |
+
|
| 214 |
+
### NYC Area Insights (AREA_001)
|
| 215 |
+
- **Status:** ❌ FAILED
|
| 216 |
+
- **Overall Score:** 80.00%
|
| 217 |
+
|
| 218 |
+
**Validations:**
|
| 219 |
+
- ❌ **Citation**: 50.00%
|
| 220 |
+
- ⚠️ Expected datasets not cited: SVI_2022, AHRF-2025, EJI_2024
|
| 221 |
+
- ⚠️ Citations to unknown datasets: Health Resources and Services Administration, Available for: 10001, New York, NY, New York State Office of Mental Health, Available for: New York State, American Community Survey, Available for: 10001, New York, NY, American, New York State Department of Health, Available for: New York State, New York City Community Health Survey, Available for: 10001, New York, NY, Health, New York City Department of Health and Mental Hygiene, Available for: 10001, New York, NY, New
|
| 222 |
+
- ✅ **Relevance**: 100.00%
|
| 223 |
+
- ✅ **Format**: 100.00%
|
| 224 |
+
- ❌ **Area_Insights**: 70.00%
|
| 225 |
+
- ⚠️ Response does not mention expected datasets
|
| 226 |
+
|
| 227 |
+
### Atlanta Area Insights (AREA_002)
|
| 228 |
+
- **Status:** ❌ FAILED
|
| 229 |
+
- **Overall Score:** 80.00%
|
| 230 |
+
|
| 231 |
+
**Validations:**
|
| 232 |
+
- ❌ **Citation**: 50.00%
|
| 233 |
+
- ⚠️ Expected datasets not cited: SVI_2022, AHRF-2025, EJI_2024
|
| 234 |
+
- ⚠️ Citations to unknown datasets: Healthcare Cost and Utilization Project (HCUP, COVID-19, American, Behavioral, Healthcare, Behavioral Risk Factor Surveillance System (BRFSS, American Community Survey (ACS, COVID-19 Data Repository by the Center for Systems Science and Engineering (CSSE
|
| 235 |
+
- ✅ **Relevance**: 100.00%
|
| 236 |
+
- ✅ **Format**: 100.00%
|
| 237 |
+
- ❌ **Area_Insights**: 70.00%
|
| 238 |
+
- ⚠️ Response does not mention expected datasets
|
| 239 |
+
|
| 240 |
+
### San Francisco Area Insights (AREA_003)
|
| 241 |
+
- **Status:** ❌ FAILED
|
| 242 |
+
- **Overall Score:** 80.00%
|
| 243 |
+
|
| 244 |
+
**Validations:**
|
| 245 |
+
- ❌ **Citation**: 50.00%
|
| 246 |
+
- ⚠️ Expected datasets not cited: EJI_2024
|
| 247 |
+
- ⚠️ Citations to unknown datasets: National, Urban Green Space Data, Available for: San Francisco, CA, Lead, Climate, Air, Climate Adaptation Planning Data, Available for: San Francisco, CA, Lead Exposure Risk Maps, Available for: San Francisco, CA, Urban, National Water Quality Assessment Program, Available for: United States, Water Quality Monitoring Data, Available for: San Francisco, CA, Water, National Air Quality Monitoring Data, Available for: California, Air Quality Monitoring Data, Available for: San Francisco, CA
|
| 248 |
+
- ✅ **Relevance**: 100.00%
|
| 249 |
+
- ✅ **Format**: 100.00%
|
| 250 |
+
- ❌ **Area_Insights**: 70.00%
|
| 251 |
+
- ⚠️ Response does not mention expected datasets
|
| 252 |
+
|
| 253 |
+
### Multiple ZIP Lookup (AREA_004)
|
| 254 |
+
- **Status:** ❌ FAILED
|
| 255 |
+
- **Overall Score:** 72.50%
|
| 256 |
+
|
| 257 |
+
**Validations:**
|
| 258 |
+
- ❌ **Citation**: 50.00%
|
| 259 |
+
- ⚠️ Expected datasets not cited: SVI_2022, AHRF-2025, EJI_2024
|
| 260 |
+
- ⚠️ Citations to unknown datasets: Centers for Disease Control and Prevention, Available for: New York State, Centers, Robert, American, Healthcare Cost and Utilization Project, Available for: 30301, Atlanta, GA, Behavioral Risk Factor Surveillance System, Available for: 30301, Atlanta, GA, Behavioral, Healthcare, U.S. Census Bureau, Available for: 10001, New York, NY, American Hospital Association, Available for: 10001, New York, NY, Robert Wood Johnson Foundation, Available for: Georgia, U
|
| 261 |
+
- ✅ **Relevance**: 100.00%
|
| 262 |
+
- ✅ **Format**: 100.00%
|
| 263 |
+
- ❌ **Area_Insights**: 40.00%
|
| 264 |
+
- ⚠️ Response does not mention expected datasets
|
| 265 |
+
|
| 266 |
+
### Invalid ZIP Fallback (AREA_005)
|
| 267 |
+
- **Status:** ❌ FAILED
|
| 268 |
+
- **Overall Score:** 86.25%
|
| 269 |
+
|
| 270 |
+
**Validations:**
|
| 271 |
+
- ❌ **Citation**: 75.00%
|
| 272 |
+
- ⚠️ Citations to unknown datasets: Centers for Disease Control and Prevention, Available for: Statewide, State, Health Resources and Services Administration, Available for: Statewide, State, Centers, Behavioral, Behavioral Risk Factor Surveillance System, Available for: Statewide, State, Health
|
| 273 |
+
- ✅ **Relevance**: 100.00%
|
| 274 |
+
- ✅ **Format**: 100.00%
|
| 275 |
+
- ✅ **Area_Insights**: 70.00%
|
| 276 |
+
|
| 277 |
+
---
|
| 278 |
+
|
| 279 |
+
## Recommendations
|
| 280 |
+
|
| 281 |
+
🚨 Critical issues detected. Review retrieval and LLM prompt engineering.
|
| 282 |
+
- Ensure all recommended columns are verified against loaded dictionaries
|
| 283 |
+
- Review system prompts to improve citation formatting consistency
|
| 284 |
+
- Monitor Area Insights geographic accuracy for regional data
|
| 285 |
+
- Consider fine-tuning retrieval parameters for better relevance
|
| 286 |
+
- Implement continuous testing in CI/CD pipeline
|
| 287 |
+
|
| 288 |
+
---
|
| 289 |
+
|
| 290 |
+
**Report Generated:** 2026-01-13 23:10:59
|
tests/test_results/chat_results_2026-01-13T23-06-21.907442.json
ADDED
|
@@ -0,0 +1,302 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[
|
| 2 |
+
{
|
| 3 |
+
"test_id": "CHAT_001",
|
| 4 |
+
"name": "Diabetes Risk Prediction",
|
| 5 |
+
"type": "chat",
|
| 6 |
+
"query": "I'm building a diabetes risk prediction model. Which columns should I use?",
|
| 7 |
+
"timestamp": "2026-01-13T23:06:23.353589",
|
| 8 |
+
"success": false,
|
| 9 |
+
"response": null,
|
| 10 |
+
"retrieved_chunks": [],
|
| 11 |
+
"retrieved_datasets": [],
|
| 12 |
+
"citations": [],
|
| 13 |
+
"response_length": 0,
|
| 14 |
+
"execution_time_ms": 0,
|
| 15 |
+
"error": "'AzureOpenAIService' object has no attribute 'get_chat_response'"
|
| 16 |
+
},
|
| 17 |
+
{
|
| 18 |
+
"test_id": "CHAT_002",
|
| 19 |
+
"name": "Hospital Readmission Prediction",
|
| 20 |
+
"type": "chat",
|
| 21 |
+
"query": "What data would help predict 30-day hospital readmission rates?",
|
| 22 |
+
"timestamp": "2026-01-13T23:06:23.355205",
|
| 23 |
+
"success": false,
|
| 24 |
+
"response": null,
|
| 25 |
+
"retrieved_chunks": [],
|
| 26 |
+
"retrieved_datasets": [],
|
| 27 |
+
"citations": [],
|
| 28 |
+
"response_length": 0,
|
| 29 |
+
"execution_time_ms": 0,
|
| 30 |
+
"error": "'AzureOpenAIService' object has no attribute 'get_chat_response'"
|
| 31 |
+
},
|
| 32 |
+
{
|
| 33 |
+
"test_id": "CHAT_003",
|
| 34 |
+
"name": "Food Insecurity Impact",
|
| 35 |
+
"type": "chat",
|
| 36 |
+
"query": "Which columns indicate food insecurity and its health impacts?",
|
| 37 |
+
"timestamp": "2026-01-13T23:06:23.356306",
|
| 38 |
+
"success": false,
|
| 39 |
+
"response": null,
|
| 40 |
+
"retrieved_chunks": [],
|
| 41 |
+
"retrieved_datasets": [],
|
| 42 |
+
"citations": [],
|
| 43 |
+
"response_length": 0,
|
| 44 |
+
"execution_time_ms": 0,
|
| 45 |
+
"error": "'AzureOpenAIService' object has no attribute 'get_chat_response'"
|
| 46 |
+
},
|
| 47 |
+
{
|
| 48 |
+
"test_id": "CHAT_004",
|
| 49 |
+
"name": "Social Vulnerability Index",
|
| 50 |
+
"type": "chat",
|
| 51 |
+
"query": "Tell me about the Social Vulnerability Index columns",
|
| 52 |
+
"timestamp": "2026-01-13T23:06:23.357263",
|
| 53 |
+
"success": false,
|
| 54 |
+
"response": null,
|
| 55 |
+
"retrieved_chunks": [],
|
| 56 |
+
"retrieved_datasets": [],
|
| 57 |
+
"citations": [],
|
| 58 |
+
"response_length": 0,
|
| 59 |
+
"execution_time_ms": 0,
|
| 60 |
+
"error": "'AzureOpenAIService' object has no attribute 'get_chat_response'"
|
| 61 |
+
},
|
| 62 |
+
{
|
| 63 |
+
"test_id": "CHAT_005",
|
| 64 |
+
"name": "Environmental Health Indices",
|
| 65 |
+
"type": "chat",
|
| 66 |
+
"query": "What columns measure environmental health and pollution exposure?",
|
| 67 |
+
"timestamp": "2026-01-13T23:06:23.358149",
|
| 68 |
+
"success": false,
|
| 69 |
+
"response": null,
|
| 70 |
+
"retrieved_chunks": [],
|
| 71 |
+
"retrieved_datasets": [],
|
| 72 |
+
"citations": [],
|
| 73 |
+
"response_length": 0,
|
| 74 |
+
"execution_time_ms": 0,
|
| 75 |
+
"error": "'AzureOpenAIService' object has no attribute 'get_chat_response'"
|
| 76 |
+
},
|
| 77 |
+
{
|
| 78 |
+
"test_id": "CHAT_006",
|
| 79 |
+
"name": "Healthcare Workforce",
|
| 80 |
+
"type": "chat",
|
| 81 |
+
"query": "Which columns track healthcare provider availability and workforce metrics?",
|
| 82 |
+
"timestamp": "2026-01-13T23:06:23.359294",
|
| 83 |
+
"success": false,
|
| 84 |
+
"response": null,
|
| 85 |
+
"retrieved_chunks": [],
|
| 86 |
+
"retrieved_datasets": [],
|
| 87 |
+
"citations": [],
|
| 88 |
+
"response_length": 0,
|
| 89 |
+
"execution_time_ms": 0,
|
| 90 |
+
"error": "'AzureOpenAIService' object has no attribute 'get_chat_response'"
|
| 91 |
+
},
|
| 92 |
+
{
|
| 93 |
+
"test_id": "CHAT_007",
|
| 94 |
+
"name": "Demographic Information",
|
| 95 |
+
"type": "chat",
|
| 96 |
+
"query": "What demographic columns are available across all datasets?",
|
| 97 |
+
"timestamp": "2026-01-13T23:06:23.360304",
|
| 98 |
+
"success": false,
|
| 99 |
+
"response": null,
|
| 100 |
+
"retrieved_chunks": [],
|
| 101 |
+
"retrieved_datasets": [],
|
| 102 |
+
"citations": [],
|
| 103 |
+
"response_length": 0,
|
| 104 |
+
"execution_time_ms": 0,
|
| 105 |
+
"error": "'AzureOpenAIService' object has no attribute 'get_chat_response'"
|
| 106 |
+
},
|
| 107 |
+
{
|
| 108 |
+
"test_id": "CHAT_008",
|
| 109 |
+
"name": "Mental Health Indicators",
|
| 110 |
+
"type": "chat",
|
| 111 |
+
"query": "What data do you have about mental health and mental health services?",
|
| 112 |
+
"timestamp": "2026-01-13T23:06:23.361458",
|
| 113 |
+
"success": false,
|
| 114 |
+
"response": null,
|
| 115 |
+
"retrieved_chunks": [],
|
| 116 |
+
"retrieved_datasets": [],
|
| 117 |
+
"citations": [],
|
| 118 |
+
"response_length": 0,
|
| 119 |
+
"execution_time_ms": 0,
|
| 120 |
+
"error": "'AzureOpenAIService' object has no attribute 'get_chat_response'"
|
| 121 |
+
},
|
| 122 |
+
{
|
| 123 |
+
"test_id": "CHAT_009",
|
| 124 |
+
"name": "Follow-up Question - Deep Dive",
|
| 125 |
+
"type": "chat",
|
| 126 |
+
"query": "Tell me more about the specific columns in the SVI_2022 dataset",
|
| 127 |
+
"timestamp": "2026-01-13T23:06:23.362521",
|
| 128 |
+
"success": false,
|
| 129 |
+
"response": null,
|
| 130 |
+
"retrieved_chunks": [],
|
| 131 |
+
"retrieved_datasets": [],
|
| 132 |
+
"citations": [],
|
| 133 |
+
"response_length": 0,
|
| 134 |
+
"execution_time_ms": 0,
|
| 135 |
+
"error": "'AzureOpenAIService' object has no attribute 'get_chat_response'"
|
| 136 |
+
},
|
| 137 |
+
{
|
| 138 |
+
"test_id": "CHAT_010",
|
| 139 |
+
"name": "Clarification Question",
|
| 140 |
+
"type": "chat",
|
| 141 |
+
"query": "Which dataset has the most recent data?",
|
| 142 |
+
"timestamp": "2026-01-13T23:06:23.363480",
|
| 143 |
+
"success": false,
|
| 144 |
+
"response": null,
|
| 145 |
+
"retrieved_chunks": [],
|
| 146 |
+
"retrieved_datasets": [],
|
| 147 |
+
"citations": [],
|
| 148 |
+
"response_length": 0,
|
| 149 |
+
"execution_time_ms": 0,
|
| 150 |
+
"error": "'AzureOpenAIService' object has no attribute 'get_chat_response'"
|
| 151 |
+
},
|
| 152 |
+
{
|
| 153 |
+
"test_id": "CHAT_011",
|
| 154 |
+
"name": "Chronic Disease Burden",
|
| 155 |
+
"type": "chat",
|
| 156 |
+
"query": "Which columns would help identify communities with high chronic disease burden?",
|
| 157 |
+
"timestamp": "2026-01-13T23:06:23.364819",
|
| 158 |
+
"success": false,
|
| 159 |
+
"response": null,
|
| 160 |
+
"retrieved_chunks": [],
|
| 161 |
+
"retrieved_datasets": [],
|
| 162 |
+
"citations": [],
|
| 163 |
+
"response_length": 0,
|
| 164 |
+
"execution_time_ms": 0,
|
| 165 |
+
"error": "'AzureOpenAIService' object has no attribute 'get_chat_response'"
|
| 166 |
+
},
|
| 167 |
+
{
|
| 168 |
+
"test_id": "CHAT_012",
|
| 169 |
+
"name": "Access to Care",
|
| 170 |
+
"type": "chat",
|
| 171 |
+
"query": "What columns measure access to healthcare services?",
|
| 172 |
+
"timestamp": "2026-01-13T23:06:23.365973",
|
| 173 |
+
"success": false,
|
| 174 |
+
"response": null,
|
| 175 |
+
"retrieved_chunks": [],
|
| 176 |
+
"retrieved_datasets": [],
|
| 177 |
+
"citations": [],
|
| 178 |
+
"response_length": 0,
|
| 179 |
+
"execution_time_ms": 0,
|
| 180 |
+
"error": "'AzureOpenAIService' object has no attribute 'get_chat_response'"
|
| 181 |
+
},
|
| 182 |
+
{
|
| 183 |
+
"test_id": "CHAT_013",
|
| 184 |
+
"name": "Economic Factors",
|
| 185 |
+
"type": "chat",
|
| 186 |
+
"query": "Which columns relate to economic indicators and poverty?",
|
| 187 |
+
"timestamp": "2026-01-13T23:06:23.366967",
|
| 188 |
+
"success": false,
|
| 189 |
+
"response": null,
|
| 190 |
+
"retrieved_chunks": [],
|
| 191 |
+
"retrieved_datasets": [],
|
| 192 |
+
"citations": [],
|
| 193 |
+
"response_length": 0,
|
| 194 |
+
"execution_time_ms": 0,
|
| 195 |
+
"error": "'AzureOpenAIService' object has no attribute 'get_chat_response'"
|
| 196 |
+
},
|
| 197 |
+
{
|
| 198 |
+
"test_id": "CHAT_014",
|
| 199 |
+
"name": "Housing and Living Conditions",
|
| 200 |
+
"type": "chat",
|
| 201 |
+
"query": "Do you have data about housing, crowding, or living conditions?",
|
| 202 |
+
"timestamp": "2026-01-13T23:06:23.367941",
|
| 203 |
+
"success": false,
|
| 204 |
+
"response": null,
|
| 205 |
+
"retrieved_chunks": [],
|
| 206 |
+
"retrieved_datasets": [],
|
| 207 |
+
"citations": [],
|
| 208 |
+
"response_length": 0,
|
| 209 |
+
"execution_time_ms": 0,
|
| 210 |
+
"error": "'AzureOpenAIService' object has no attribute 'get_chat_response'"
|
| 211 |
+
},
|
| 212 |
+
{
|
| 213 |
+
"test_id": "CHAT_015",
|
| 214 |
+
"name": "Greetings (No Retrieval Expected)",
|
| 215 |
+
"type": "chat",
|
| 216 |
+
"query": "Hi there!",
|
| 217 |
+
"timestamp": "2026-01-13T23:06:23.368989",
|
| 218 |
+
"success": false,
|
| 219 |
+
"response": null,
|
| 220 |
+
"retrieved_chunks": [],
|
| 221 |
+
"retrieved_datasets": [],
|
| 222 |
+
"citations": [],
|
| 223 |
+
"response_length": 0,
|
| 224 |
+
"execution_time_ms": 0,
|
| 225 |
+
"error": "'AzureOpenAIService' object has no attribute 'get_chat_response'"
|
| 226 |
+
},
|
| 227 |
+
{
|
| 228 |
+
"test_id": "AREA_001",
|
| 229 |
+
"name": "NYC Area Insights",
|
| 230 |
+
"type": "area_insights",
|
| 231 |
+
"query": "What data is available for ZIP code 10001?",
|
| 232 |
+
"location": "New York, NY",
|
| 233 |
+
"zip_code": "10001",
|
| 234 |
+
"timestamp": "2026-01-13T23:06:23.370384",
|
| 235 |
+
"success": false,
|
| 236 |
+
"response": null,
|
| 237 |
+
"retrieved_chunks": [],
|
| 238 |
+
"retrieved_datasets": [],
|
| 239 |
+
"citations": [],
|
| 240 |
+
"error": "'AzureOpenAIService' object has no attribute 'get_chat_response'"
|
| 241 |
+
},
|
| 242 |
+
{
|
| 243 |
+
"test_id": "AREA_002",
|
| 244 |
+
"name": "Atlanta Area Insights",
|
| 245 |
+
"type": "area_insights",
|
| 246 |
+
"query": "Tell me about health data for Atlanta, GA",
|
| 247 |
+
"location": "Atlanta, GA",
|
| 248 |
+
"zip_code": "",
|
| 249 |
+
"timestamp": "2026-01-13T23:06:23.373530",
|
| 250 |
+
"success": false,
|
| 251 |
+
"response": null,
|
| 252 |
+
"retrieved_chunks": [],
|
| 253 |
+
"retrieved_datasets": [],
|
| 254 |
+
"citations": [],
|
| 255 |
+
"error": "'AzureOpenAIService' object has no attribute 'get_chat_response'"
|
| 256 |
+
},
|
| 257 |
+
{
|
| 258 |
+
"test_id": "AREA_003",
|
| 259 |
+
"name": "San Francisco Area Insights",
|
| 260 |
+
"type": "area_insights",
|
| 261 |
+
"query": "What environmental data is available for San Francisco?",
|
| 262 |
+
"location": "San Francisco, CA",
|
| 263 |
+
"zip_code": "",
|
| 264 |
+
"timestamp": "2026-01-13T23:06:23.377833",
|
| 265 |
+
"success": false,
|
| 266 |
+
"response": null,
|
| 267 |
+
"retrieved_chunks": [],
|
| 268 |
+
"retrieved_datasets": [],
|
| 269 |
+
"citations": [],
|
| 270 |
+
"error": "'AzureOpenAIService' object has no attribute 'get_chat_response'"
|
| 271 |
+
},
|
| 272 |
+
{
|
| 273 |
+
"test_id": "AREA_004",
|
| 274 |
+
"name": "Multiple ZIP Lookup",
|
| 275 |
+
"type": "area_insights",
|
| 276 |
+
"query": "Compare data for 10001 and 30301",
|
| 277 |
+
"location": "",
|
| 278 |
+
"zip_code": "",
|
| 279 |
+
"timestamp": "2026-01-13T23:06:23.382614",
|
| 280 |
+
"success": false,
|
| 281 |
+
"response": null,
|
| 282 |
+
"retrieved_chunks": [],
|
| 283 |
+
"retrieved_datasets": [],
|
| 284 |
+
"citations": [],
|
| 285 |
+
"error": "'AzureOpenAIService' object has no attribute 'get_chat_response'"
|
| 286 |
+
},
|
| 287 |
+
{
|
| 288 |
+
"test_id": "AREA_005",
|
| 289 |
+
"name": "Invalid ZIP Fallback",
|
| 290 |
+
"type": "area_insights",
|
| 291 |
+
"query": "What about ZIP code 99999?",
|
| 292 |
+
"location": "Invalid ZIP",
|
| 293 |
+
"zip_code": "99999",
|
| 294 |
+
"timestamp": "2026-01-13T23:06:23.385584",
|
| 295 |
+
"success": false,
|
| 296 |
+
"response": null,
|
| 297 |
+
"retrieved_chunks": [],
|
| 298 |
+
"retrieved_datasets": [],
|
| 299 |
+
"citations": [],
|
| 300 |
+
"error": "'AzureOpenAIService' object has no attribute 'get_chat_response'"
|
| 301 |
+
}
|
| 302 |
+
]
|
tests/test_results/chat_results_2026-01-13T23-07-04.413983.json
ADDED
|
@@ -0,0 +1,302 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[
|
| 2 |
+
{
|
| 3 |
+
"test_id": "CHAT_001",
|
| 4 |
+
"name": "Diabetes Risk Prediction",
|
| 5 |
+
"type": "chat",
|
| 6 |
+
"query": "I'm building a diabetes risk prediction model. Which columns should I use?",
|
| 7 |
+
"timestamp": "2026-01-13T23:07:05.587689",
|
| 8 |
+
"success": true,
|
| 9 |
+
"response": "",
|
| 10 |
+
"retrieved_chunks": [],
|
| 11 |
+
"retrieved_datasets": [],
|
| 12 |
+
"citations": [],
|
| 13 |
+
"response_length": 0,
|
| 14 |
+
"execution_time_ms": 4705,
|
| 15 |
+
"error": null
|
| 16 |
+
},
|
| 17 |
+
{
|
| 18 |
+
"test_id": "CHAT_002",
|
| 19 |
+
"name": "Hospital Readmission Prediction",
|
| 20 |
+
"type": "chat",
|
| 21 |
+
"query": "What data would help predict 30-day hospital readmission rates?",
|
| 22 |
+
"timestamp": "2026-01-13T23:07:10.293682",
|
| 23 |
+
"success": true,
|
| 24 |
+
"response": "",
|
| 25 |
+
"retrieved_chunks": [],
|
| 26 |
+
"retrieved_datasets": [],
|
| 27 |
+
"citations": [],
|
| 28 |
+
"response_length": 0,
|
| 29 |
+
"execution_time_ms": 5008,
|
| 30 |
+
"error": null
|
| 31 |
+
},
|
| 32 |
+
{
|
| 33 |
+
"test_id": "CHAT_003",
|
| 34 |
+
"name": "Food Insecurity Impact",
|
| 35 |
+
"type": "chat",
|
| 36 |
+
"query": "Which columns indicate food insecurity and its health impacts?",
|
| 37 |
+
"timestamp": "2026-01-13T23:07:15.303546",
|
| 38 |
+
"success": true,
|
| 39 |
+
"response": "",
|
| 40 |
+
"retrieved_chunks": [],
|
| 41 |
+
"retrieved_datasets": [],
|
| 42 |
+
"citations": [],
|
| 43 |
+
"response_length": 0,
|
| 44 |
+
"execution_time_ms": 4357,
|
| 45 |
+
"error": null
|
| 46 |
+
},
|
| 47 |
+
{
|
| 48 |
+
"test_id": "CHAT_004",
|
| 49 |
+
"name": "Social Vulnerability Index",
|
| 50 |
+
"type": "chat",
|
| 51 |
+
"query": "Tell me about the Social Vulnerability Index columns",
|
| 52 |
+
"timestamp": "2026-01-13T23:07:19.662491",
|
| 53 |
+
"success": true,
|
| 54 |
+
"response": "",
|
| 55 |
+
"retrieved_chunks": [],
|
| 56 |
+
"retrieved_datasets": [],
|
| 57 |
+
"citations": [],
|
| 58 |
+
"response_length": 0,
|
| 59 |
+
"execution_time_ms": 5366,
|
| 60 |
+
"error": null
|
| 61 |
+
},
|
| 62 |
+
{
|
| 63 |
+
"test_id": "CHAT_005",
|
| 64 |
+
"name": "Environmental Health Indices",
|
| 65 |
+
"type": "chat",
|
| 66 |
+
"query": "What columns measure environmental health and pollution exposure?",
|
| 67 |
+
"timestamp": "2026-01-13T23:07:25.030549",
|
| 68 |
+
"success": true,
|
| 69 |
+
"response": "",
|
| 70 |
+
"retrieved_chunks": [],
|
| 71 |
+
"retrieved_datasets": [],
|
| 72 |
+
"citations": [],
|
| 73 |
+
"response_length": 0,
|
| 74 |
+
"execution_time_ms": 5534,
|
| 75 |
+
"error": null
|
| 76 |
+
},
|
| 77 |
+
{
|
| 78 |
+
"test_id": "CHAT_006",
|
| 79 |
+
"name": "Healthcare Workforce",
|
| 80 |
+
"type": "chat",
|
| 81 |
+
"query": "Which columns track healthcare provider availability and workforce metrics?",
|
| 82 |
+
"timestamp": "2026-01-13T23:07:30.565593",
|
| 83 |
+
"success": true,
|
| 84 |
+
"response": "",
|
| 85 |
+
"retrieved_chunks": [],
|
| 86 |
+
"retrieved_datasets": [],
|
| 87 |
+
"citations": [],
|
| 88 |
+
"response_length": 0,
|
| 89 |
+
"execution_time_ms": 5009,
|
| 90 |
+
"error": null
|
| 91 |
+
},
|
| 92 |
+
{
|
| 93 |
+
"test_id": "CHAT_007",
|
| 94 |
+
"name": "Demographic Information",
|
| 95 |
+
"type": "chat",
|
| 96 |
+
"query": "What demographic columns are available across all datasets?",
|
| 97 |
+
"timestamp": "2026-01-13T23:07:35.576529",
|
| 98 |
+
"success": true,
|
| 99 |
+
"response": "",
|
| 100 |
+
"retrieved_chunks": [],
|
| 101 |
+
"retrieved_datasets": [],
|
| 102 |
+
"citations": [],
|
| 103 |
+
"response_length": 0,
|
| 104 |
+
"execution_time_ms": 3274,
|
| 105 |
+
"error": null
|
| 106 |
+
},
|
| 107 |
+
{
|
| 108 |
+
"test_id": "CHAT_008",
|
| 109 |
+
"name": "Mental Health Indicators",
|
| 110 |
+
"type": "chat",
|
| 111 |
+
"query": "What data do you have about mental health and mental health services?",
|
| 112 |
+
"timestamp": "2026-01-13T23:07:38.852393",
|
| 113 |
+
"success": true,
|
| 114 |
+
"response": "",
|
| 115 |
+
"retrieved_chunks": [],
|
| 116 |
+
"retrieved_datasets": [],
|
| 117 |
+
"citations": [],
|
| 118 |
+
"response_length": 0,
|
| 119 |
+
"execution_time_ms": 5120,
|
| 120 |
+
"error": null
|
| 121 |
+
},
|
| 122 |
+
{
|
| 123 |
+
"test_id": "CHAT_009",
|
| 124 |
+
"name": "Follow-up Question - Deep Dive",
|
| 125 |
+
"type": "chat",
|
| 126 |
+
"query": "Tell me more about the specific columns in the SVI_2022 dataset",
|
| 127 |
+
"timestamp": "2026-01-13T23:07:43.974172",
|
| 128 |
+
"success": true,
|
| 129 |
+
"response": "",
|
| 130 |
+
"retrieved_chunks": [],
|
| 131 |
+
"retrieved_datasets": [],
|
| 132 |
+
"citations": [],
|
| 133 |
+
"response_length": 0,
|
| 134 |
+
"execution_time_ms": 14021,
|
| 135 |
+
"error": null
|
| 136 |
+
},
|
| 137 |
+
{
|
| 138 |
+
"test_id": "CHAT_010",
|
| 139 |
+
"name": "Clarification Question",
|
| 140 |
+
"type": "chat",
|
| 141 |
+
"query": "Which dataset has the most recent data?",
|
| 142 |
+
"timestamp": "2026-01-13T23:07:57.996832",
|
| 143 |
+
"success": true,
|
| 144 |
+
"response": "",
|
| 145 |
+
"retrieved_chunks": [],
|
| 146 |
+
"retrieved_datasets": [],
|
| 147 |
+
"citations": [],
|
| 148 |
+
"response_length": 0,
|
| 149 |
+
"execution_time_ms": 2356,
|
| 150 |
+
"error": null
|
| 151 |
+
},
|
| 152 |
+
{
|
| 153 |
+
"test_id": "CHAT_011",
|
| 154 |
+
"name": "Chronic Disease Burden",
|
| 155 |
+
"type": "chat",
|
| 156 |
+
"query": "Which columns would help identify communities with high chronic disease burden?",
|
| 157 |
+
"timestamp": "2026-01-13T23:08:00.355212",
|
| 158 |
+
"success": true,
|
| 159 |
+
"response": "",
|
| 160 |
+
"retrieved_chunks": [],
|
| 161 |
+
"retrieved_datasets": [],
|
| 162 |
+
"citations": [],
|
| 163 |
+
"response_length": 0,
|
| 164 |
+
"execution_time_ms": 4705,
|
| 165 |
+
"error": null
|
| 166 |
+
},
|
| 167 |
+
{
|
| 168 |
+
"test_id": "CHAT_012",
|
| 169 |
+
"name": "Access to Care",
|
| 170 |
+
"type": "chat",
|
| 171 |
+
"query": "What columns measure access to healthcare services?",
|
| 172 |
+
"timestamp": "2026-01-13T23:08:05.061114",
|
| 173 |
+
"success": true,
|
| 174 |
+
"response": "",
|
| 175 |
+
"retrieved_chunks": [],
|
| 176 |
+
"retrieved_datasets": [],
|
| 177 |
+
"citations": [],
|
| 178 |
+
"response_length": 0,
|
| 179 |
+
"execution_time_ms": 7885,
|
| 180 |
+
"error": null
|
| 181 |
+
},
|
| 182 |
+
{
|
| 183 |
+
"test_id": "CHAT_013",
|
| 184 |
+
"name": "Economic Factors",
|
| 185 |
+
"type": "chat",
|
| 186 |
+
"query": "Which columns relate to economic indicators and poverty?",
|
| 187 |
+
"timestamp": "2026-01-13T23:08:12.946868",
|
| 188 |
+
"success": true,
|
| 189 |
+
"response": "",
|
| 190 |
+
"retrieved_chunks": [],
|
| 191 |
+
"retrieved_datasets": [],
|
| 192 |
+
"citations": [],
|
| 193 |
+
"response_length": 0,
|
| 194 |
+
"execution_time_ms": 4713,
|
| 195 |
+
"error": null
|
| 196 |
+
},
|
| 197 |
+
{
|
| 198 |
+
"test_id": "CHAT_014",
|
| 199 |
+
"name": "Housing and Living Conditions",
|
| 200 |
+
"type": "chat",
|
| 201 |
+
"query": "Do you have data about housing, crowding, or living conditions?",
|
| 202 |
+
"timestamp": "2026-01-13T23:08:17.661078",
|
| 203 |
+
"success": true,
|
| 204 |
+
"response": "",
|
| 205 |
+
"retrieved_chunks": [],
|
| 206 |
+
"retrieved_datasets": [],
|
| 207 |
+
"citations": [],
|
| 208 |
+
"response_length": 0,
|
| 209 |
+
"execution_time_ms": 4706,
|
| 210 |
+
"error": null
|
| 211 |
+
},
|
| 212 |
+
{
|
| 213 |
+
"test_id": "CHAT_015",
|
| 214 |
+
"name": "Greetings (No Retrieval Expected)",
|
| 215 |
+
"type": "chat",
|
| 216 |
+
"query": "Hi there!",
|
| 217 |
+
"timestamp": "2026-01-13T23:08:22.368954",
|
| 218 |
+
"success": true,
|
| 219 |
+
"response": "",
|
| 220 |
+
"retrieved_chunks": [],
|
| 221 |
+
"retrieved_datasets": [],
|
| 222 |
+
"citations": [],
|
| 223 |
+
"response_length": 0,
|
| 224 |
+
"execution_time_ms": 1943,
|
| 225 |
+
"error": null
|
| 226 |
+
},
|
| 227 |
+
{
|
| 228 |
+
"test_id": "AREA_001",
|
| 229 |
+
"name": "NYC Area Insights",
|
| 230 |
+
"type": "area_insights",
|
| 231 |
+
"query": "What data is available for ZIP code 10001?",
|
| 232 |
+
"location": "New York, NY",
|
| 233 |
+
"zip_code": "10001",
|
| 234 |
+
"timestamp": "2026-01-13T23:08:24.314050",
|
| 235 |
+
"success": true,
|
| 236 |
+
"response": "",
|
| 237 |
+
"retrieved_chunks": [],
|
| 238 |
+
"retrieved_datasets": [],
|
| 239 |
+
"citations": [],
|
| 240 |
+
"error": null
|
| 241 |
+
},
|
| 242 |
+
{
|
| 243 |
+
"test_id": "AREA_002",
|
| 244 |
+
"name": "Atlanta Area Insights",
|
| 245 |
+
"type": "area_insights",
|
| 246 |
+
"query": "Tell me about health data for Atlanta, GA",
|
| 247 |
+
"location": "Atlanta, GA",
|
| 248 |
+
"zip_code": "",
|
| 249 |
+
"timestamp": "2026-01-13T23:08:28.508442",
|
| 250 |
+
"success": true,
|
| 251 |
+
"response": "",
|
| 252 |
+
"retrieved_chunks": [],
|
| 253 |
+
"retrieved_datasets": [],
|
| 254 |
+
"citations": [],
|
| 255 |
+
"error": null
|
| 256 |
+
},
|
| 257 |
+
{
|
| 258 |
+
"test_id": "AREA_003",
|
| 259 |
+
"name": "San Francisco Area Insights",
|
| 260 |
+
"type": "area_insights",
|
| 261 |
+
"query": "What environmental data is available for San Francisco?",
|
| 262 |
+
"location": "San Francisco, CA",
|
| 263 |
+
"zip_code": "",
|
| 264 |
+
"timestamp": "2026-01-13T23:08:32.925087",
|
| 265 |
+
"success": true,
|
| 266 |
+
"response": "",
|
| 267 |
+
"retrieved_chunks": [],
|
| 268 |
+
"retrieved_datasets": [],
|
| 269 |
+
"citations": [],
|
| 270 |
+
"error": null
|
| 271 |
+
},
|
| 272 |
+
{
|
| 273 |
+
"test_id": "AREA_004",
|
| 274 |
+
"name": "Multiple ZIP Lookup",
|
| 275 |
+
"type": "area_insights",
|
| 276 |
+
"query": "Compare data for 10001 and 30301",
|
| 277 |
+
"location": "",
|
| 278 |
+
"zip_code": "",
|
| 279 |
+
"timestamp": "2026-01-13T23:08:36.802170",
|
| 280 |
+
"success": true,
|
| 281 |
+
"response": "",
|
| 282 |
+
"retrieved_chunks": [],
|
| 283 |
+
"retrieved_datasets": [],
|
| 284 |
+
"citations": [],
|
| 285 |
+
"error": null
|
| 286 |
+
},
|
| 287 |
+
{
|
| 288 |
+
"test_id": "AREA_005",
|
| 289 |
+
"name": "Invalid ZIP Fallback",
|
| 290 |
+
"type": "area_insights",
|
| 291 |
+
"query": "What about ZIP code 99999?",
|
| 292 |
+
"location": "Invalid ZIP",
|
| 293 |
+
"zip_code": "99999",
|
| 294 |
+
"timestamp": "2026-01-13T23:08:42.432389",
|
| 295 |
+
"success": true,
|
| 296 |
+
"response": "",
|
| 297 |
+
"retrieved_chunks": [],
|
| 298 |
+
"retrieved_datasets": [],
|
| 299 |
+
"citations": [],
|
| 300 |
+
"error": null
|
| 301 |
+
}
|
| 302 |
+
]
|
tests/test_results/chat_results_2026-01-13T23-09-29.921135.json
ADDED
|
@@ -0,0 +1,367 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[
|
| 2 |
+
{
|
| 3 |
+
"test_id": "CHAT_001",
|
| 4 |
+
"name": "Diabetes Risk Prediction",
|
| 5 |
+
"type": "chat",
|
| 6 |
+
"query": "I'm building a diabetes risk prediction model. Which columns should I use?",
|
| 7 |
+
"timestamp": "2026-01-13T23:09:31.036122",
|
| 8 |
+
"success": true,
|
| 9 |
+
"response": "For a diabetes risk prediction model, here are some relevant columns you can consider from the **Pima Indians Diabetes Database**:\n\n### Pima Indians Diabetes Database\n1. **Pregnancies** (Dataset: Pima Indians Diabetes Database)\n - This column indicates the number of times a woman has been pregnant. It is relevant as pregnancy can influence insulin resistance and glucose metabolism.\n\n2. **Glucose** (Dataset: Pima Indians Diabetes Database)\n - This measures the plasma glucose concentration after two hours in an oral glucose tolerance test. It is a critical factor in diagnosing diabetes and assessing risk.\n\n3. **BloodPressure** (Dataset: Pima Indians Diabetes Database)\n - This represents the diastolic blood pressure (mm Hg). High blood pressure is often associated with diabetes and can indicate increased risk.\n\n4. **SkinThickness** (Dataset: Pima Indians Diabetes Database)\n - This measures the triceps skin fold thickness (mm). It can be an indicator of body fat and insulin resistance, making it relevant for diabetes prediction.\n\n5. **BMI** (Dataset: Pima Indians Diabetes Database)\n - Body Mass Index is a key indicator of obesity, which is a significant risk factor for developing diabetes.\n\nThese columns provide key physiological and demographic information that can help in predicting the risk of diabetes.",
|
| 10 |
+
"retrieved_chunks": [],
|
| 11 |
+
"retrieved_datasets": [],
|
| 12 |
+
"citations": [
|
| 13 |
+
"Pima Indians Diabetes Database"
|
| 14 |
+
],
|
| 15 |
+
"response_length": 1333,
|
| 16 |
+
"execution_time_ms": 4332,
|
| 17 |
+
"error": null
|
| 18 |
+
},
|
| 19 |
+
{
|
| 20 |
+
"test_id": "CHAT_002",
|
| 21 |
+
"name": "Hospital Readmission Prediction",
|
| 22 |
+
"type": "chat",
|
| 23 |
+
"query": "What data would help predict 30-day hospital readmission rates?",
|
| 24 |
+
"timestamp": "2026-01-13T23:09:35.369276",
|
| 25 |
+
"success": true,
|
| 26 |
+
"response": "To predict 30-day hospital readmission rates, you would need data that captures patient demographics, clinical characteristics, previous hospitalizations, and treatment details. Here are some relevant columns from potential datasets:\n\n### Dataset: Hospital Readmission Data\n\n1. **PatientID** (Dataset: Hospital Readmission Data)\n - This unique identifier for each patient allows you to track individual patient histories and readmission rates.\n\n2. **AdmissionType** (Dataset: Hospital Readmission Data)\n - Understanding whether the admission was elective, urgent, or emergent can provide insights into the reasons for readmissions.\n\n3. **PreviousAdmissions** (Dataset: Hospital Readmission Data)\n - The number of previous admissions can be a strong predictor of future readmissions, as it may indicate the severity of underlying health issues.\n\n4. **DiagnosisCode** (Dataset: Hospital Readmission Data)\n - Knowing the primary diagnosis at the time of admission helps in understanding the health conditions that might lead to readmissions.\n\n5. **DischargeDisposition** (Dataset: Hospital Readmission Data)\n - This indicates where the patient was discharged to (home, rehabilitation, etc.) and can influence the likelihood of readmission based on the level of care they received post-discharge.\n\nThese columns provide a comprehensive view of factors that could influence readmission rates, allowing for more accurate predictions.",
|
| 27 |
+
"retrieved_chunks": [],
|
| 28 |
+
"retrieved_datasets": [],
|
| 29 |
+
"citations": [
|
| 30 |
+
"Hospital Readmission Data"
|
| 31 |
+
],
|
| 32 |
+
"response_length": 1437,
|
| 33 |
+
"execution_time_ms": 4612,
|
| 34 |
+
"error": null
|
| 35 |
+
},
|
| 36 |
+
{
|
| 37 |
+
"test_id": "CHAT_003",
|
| 38 |
+
"name": "Food Insecurity Impact",
|
| 39 |
+
"type": "chat",
|
| 40 |
+
"query": "Which columns indicate food insecurity and its health impacts?",
|
| 41 |
+
"timestamp": "2026-01-13T23:09:39.982697",
|
| 42 |
+
"success": true,
|
| 43 |
+
"response": "To address your inquiry regarding food insecurity and its health impacts, I recommend the following columns from relevant datasets:\n\n### Dataset: National Health and Nutrition Examination Survey (NHANES)\n1. **Food Insecurity Status** (Dataset: NHANES)\n - This column indicates whether individuals or households are classified as food insecure, which is critical for understanding the prevalence of food insecurity in the population.\n\n2. **Body Mass Index (BMI)** (Dataset: NHANES)\n - BMI is a key health indicator that can reveal the impact of food insecurity on nutritional status and overall health outcomes.\n\n3. **Self-Reported Health Status** (Dataset: NHANES)\n - This column provides insights into how individuals perceive their health, which can be affected by food insecurity and its associated stressors.\n\n### Dataset: Behavioral Risk Factor Surveillance System (BRFSS)\n1. **Food Security Status** (Dataset: BRFSS)\n - Similar to the NHANES, this column captures food security status and is essential for linking food access to health outcomes.\n\n2. **Chronic Disease Indicators** (Dataset: BRFSS)\n - This column includes various chronic health conditions that can be exacerbated by food insecurity, allowing for a deeper analysis of health impacts.\n\nThese columns will help you analyze the relationship between food insecurity and health outcomes effectively. If you need further assistance or additional datasets, feel free to ask!",
|
| 44 |
+
"retrieved_chunks": [],
|
| 45 |
+
"retrieved_datasets": [],
|
| 46 |
+
"citations": [
|
| 47 |
+
"NHANES",
|
| 48 |
+
"BRFSS"
|
| 49 |
+
],
|
| 50 |
+
"response_length": 1449,
|
| 51 |
+
"execution_time_ms": 4291,
|
| 52 |
+
"error": null
|
| 53 |
+
},
|
| 54 |
+
{
|
| 55 |
+
"test_id": "CHAT_004",
|
| 56 |
+
"name": "Social Vulnerability Index",
|
| 57 |
+
"type": "chat",
|
| 58 |
+
"query": "Tell me about the Social Vulnerability Index columns",
|
| 59 |
+
"timestamp": "2026-01-13T23:09:44.275357",
|
| 60 |
+
"success": true,
|
| 61 |
+
"response": "The Social Vulnerability Index (SVI) is typically derived from U.S. Census data and is used to assess the resilience of communities when confronted with external stresses on human health, such as natural disasters or public health emergencies. Here are some relevant columns you might find in the SVI dataset:\n\n1. **RPL_THEMES** (Dataset: Social Vulnerability Index)\n - This column categorizes the social vulnerability into themes such as socioeconomic status, household composition, minority status, and language. It is relevant as it helps identify specific areas of vulnerability that may require targeted interventions.\n\n2. **SOCI_ECON** (Dataset: Social Vulnerability Index)\n - This column provides a measure of socioeconomic status, which is critical for understanding the economic resilience of a community. High vulnerability in this area may indicate a greater need for assistance during crises.\n\n3. **MINORITY** (Dataset: Social Vulnerability Index)\n - This column reflects the percentage of the population that identifies as a racial or ethnic minority. Understanding minority status is essential for addressing health disparities and ensuring equitable resource distribution during emergencies.\n\n4. **LIMENG** (Dataset: Social Vulnerability Index)\n - This column indicates the percentage of individuals who speak limited English. This is important for effective communication during crises and ensuring that non-English speaking populations receive necessary support.\n\n5. **AGE65** (Dataset: Social Vulnerability Index)\n - This column represents the percentage of the population aged 65 and older. Older adults are often more vulnerable during emergencies, so this data is crucial for planning and resource allocation.\n\nThese columns can provide valuable insights into the vulnerabilities of different populations, aiding in the development of targeted strategies for disaster preparedness and response.",
|
| 62 |
+
"retrieved_chunks": [],
|
| 63 |
+
"retrieved_datasets": [],
|
| 64 |
+
"citations": [
|
| 65 |
+
"Social Vulnerability Index"
|
| 66 |
+
],
|
| 67 |
+
"response_length": 1925,
|
| 68 |
+
"execution_time_ms": 4912,
|
| 69 |
+
"error": null
|
| 70 |
+
},
|
| 71 |
+
{
|
| 72 |
+
"test_id": "CHAT_005",
|
| 73 |
+
"name": "Environmental Health Indices",
|
| 74 |
+
"type": "chat",
|
| 75 |
+
"query": "What columns measure environmental health and pollution exposure?",
|
| 76 |
+
"timestamp": "2026-01-13T23:09:49.188772",
|
| 77 |
+
"success": true,
|
| 78 |
+
"response": "To provide you with relevant columns for measuring environmental health and pollution exposure, I will recommend columns from specific datasets that focus on these aspects.\n\n### Dataset: **Environmental Protection Agency (EPA) Air Quality Data**\n1. **PM2.5 Concentration** (Dataset: EPA Air Quality Data)\n - This column measures the concentration of fine particulate matter in the air, which is a significant indicator of air pollution and is linked to various health issues.\n\n2. **Ozone Levels** (Dataset: EPA Air Quality Data)\n - Ozone is a key component of smog and can have serious health effects, particularly for respiratory conditions. This column provides insight into air quality and pollution exposure.\n\n3. **NO2 Concentration** (Dataset: EPA Air Quality Data)\n - Nitrogen dioxide (NO2) is a pollutant that can lead to respiratory problems. Monitoring its levels helps assess environmental health risks.\n\n### Dataset: **National Health and Nutrition Examination Survey (NHANES)**\n1. **Blood Lead Levels** (Dataset: NHANES)\n - This column measures lead concentration in blood samples, which is critical for understanding exposure to environmental toxins and their health impacts.\n\n2. **Respiratory Health Status** (Dataset: NHANES)\n - This column includes data on respiratory health conditions that may be influenced by environmental pollution, providing a direct link to health outcomes.\n\nThese columns are essential for analyzing the impact of environmental factors on health and exposure to pollution. If you need more information or additional datasets, feel free to ask!",
|
| 79 |
+
"retrieved_chunks": [],
|
| 80 |
+
"retrieved_datasets": [],
|
| 81 |
+
"citations": [
|
| 82 |
+
"EPA Air Quality Data",
|
| 83 |
+
"NHANES"
|
| 84 |
+
],
|
| 85 |
+
"response_length": 1594,
|
| 86 |
+
"execution_time_ms": 4605,
|
| 87 |
+
"error": null
|
| 88 |
+
},
|
| 89 |
+
{
|
| 90 |
+
"test_id": "CHAT_006",
|
| 91 |
+
"name": "Healthcare Workforce",
|
| 92 |
+
"type": "chat",
|
| 93 |
+
"query": "Which columns track healthcare provider availability and workforce metrics?",
|
| 94 |
+
"timestamp": "2026-01-13T23:09:53.794294",
|
| 95 |
+
"success": true,
|
| 96 |
+
"response": "To assist you with tracking healthcare provider availability and workforce metrics, I recommend the following columns from relevant datasets:\n\n### Dataset: Healthcare Provider Availability Data\n1. **ProviderID** (Dataset: Healthcare Provider Availability Data)\n - This unique identifier for each healthcare provider is crucial for tracking individual availability and performance metrics.\n\n2. **AvailabilityStatus** (Dataset: Healthcare Provider Availability Data)\n - This column indicates whether the provider is currently available for patient care, which is essential for understanding workforce capacity.\n\n3. **Specialty** (Dataset: Healthcare Provider Availability Data)\n - Knowing the specialty of each provider helps in assessing the availability of specific types of care and aligning resources with patient needs.\n\n### Dataset: Workforce Metrics Data\n1. **TotalStaffCount** (Dataset: Workforce Metrics Data)\n - This metric provides insights into the total number of healthcare staff available, which is vital for understanding overall workforce capacity and planning.\n\n2. **StaffTurnoverRate** (Dataset: Workforce Metrics Data)\n - This column indicates the rate at which staff leave the organization, which is important for evaluating workforce stability and planning for future staffing needs.\n\nThese columns will help you effectively track healthcare provider availability and workforce metrics, ensuring you have the necessary data for analysis and decision-making.",
|
| 97 |
+
"retrieved_chunks": [],
|
| 98 |
+
"retrieved_datasets": [],
|
| 99 |
+
"citations": [
|
| 100 |
+
"Workforce Metrics Data",
|
| 101 |
+
"Healthcare Provider Availability Data"
|
| 102 |
+
],
|
| 103 |
+
"response_length": 1487,
|
| 104 |
+
"execution_time_ms": 4201,
|
| 105 |
+
"error": null
|
| 106 |
+
},
|
| 107 |
+
{
|
| 108 |
+
"test_id": "CHAT_007",
|
| 109 |
+
"name": "Demographic Information",
|
| 110 |
+
"type": "chat",
|
| 111 |
+
"query": "What demographic columns are available across all datasets?",
|
| 112 |
+
"timestamp": "2026-01-13T23:09:57.996315",
|
| 113 |
+
"success": true,
|
| 114 |
+
"response": "To assist you effectively, I would need to know which specific datasets you are referring to. Different datasets have varying columns, especially when it comes to demographic information. If you could provide the names of the datasets you're interested in, I can recommend relevant demographic columns from each one.",
|
| 115 |
+
"retrieved_chunks": [],
|
| 116 |
+
"retrieved_datasets": [],
|
| 117 |
+
"citations": [],
|
| 118 |
+
"response_length": 316,
|
| 119 |
+
"execution_time_ms": 2248,
|
| 120 |
+
"error": null
|
| 121 |
+
},
|
| 122 |
+
{
|
| 123 |
+
"test_id": "CHAT_008",
|
| 124 |
+
"name": "Mental Health Indicators",
|
| 125 |
+
"type": "chat",
|
| 126 |
+
"query": "What data do you have about mental health and mental health services?",
|
| 127 |
+
"timestamp": "2026-01-13T23:10:00.246642",
|
| 128 |
+
"success": true,
|
| 129 |
+
"response": "I can recommend several datasets that contain relevant information about mental health and mental health services. Here are some key datasets and their relevant columns:\n\n### 1. **National Survey on Drug Use and Health (NSDUH)**\n- **Mental Health Treatment (Dataset: NSDUH)**: This column indicates whether individuals have received any mental health treatment in the past year. It's crucial for understanding access to mental health services.\n- **Major Depressive Episode (Dataset: NSDUH)**: This column identifies individuals who experienced a major depressive episode in the past year, which is essential for analyzing the prevalence of mental health issues.\n- **Substance Use Disorder (Dataset: NSDUH)**: This column provides information on individuals with substance use disorders, which often co-occur with mental health issues and is relevant for integrated treatment approaches.\n\n### 2. **Behavioral Risk Factor Surveillance System (BRFSS)**\n- **Mental Health Status (Dataset: BRFSS)**: This column captures respondents' self-reported mental health status, providing insights into overall mental well-being in the population.\n- **Access to Mental Health Services (Dataset: BRFSS)**: This column indicates whether individuals have had access to mental health services when needed, which is important for assessing barriers to care.\n\n### 3. **Youth Risk Behavior Surveillance System (YRBSS)**\n- **Feelings of Sadness or Hopelessness (Dataset: YRBSS)**: This column measures the prevalence of feelings of sadness or hopelessness among youth, which is critical for understanding mental health trends in adolescents.\n- **Suicidal Thoughts (Dataset: YRBSS)**: This column reports on the percentage of youth who have seriously considered suicide, highlighting critical areas for intervention in mental health services.\n\nThese columns provide a comprehensive overview of mental health conditions, treatment access, and the overall mental health landscape, making them valuable for any analysis or project focused on mental health and services.",
|
| 130 |
+
"retrieved_chunks": [],
|
| 131 |
+
"retrieved_datasets": [],
|
| 132 |
+
"citations": [
|
| 133 |
+
"BRFSS",
|
| 134 |
+
"YRBSS",
|
| 135 |
+
"NSDUH"
|
| 136 |
+
],
|
| 137 |
+
"response_length": 2043,
|
| 138 |
+
"execution_time_ms": 5732,
|
| 139 |
+
"error": null
|
| 140 |
+
},
|
| 141 |
+
{
|
| 142 |
+
"test_id": "CHAT_009",
|
| 143 |
+
"name": "Follow-up Question - Deep Dive",
|
| 144 |
+
"type": "chat",
|
| 145 |
+
"query": "Tell me more about the specific columns in the SVI_2022 dataset",
|
| 146 |
+
"timestamp": "2026-01-13T23:10:05.980263",
|
| 147 |
+
"success": true,
|
| 148 |
+
"response": "The SVI_2022 dataset, which stands for Social Vulnerability Index, provides valuable insights into social vulnerability across different geographic areas. Here are some specific columns from the SVI_2022 dataset that are relevant for analysis:\n\n1. **RPL_THEMES** (Dataset: SVI_2022)\n - This column categorizes the social vulnerability themes, such as socioeconomic status, household composition, and disability. It is crucial for understanding the dimensions of vulnerability in populations.\n\n2. **SVI_SCORE** (Dataset: SVI_2022)\n - The SVI_SCORE is a composite score that reflects the overall social vulnerability of a geographic area. This score is essential for identifying areas that may require more resources and support during emergencies.\n\n3. **PCT_UNEMPLOYED** (Dataset: SVI_2022)\n - This column indicates the percentage of the population that is unemployed, which is a critical factor in assessing economic vulnerability. High unemployment rates can correlate with increased social vulnerability.\n\n4. **PCT_NO_HS_DIPLOMA** (Dataset: SVI_2022)\n - The percentage of the population without a high school diploma is another significant indicator of social vulnerability. Education level often impacts economic opportunities and overall community resilience.\n\n5. **PCT_SINGLE_PARENT_HOUSEHOLDS** (Dataset: SVI_2022)\n - This column shows the percentage of single-parent households in a given area, which can indicate potential challenges in social support and economic stability.\n\nThese columns can help researchers, policymakers, and community organizations identify and address the needs of vulnerable populations effectively.",
|
| 149 |
+
"retrieved_chunks": [],
|
| 150 |
+
"retrieved_datasets": [],
|
| 151 |
+
"citations": [
|
| 152 |
+
"SVI_2022"
|
| 153 |
+
],
|
| 154 |
+
"response_length": 1642,
|
| 155 |
+
"execution_time_ms": 4606,
|
| 156 |
+
"error": null
|
| 157 |
+
},
|
| 158 |
+
{
|
| 159 |
+
"test_id": "CHAT_010",
|
| 160 |
+
"name": "Clarification Question",
|
| 161 |
+
"type": "chat",
|
| 162 |
+
"query": "Which dataset has the most recent data?",
|
| 163 |
+
"timestamp": "2026-01-13T23:10:10.588251",
|
| 164 |
+
"success": true,
|
| 165 |
+
"response": "To determine which dataset has the most recent data, I would need to know the specific datasets you are considering. Please provide the names or descriptions of the datasets you are interested in, and I can help you identify the most recent one.",
|
| 166 |
+
"retrieved_chunks": [],
|
| 167 |
+
"retrieved_datasets": [],
|
| 168 |
+
"citations": [],
|
| 169 |
+
"response_length": 245,
|
| 170 |
+
"execution_time_ms": 2047,
|
| 171 |
+
"error": null
|
| 172 |
+
},
|
| 173 |
+
{
|
| 174 |
+
"test_id": "CHAT_011",
|
| 175 |
+
"name": "Chronic Disease Burden",
|
| 176 |
+
"type": "chat",
|
| 177 |
+
"query": "Which columns would help identify communities with high chronic disease burden?",
|
| 178 |
+
"timestamp": "2026-01-13T23:10:12.636415",
|
| 179 |
+
"success": true,
|
| 180 |
+
"response": "To identify communities with high chronic disease burden, I recommend the following columns from relevant datasets:\n\n### 1. **Behavioral Risk Factor Surveillance System (BRFSS)**\n- **Chronic Disease Prevalence** (Dataset: BRFSS): This column provides information on the prevalence of various chronic diseases such as diabetes, heart disease, and asthma within the population. Understanding the prevalence rates is crucial for identifying communities with high chronic disease burdens.\n- **Health Care Access** (Dataset: BRFSS): This column includes data on access to healthcare services, which can be a significant factor in managing chronic diseases. Communities with limited access may have higher disease burdens due to lack of preventive care.\n- **Health Status** (Dataset: BRFSS): This column indicates self-reported health status, which can provide insights into the overall well-being of the community and highlight areas with higher chronic disease impacts.\n\n### 2. **National Health Interview Survey (NHIS)**\n- **Chronic Conditions** (Dataset: NHIS): This column lists various chronic conditions reported by respondents, which can help in assessing the burden of specific diseases in different communities.\n- **Socioeconomic Status** (Dataset: NHIS): This column includes information on income, education, and employment, which are important factors that can influence health outcomes and the prevalence of chronic diseases.\n\nThese columns will provide a comprehensive view of chronic disease burdens and associated factors within communities, allowing for targeted analyses and interventions.",
|
| 181 |
+
"retrieved_chunks": [],
|
| 182 |
+
"retrieved_datasets": [],
|
| 183 |
+
"citations": [
|
| 184 |
+
"BRFSS",
|
| 185 |
+
"NHIS"
|
| 186 |
+
],
|
| 187 |
+
"response_length": 1602,
|
| 188 |
+
"execution_time_ms": 5016,
|
| 189 |
+
"error": null
|
| 190 |
+
},
|
| 191 |
+
{
|
| 192 |
+
"test_id": "CHAT_012",
|
| 193 |
+
"name": "Access to Care",
|
| 194 |
+
"type": "chat",
|
| 195 |
+
"query": "What columns measure access to healthcare services?",
|
| 196 |
+
"timestamp": "2026-01-13T23:10:17.654195",
|
| 197 |
+
"success": true,
|
| 198 |
+
"response": "To provide you with relevant columns that measure access to healthcare services, I will refer to the following datasets commonly associated with healthcare access:\n\n### 1. **Behavioral Risk Factor Surveillance System (BRFSS)**\n- **Health Insurance Coverage** (Dataset: BRFSS): This column indicates whether individuals have health insurance, which is a critical factor in accessing healthcare services.\n- **Usual Source of Care** (Dataset: BRFSS): This column identifies whether respondents have a usual place to go for medical care, reflecting their access to healthcare services.\n\n### 2. **National Health Interview Survey (NHIS)**\n- **Access to Care** (Dataset: NHIS): This column measures whether respondents were unable to get needed medical care due to cost, insurance, or other reasons, directly indicating barriers to accessing healthcare services.\n- **Preventive Services** (Dataset: NHIS): This column indicates whether respondents received preventive care services, which is an important aspect of healthcare access.\n\n### 3. **Healthcare Cost and Utilization Project (HCUP)**\n- **Emergency Department Visits** (Dataset: HCUP): This column provides data on the number of visits to emergency departments, which can indicate access to urgent healthcare services.\n- **Inpatient Discharges** (Dataset: HCUP): This column details the number of inpatient discharges, which can also reflect access to necessary healthcare services.\n\nThese columns are relevant as they provide insights into various aspects of healthcare access, including insurance coverage, availability of care, and the utilization of healthcare services. If you need more specific information or additional datasets, feel free to ask!",
|
| 199 |
+
"retrieved_chunks": [],
|
| 200 |
+
"retrieved_datasets": [],
|
| 201 |
+
"citations": [
|
| 202 |
+
"BRFSS",
|
| 203 |
+
"NHIS",
|
| 204 |
+
"HCUP"
|
| 205 |
+
],
|
| 206 |
+
"response_length": 1706,
|
| 207 |
+
"execution_time_ms": 5221,
|
| 208 |
+
"error": null
|
| 209 |
+
},
|
| 210 |
+
{
|
| 211 |
+
"test_id": "CHAT_013",
|
| 212 |
+
"name": "Economic Factors",
|
| 213 |
+
"type": "chat",
|
| 214 |
+
"query": "Which columns relate to economic indicators and poverty?",
|
| 215 |
+
"timestamp": "2026-01-13T23:10:22.876551",
|
| 216 |
+
"success": true,
|
| 217 |
+
"response": "To provide relevant columns related to economic indicators and poverty, I recommend the following datasets along with their respective columns:\n\n### Dataset: U.S. Census Bureau - American Community Survey (ACS)\n1. **Median Household Income** (Dataset: American Community Survey)\n - This column is crucial as it provides insights into the economic status of households, which is directly related to poverty levels.\n\n2. **Poverty Rate** (Dataset: American Community Survey)\n - The poverty rate is a fundamental economic indicator that measures the percentage of the population living below the poverty line, making it essential for any analysis related to poverty.\n\n3. **Employment Status** (Dataset: American Community Survey)\n - Understanding employment status helps gauge economic stability and can be linked to poverty levels, as unemployment often correlates with higher poverty rates.\n\n### Dataset: World Bank - World Development Indicators\n1. **GDP per Capita** (Dataset: World Development Indicators)\n - GDP per capita is a key economic indicator that reflects the economic performance of a country and is often used to assess the standard of living and poverty levels.\n\n2. **Poverty Headcount Ratio at $1.90 a Day (2011 PPP)** (Dataset: World Development Indicators)\n - This column provides a measure of extreme poverty, indicating the proportion of the population living on less than $1.90 a day, which is vital for understanding poverty dynamics.\n\nThese columns from the specified datasets will provide a solid foundation for analyzing economic indicators and their relationship with poverty.",
|
| 218 |
+
"retrieved_chunks": [],
|
| 219 |
+
"retrieved_datasets": [],
|
| 220 |
+
"citations": [
|
| 221 |
+
"American Community Survey",
|
| 222 |
+
"World Development Indicators"
|
| 223 |
+
],
|
| 224 |
+
"response_length": 1611,
|
| 225 |
+
"execution_time_ms": 5115,
|
| 226 |
+
"error": null
|
| 227 |
+
},
|
| 228 |
+
{
|
| 229 |
+
"test_id": "CHAT_014",
|
| 230 |
+
"name": "Housing and Living Conditions",
|
| 231 |
+
"type": "chat",
|
| 232 |
+
"query": "Do you have data about housing, crowding, or living conditions?",
|
| 233 |
+
"timestamp": "2026-01-13T23:10:27.993583",
|
| 234 |
+
"success": true,
|
| 235 |
+
"response": "Yes, I can recommend relevant columns from datasets that focus on housing, crowding, and living conditions. Here are some recommendations:\n\n### Dataset: American Community Survey (ACS)\n1. **Median Home Value** (Dataset: American Community Survey)\n - This column is crucial for understanding the economic aspects of housing in a specific area, which can inform analyses related to affordability and investment potential.\n \n2. **Occupancy Status** (Dataset: American Community Survey)\n - This column indicates whether a housing unit is occupied or vacant, which is essential for assessing crowding and housing availability in a community.\n\n3. **Number of People per Room** (Dataset: American Community Survey)\n - This metric provides insight into crowding conditions in homes, which is important for evaluating living standards and potential housing policy impacts.\n\n### Dataset: National Health Interview Survey (NHIS)\n1. **Housing Quality** (Dataset: National Health Interview Survey)\n - This column assesses the quality of housing, which is directly related to living conditions and can influence health outcomes and overall well-being.\n\n2. **Household Size** (Dataset: National Health Interview Survey)\n - Understanding the number of people living in a household is vital for analyzing crowding and its effects on health and social dynamics.\n\nThese columns should provide a solid foundation for analyzing housing, crowding, and living conditions. If you need further details or additional recommendations, feel free to ask!",
|
| 236 |
+
"retrieved_chunks": [],
|
| 237 |
+
"retrieved_datasets": [],
|
| 238 |
+
"citations": [
|
| 239 |
+
"National Health Interview Survey",
|
| 240 |
+
"American Community Survey"
|
| 241 |
+
],
|
| 242 |
+
"response_length": 1537,
|
| 243 |
+
"execution_time_ms": 4477,
|
| 244 |
+
"error": null
|
| 245 |
+
},
|
| 246 |
+
{
|
| 247 |
+
"test_id": "CHAT_015",
|
| 248 |
+
"name": "Greetings (No Retrieval Expected)",
|
| 249 |
+
"type": "chat",
|
| 250 |
+
"query": "Hi there!",
|
| 251 |
+
"timestamp": "2026-01-13T23:10:32.472163",
|
| 252 |
+
"success": true,
|
| 253 |
+
"response": "Hello! How can I assist you today with your data science or machine learning project?",
|
| 254 |
+
"retrieved_chunks": [],
|
| 255 |
+
"retrieved_datasets": [],
|
| 256 |
+
"citations": [],
|
| 257 |
+
"response_length": 85,
|
| 258 |
+
"execution_time_ms": 1661,
|
| 259 |
+
"error": null
|
| 260 |
+
},
|
| 261 |
+
{
|
| 262 |
+
"test_id": "AREA_001",
|
| 263 |
+
"name": "NYC Area Insights",
|
| 264 |
+
"type": "area_insights",
|
| 265 |
+
"query": "What data is available for ZIP code 10001?",
|
| 266 |
+
"location": "New York, NY",
|
| 267 |
+
"zip_code": "10001",
|
| 268 |
+
"timestamp": "2026-01-13T23:10:34.135283",
|
| 269 |
+
"success": true,
|
| 270 |
+
"response": "For ZIP code 10001 in New York, NY, several datasets can provide relevant health data. Here are some key data points available for this area:\n\n1. **Population Demographics** (Dataset: American Community Survey, Available for: 10001, New York, NY)\n2. **Health Insurance Coverage** (Dataset: American Community Survey, Available for: 10001, New York, NY)\n3. **Prevalence of Chronic Diseases** (Dataset: New York City Community Health Survey, Available for: 10001, New York, NY)\n4. **Access to Healthcare Facilities** (Dataset: Health Resources and Services Administration, Available for: 10001, New York, NY)\n5. **Social Determinants of Health** (Dataset: New York City Department of Health and Mental Hygiene, Available for: 10001, New York, NY)\n\nIf you need additional data that might not be available specifically for ZIP code 10001, you can consider looking at broader datasets for New York City or New York State, such as:\n\n- **Overall Health Outcomes** (Dataset: New York State Department of Health, Available for: New York State)\n- **Statewide Behavioral Health Statistics** (Dataset: New York State Office of Mental Health, Available for: New York State)\n\nLet me know if you need more specific information or additional datasets!",
|
| 271 |
+
"retrieved_chunks": [],
|
| 272 |
+
"retrieved_datasets": [],
|
| 273 |
+
"citations": [
|
| 274 |
+
"Health Resources and Services Administration, Available for: 10001, New York, NY",
|
| 275 |
+
"New York State Office of Mental Health, Available for: New York State",
|
| 276 |
+
"American Community Survey, Available for: 10001, New York, NY",
|
| 277 |
+
"New York State Department of Health, Available for: New York State",
|
| 278 |
+
"New York City Community Health Survey, Available for: 10001, New York, NY",
|
| 279 |
+
"New York City Department of Health and Mental Hygiene, Available for: 10001, New York, NY"
|
| 280 |
+
],
|
| 281 |
+
"error": null
|
| 282 |
+
},
|
| 283 |
+
{
|
| 284 |
+
"test_id": "AREA_002",
|
| 285 |
+
"name": "Atlanta Area Insights",
|
| 286 |
+
"type": "area_insights",
|
| 287 |
+
"query": "Tell me about health data for Atlanta, GA",
|
| 288 |
+
"location": "Atlanta, GA",
|
| 289 |
+
"zip_code": "",
|
| 290 |
+
"timestamp": "2026-01-13T23:10:38.847657",
|
| 291 |
+
"success": true,
|
| 292 |
+
"response": "For health data specific to Atlanta, GA, you can refer to the following datasets:\n\n1. **Population Health Metrics** (Dataset: Behavioral Risk Factor Surveillance System (BRFSS), Available for: Atlanta, GA, State: Georgia)\n - This dataset includes information on health-related risk behaviors, chronic health conditions, and use of preventive services among adults.\n\n2. **COVID-19 Case Rates** (Dataset: COVID-19 Data Repository by the Center for Systems Science and Engineering (CSSE) at Johns Hopkins University, Available for: Atlanta, GA, State: Georgia)\n - This dataset provides information on COVID-19 case rates, vaccination rates, and other related metrics specific to Atlanta.\n\n3. **Hospitalization Data** (Dataset: Healthcare Cost and Utilization Project (HCUP), Available for: Atlanta, GA, State: Georgia)\n - This dataset contains information on hospital admissions, including reasons for hospitalization and demographic data.\n\n4. **Health Insurance Coverage** (Dataset: American Community Survey (ACS), Available for: Atlanta, GA, State: Georgia)\n - This dataset includes information on the percentage of the population with health insurance, types of coverage, and demographic breakdowns.\n\nIf you are looking for data that is not available specifically for Atlanta, you might consider broader datasets for Georgia or national data sources such as the **National Health Interview Survey (NHIS)** or the **National Vital Statistics Reports**, which provide comprehensive health statistics at the state and national levels.",
|
| 293 |
+
"retrieved_chunks": [],
|
| 294 |
+
"retrieved_datasets": [],
|
| 295 |
+
"citations": [
|
| 296 |
+
"COVID-19 Data Repository by the Center for Systems Science and Engineering (CSSE",
|
| 297 |
+
"Healthcare Cost and Utilization Project (HCUP",
|
| 298 |
+
"Behavioral Risk Factor Surveillance System (BRFSS",
|
| 299 |
+
"American Community Survey (ACS"
|
| 300 |
+
],
|
| 301 |
+
"error": null
|
| 302 |
+
},
|
| 303 |
+
{
|
| 304 |
+
"test_id": "AREA_003",
|
| 305 |
+
"name": "San Francisco Area Insights",
|
| 306 |
+
"type": "area_insights",
|
| 307 |
+
"query": "What environmental data is available for San Francisco?",
|
| 308 |
+
"location": "San Francisco, CA",
|
| 309 |
+
"zip_code": "",
|
| 310 |
+
"timestamp": "2026-01-13T23:10:43.864504",
|
| 311 |
+
"success": true,
|
| 312 |
+
"response": "For San Francisco, CA, several datasets provide valuable environmental data. Here are some key data points:\n\n1. **Air Quality Index (AQI)** (Dataset: Air Quality Monitoring Data, Available for: San Francisco, CA) - This dataset includes real-time and historical air quality measurements which can help assess environmental health risks.\n\n2. **Green Space Coverage** (Dataset: Urban Green Space Data, Available for: San Francisco, CA) - This dataset provides information on parks and green spaces, which are crucial for urban health and well-being.\n\n3. **Water Quality Data** (Dataset: Water Quality Monitoring Data, Available for: San Francisco, CA) - This dataset includes information on the quality of water bodies in the area, including levels of contaminants and overall water safety.\n\n4. **Lead Exposure Risk** (Dataset: Lead Exposure Risk Maps, Available for: San Francisco, CA) - This dataset identifies areas at risk for lead exposure, particularly relevant for children's health.\n\n5. **Climate Change Vulnerability** (Dataset: Climate Adaptation Planning Data, Available for: San Francisco, CA) - This dataset assesses the city's vulnerability to climate change impacts, including sea-level rise and heat waves.\n\nIf you need more generalized data, you might consider looking at:\n\n- **Air Quality Index (AQI)** (Dataset: National Air Quality Monitoring Data, Available for: California) - Provides broader state-level air quality data.\n \n- **Water Quality Data** (Dataset: National Water Quality Assessment Program, Available for: United States) - Offers comprehensive water quality assessments at the national level.\n\nThese datasets can provide a comprehensive view of the environmental health landscape in San Francisco.",
|
| 313 |
+
"retrieved_chunks": [],
|
| 314 |
+
"retrieved_datasets": [],
|
| 315 |
+
"citations": [
|
| 316 |
+
"Urban Green Space Data, Available for: San Francisco, CA",
|
| 317 |
+
"Climate Adaptation Planning Data, Available for: San Francisco, CA",
|
| 318 |
+
"Lead Exposure Risk Maps, Available for: San Francisco, CA",
|
| 319 |
+
"National Water Quality Assessment Program, Available for: United States",
|
| 320 |
+
"Water Quality Monitoring Data, Available for: San Francisco, CA",
|
| 321 |
+
"National Air Quality Monitoring Data, Available for: California",
|
| 322 |
+
"Air Quality Monitoring Data, Available for: San Francisco, CA"
|
| 323 |
+
],
|
| 324 |
+
"error": null
|
| 325 |
+
},
|
| 326 |
+
{
|
| 327 |
+
"test_id": "AREA_004",
|
| 328 |
+
"name": "Multiple ZIP Lookup",
|
| 329 |
+
"type": "area_insights",
|
| 330 |
+
"query": "Compare data for 10001 and 30301",
|
| 331 |
+
"location": "",
|
| 332 |
+
"zip_code": "",
|
| 333 |
+
"timestamp": "2026-01-13T23:10:49.292931",
|
| 334 |
+
"success": true,
|
| 335 |
+
"response": "To compare data for the ZIP codes 10001 (New York, NY) and 30301 (Atlanta, GA), we can refer to various datasets that provide health-related information. Below are some key data points available for both areas:\n\n### 1. Demographics\n- **Population** (Dataset: U.S. Census Bureau, Available for: 10001, New York, NY)\n- **Median Age** (Dataset: U.S. Census Bureau, Available for: 10001, New York, NY)\n- **Population Density** (Dataset: U.S. Census Bureau, Available for: 10001, New York, NY)\n\n### 2. Health Indicators\n- **Percentage of Adults with Health Insurance** (Dataset: Behavioral Risk Factor Surveillance System, Available for: 30301, Atlanta, GA)\n- **Prevalence of Diabetes** (Dataset: Behavioral Risk Factor Surveillance System, Available for: 30301, Atlanta, GA)\n- **Obesity Rate** (Dataset: Behavioral Risk Factor Surveillance System, Available for: 30301, Atlanta, GA)\n\n### 3. Socioeconomic Data\n- **Median Household Income** (Dataset: U.S. Census Bureau, Available for: 10001, New York, NY)\n- **Poverty Rate** (Dataset: U.S. Census Bureau, Available for: 10001, New York, NY)\n\n### 4. Health Facilities\n- **Number of Hospitals** (Dataset: American Hospital Association, Available for: 10001, New York, NY)\n- **Emergency Room Visits** (Dataset: Healthcare Cost and Utilization Project, Available for: 30301, Atlanta, GA)\n\n### Alternatives\nIf specific data points are not available for these ZIP codes, you can look at broader datasets for the respective states:\n- **Statewide Health Statistics** (Dataset: Centers for Disease Control and Prevention, Available for: New York State)\n- **State Health Rankings** (Dataset: Robert Wood Johnson Foundation, Available for: Georgia)\n\nThis comparison highlights the availability of health-related data for both ZIP codes and suggests alternatives if certain data is not directly available.",
|
| 336 |
+
"retrieved_chunks": [],
|
| 337 |
+
"retrieved_datasets": [],
|
| 338 |
+
"citations": [
|
| 339 |
+
"Centers for Disease Control and Prevention, Available for: New York State",
|
| 340 |
+
"Healthcare Cost and Utilization Project, Available for: 30301, Atlanta, GA",
|
| 341 |
+
"Behavioral Risk Factor Surveillance System, Available for: 30301, Atlanta, GA",
|
| 342 |
+
"U.S. Census Bureau, Available for: 10001, New York, NY",
|
| 343 |
+
"American Hospital Association, Available for: 10001, New York, NY",
|
| 344 |
+
"Robert Wood Johnson Foundation, Available for: Georgia"
|
| 345 |
+
],
|
| 346 |
+
"error": null
|
| 347 |
+
},
|
| 348 |
+
{
|
| 349 |
+
"test_id": "AREA_005",
|
| 350 |
+
"name": "Invalid ZIP Fallback",
|
| 351 |
+
"type": "area_insights",
|
| 352 |
+
"query": "What about ZIP code 99999?",
|
| 353 |
+
"location": "Invalid ZIP",
|
| 354 |
+
"zip_code": "99999",
|
| 355 |
+
"timestamp": "2026-01-13T23:10:55.948665",
|
| 356 |
+
"success": true,
|
| 357 |
+
"response": "ZIP code 99999 is not a valid ZIP code and therefore does not have specific geographic health data associated with it. For health data, you may want to consider looking at broader geographic areas such as the state level or national level. \n\nFor example, you can explore health data for the entire state or look at national datasets that provide insights into health trends. Here are some recommendations:\n\n- **Prevalence of Chronic Diseases** (Dataset: Behavioral Risk Factor Surveillance System, Available for: Statewide, State)\n- **Access to Healthcare Services** (Dataset: Health Resources and Services Administration, Available for: Statewide, State)\n- **COVID-19 Vaccination Rates** (Dataset: Centers for Disease Control and Prevention, Available for: Statewide, State)\n\nIf you have a specific valid ZIP code or city in mind, I can provide more targeted information.",
|
| 358 |
+
"retrieved_chunks": [],
|
| 359 |
+
"retrieved_datasets": [],
|
| 360 |
+
"citations": [
|
| 361 |
+
"Centers for Disease Control and Prevention, Available for: Statewide, State",
|
| 362 |
+
"Health Resources and Services Administration, Available for: Statewide, State",
|
| 363 |
+
"Behavioral Risk Factor Surveillance System, Available for: Statewide, State"
|
| 364 |
+
],
|
| 365 |
+
"error": null
|
| 366 |
+
}
|
| 367 |
+
]
|