DEV Community

Cover image for Chatcraft Enhancement
Amir Helali
Amir Helali

Posted on

Chatcraft Enhancement

Issue

This is the first post that I am making about the work I will do on an open source project. The project that I've picked is called ChatCraft. It is an open source browser-based companion for coding with large language models. It also provides the option to choose between OpenAI and OpenRouter. The issue that I've picked to work on is about refactoring the response handling of OpenAI so that the right handler is picked at run-time based on two different response types: streaming response and non-streaming response.

Plan

My plan is to use the Strategy Pattern because it gives me the flexibility to encapsulate and dynamically change the behaviour of the object at run-time. I think that I will be able to have an abstract response handler with 2 different implementations for each response. One implementation will handle streaming response and the other will handle non-streaming response. The way I will handle choosing the response type will be based on a flag that identifies if a response is streaming or non-streaming. After the type of response is decided I will use a Factory Method to create the object based on the response flag.

To be Continued

I will be posting more as I progress towards solving this issue, so keep an eye out for future updates.

Top comments (0)