Skip to content

Commit

Permalink
update AgentConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcheng1982 committed Apr 15, 2024
1 parent bf3b4a9 commit 68d2f1d
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,9 @@ class AgentConfig(
val memoryConfig: MemoryConfig? = null,
val observationConfig: ObservationConfig? = null,
) {
fun metadataConfig() = metadataConfig ?: MetadataConfig()
fun plannerConfig() = plannerConfig ?: PlannerConfig()
fun toolsConfig() = toolsConfig ?: ToolsConfig()
fun memoryConfig() = memoryConfig ?: MemoryConfig()
fun observationConfig() = observationConfig ?: ObservationConfig()
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@ import io.github.alexcheng1982.agentappbuilder.core.ChatAgent

object ConfiguredAgentFactory {
fun createChatAgent(config: AgentConfig): ChatAgent {
val (name, description, id, usageInstruction) = config.metadataConfig
?: MetadataConfig()
val (plannerType) = config.plannerConfig ?: PlannerConfig()
val (agentToolsProvider) = config.toolsConfig ?: ToolsConfig()
val (observationRegistry) = config.observationConfig
?: ObservationConfig()
val (name, description, id, usageInstruction) = config.metadataConfig()
val (plannerType) = config.plannerConfig()
val (agentToolsProvider) = config.toolsConfig()
val (observationRegistry) = config.observationConfig()
return AgentFactory.createChatAgent(
plannerType.create(config),
name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import io.github.alexcheng1982.agentappbuilder.core.chatmemory.ChatMemory
import io.github.alexcheng1982.agentappbuilder.core.chatmemory.ChatMemoryProvider
import io.github.alexcheng1982.agentappbuilder.core.chatmemory.ChatMemoryStore
import io.github.alexcheng1982.agentappbuilder.core.chatmemory.MessageWindowChatMemory
import io.github.alexcheng1982.agentappbuilder.core.config.*
import io.github.alexcheng1982.agentappbuilder.core.config.AgentConfig
import io.github.alexcheng1982.agentappbuilder.core.executor.ActionPlanningResult
import io.github.alexcheng1982.agentappbuilder.core.observation.AgentPlanningObservationContext
import io.github.alexcheng1982.agentappbuilder.core.observation.AgentPlanningObservationDocumentation
Expand Down Expand Up @@ -265,12 +265,10 @@ abstract class LLMPlannerFactory {

fun create(agentConfig: AgentConfig): LLMPlanner {
val (chatClient) = agentConfig.llmConfig
val (_, systemInstruction) = agentConfig.plannerConfig
?: PlannerConfig()
val (agentToolsProvider) = agentConfig.toolsConfig ?: ToolsConfig()
val (chatMemoryStore) = agentConfig.memoryConfig ?: MemoryConfig()
val (observationRegistry, meterRegistry) = agentConfig.observationConfig
?: ObservationConfig()
val (_, systemInstruction) = agentConfig.plannerConfig()
val (agentToolsProvider) = agentConfig.toolsConfig()
val (chatMemoryStore) = agentConfig.memoryConfig()
val (observationRegistry, meterRegistry) = agentConfig.observationConfig()
return create(
chatClient,
agentToolsProvider,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class JdkHttpSyncLauncher {
ObjectMapper().registerModule(KotlinModule.Builder().build())
val chatAgent = ConfiguredAgentFactory.createChatAgent(agentConfig)
val agentToolsProvider =
agentConfig.toolsConfig.agentToolsProvider
agentConfig.toolsConfig().agentToolsProvider
?: AutoDiscoveredAgentToolsProvider

val (chatAgentPath, agentInfoPath) = launchOptions.pathOptions
Expand Down

0 comments on commit 68d2f1d

Please sign in to comment.