Skip to content

Commit

Permalink
feat: add emoji to the tui rank results
Browse files Browse the repository at this point in the history
Signed-off-by: Keming <[email protected]>
  • Loading branch information
kemingy committed Apr 4, 2024
1 parent d00b725 commit e96b239
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions tui.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,14 @@ def fill_retrieve(self, retrieve: RetrieveResponse):
table.add_row(doc.id, doc.title, doc.text)

def fill_rank(self, ranked: RankedResponse):
def check_index_value(value: int | None) -> str:
return "❌" if value is None else value
def pretty_index_value(value: int | None, base: int) -> str:
if value is None:
return "❌"
if value > base:
return f"🔼{value}"
elif value < base:
return f"🔽{value}"
return f"🔵{value}"

time = self.query_one(Static)
time.update(f"Time cost: {ranked.elapsed:.6f}")
Expand All @@ -96,9 +102,9 @@ def check_index_value(value: int | None) -> str:
):
table.add_row(
i,
check_index_value(from_vec),
check_index_value(from_sparse),
check_index_value(from_text),
pretty_index_value(from_vec, i),
pretty_index_value(from_sparse, i),
pretty_index_value(from_text, i),
doc.id,
doc.title,
doc.text,
Expand Down

0 comments on commit e96b239

Please sign in to comment.