@@ -109,7 +109,7 @@ def print_content(self, content: str, doc: Document):
109
109
else Syntax (content , lexer , theme = "monokai" , word_wrap = True )
110
110
)
111
111
112
- def print_relevance (self , relevance : float ):
112
+ def print_score (self , relevance : float ):
113
113
"""Print relevance score."""
114
114
self .console .print (f"\n [yellow]Relevance: { relevance :.2f} [/yellow]" )
115
115
@@ -342,6 +342,11 @@ def index(
342
342
help = "Context expansion: none (matched chunks), adjacent (with neighboring chunks), file (entire file)" ,
343
343
)
344
344
@click .option ("--raw" , is_flag = True , help = "Skip syntax highlighting" )
345
+ @click .option (
346
+ "--score" ,
347
+ is_flag = True ,
348
+ help = "Output relevance scores" ,
349
+ )
345
350
@click .option ("--explain" , is_flag = True , help = "Show scoring explanations" )
346
351
@click .option (
347
352
"--weights" ,
@@ -370,6 +375,7 @@ def search(
370
375
n_results : int ,
371
376
persist_dir : Path ,
372
377
max_tokens : int ,
378
+ score : bool ,
373
379
format : str ,
374
380
expand : str ,
375
381
raw : bool ,
@@ -406,9 +412,9 @@ def search(
406
412
persist_directory = persist_dir ,
407
413
enable_persist = True ,
408
414
scoring_weights = scoring_weights ,
409
- embedding_function = "modernbert"
410
- if embedding_function is None
411
- else embedding_function ,
415
+ embedding_function = (
416
+ "modernbert" if embedding_function is None else embedding_function
417
+ ) ,
412
418
device = device or "cpu" ,
413
419
)
414
420
assembler = ContextAssembler (max_tokens = max_tokens )
@@ -498,8 +504,8 @@ def get_expanded_content(doc: Document, expand: str, indexer: Indexer) -> str:
498
504
if format == "full" :
499
505
for i , doc in enumerate (documents ):
500
506
# Show relevance info first
501
- if distances :
502
- formatter .print_relevance (1 - distances [i ])
507
+ if distances and score :
508
+ formatter .print_score (1 - distances [i ])
503
509
504
510
# Get and format content
505
511
content = get_expanded_content (doc , expand , indexer )
@@ -550,7 +556,8 @@ def get_expanded_content(doc: Document, expand: str, indexer: Indexer) -> str:
550
556
console .print (f"\n { 'Total' :15} [bold blue]{ total :>7.3f} [/bold blue]" )
551
557
else :
552
558
# Just show the base relevance score
553
- formatter .print_relevance (1 - distances [i ])
559
+ if distances and score :
560
+ formatter .print_score (1 - distances [i ])
554
561
555
562
# Display preview
556
563
formatter .print_preview (doc )
@@ -617,9 +624,9 @@ def watch(
617
624
indexer = Indexer (
618
625
persist_directory = persist_dir ,
619
626
enable_persist = True ,
620
- embedding_function = "modernbert"
621
- if embedding_function is None
622
- else embedding_function ,
627
+ embedding_function = (
628
+ "modernbert" if embedding_function is None else embedding_function
629
+ ) ,
623
630
device = device or "cpu" ,
624
631
chunk_size = chunk_size , # Now optional in Indexer
625
632
chunk_overlap = chunk_overlap , # Now optional in Indexer
0 commit comments