Test a sample query if tables exist
(agent)
| 114 | return False |
| 115 | |
| 116 | def check_sample_query(agent): |
| 117 | """Test a sample query if tables exist""" |
| 118 | print_status("Testing sample query...") |
| 119 | try: |
| 120 | import lancedb |
| 121 | db = lancedb.connect('./lancedb') |
| 122 | tables = db.table_names() |
| 123 | |
| 124 | if not tables: |
| 125 | print_status("No tables available for query test", None) |
| 126 | return True |
| 127 | |
| 128 | # Use first available table |
| 129 | table_name = tables[0] |
| 130 | print_status(f"Testing query on table: {table_name}") |
| 131 | |
| 132 | result = agent.run('what is this document about?', table_name=table_name) |
| 133 | |
| 134 | if result and 'answer' in result: |
| 135 | print_status("Sample query successful", True) |
| 136 | print(f"📝 Answer preview: {result['answer'][:100]}...") |
| 137 | print(f"📊 Found {len(result.get('source_documents', []))} source documents") |
| 138 | else: |
| 139 | print_status("Query returned empty result", None) |
| 140 | |
| 141 | return True |
| 142 | except Exception as e: |
| 143 | print_status(f"Sample query failed: {e}", False) |
| 144 | return False |
| 145 | |
| 146 | def main(): |
| 147 | """Run complete system health check""" |
no test coverage detected