Skip to content

Commit

Permalink
minor updates
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcheng1982 committed Dec 26, 2024
1 parent 388088e commit 7f911b8
Show file tree
Hide file tree
Showing 12 changed files with 322 additions and 328 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ class SystemMessageProfileAdvisor(
chain: CallAroundAdvisorChain
): AdvisedResponse {
val systemParams =
(advisedRequest.systemParams ?: mapOf()) + (systemMessageParams
advisedRequest.systemParams + (systemMessageParams
?: mapOf())
val request = AdvisedRequest.from(advisedRequest)
.withSystemText(systemMessage)
.withSystemParams(systemParams)
.systemText(systemMessage)
.systemParams(systemParams)
.build()
return chain.nextAroundCall(request)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,14 @@ class AgentToolInfoAdvisor(private val tools: Map<String, AgentTool<*, *>>) :
): AdvisedResponse {
val toolNames = tools.keys
val toolsDescription = renderTools(tools.values)
val systemParams = HashMap(advisedRequest.systemParams ?: mapOf())
val systemParams = HashMap(advisedRequest.systemParams)
systemParams[SYSTEM_PARAM_TOOLS] = toolsDescription
systemParams[SYSTEM_PARAM_TOOL_NAMES] = toolNames.joinToString(", ")
val functionNames =
(HashSet(
advisedRequest.functionNames ?: listOf()
) + tools.keys).toList()
(HashSet(advisedRequest.functionNames) + tools.keys).toList()
val request = AdvisedRequest.from(advisedRequest)
.withFunctionNames(functionNames)
.withSystemParams(systemParams)
.functionNames(functionNames)
.systemParams(systemParams)
.build()
return chain.nextAroundCall(request)
}
Expand Down
4 changes: 2 additions & 2 deletions bootstrap/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<dependency>
<groupId>io.github.llmagentbuilder</groupId>
<artifactId>chat-agent-ui</artifactId>
<version>0.3.1</version>
<version>0.4.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
Expand All @@ -61,7 +61,7 @@
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.5.8</version>
<version>1.5.15</version>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package io.github.llmagentbuilder.bootstrap
import io.github.llmagentbuilder.agent.profile.systemmessage.SystemMessageProfileAdvisor
import io.github.llmagentbuilder.agent.tool.AgentToolInfoAdvisor
import io.github.llmagentbuilder.core.*
import io.github.llmagentbuilder.core.tool.AgentToolFunctionCallbackContext
import io.github.llmagentbuilder.core.tool.AgentToolFunctionCallbackResolver
import io.github.llmagentbuilder.core.tool.AgentToolsProviderFactory
import io.github.llmagentbuilder.launcher.ktor.server.KtorLauncher
import io.github.llmagentbuilder.plugin.observation.opentelemetry.OpenTelemetryPlugin
Expand Down Expand Up @@ -54,6 +54,7 @@ object AgentBootstrap {
.map { it.get() }
.asSequence()
.forEach {
logger.info("Found PromptParamsProvider: {}", it.javaClass.name)
it.provideSystemParams()?.run {
providedSystemParams.putAll(this)
}
Expand All @@ -72,7 +73,7 @@ object AgentBootstrap {
val observationRegistry =
if (observationEnabled) ObservationRegistry.create() else ObservationRegistry.NOOP
val functionCallbackContext =
AgentToolFunctionCallbackContext(
AgentToolFunctionCallbackResolver(
agentToolsProvider,
observationRegistry,
)
Expand Down Expand Up @@ -154,13 +155,13 @@ object AgentBootstrap {
advisedRequest: AdvisedRequest,
chain: CallAroundAdvisorChain
): AdvisedResponse {
val systemParams = HashMap(advisedRequest.systemParams ?: mapOf())
val systemParams = HashMap(advisedRequest.systemParams)
systemParams.putAll(providedSystemParams)
val userParams = HashMap(advisedRequest.userParams ?: mapOf())
val userParams = HashMap(advisedRequest.userParams)
userParams.putAll(providedUserParams)
val request = AdvisedRequest.from(advisedRequest)
.withSystemParams(systemParams)
.withUserParams(userParams)
.systemParams(systemParams)
.userParams(userParams)
.build()
return chain.nextAroundCall(request)
}
Expand Down
2 changes: 1 addition & 1 deletion cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.5.8</version>
<version>1.5.15</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

package io.github.llmagentbuilder.core

const val VERSION = "0.3.4"
const val VERSION = "0.4.0"
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ interface AgentTool<REQUEST, RESPONSE> : Function<REQUEST, RESPONSE> {
}

interface ConfigurableAgentTool<REQUEST, RESPONSE, CONFIG> :
AgentTool<REQUEST, RESPONSE> {

}
AgentTool<REQUEST, RESPONSE>

class ExceptionTool : AgentTool<String, String> {
override fun name(): String {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import org.slf4j.LoggerFactory
import org.springframework.ai.model.function.DefaultFunctionCallbackResolver
import org.springframework.ai.model.function.FunctionCallback

class AgentToolFunctionCallbackContext(
class AgentToolFunctionCallbackResolver(
agentToolsProvider: AgentToolsProvider,
observationRegistry: ObservationRegistry? = null,
) :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ class AgentToolWrappersProvider(
private class InstrumentedFunctionCallbackWrapper(
private val functionCallback: FunctionCallback,
private val observationRegistry: ObservationRegistry? = null
) :
FunctionCallback {
) : FunctionCallback {
override fun getName(): String {
return functionCallback.name
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ class OpenAiChatOptionsConfigurer : ChatOptionsConfigurer {
val stops = config.stopSequence ?: listOf()
return chatOptions?.let {
OpenAiChatOptions.Builder(it as OpenAiChatOptions)
.withStop(
(it.stopSequences ?: listOf()) + stops
).build()
} ?: OpenAiChatOptions.builder().withStop(stops).build()
.stop((it.stopSequences ?: listOf()) + stops).build()
} ?: OpenAiChatOptions.builder().stop(stops).build()
}
}
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
<java.version>21</java.version>
<spring-ai.version>1.0.0-M5</spring-ai.version>
<kotlin.version>2.1.0</kotlin.version>
<spring-boot.version>3.2.4</spring-boot.version>
<spring.version>6.1.4</spring.version>
<spring-boot.version>3.3.7</spring-boot.version>
<spring.version>6.1.16</spring.version>
<jackson.version>2.16.1</jackson.version>
<micrometer.version>1.12.4</micrometer.version>
<micrometer-tracing.version>1.2.4</micrometer-tracing.version>
Expand Down
Loading

0 comments on commit 7f911b8

Please sign in to comment.