ScottLogic / prompt-injection

Application which investigates defensive measures against prompt injection attacks on an LLM, with a focus on the exposure of external tools.
MIT License
15 stars 10 forks source link

Reorganise backend modules used for chat #761

Open pmarsh-scottlogic opened 8 months ago

pmarsh-scottlogic commented 8 months ago

Feature Request

Completing this will greatly ease unit testing and documentation, which are two priorities for the end of the project.

Description

Lil' refactor to separate concerns and hopefully ease testing.

At the moment we have chatController.ts and openai.ts modules which contain the bulk of the logic for chatting with the chatbot. Both files are a bit bloated and seperation of concerns is wish-washy.

I propose that we introduce a new module chatService.ts, so that the concerns are separated into 3 layers (plus utils, introduced in #740 ):

In concrete terms, I reckon we should:

After all this it should be easier to unit test the exported methods from each layer.

NB: AFter a bunch of backend refactoring (#740, #743, #758) some of the above details will change, but the general gist is the same

Acceptance criteria

Refactor, so only regression testing.

Question: Do we want this, or does the benefit not outweigh the effort?