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

added page(s) to 341 line #274

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion ragna/deploy/_ui/central_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,9 +336,16 @@ def on_click_source_info_wrapper(self, event, sources):
]
for rank, source in enumerate(sources, 1):
location = source["location"]
pages = source["document"].get("pages")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

source["document"] does not have a field called pages. You can find the schemas here

class Source(BaseModel):
# See orm.Source on why this is not a UUID
id: str
document: Document
location: str

class Document(BaseModel):
id: uuid.UUID = Field(default_factory=uuid.uuid4)
name: str

The location field is what you want. You can check if it is a non-empty string and if yes, prepend page(s) to it. You can use the following existing block for it:

if location:
location = f": {location}"


if location:
location = f": {location}"
markdown.append(f"{rank}. **{source['document']['name']}**{location}")

if pages:
pages_str = ', '.join(f"Page(s) {page}" for page in pages)
markdown.append(f"{rank}. **{source['document']['name']}**: {pages_str}{location}")
else:
markdown.append(f"{rank}. **{source['document']['name']}**{location}")
markdown.append("----")

self.on_click_chat_info(
Expand Down