-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
302 additions
and
100 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
16 changes: 16 additions & 0 deletions
16
backend/src/main/java/ai/dragon/dto/llm/StreamingChatLanguageModelDefinition.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 |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package ai.dragon.dto.llm; | ||
|
||
import java.util.function.Function; | ||
|
||
import ai.dragon.enumeration.ProviderType; | ||
import ai.dragon.properties.embedding.LanguageModelSettings; | ||
import dev.langchain4j.model.chat.StreamingChatLanguageModel; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
|
||
@Data | ||
@Builder | ||
public class StreamingChatLanguageModelDefinition { | ||
private Function<LanguageModelSettings, StreamingChatLanguageModel> modelWithSettings; | ||
private ProviderType providerType; | ||
} |
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
3 changes: 2 additions & 1 deletion
3
backend/src/main/java/ai/dragon/dto/openai/completion/OpenAiCompletionRequest.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
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
47 changes: 47 additions & 0 deletions
47
backend/src/main/java/ai/dragon/enumeration/LanguageModelType.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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package ai.dragon.enumeration; | ||
|
||
import ai.dragon.dto.llm.StreamingChatLanguageModelDefinition; | ||
import dev.langchain4j.model.openai.OpenAiStreamingChatModel; | ||
|
||
public enum LanguageModelType { | ||
OpenAiModel("OpenAiModel"); | ||
|
||
private String value; | ||
|
||
LanguageModelType(String value) { | ||
this.value = value; | ||
} | ||
|
||
public static LanguageModelType fromString(String text) { | ||
for (LanguageModelType b : LanguageModelType.values()) { | ||
if (b.value.equalsIgnoreCase(text)) { | ||
return b; | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return value; | ||
} | ||
|
||
public StreamingChatLanguageModelDefinition getStreamingChatLanguageModel() throws ClassNotFoundException { | ||
switch (this) { | ||
case OpenAiModel: | ||
return StreamingChatLanguageModelDefinition | ||
.builder() | ||
.modelWithSettings(parameters -> { | ||
return OpenAiStreamingChatModel | ||
.builder() | ||
.apiKey(parameters.getApiKey()) | ||
.modelName(parameters.getModelName()) | ||
.build(); | ||
}) | ||
.providerType(ProviderType.OpenAI) | ||
.build(); | ||
default: | ||
throw new ClassNotFoundException("Model not found"); | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
backend/src/main/java/ai/dragon/properties/embedding/LanguageModelSettings.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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package ai.dragon.properties.embedding; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
public class LanguageModelSettings { | ||
private String apiKey; | ||
private String modelName; | ||
} |
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
16 changes: 15 additions & 1 deletion
16
backend/src/main/java/ai/dragon/service/EmbeddingModelService.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
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.