From cb1b2b060f5527a712f1daccbdbb422a09e901ea Mon Sep 17 00:00:00 2001 From: Michael Neale Date: Sat, 21 Dec 2024 16:13:35 +1100 Subject: [PATCH] conditionally load memory system in goose server (#508) --- Justfile | 5 +++++ crates/goose-server/src/state.rs | 11 ++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Justfile b/Justfile index 28820a5e4..88baa2de6 100644 --- a/Justfile +++ b/Justfile @@ -25,3 +25,8 @@ run-ui: run-server: @echo "Running server..." cargo run -p goose-server + +# make GUI with latest binary +make-ui: + @just release + cd ui/desktop && npm run bundle:default diff --git a/crates/goose-server/src/state.rs b/crates/goose-server/src/state.rs index 8c07f8254..fa430c316 100644 --- a/crates/goose-server/src/state.rs +++ b/crates/goose-server/src/state.rs @@ -3,10 +3,11 @@ use goose::providers::configs::GroqProviderConfig; use goose::{ agent::Agent, developer::DeveloperSystem, + memory::MemorySystem, providers::{configs::ProviderConfig, factory}, systems::goose_hints::GooseHintsSystem, }; -use std::sync::Arc; +use std::{env, sync::Arc}; use tokio::sync::Mutex; /// Shared application state @@ -21,6 +22,14 @@ impl AppState { let provider = factory::get_provider(provider_config.clone())?; let mut agent = Agent::new(provider); agent.add_system(Box::new(DeveloperSystem::new())); + + // Add memory system only if GOOSE_SERVER__MEMORY is set to "true" + if let Ok(memory_enabled) = env::var("GOOSE_SERVER__MEMORY") { + if memory_enabled.to_lowercase() == "true" { + agent.add_system(Box::new(MemorySystem::new())); + } + } + let goosehints_system = Box::new(GooseHintsSystem::new()); agent.add_system(goosehints_system);