Skip to content

Commit

Permalink
Merge pull request #159 from quarkiverse/#158
Browse files Browse the repository at this point in the history
Make sure ChatMemoryStore beans are unremovable
  • Loading branch information
geoand authored Dec 14, 2023
2 parents b6a38ef + 868cdb3 commit 0c8ab60
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import io.quarkiverse.langchain4j.runtime.aiservice.ChatMemoryConfig;
import io.quarkus.arc.SyntheticCreationalContext;
import io.quarkus.arc.deployment.SyntheticBeanBuildItem;
import io.quarkus.arc.deployment.UnremovableBeanBuildItem;
import io.quarkus.deployment.annotations.BuildProducer;
import io.quarkus.deployment.annotations.BuildStep;
import io.quarkus.deployment.annotations.ExecutionTime;
Expand All @@ -24,6 +25,7 @@ public class ChatMemoryProcessor {
@Record(ExecutionTime.RUNTIME_INIT)
void setupBeans(ChatMemoryBuildConfig buildConfig, ChatMemoryConfig runtimeConfig,
ChatMemoryRecorder recorder,
BuildProducer<UnremovableBeanBuildItem> unremovableProducer,
BuildProducer<SyntheticBeanBuildItem> syntheticBeanProducer) {

Function<SyntheticCreationalContext<ChatMemoryProvider>, ChatMemoryProvider> fun;
Expand All @@ -47,5 +49,6 @@ void setupBeans(ChatMemoryBuildConfig buildConfig, ChatMemoryConfig runtimeConfi
configurator.createWith(fun);

syntheticBeanProducer.produce(configurator.done());
unremovableProducer.produce(UnremovableBeanBuildItem.beanTypes(ChatMemoryStore.class));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import dev.langchain4j.store.memory.chat.InMemoryChatMemoryStore;
import io.quarkiverse.langchain4j.RegisterAiService;
import io.quarkus.arc.DefaultBean;
import io.quarkus.arc.Unremovable;

/**
* Creates the default {@link InMemoryChatMemoryStore} store to be used by classes annotated with {@link RegisterAiService}
Expand All @@ -16,7 +15,6 @@ public class InMemoryChatMemoryStoreProducer {
@Produces
@Singleton
@DefaultBean
@Unremovable
public InMemoryChatMemoryStore chatMemoryStore() {
return new InMemoryChatMemoryStore();
}
Expand Down

0 comments on commit 0c8ab60

Please sign in to comment.