-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_query.py
More file actions
30 lines (24 loc) · 815 Bytes
/
test_query.py
File metadata and controls
30 lines (24 loc) · 815 Bytes
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
#!/usr/bin/env python3
"""
Test the query_codebase method to get structured results.
"""
import os
import json
from app.main import CodeEmbedder
def main():
"""Run the test query."""
# Create a data directory for the database
data_dir = os.path.join(os.path.dirname(__file__), "data")
os.makedirs(data_dir, exist_ok=True)
# Initialize the code embedder
print("Initializing CodeEmbedder...")
embedder = CodeEmbedder(data_dir=data_dir)
# Use the query_codebase method
query = "how to process CSV data"
print(f"Querying codebase with: '{query}'")
results = embedder.query_codebase(query, top_k=3)
# Pretty print the structured results
print("\nStructured Results:")
print(json.dumps(results, indent=2))
if __name__ == "__main__":
main()