Skip to content

Commit

Permalink
Merge pull request #309 from quarkiverse/chat-devui
Browse files Browse the repository at this point in the history
Make DevUI not require the default chat model
  • Loading branch information
jmartisk authored Feb 16, 2024
2 parents 29278b4 + cd76400 commit ee569ea
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package io.quarkiverse.langchain4j.runtime.devui;

import java.util.List;
import java.util.concurrent.ThreadLocalRandom;
import java.util.concurrent.atomic.AtomicReference;

import jakarta.enterprise.context.control.ActivateRequestContext;
import jakarta.inject.Inject;

import dev.langchain4j.data.message.AiMessage;
import dev.langchain4j.data.message.SystemMessage;
Expand All @@ -13,17 +13,22 @@
import dev.langchain4j.memory.chat.ChatMemoryProvider;
import dev.langchain4j.model.chat.ChatLanguageModel;
import dev.langchain4j.model.output.Response;
import io.quarkus.arc.All;

@ActivateRequestContext
public class ChatJsonRPCService {

@Inject
ChatLanguageModel model;
private final ChatLanguageModel model;

@Inject
ChatMemoryProvider memoryProvider;
private final ChatMemoryProvider memoryProvider;

private AtomicReference<ChatMemory> currentMemory = new AtomicReference<>();
public ChatJsonRPCService(@All List<ChatLanguageModel> models, // don't use ChatLanguageModel model because it results in the default model not being configured
ChatMemoryProvider memoryProvider) {
this.model = models.get(0);
this.memoryProvider = memoryProvider;
}

private final AtomicReference<ChatMemory> currentMemory = new AtomicReference<>();

public String reset(String systemMessage) {
if (currentMemory.get() != null) {
Expand Down
2 changes: 1 addition & 1 deletion docs/modules/ROOT/pages/includes/attributes.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
:project-version: 0.8.1
:langchain4j-version: 0.27.1
:examples-dir: ./../examples/
:examples-dir: ./../examples/

0 comments on commit ee569ea

Please sign in to comment.