-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #77 from devoxx/issue-70
Issue 70
- Loading branch information
Showing
68 changed files
with
978 additions
and
510 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 18 additions & 17 deletions
35
src/main/java/com/devoxx/genie/chatmodel/ChatModelFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,46 @@ | ||
package com.devoxx.genie.chatmodel; | ||
|
||
import com.devoxx.genie.model.ChatModel; | ||
import com.devoxx.genie.model.enumarations.ModelProvider; | ||
import com.devoxx.genie.ui.SettingsState; | ||
import dev.langchain4j.model.chat.ChatLanguageModel; | ||
import org.jetbrains.annotations.NotNull; | ||
import dev.langchain4j.model.chat.StreamingChatLanguageModel; | ||
|
||
import java.util.List; | ||
|
||
public interface ChatModelFactory { | ||
|
||
/** | ||
* Create a chat model with the given parameters. | ||
* | ||
* @param chatModel the chat model | ||
* @return the chat model | ||
*/ | ||
ChatLanguageModel createChatModel(ChatModel chatModel); | ||
|
||
/** | ||
* Create a streaming chat model with the given parameters. | ||
* | ||
* @param chatModel the chat model | ||
* @return the streaming chat model | ||
*/ | ||
default StreamingChatLanguageModel createStreamingChatModel(ChatModel chatModel) { | ||
return null; | ||
} | ||
|
||
/** | ||
* List the available model names. | ||
* | ||
* @return the list of model names | ||
*/ | ||
default List<String> getModelNames() { | ||
return List.of(); | ||
} | ||
|
||
default String getApiKey() { | ||
return ""; | ||
} | ||
|
||
/** | ||
* Get the base URL by the model type. | ||
* @param modelProvider the language model provider | ||
* @return the base URL | ||
* Get the model provider API key. | ||
* | ||
* @return the API key | ||
*/ | ||
default String getBaseUrlByType(@NotNull ModelProvider modelProvider) { | ||
return switch (modelProvider) { | ||
case GPT4All -> SettingsState.getInstance().getGpt4allModelUrl(); | ||
case LMStudio -> SettingsState.getInstance().getLmstudioModelUrl(); | ||
case Ollama -> SettingsState.getInstance().getOllamaModelUrl(); | ||
default -> "na"; | ||
}; | ||
default String getApiKey() { | ||
return ""; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.