Skip to content

Commit

Permalink
Add page id to extra_info (run-llama#542)
Browse files Browse the repository at this point in the history
Add page id to extra_info
  • Loading branch information
kbohra authored Sep 28, 2023
1 parent 08f6157 commit 2086fb2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
4 changes: 3 additions & 1 deletion llama_hub/confluence/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,9 @@ def process_page(self, page, include_attachments, text_maker):
attachment_texts
)
return Document(
text=text, doc_id=page["id"], extra_info={"title": page["title"]}
text=text,
doc_id=page["id"],
extra_info={"title": page["title"], "page_id": page["id"]},
)

def process_attachment(self, page_id):
Expand Down
12 changes: 6 additions & 6 deletions tests/tests_confluence/test_confluence_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ def test_confluence_reader_load_data_by_page_ids(self, mock_confluence):
assert len(documents) == 2
assert all(isinstance(doc, Document) for doc in documents)
assert documents[0].doc_id == "123"
assert documents[0].extra_info == {"title": "Page 123"}
assert documents[0].extra_info == {"title": "Page 123", "page_id": "123"}
assert documents[1].doc_id == "456"
assert documents[1].extra_info == {"title": "Page 456"}
assert documents[1].extra_info == {"title": "Page 456", "page_id": "456"}

assert mock_confluence.get_page_by_id.call_count == 2

Expand Down Expand Up @@ -205,9 +205,9 @@ def test_confluence_reader_load_data_by_space_id(self, mock_confluence):
assert len(documents) == 2
assert all(isinstance(doc, Document) for doc in documents)
assert documents[0].doc_id == "123"
assert documents[0].extra_info == {"title": "Page 123"}
assert documents[0].extra_info == {"title": "Page 123", "page_id": "123"}
assert documents[1].doc_id == "456"
assert documents[1].extra_info == {"title": "Page 456"}
assert documents[1].extra_info == {"title": "Page 456", "page_id": "456"}

assert mock_confluence.get_page_by_id.call_count == 0
assert mock_confluence.get_all_pages_by_label.call_count == 0
Expand Down Expand Up @@ -256,9 +256,9 @@ def test_confluence_reader_load_data_by_space_id_pagination(self, mock_confluenc
assert len(documents) == 2
assert all(isinstance(doc, Document) for doc in documents)
assert documents[0].doc_id == "123"
assert documents[0].extra_info == {"title": "Page 123"}
assert documents[0].extra_info == {"title": "Page 123", "page_id": "123"}
assert documents[1].doc_id == "456"
assert documents[1].extra_info == {"title": "Page 456"}
assert documents[1].extra_info == {"title": "Page 456", "page_id": "456"}

assert mock_confluence.get_page_by_id.call_count == 0
assert mock_confluence.get_all_pages_by_label.call_count == 0
Expand Down

0 comments on commit 2086fb2

Please sign in to comment.