Open fmatar opened 6 months ago
Looking at the issue I think it's quite an easy fix:
The filtering could include the non null values. Possibly update
private void addChatPage(CardPageBuildItem card, List<DeclarativeAiServiceBuildItem> aiServices) {
List<String> systemMessages = aiServices.stream()
.map(s -> s.getServiceClassInfo())
.flatMap(c -> c.annotations().stream()) //This includes method annotations
.filter(a -> a.name().equals(LangChain4jDotNames.SYSTEM_MESSAGE))
.map(a -> String.join("", a.value().asStringArray()))
.toList();
...
}
to:
private void addChatPage(CardPageBuildItem card, List<DeclarativeAiServiceBuildItem> aiServices) {
List<String> systemMessages = aiServices.stream()
.map(s -> s.getServiceClassInfo())
.flatMap(c -> c.annotations().stream()) //This includes method annotations
.filter(a -> a.name().equals(LangChain4jDotNames.SYSTEM_MESSAGE) && a.value()!=null)
.map(a -> String.join("", a.value().asStringArray()))
.toList();
...
}
Thoughts?
I think you would have to resolve the system message instead and reading it from the file. Not sure where it's done for runtime but you need something similar (or a way to propagate the value) in Dev UI.
I'm looking a bit more into it, thank you for the suggestion
cc @jmartisk
found a super hacky way to make it work.
@SystemMessage(value="", fromResource="my_prompt.txt")
fromResource still overrides the value.
That also uncovered another issue. In dev mode a message changed from an external file won't be changed unless I rebuild the app
That also uncovered another issue. In dev mode a message changed from an external file won't be changed unless I rebuild the app
Yeah the extension will have to declare that file to be watched for changes, this should be doable. Sorry for the delay in answering, I'm traveling all week and on wifi that mostly doesn't work, but I'll have a look into this as soon as I can.
this should be doable.
Definitely doable and easy 😜
I have moved my prompt content to a file named
my_prompt.txt
toresources/dev/langchain4j/services
My service looks as follows:
The following error happens in dev mode only, I can get around it by building and running it in prod, not fun!