Instructions to use Navaneeth-14/rag-hackathon-app with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- llama.cpp
How to use Navaneeth-14/rag-hackathon-app with llama.cpp:
Install (macOS, Linux)
curl -LsSf https://llama.app/install.sh | sh # Start a local OpenAI-compatible server with a web UI: llama serve -hf Navaneeth-14/rag-hackathon-app:Q4_K_M # Run inference directly in the terminal: llama cli -hf Navaneeth-14/rag-hackathon-app:Q4_K_M
Install from WinGet (Windows)
winget install llama.cpp # Start a local OpenAI-compatible server with a web UI: llama serve -hf Navaneeth-14/rag-hackathon-app:Q4_K_M # Run inference directly in the terminal: llama cli -hf Navaneeth-14/rag-hackathon-app:Q4_K_M
Use pre-built binary
# Download pre-built binary from: # https://github.com/ggerganov/llama.cpp/releases # Start a local OpenAI-compatible server with a web UI: ./llama-server -hf Navaneeth-14/rag-hackathon-app:Q4_K_M # Run inference directly in the terminal: ./llama-cli -hf Navaneeth-14/rag-hackathon-app:Q4_K_M
Build from source code
git clone https://github.com/ggerganov/llama.cpp.git cd llama.cpp cmake -B build cmake --build build -j --target llama-server llama-cli # Start a local OpenAI-compatible server with a web UI: ./build/bin/llama-server -hf Navaneeth-14/rag-hackathon-app:Q4_K_M # Run inference directly in the terminal: ./build/bin/llama-cli -hf Navaneeth-14/rag-hackathon-app:Q4_K_M
Use Docker
docker model run hf.co/Navaneeth-14/rag-hackathon-app:Q4_K_M
- LM Studio
- Jan
- Ollama
How to use Navaneeth-14/rag-hackathon-app with Ollama:
ollama run hf.co/Navaneeth-14/rag-hackathon-app:Q4_K_M
- Unsloth Studio
How to use Navaneeth-14/rag-hackathon-app with Unsloth Studio:
Install Unsloth Studio (macOS, Linux, WSL)
curl -fsSL https://unsloth.ai/install.sh | sh # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for Navaneeth-14/rag-hackathon-app to start chatting
Install Unsloth Studio (Windows)
irm https://unsloth.ai/install.ps1 | iex # Run unsloth studio unsloth studio -H 0.0.0.0 -p 8888 # Then open http://localhost:8888 in your browser # Search for Navaneeth-14/rag-hackathon-app to start chatting
Using HuggingFace Spaces for Unsloth
# No setup required # Open https://huggingface.co/spaces/unsloth/studio in your browser # Search for Navaneeth-14/rag-hackathon-app to start chatting
- Docker Model Runner
How to use Navaneeth-14/rag-hackathon-app with Docker Model Runner:
docker model run hf.co/Navaneeth-14/rag-hackathon-app:Q4_K_M
- Lemonade
How to use Navaneeth-14/rag-hackathon-app with Lemonade:
Pull the model
# Download Lemonade from https://lemonade-server.ai/ lemonade pull Navaneeth-14/rag-hackathon-app:Q4_K_M
Run and chat with the model
lemonade run user.rag-hackathon-app-Q4_K_M
List all available models
lemonade list
- Atomic Chat
File size: 17,256 Bytes
09281fe | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 | """
Test file for Query Parser
Checks if query_parser.py is working correctly with various test cases
"""
import sys
import os
from datetime import datetime
def test_query_parser_import():
"""Test if query parser can be imported without errors"""
print("π§ͺ Testing Query Parser Import")
print("="*40)
try:
from query_parser import AdvancedQueryParser, ParsedQuery, QueryEntity
print("β
Query parser imported successfully")
return True
except Exception as e:
print(f"β Error importing query parser: {e}")
import traceback
traceback.print_exc()
return False
def test_query_parser_initialization():
"""Test if query parser can be initialized"""
print("\nπ§ͺ Testing Query Parser Initialization")
print("="*50)
try:
from query_parser import AdvancedQueryParser
# Test initialization with default parameters
print("π Initializing query parser...")
parser = AdvancedQueryParser(use_gpu=False) # Use CPU for testing
print("β
Query parser initialized successfully")
# Test basic attributes
print("π Checking parser attributes...")
assert hasattr(parser, 'lemmatizer'), "Lemmatizer not found"
assert hasattr(parser, 'stop_words'), "Stop words not found"
assert hasattr(parser, 'insurance_entities'), "Insurance entities not found"
assert hasattr(parser, 'query_types'), "Query types not found"
print("β
All required attributes present")
return True
except Exception as e:
print(f"β Error initializing query parser: {e}")
import traceback
traceback.print_exc()
return False
def test_basic_query_parsing():
"""Test basic query parsing functionality"""
print("\nπ§ͺ Testing Basic Query Parsing")
print("="*40)
try:
from query_parser import AdvancedQueryParser
parser = AdvancedQueryParser(use_gpu=False)
# Test queries
test_queries = [
"Is heart surgery covered?",
"How do I file a claim?",
"What's the waiting period?",
"Can I claim for dental treatment?",
"What documents are needed?"
]
results = []
for i, query in enumerate(test_queries):
print(f"\nπ Test Query {i+1}: {query}")
try:
parsed = parser.parse_query(query)
# Check if parsed query has required attributes
assert hasattr(parsed, 'original_query'), "Missing original_query"
assert hasattr(parsed, 'enhanced_query'), "Missing enhanced_query"
assert hasattr(parsed, 'query_type'), "Missing query_type"
assert hasattr(parsed, 'entities'), "Missing entities"
assert hasattr(parsed, 'intent'), "Missing intent"
assert hasattr(parsed, 'confidence'), "Missing confidence"
assert hasattr(parsed, 'keywords'), "Missing keywords"
assert hasattr(parsed, 'synonyms'), "Missing synonyms"
assert hasattr(parsed, 'context'), "Missing context"
assert hasattr(parsed, 'timestamp'), "Missing timestamp"
print(f" β
Parsed successfully")
print(f" π Type: {parsed.query_type}")
print(f" π― Intent: {parsed.intent}")
print(f" π Confidence: {parsed.confidence:.2f}")
print(f" π Keywords: {parsed.keywords[:3]}")
print(f" π·οΈ Entities: {list(parsed.entities.keys())}")
results.append(True)
except Exception as e:
print(f" β Failed to parse: {e}")
results.append(False)
success_count = sum(results)
total_count = len(results)
print(f"\nπ Basic Parsing Results: {success_count}/{total_count} successful")
return success_count == total_count
except Exception as e:
print(f"β Error in basic query parsing: {e}")
return False
def test_entity_extraction():
"""Test entity extraction functionality"""
print("\nπ§ͺ Testing Entity Extraction")
print("="*40)
try:
from query_parser import AdvancedQueryParser
parser = AdvancedQueryParser(use_gpu=False)
# Test queries with specific entities
test_cases = [
{
'query': "Is heart surgery covered under my policy?",
'expected_entities': ['medical_condition', 'coverage_type']
},
{
'query': "Can I claim $5000 for dental treatment?",
'expected_entities': ['amount', 'medical_condition']
},
{
'query': "What's the 30-day waiting period for pre-existing conditions?",
'expected_entities': ['time_period']
},
{
'query': "Do I need a doctor's report for this claim?",
'expected_entities': ['document_type']
}
]
results = []
for i, test_case in enumerate(test_cases):
query = test_case['query']
expected_entities = test_case['expected_entities']
print(f"\nπ Test Case {i+1}: {query}")
try:
parsed = parser.parse_query(query)
extracted_entities = list(parsed.entities.keys())
print(f" π·οΈ Extracted entities: {extracted_entities}")
print(f" π― Expected entities: {expected_entities}")
# Check if any expected entities were found
found_entities = [entity for entity in expected_entities if entity in extracted_entities]
if found_entities:
print(f" β
Found expected entities: {found_entities}")
results.append(True)
else:
print(f" β οΈ No expected entities found")
results.append(False)
except Exception as e:
print(f" β Error: {e}")
results.append(False)
success_count = sum(results)
total_count = len(results)
print(f"\nπ Entity Extraction Results: {success_count}/{total_count} successful")
return success_count > 0 # At least some entities should be found
except Exception as e:
print(f"β Error in entity extraction: {e}")
return False
def test_query_classification():
"""Test query type classification"""
print("\nπ§ͺ Testing Query Classification")
print("="*40)
try:
from query_parser import AdvancedQueryParser
parser = AdvancedQueryParser(use_gpu=False)
# Test queries for different types
test_cases = [
{
'query': "How do I file a claim?",
'expected_type': 'claim_inquiry'
},
{
'query': "What is covered under my policy?",
'expected_type': 'coverage_check'
},
{
'query': "What are the policy terms?",
'expected_type': 'policy_review'
},
{
'query': "Is dental treatment covered?",
'expected_type': 'medical_coverage'
},
{
'query': "What is this document about?",
'expected_type': 'general_inquiry'
}
]
results = []
for i, test_case in enumerate(test_cases):
query = test_case['query']
expected_type = test_case['expected_type']
print(f"\nπ Test Case {i+1}: {query}")
try:
parsed = parser.parse_query(query)
actual_type = parsed.query_type
print(f" π― Expected type: {expected_type}")
print(f" π Actual type: {actual_type}")
print(f" π Confidence: {parsed.confidence:.2f}")
if actual_type == expected_type:
print(f" β
Classification correct")
results.append(True)
else:
print(f" β οΈ Classification mismatch")
results.append(False)
except Exception as e:
print(f" β Error: {e}")
results.append(False)
success_count = sum(results)
total_count = len(results)
print(f"\nπ Classification Results: {success_count}/{total_count} correct")
return success_count > 0 # At least some classifications should work
except Exception as e:
print(f"β Error in query classification: {e}")
return False
def test_query_suggestions():
"""Test query suggestion functionality"""
print("\nπ§ͺ Testing Query Suggestions")
print("="*40)
try:
from query_parser import AdvancedQueryParser
parser = AdvancedQueryParser(use_gpu=False)
# Test queries for suggestions
test_queries = [
"claim",
"coverage",
"medical",
"policy",
"documents"
]
results = []
for i, query in enumerate(test_queries):
print(f"\nπ Test Query {i+1}: {query}")
try:
suggestions = parser.get_query_suggestions(query)
print(f" π‘ Suggestions: {len(suggestions)} found")
for j, suggestion in enumerate(suggestions[:2]):
print(f" {j+1}. {suggestion}")
if suggestions:
print(f" β
Suggestions generated successfully")
results.append(True)
else:
print(f" β οΈ No suggestions generated")
results.append(False)
except Exception as e:
print(f" β Error: {e}")
results.append(False)
success_count = sum(results)
total_count = len(results)
print(f"\nπ Suggestion Results: {success_count}/{total_count} successful")
return success_count > 0 # At least some suggestions should work
except Exception as e:
print(f"β Error in query suggestions: {e}")
return False
def test_error_handling():
"""Test error handling with invalid inputs"""
print("\nπ§ͺ Testing Error Handling")
print("="*40)
try:
from query_parser import AdvancedQueryParser
parser = AdvancedQueryParser(use_gpu=False)
# Test with invalid inputs
invalid_inputs = [
"", # Empty string
" ", # Whitespace only
"a", # Single character
"123", # Numbers only
"!@#$%", # Special characters only
None # None value
]
results = []
for i, invalid_input in enumerate(invalid_inputs):
print(f"\nπ Test Case {i+1}: {repr(invalid_input)}")
try:
parsed = parser.parse_query(invalid_input)
# Should return a basic parsed query
assert parsed is not None, "Should return a parsed query"
assert hasattr(parsed, 'original_query'), "Should have original_query"
assert hasattr(parsed, 'enhanced_query'), "Should have enhanced_query"
print(f" β
Handled gracefully")
results.append(True)
except Exception as e:
print(f" β Error: {e}")
results.append(False)
success_count = sum(results)
total_count = len(results)
print(f"\nπ Error Handling Results: {success_count}/{total_count} handled")
return success_count > 0 # At least some should be handled
except Exception as e:
print(f"β Error in error handling test: {e}")
return False
def test_comprehensive_workflow():
"""Test a comprehensive workflow with real-world queries"""
print("\nπ§ͺ Testing Comprehensive Workflow")
print("="*50)
try:
from query_parser import AdvancedQueryParser
parser = AdvancedQueryParser(use_gpu=False)
# Real-world insurance queries
real_queries = [
"I need to file a claim for my recent heart surgery that cost $25,000",
"What's covered under my health insurance policy for dental procedures?",
"How long is the waiting period for pre-existing conditions?",
"Do I need a doctor's report and medical certificate for this claim?",
"Can I claim for prescription medications and hospital stays?"
]
results = []
for i, query in enumerate(real_queries):
print(f"\nπ Real Query {i+1}: {query}")
try:
parsed = parser.parse_query(query)
print(f" π Type: {parsed.query_type}")
print(f" π― Intent: {parsed.intent}")
print(f" π Confidence: {parsed.confidence:.2f}")
print(f" π Keywords: {parsed.keywords[:5]}")
print(f" π·οΈ Entities: {list(parsed.entities.keys())}")
# Check if enhanced query is different from original
if parsed.enhanced_query != parsed.original_query:
print(f" β¨ Query enhanced successfully")
# Check if we have meaningful results
if parsed.confidence > 0.0 or parsed.keywords or parsed.entities:
print(f" β
Meaningful results extracted")
results.append(True)
else:
print(f" β οΈ Limited results")
results.append(False)
except Exception as e:
print(f" β Error: {e}")
results.append(False)
success_count = sum(results)
total_count = len(results)
print(f"\nπ Comprehensive Results: {success_count}/{total_count} successful")
return success_count > 0 # At least some should work
except Exception as e:
print(f"β Error in comprehensive workflow: {e}")
return False
def main():
"""Run all tests"""
print("π Query Parser Test Suite")
print("="*60)
print("Testing query_parser.py functionality")
print()
# Run all tests
tests = [
("Import Test", test_query_parser_import),
("Initialization Test", test_query_parser_initialization),
("Basic Parsing Test", test_basic_query_parsing),
("Entity Extraction Test", test_entity_extraction),
("Query Classification Test", test_query_classification),
("Query Suggestions Test", test_query_suggestions),
("Error Handling Test", test_error_handling),
("Comprehensive Workflow Test", test_comprehensive_workflow)
]
results = {}
for test_name, test_func in tests:
print(f"\n{'='*60}")
print(f"π§ͺ Running {test_name}")
print(f"{'='*60}")
success = test_func()
results[test_name] = success
if success:
print(f"β
{test_name} PASSED")
else:
print(f"β {test_name} FAILED")
# Summary
print(f"\n{'='*60}")
print("π TEST SUMMARY")
print(f"{'='*60}")
passed = sum(results.values())
total = len(results)
for test_name, success in results.items():
status = "β
PASS" if success else "β FAIL"
print(f"{test_name:<30}: {status}")
print(f"\nOverall: {passed}/{total} tests passed")
if passed == total:
print("π All tests passed! Your query parser is working correctly.")
elif passed > total // 2:
print("β οΈ Most tests passed, but some issues need attention.")
print("\nπ‘ Areas to check:")
for test_name, success in results.items():
if not success:
print(f" - {test_name}")
else:
print("β Many tests failed. Check the error messages above.")
print("\nπ‘ Common issues:")
print(" - Missing dependencies (NLTK, spaCy)")
print(" - Import errors")
print(" - Initialization problems")
if __name__ == "__main__":
main() |