Skip to content

feat(knowledge): Save generated content to file system

Edouard Legoupil requested to merge feat/save-knowledge-content into main_dev

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 to backend/api/knowledge.py to handle the file-saving logic.
  • The generate_content_background and update_knowledge_card_section functions now call this helper to ensure the file is created and kept in sync.
  • The python-slugify library 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_engine fixture in conftest.py now uses a function scope and a shared in-memory cache (sqlite:///file::memory:?cache=shared) to ensure proper test isolation.

  • The CREATE TABLE statements in conftest.py have been made idempotent with IF NOT EXISTS to prevent errors during test runs.

  • The update_knowledge_card_section endpoint 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?

Merge request reports

Loading