Skip to content

Commit

Permalink
Merge pull request #408 from devoxx/issue-406
Browse files Browse the repository at this point in the history
Issue 406
  • Loading branch information
stephanj authored Dec 17, 2024
2 parents 90c3f10 + 6e498a5 commit 3cf8c16
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 15 deletions.
15 changes: 5 additions & 10 deletions src/main/java/com/devoxx/genie/chatmodel/ChatModelProvider.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.devoxx.genie.chatmodel;

import com.devoxx.genie.chatmodel.local.gpt4all.GPT4AllChatModelFactory;
import com.devoxx.genie.chatmodel.local.jan.JanChatModelFactory;
import com.devoxx.genie.chatmodel.local.lmstudio.LMStudioChatModelFactory;
import com.devoxx.genie.chatmodel.local.ollama.OllamaChatModelFactory;
import com.devoxx.genie.model.ChatModel;
import com.devoxx.genie.model.Constant;
import com.devoxx.genie.model.LanguageModel;
Expand All @@ -20,19 +23,11 @@
@Setter
public class ChatModelProvider {

private static final ModelProvider DEFAULT_PROVIDER = ModelProvider.OpenAI; // Choose an appropriate default
private static final ModelProvider DEFAULT_PROVIDER = ModelProvider.OpenAI;

public ChatLanguageModel getChatLanguageModel(@NotNull ChatMessageContext chatMessageContext) {
ChatModel chatModel = initChatModel(chatMessageContext);
ChatModelFactory factory = getFactory(chatMessageContext);

if (factory instanceof LMStudioChatModelFactory) {
if (factory.getModels().isEmpty()) {
throw new IllegalStateException("LMStudio is not running. Please start it and try again.");
}
}

return factory.createChatModel(chatModel);
return getFactory(chatMessageContext).createChatModel(chatModel);
}

public StreamingChatLanguageModel getStreamingChatLanguageModel(@NotNull ChatMessageContext chatMessageContext) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.devoxx.genie.chatmodel;
package com.devoxx.genie.chatmodel.local;

import com.devoxx.genie.chatmodel.ChatModelFactory;
import com.devoxx.genie.model.ChatModel;
import com.devoxx.genie.model.LanguageModel;
import com.devoxx.genie.model.enumarations.ModelProvider;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.devoxx.genie.chatmodel.local.gpt4all;

import com.devoxx.genie.chatmodel.LocalChatModelFactory;
import com.devoxx.genie.chatmodel.local.LocalChatModelFactory;
import com.devoxx.genie.model.ChatModel;
import com.devoxx.genie.model.LanguageModel;
import com.devoxx.genie.model.enumarations.ModelProvider;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.devoxx.genie.chatmodel.local.jan;

import com.devoxx.genie.chatmodel.LocalChatModelFactory;
import com.devoxx.genie.chatmodel.local.LocalChatModelFactory;
import com.devoxx.genie.model.ChatModel;
import com.devoxx.genie.model.LanguageModel;
import com.devoxx.genie.model.enumarations.ModelProvider;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.devoxx.genie.chatmodel.local.lmstudio;

import com.devoxx.genie.chatmodel.LocalChatModelFactory;
import com.devoxx.genie.chatmodel.local.LocalChatModelFactory;
import com.devoxx.genie.model.ChatModel;
import com.devoxx.genie.model.LanguageModel;
import com.devoxx.genie.model.enumarations.ModelProvider;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.devoxx.genie.chatmodel.local.ollama;

import com.devoxx.genie.chatmodel.LocalChatModelFactory;
import com.devoxx.genie.chatmodel.local.LocalChatModelFactory;
import com.devoxx.genie.model.ChatModel;
import com.devoxx.genie.model.LanguageModel;
import com.devoxx.genie.model.enumarations.ModelProvider;
Expand Down

0 comments on commit 3cf8c16

Please sign in to comment.