(self, tmp_path)
| 1615 | class TestCompileLongDoc: |
| 1616 | @pytest.mark.asyncio |
| 1617 | async def test_full_pipeline(self, tmp_path): |
| 1618 | wiki = tmp_path / "wiki" |
| 1619 | (wiki / "summaries").mkdir(parents=True) |
| 1620 | (wiki / "concepts").mkdir(parents=True) |
| 1621 | (wiki / "index.md").write_text( |
| 1622 | "# Index\n\n## Documents\n\n## Concepts\n", |
| 1623 | encoding="utf-8", |
| 1624 | ) |
| 1625 | summary_path = wiki / "summaries" / "big-doc.md" |
| 1626 | summary_path.write_text("# Big Doc\n\nPageIndex summary tree.", encoding="utf-8") |
| 1627 | openkb_dir = tmp_path / ".openkb" |
| 1628 | openkb_dir.mkdir() |
| 1629 | (openkb_dir / "config.yaml").write_text("model: gpt-4o-mini\n") |
| 1630 | (tmp_path / "raw").mkdir() |
| 1631 | (tmp_path / "raw" / "big-doc.pdf").write_bytes(b"fake") |
| 1632 | |
| 1633 | overview_response = "Overview of the big document." |
| 1634 | concepts_list_response = json.dumps( |
| 1635 | { |
| 1636 | "create": [{"name": "deep-learning", "title": "Deep Learning"}], |
| 1637 | "update": [], |
| 1638 | "related": [], |
| 1639 | } |
| 1640 | ) |
| 1641 | concept_page_response = json.dumps( |
| 1642 | { |
| 1643 | "brief": "Subfield of ML using neural networks", |
| 1644 | "content": "# Deep Learning\n\nA subfield of ML.", |
| 1645 | } |
| 1646 | ) |
| 1647 | |
| 1648 | with patch("openkb.agent.compiler.litellm") as mock_litellm: |
| 1649 | mock_litellm.completion = MagicMock( |
| 1650 | side_effect=_mock_completion([overview_response, concepts_list_response]) |
| 1651 | ) |
| 1652 | mock_litellm.acompletion = AsyncMock( |
| 1653 | side_effect=_mock_acompletion([concept_page_response]) |
| 1654 | ) |
| 1655 | await compile_long_doc("big-doc", summary_path, "doc-123", tmp_path, "gpt-4o-mini") |
| 1656 | |
| 1657 | concept_path = wiki / "concepts" / "deep-learning.md" |
| 1658 | assert concept_path.exists() |
| 1659 | assert "Deep Learning" in concept_path.read_text() |
| 1660 | |
| 1661 | index_text = (wiki / "index.md").read_text() |
| 1662 | assert "[[summaries/big-doc]]" in index_text |
| 1663 | assert "[[concepts/deep-learning]]" in index_text |
| 1664 | |
| 1665 | |
| 1666 | class TestCompileConceptsPlan: |
nothing calls this directly
no test coverage detected