Skip to content

Commit da674c0

Browse files
committed
fix(query): preserve CamelCase in code term extraction
Pass original query to _extract_code_terms instead of lowercased version
1 parent 331a580 commit da674c0

12 files changed

Lines changed: 53 additions & 23 deletions

backend/routes/playground.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -421,8 +421,9 @@ async def playground_search(
421421
try:
422422
sanitized_query = InputValidator.sanitize_string(request.query, max_length=200)
423423

424-
# Check cache
425-
cached_results = cache.get_search_results(sanitized_query, repo_id)
424+
# Check cache (include flags in key to avoid returning wrong results)
425+
cache_key = f"{sanitized_query}:v3={request.use_v3}:tests={request.include_tests}"
426+
cached_results = cache.get_search_results(cache_key, repo_id)
426427
if cached_results:
427428
return {
428429
"results": cached_results,
@@ -468,8 +469,8 @@ async def playground_search(
468469
"is_test_file": r.get("is_test_file", False), # V3 feature
469470
})
470471

471-
# Cache results
472-
cache.set_search_results(sanitized_query, repo_id, results, ttl=3600)
472+
# Cache results (using same key that includes flags)
473+
cache.set_search_results(cache_key, repo_id, results, ttl=3600)
473474

474475
search_time = int((time.time() - start_time) * 1000)
475476

backend/scripts/benchmark_search_v3.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,8 @@ async def run_benchmark(repo_id: str):
232232
else:
233233
print("⚠️ Voyage AI not enabled - using OpenAI embeddings")
234234
print(" Set VOYAGE_API_KEY for better code search accuracy!")
235-
except:
236-
pass
235+
except Exception as e:
236+
print(f"⚠️ Could not check Voyage status: {e}")
237237

238238

239239
if __name__ == "__main__":

backend/scripts/cross_repo_test.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77
import sys
88

99
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
10-
os.environ["VOYAGE_API_KEY"] = "pa-LPXoLbJ3W-S01F70zQsHcRFUTPXZ52dZ3d9PrXnxm7A"
10+
11+
# Load from environment (set in .env or export manually)
12+
if not os.environ.get("VOYAGE_API_KEY"):
13+
print("❌ VOYAGE_API_KEY not set. Export it or add to .env file.")
14+
sys.exit(1)
1115

1216
from services.indexer_optimized import OptimizedCodeIndexer
1317

backend/scripts/edge_case_test.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,11 @@
77
import sys
88

99
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
10-
os.environ["VOYAGE_API_KEY"] = "pa-LPXoLbJ3W-S01F70zQsHcRFUTPXZ52dZ3d9PrXnxm7A"
10+
11+
# Load from environment (set in .env or export manually)
12+
if not os.environ.get("VOYAGE_API_KEY"):
13+
print("❌ VOYAGE_API_KEY not set. Export it or add to .env file.")
14+
sys.exit(1)
1115

1216
from services.indexer_optimized import OptimizedCodeIndexer
1317

backend/scripts/extended_query_test.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88
import time
99

1010
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
11-
os.environ["VOYAGE_API_KEY"] = "pa-LPXoLbJ3W-S01F70zQsHcRFUTPXZ52dZ3d9PrXnxm7A"
11+
12+
# Load from environment (set in .env or export manually)
13+
if not os.environ.get("VOYAGE_API_KEY"):
14+
print("❌ VOYAGE_API_KEY not set. Export it or add to .env file.")
15+
sys.exit(1)
1216

1317
from services.indexer_optimized import OptimizedCodeIndexer
1418

backend/scripts/extended_v3_test.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88
import sys
99

1010
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
11-
os.environ["VOYAGE_API_KEY"] = "pa-LPXoLbJ3W-S01F70zQsHcRFUTPXZ52dZ3d9PrXnxm7A"
11+
12+
# Load from environment (set in .env or export manually)
13+
if not os.environ.get("VOYAGE_API_KEY"):
14+
print("❌ VOYAGE_API_KEY not set. Export it or add to .env file.")
15+
sys.exit(1)
1216

1317
from services.indexer_optimized import OptimizedCodeIndexer
1418

@@ -61,13 +65,15 @@ async def run_extended_tests():
6165
# V2
6266
try:
6367
v2_results = await indexer.search_v2(query, repo_id, top_k=3)
64-
except:
68+
except Exception as e:
69+
print(f" V2 error: {e}")
6570
v2_results = []
6671

6772
# V3
6873
try:
6974
v3_results = await indexer.search_v3(query, repo_id, top_k=3, include_tests=False)
70-
except:
75+
except Exception as e:
76+
print(f" V3 error: {e}")
7177
v3_results = []
7278

7379
# Check for test files in top 3

backend/scripts/final_v3_test.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88
import time
99

1010
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
11-
os.environ["VOYAGE_API_KEY"] = "pa-LPXoLbJ3W-S01F70zQsHcRFUTPXZ52dZ3d9PrXnxm7A"
11+
12+
# Load from environment (set in .env or export manually)
13+
if not os.environ.get("VOYAGE_API_KEY"):
14+
print("❌ VOYAGE_API_KEY not set. Export it or add to .env file.")
15+
sys.exit(1)
1216

1317
from services.indexer_optimized import OptimizedCodeIndexer
1418

backend/scripts/human_query_test.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@
1010

1111
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
1212

13-
# Set env vars before imports
14-
os.environ["VOYAGE_API_KEY"] = "pa-LPXoLbJ3W-S01F70zQsHcRFUTPXZ52dZ3d9PrXnxm7A"
13+
# Load from environment (set in .env or export manually)
14+
if not os.environ.get("VOYAGE_API_KEY"):
15+
print("❌ VOYAGE_API_KEY not set. Export it or add to .env file.")
16+
sys.exit(1)
1517

1618
from services.indexer_optimized import OptimizedCodeIndexer
1719

backend/services/indexer_optimized.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,6 @@ async def embed_query(q: str) -> List[float]:
547547
pinecone_index=self.index,
548548
embedding_fn=embed_query,
549549
)
550-
searcher.embed = embed_query
551550

552551
results = await searcher.search(
553552
query=query,

backend/services/search_v3/code_graph_ranker.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,9 @@ def calculate_importance(
9191
# find max for normalization
9292
max_dependents = max(dependent_counts.values()) if dependent_counts else 1
9393

94-
# calculate importance for each file
95-
for file_path in file_dependencies.keys():
94+
# calculate importance for each file (include files that only appear as dependencies)
95+
all_files = set(file_dependencies.keys()) | set(dependent_counts.keys())
96+
for file_path in all_files:
9697
is_test = self._is_test_file(file_path)
9798
is_core = self._is_core_file(file_path)
9899
dep_count = dependent_counts.get(file_path, 0)

0 commit comments

Comments
 (0)