Encapsulate settings (#180)

This commit is contained in:
Carl-Robert 2023-08-27 18:16:08 +03:00 committed by GitHub
parent de971806d0
commit ef5fd5919f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
36 changed files with 697 additions and 369 deletions

View file

@ -3,7 +3,7 @@ package ee.carlrobert.codegpt.conversations;
import static java.util.stream.Collectors.toList;
import ee.carlrobert.codegpt.conversations.message.Message;
import ee.carlrobert.codegpt.settings.SettingsState;
import ee.carlrobert.codegpt.settings.state.ModelSettingsState;
import ee.carlrobert.openai.client.ClientCode;
import java.time.LocalDateTime;
import java.util.ArrayList;
@ -38,13 +38,10 @@ public class ConversationService {
}
public Conversation createConversation(ClientCode clientCode) {
var settings = SettingsState.getInstance();
var conversation = new Conversation();
conversation.setId(UUID.randomUUID());
conversation.setClientCode(clientCode);
conversation.setModel(settings.isChatCompletionOptionSelected ?
settings.getChatCompletionModel() :
settings.getTextCompletionModel());
conversation.setModel(ModelSettingsState.getInstance().getCompletionModel());
conversation.setCreatedOn(LocalDateTime.now());
conversation.setUpdatedOn(LocalDateTime.now());
return conversation;
@ -111,8 +108,7 @@ public class ConversationService {
}
public Conversation startConversation() {
var currentClientCode = SettingsState.getInstance().isChatCompletionOptionSelected ?
ClientCode.CHAT_COMPLETION : ClientCode.TEXT_COMPLETION;
var currentClientCode = ModelSettingsState.getInstance().isUseChatCompletion() ? ClientCode.CHAT_COMPLETION : ClientCode.TEXT_COMPLETION;
var conversation = createConversation(currentClientCode);
conversationState.setCurrentConversation(conversation);
addConversation(conversation);