-
-
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.
* OpenAiCompatibleV1ApiControllerTest : listModels() (#44) (#45) Co-authored-by: Arnaud MENGUS <[email protected]> * Raag init OpenAI (#46) * Adding CheckStyle module for banning OpenAI API Keys * RaaG : Begin with langchain4j assistant * Init RaagService to call OpenAI LLM * Fix OpenAiCompatibleV1ApiControllerTest * Fix : Adding finish_reason on last chunk (#47) * Adding CheckStyle module for banning OpenAI API Keys * RaaG : Begin with langchain4j assistant * Init RaagService to call OpenAI LLM * Fix OpenAiCompatibleV1ApiControllerTest * Adding finish_reason in order to fix : [OpenAIClient.chatCompletion][stream] Missing finish_reason * Increase SSE timeout from 10 to 90 secs * Increase OpenAI client timeout from 60 to 90 secs * Begin Chat Memory (#48) * Adding CheckStyle module for banning OpenAI API Keys * RaaG : Begin with langchain4j assistant * Init RaagService to call OpenAI LLM * Fix OpenAiCompatibleV1ApiControllerTest * Adding finish_reason in order to fix : [OpenAIClient.chatCompletion][stream] Missing finish_reason * Increase SSE timeout from 10 to 90 secs * Increase OpenAI client timeout from 60 to 90 secs * Begin Chat Memory * Ability to use the Chat Memory * Fix checkstyle
- Loading branch information
1 parent
e159aab
commit e028201
Showing
21 changed files
with
477 additions
and
82 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
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
51 changes: 51 additions & 0 deletions
51
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,51 @@ | ||
package ai.dragon.enumeration; | ||
|
||
import java.time.Duration; | ||
|
||
import ai.dragon.dto.llm.StreamingChatLanguageModelDefinition; | ||
import ai.dragon.service.SseService; | ||
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()) | ||
.timeout(Duration.ofSeconds(SseService.DEFAULT_TIMEOUT)) | ||
.build(); | ||
}) | ||
.providerType(ProviderType.OpenAI) | ||
.build(); | ||
default: | ||
throw new ClassNotFoundException("Model not found"); | ||
} | ||
} | ||
} |
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
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
Oops, something went wrong.