Skip to content
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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Add Source Link to the sources #2036

wants to merge 3 commits into from

Conversation

slale-91
Copy link

@slale-91 slale-91 commented Aug 5, 2024

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

  • New feature (non-breaking change which adds functionality)

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

  • I stared at the code and made sure it makes sense

Test Configuration:

  • Firmware version:
  • Hardware:
  • Toolchain:
  • SDK:

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I ran make check; make test to ensure mypy and tests pass

# Sort the uploaded files alphabetically
Change Source to hyperlink to local pdf with corresponding page
add a setting named USE_HYPERLINKS_FOR_SOURCES
@slale-91
Copy link
Author

slale-91 commented Aug 5, 2024

image

@@ -55,9 +55,11 @@ class Source(BaseModel):
file: str
page: str
text: str
pdf_prefix: str = "C:/UsedFilesFolder/"
Copy link
Collaborator

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}"
Copy link
Collaborator

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:
Copy link
Collaborator

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

Copy link
Collaborator

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants