Skip to content

Commit 4072480

Browse files
committed
Bump langchain4j version and beautify
1 parent 593142f commit 4072480

File tree

3 files changed

+22
-17
lines changed

3 files changed

+22
-17
lines changed

build.sbt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ val gatlingVersion = "3.13.5"
2424
val circeVersion = "0.14.8"
2525

2626
// https://github.com/langchain4j/langchain4j/issues/2955
27-
val langchain4jVersion = "1.1.0"
27+
val langchain4jVersion = "1.2.0"
2828

2929
libraryDependencies ++= Seq(
3030
"org.scala-lang.modules" %% "scala-parallel-collections" % "1.2.0",
@@ -149,14 +149,14 @@ libraryDependencies ++= Seq(
149149

150150
"dev.langchain4j" % "langchain4j" % langchain4jVersion,
151151
"dev.langchain4j" % "langchain4j-open-ai" % langchain4jVersion,
152-
"dev.langchain4j" % "langchain4j-anthropic" % "1.1.0-rc1",
152+
"dev.langchain4j" % "langchain4j-anthropic" % langchain4jVersion,
153153

154154
// LangChain4j PgVector extension
155-
"dev.langchain4j" % "langchain4j-pgvector" % "1.1.0-beta7",
155+
"dev.langchain4j" % "langchain4j-pgvector" % "1.2.0-beta8",
156156

157157
// LangChain4j embedding models
158-
"dev.langchain4j" % "langchain4j-embeddings-bge-small-en-v15-q" % "1.1.0-beta7",
159-
"dev.langchain4j" % "langchain4j-embeddings-all-minilm-l6-v2-q" % "1.1.0-beta7",
158+
"dev.langchain4j" % "langchain4j-embeddings-bge-small-en-v15-q" % "1.2.0-beta8",
159+
"dev.langchain4j" % "langchain4j-embeddings-all-minilm-l6-v2-q" % "1.2.0-beta8",
160160

161161
// https://docs.gatling.io/reference/integrations/build-tools/sbt-plugin
162162
"io.gatling" % "gatling-core" % gatlingVersion,

src/main/resources/assistant.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@ <h3>Processing Control</h3>
195195
<button id="statusBtn" onclick="getProcessingStatus()">Get Status</button>
196196
<button id="startBtn" onclick="startProcessing()">Enable Processing</button>
197197
<button id="stopBtn" onclick="stopProcessing()">Disable Processing</button>
198-
<button id="countBtn" onclick="getIndexCount()">Get Index Count</button>
199198
<div id="statusResult"></div>
200199
<div id="countResult"></div>
201200
</div>

src/main/scala/alpakka/sse_to_elasticsearch/WikipediaEditsAnalyser.scala

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ import org.apache.commons.text.StringEscapeUtils
2626
import org.apache.pekko.NotUsed
2727
import org.apache.pekko.actor.ActorSystem
2828
import org.apache.pekko.http.scaladsl.Http
29-
import org.apache.pekko.http.scaladsl.model.sse.ServerSentEvent
3029
import org.apache.pekko.http.scaladsl.model.*
30+
import org.apache.pekko.http.scaladsl.model.sse.ServerSentEvent
3131
import org.apache.pekko.http.scaladsl.server.Directives.{as, complete, concat, entity, get, getFromFile, onComplete, path, pathEndOrSingleSlash, pathPrefix, post}
3232
import org.apache.pekko.http.scaladsl.server.Route
3333
import org.apache.pekko.http.scaladsl.unmarshalling.Unmarshal
@@ -275,6 +275,15 @@ object WikipediaEditsAnalyser extends App {
275275
}
276276
}
277277

278+
private def sanitizePersonNames(names: List[String]): List[String] = {
279+
names
280+
.map(each => StringEscapeUtils.unescapeJava(each))
281+
// Keep name related content (letters, whitespace, apostrophes, periods, hyphens)
282+
.map(_.replaceAll("[^\\p{L}\\s'.\\-]", ""))
283+
.map(StringUtils.trim)
284+
.filter(StringUtils.isNotBlank)
285+
}
286+
278287
private def findPersonsLocalNER(ctx: Ctx): Future[Ctx] = {
279288
logger.info(s"[${ctx.traceId}] Local NER: About to find person names in: ${ctx.change.title}")
280289
val content = ctx.content
@@ -293,12 +302,7 @@ object WikipediaEditsAnalyser extends App {
293302
if (personsFound.isEmpty) {
294303
Future(ctx)
295304
} else {
296-
val personsFoundCleaned = personsFound
297-
.map(each => StringEscapeUtils.unescapeJava(each))
298-
// Keep name related content (letters, whitespace, apostrophes, periods, hyphens)
299-
.map(_.replaceAll("[^\\p{L}\\s'.\\-]", ""))
300-
.map(StringUtils.trim)
301-
.filter(StringUtils.isNotBlank)
305+
val personsFoundCleaned = sanitizePersonNames(personsFound)
302306

303307
logger.debug(s"[${ctx.traceId}] Local NER found persons: $personsFoundCleaned from content: $content")
304308
Future(ctx.copy(personsFoundLocal = personsFoundCleaned))
@@ -361,11 +365,12 @@ object WikipediaEditsAnalyser extends App {
361365
val personsFoundList = if (personsFoundText.isEmpty || personsFoundText.equalsIgnoreCase("NONE")) {
362366
List.empty[String]
363367
} else {
364-
personsFoundText.split("\n")
368+
val rawNames = personsFoundText.split("\n")
365369
.map(_.trim)
366370
.filter(_.nonEmpty)
367371
.filter(!_.equalsIgnoreCase("NONE"))
368372
.toList
373+
sanitizePersonNames(rawNames)
369374
}
370375

371376
if (personsFoundList.isEmpty) {
@@ -586,8 +591,9 @@ object WikipediaEditsAnalyser extends App {
586591
def disableProcessing(): ProcessingControlResponse = {
587592
if (isProcessingEnabled.get()) {
588593
isProcessingEnabled.set(false)
589-
logger.info("Processing disabled - suspending LLM calls and indexing (flow continues)")
590-
ProcessingControlResponse(false, "Processing disabled - suspending LLM calls and indexing")
594+
val msg = "Processing disabled - suspending LLM calls and indexing (flow and local NER continues)"
595+
logger.info(msg)
596+
ProcessingControlResponse(false, msg)
591597
} else {
592598
ProcessingControlResponse(false, "Processing already disabled")
593599
}
@@ -660,7 +666,7 @@ object WikipediaEditsAnalyser extends App {
660666
},
661667
get {
662668
val response = ProcessingControlResponse(isProcessingEnabled.get(),
663-
if (isProcessingEnabled.get()) "Processing enabled" else "Processing disabled")
669+
if (isProcessingEnabled.get()) "Processing enabled" else "Processing disabled (local NER active)")
664670
complete(HttpEntity(ContentTypes.`application/json`, response.asJson.noSpaces))
665671
}
666672
)

0 commit comments

Comments
 (0)