feat(ui): add sources check to not repeat identical sources (#1705)
This commit is contained in:
		
							parent
							
								
									1b03b369c0
								
							
						
					
					
						commit
						290b9fb084
					
				|  | @ -96,10 +96,15 @@ class PrivateGptUi: | ||||||
|             if completion_gen.sources: |             if completion_gen.sources: | ||||||
|                 full_response += SOURCES_SEPARATOR |                 full_response += SOURCES_SEPARATOR | ||||||
|                 cur_sources = Source.curate_sources(completion_gen.sources) |                 cur_sources = Source.curate_sources(completion_gen.sources) | ||||||
|                 sources_text = "\n\n\n".join( |                 sources_text = "\n\n\n" | ||||||
|                     f"{index}. {source.file} (page {source.page})" |                 used_files = set() | ||||||
|                     for index, source in enumerate(cur_sources, start=1) |                 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 |                 full_response += sources_text | ||||||
|             yield full_response |             yield full_response | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue