-
Notifications
You must be signed in to change notification settings - Fork 7.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Source Link to the sources #2036
base: main
Are you sure you want to change the base?
Conversation
# Sort the uploaded files alphabetically
Change Source to hyperlink to local pdf with corresponding page
add a setting named USE_HYPERLINKS_FOR_SOURCES
@@ -55,9 +55,11 @@ class Source(BaseModel): | |||
file: str | |||
page: str | |||
text: str | |||
pdf_prefix: str = "C:/UsedFilesFolder/" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you cannot assume that. You will need to store files in a folder in addition to current process
|
||
def to_hyperlink(self) -> str: | ||
encoded_file = self.file.replace(" ", "%20") | ||
file_path = f"{self.pdf_prefix}{encoded_file}#page={self.page}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#page
will only work when it's a doc and it's indexable (e.g. pdf)
sources_text | ||
+ f"{index}. {source.file} (page {source.page}) \n\n" | ||
) | ||
if settings().USE_HYPERLINKS_FOR_SOURCES: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is a ui setting object. The best idea is create a new filed in UI settings and create a boolean property
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, you will need to do more than you might expect. Storing files in the local folder may not be trivial. If anything, please update the PR, ping me and we'll check it out :)
Description
This change does two things. The files to be used on the left-hand side are sorted alphabetically. This makes it easier to find the individual files you want to work with.
Furthermore, the variable USE_HYPERLINKS_FOR_SOURCES = TRUE can be used to refer to local sources via hyperlink.
BUG: Hyperlink is generated but cannot be clicked.
Type of Change
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Test Configuration:
Checklist:
make check; make test
to ensure mypy and tests pass