Skip to content

Commit

Permalink
feat(ui): add sources check to not repeat identical sources (#1705)
Browse files Browse the repository at this point in the history
  • Loading branch information
icsy7867 committed Mar 11, 2024
1 parent 1b03b36 commit 290b9fb
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions private_gpt/ui/ui.py
Expand Up @@ -96,10 +96,15 @@ def yield_deltas(completion_gen: CompletionGen) -> Iterable[str]:
if completion_gen.sources:
full_response += SOURCES_SEPARATOR
cur_sources = Source.curate_sources(completion_gen.sources)
sources_text = "\n\n\n".join(
f"{index}. {source.file} (page {source.page})"
for index, source in enumerate(cur_sources, start=1)
)
sources_text = "\n\n\n"
used_files = set()
for index, source in enumerate(cur_sources, start=1):
if (source.file + "-" + source.page) not in used_files:
sources_text = (
sources_text
+ f"{index}. {source.file} (page {source.page}) \n\n"
)
used_files.add(source.file + "-" + source.page)
full_response += sources_text
yield full_response

Expand Down

0 comments on commit 290b9fb

Please sign in to comment.