Skip to content

Commit

Permalink
feat: don't print relevance score by default
Browse files Browse the repository at this point in the history
  • Loading branch information
Miyou committed Feb 4, 2025
1 parent 2265bbe commit 1aa5797
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions gptme_rag/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,11 @@ def index(
type=click.Choice(["cuda", "cpu"]),
help="Device to run embeddings on (cuda or cpu)",
)
@click.option(
"--print-relevance",
is_flag=True,
help="Print relevance scores",
)
def search(
query: str,
paths: list[Path],
Expand All @@ -371,6 +376,7 @@ def search(
weights: str | None,
embedding_function: str | None,
device: str | None,
print_relevance: bool,
):
"""Search the index and assemble context."""
paths = [path.resolve() for path in paths]
Expand Down Expand Up @@ -477,7 +483,7 @@ def get_expanded_content(doc: Document, expand: str, indexer: Indexer) -> str:
if format == "full":
for i, doc in enumerate(documents):
# Show relevance info first
if distances:
if distances and print_relevance:
formatter.print_relevance(1 - distances[i])

# Get and format content
Expand Down Expand Up @@ -529,7 +535,8 @@ def get_expanded_content(doc: Document, expand: str, indexer: Indexer) -> str:
console.print(f"\n {'Total':15} [bold blue]{total:>7.3f}[/bold blue]")
else:
# Just show the base relevance score
formatter.print_relevance(1 - distances[i])
if distances and print_relevance:
formatter.print_relevance(1 - distances[i])

# Display preview
formatter.print_preview(doc)
Expand Down

0 comments on commit 1aa5797

Please sign in to comment.