Skip to content

Commit f3a4ed0

Browse files
committed
Expose RAG on Ai
1 parent f18429d commit f3a4ed0

File tree

4 files changed

+23
-7
lines changed

4 files changed

+23
-7
lines changed

embabel-agent-api/src/main/kotlin/com/embabel/agent/api/common/Ai.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616
package com.embabel.agent.api.common
1717

18+
import com.embabel.agent.rag.RagService
1819
import com.embabel.common.ai.model.*
1920
import org.springframework.ai.embedding.EmbeddingModel
2021

@@ -27,14 +28,24 @@ typealias Embedding = FloatArray
2728
*/
2829
interface Ai {
2930

31+
/**
32+
* Return an embedding model with the given name
33+
*/
3034
fun withEmbeddingModel(model: String): EmbeddingModel =
3135
withEmbeddingModel(ModelSelectionCriteria.byName(model))
3236

37+
/**
38+
* Return an embedding model matching the given criteria.
39+
*/
3340
fun withEmbeddingModel(criteria: ModelSelectionCriteria): EmbeddingModel
3441

3542
fun withDefaultEmbeddingModel(): EmbeddingModel =
3643
withEmbeddingModel(DefaultModelSelectionCriteria)
3744

45+
/**
46+
* Return the RagService
47+
*/
48+
fun rag(): RagService
3849

3950
/**
4051
* Get a configurable PromptRunner for this context using

embabel-agent-api/src/main/kotlin/com/embabel/agent/api/common/OperationContext.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import com.embabel.agent.api.dsl.AgentScopeBuilder
2121
import com.embabel.agent.core.*
2222
import com.embabel.agent.event.AgenticEventListener
2323
import com.embabel.agent.prompt.element.ContextualPromptElement
24+
import com.embabel.agent.rag.RagService
2425
import com.embabel.common.ai.model.LlmOptions
2526
import com.embabel.common.ai.model.ModelSelectionCriteria
2627
import com.embabel.common.ai.prompt.CurrentDate
@@ -232,4 +233,8 @@ private class OperationContextAi(
232233
override fun withLlm(llm: LlmOptions): PromptRunner {
233234
return context.promptRunner().withLlm(llm)
234235
}
236+
237+
override fun rag(): RagService {
238+
return context.processContext.platformServices.ragService
239+
}
235240
}

embabel-agent-rag-lucene/pom.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<artifactId>embabel-agent-parent</artifactId>
88
<version>0.1.2-SNAPSHOT</version>
99
</parent>
10-
<artifactId>embabel-agent-lucene</artifactId>
10+
<artifactId>embabel-agent-rag-lucene</artifactId>
1111
<packaging>jar</packaging>
1212
<name>Embabel Agent Rag for Lucene</name>
1313
<description>Embabel Agent Rag for Lucene</description>
@@ -34,26 +34,26 @@
3434
<artifactId>lucene-core</artifactId>
3535
<version>9.11.1</version>
3636
</dependency>
37-
37+
3838
<dependency>
3939
<groupId>org.apache.lucene</groupId>
4040
<artifactId>lucene-analysis-common</artifactId>
4141
<version>9.11.1</version>
4242
</dependency>
43-
43+
4444
<dependency>
4545
<groupId>org.apache.lucene</groupId>
4646
<artifactId>lucene-queryparser</artifactId>
4747
<version>9.11.1</version>
4848
</dependency>
49-
49+
5050
<dependency>
5151
<groupId>org.apache.lucene</groupId>
5252
<artifactId>lucene-memory</artifactId>
5353
<version>9.11.1</version>
5454
</dependency>
55-
56-
55+
56+
5757
</dependencies>
5858

5959
<build>

embabel-agent-rag-lucene/src/main/kotlin/com/embabel/agent/rag/lucene/LuceneRagService.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import java.io.Closeable
3737
import kotlin.math.sqrt
3838
import org.springframework.ai.document.Document as SpringAiDocument
3939

40-
class LuceneRagService(
40+
class LuceneRagService @JvmOverloads constructor(
4141
override val name: String = "lucene-rag",
4242
override val description: String = "In-memory Lucene-based RAG service with hybrid text and vector search capabilities",
4343
private val embeddingModel: EmbeddingModel? = null,

0 commit comments

Comments
 (0)