Skip to content

Commit

Permalink
Merge pull request #405 from devoxx/issue-402
Browse files Browse the repository at this point in the history
Enabled 'Add Project' for LMStudio and Jan
  • Loading branch information
stephanj authored Dec 17, 2024
2 parents b79cdf9 + 8271386 commit 7bc3b00
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ private boolean isSupportedProvider(@NotNull ModelProvider modelProvider) {
modelProvider.equals(DeepSeek) ||
modelProvider.equals(OpenRouter) ||
modelProvider.equals(DeepInfra) ||
modelProvider.equals(Ollama);
modelProvider.equals(Ollama) ||
modelProvider.equals(Jan) ||
modelProvider.equals(LMStudio);
// Note : NOT GPT4All because the selected context window is not provided in JSON model response
}

private int getWindowContext() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public void restoreConversation(@NotNull Project project, @NotNull Conversation
clear(project);
for (com.devoxx.genie.model.conversation.ChatMessage message : conversation.getMessages()) {
if (message.isUser()) {
add(project, UserMessage.from(new TextContent(message.getContent())));
add(project, UserMessage.from(message.getContent()));
} else {
add(project, AiMessage.from(message.getContent()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ private void constructUserMessageWithCombinedContext(@NotNull ChatMessageContext
stringBuilder.append(editorContent);
}

chatMessageContext.setUserMessage(UserMessage.from(new TextContent(stringBuilder.toString())));
chatMessageContext.setUserMessage(UserMessage.from(stringBuilder.toString()));
}

/**
Expand Down Expand Up @@ -244,7 +244,7 @@ private void constructUserMessageWithFullContext(@NotNull ChatMessageContext cha
stringBuilder.append(chatMessageContext.getUserPrompt());
stringBuilder.append("</UserPrompt>");

chatMessageContext.setUserMessage(UserMessage.from(new TextContent(stringBuilder.toString())));
chatMessageContext.setUserMessage(UserMessage.from(stringBuilder.toString()));
}

/**
Expand Down
13 changes: 3 additions & 10 deletions src/main/java/com/devoxx/genie/service/PromptExecutionService.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ static PromptExecutionService getInstance() {

// Add User message to context
MessageCreationService.getInstance().addUserMessageToContext(chatMessageContext);

// chatMemoryService.add(chatMessageContext.getProject(), chatMessageContext.getUserMessage());
chatMemoryService.add(chatMessageContext.getProject(), chatMessageContext.getUserMessage());

long startTime = System.currentTimeMillis();

Expand Down Expand Up @@ -114,17 +113,11 @@ private boolean isCanceled() {
private @NotNull Response<AiMessage> processChatMessage(ChatMessageContext chatMessageContext) {
try {
ChatLanguageModel chatLanguageModel = chatMessageContext.getChatLanguageModel();

ChatMemoryService chatMemoryService = ChatMemoryService.getInstance();
List<ChatMessage> messages = chatMemoryService.messages(chatMessageContext.getProject());

List<ChatMessage> messages = ChatMemoryService.getInstance().messages(chatMessageContext.getProject());
Response<AiMessage> response = chatLanguageModel.generate(messages);

chatMemoryService.add(chatMessageContext.getProject(), response.content());

ChatMemoryService.getInstance().add(chatMessageContext.getProject(), response.content());
return response;
} catch (Exception e) {
LOG.error("Error occurred while processing chat message", e);
if (chatMessageContext.getLanguageModel().getProvider().equals(ModelProvider.Jan)) {
throw new ModelNotActiveException("Selected Jan model is not active. Download and make it active or add API Key in Jan settings.");
}
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
<LI>Feat #400 : List "custom local model" when enabled in dropdown</LI>
<LI>Feat #400 : Removed Exo & JLama because they can use the Custom OpenAI-compliant local provider</LI>
<LI>Fix #399 : Fixed UserMessage GPT4ALL issue</LI>
<LI>Feat #402 : Allow all LLM Providers to have the "Add Project" feature</LI>
</UL>
<h2>V0.4.5</h2>
<UL>
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#Tue Dec 17 13:03:41 CET 2024
#Tue Dec 17 19:51:55 CET 2024
version=0.4.6

0 comments on commit 7bc3b00

Please sign in to comment.