mirror of
https://github.com/zylon-ai/private-gpt.git
synced 2025-12-22 20:12:55 +01:00
Update ui.py
add a setting named USE_HYPERLINKS_FOR_SOURCES
This commit is contained in:
parent
971c9780d0
commit
3665da2eb3
1 changed files with 5 additions and 4 deletions
|
|
@ -59,6 +59,7 @@ class Source(BaseModel):
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
frozen = True
|
frozen = True
|
||||||
|
USE_HYPERLINKS_FOR_SOURCES: bool = True
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def curate_sources(sources: list[Chunk]) -> list["Source"]:
|
def curate_sources(sources: list[Chunk]) -> list["Source"]:
|
||||||
|
|
@ -128,10 +129,10 @@ class PrivateGptUi:
|
||||||
used_files = set()
|
used_files = set()
|
||||||
for index, source in enumerate(cur_sources, start=1):
|
for index, source in enumerate(cur_sources, start=1):
|
||||||
if f"{source.file}-{source.page}" not in used_files:
|
if f"{source.file}-{source.page}" not in used_files:
|
||||||
sources_text = (
|
if settings().USE_HYPERLINKS_FOR_SOURCES:
|
||||||
sources_text
|
sources_text += f"{index}. {source.to_hyperlink()} \n\n"
|
||||||
+ f"{index}. {source.to_hyperlink()} \n\n"
|
else:
|
||||||
)
|
sources_text += f"{index}. {source.to_text()} \n\n"
|
||||||
used_files.add(f"{source.file}-{source.page}")
|
used_files.add(f"{source.file}-{source.page}")
|
||||||
sources_text += "<hr>\n\n"
|
sources_text += "<hr>\n\n"
|
||||||
full_response += sources_text
|
full_response += sources_text
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue