feat(knowledge): Save generated content to file system
Created by: Edouard-Legoupil
This commit introduces a new feature that saves the generated content of a knowledge card to a JSON file in the backend/knowledge/ directory. This makes the content accessible for use by the proposal generation AI.
Key changes include:
- A new helper function,
_save_knowledge_card_content_to_file, has been added tobackend/api/knowledge.pyto handle the file-saving logic. - The
generate_content_backgroundandupdate_knowledge_card_sectionfunctions now call this helper to ensure the file is created and kept in sync. - The
python-slugifylibrary has been added as a dependency to create clean, URL-safe filenames from the knowledge card summaries.
Additionally, this commit includes fixes to the backend test suite that were identified while developing the new feature:
-
The
test_enginefixture inconftest.pynow uses afunctionscope and a shared in-memory cache (sqlite:///file::memory:?cache=shared) to ensure proper test isolation. -
The
CREATE TABLEstatements inconftest.pyhave been made idempotent withIF NOT EXISTSto prevent errors during test runs. -
The
update_knowledge_card_sectionendpoint now correctly receives the database engine as a FastAPI dependency. -
A new test file,
test_knowledge.py, has been added to verify the file-saving functionality. -
Does my code meet the quality standards for releasing packages?
-
Does the reviewer have all the information to validate the features/issues without too much research?
-
Does the customer who will validate the associated tickets have the information to do so without wasting time?
Issues to validate to close :
-
issue #
Processed issues to keep open or in progress:
-
issue #
Checklist:
-
Does the package check go local? -
Does the CI pass? -
Are the added / fixed features documented, tested? -
Are the added features / solved problems briefly presented in the PR message? -
Are the changes related to tickets / issues that I have listed in the commits and in the PR itself? -
Are the tickets in "review" mode in the Project Tracking Board? -
Does each ticket, if it is to be closed after acceptance of the PR, contain a comment that tells how to validate it?