From a5f1d3012a74c7c9c787fc321b713b3525a5caff Mon Sep 17 00:00:00 2001 From: Timon Vonk Date: Sat, 4 Jan 2025 13:32:34 +0100 Subject: [PATCH] fix(agents): Remove circular dev dependency breaking build --- Cargo.lock | 1 - swiftide-agents/Cargo.toml | 3 --- swiftide-agents/src/agent.rs | 9 ++++++--- swiftide-agents/src/default_context.rs | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index aedbce5d..5c7bffef 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8581,7 +8581,6 @@ dependencies = [ "strum", "strum_macros", "swiftide-core", - "swiftide-integrations", "swiftide-macros", "temp-dir", "test-log", diff --git a/swiftide-agents/Cargo.toml b/swiftide-agents/Cargo.toml index 34c39437..82cb06ff 100644 --- a/swiftide-agents/Cargo.toml +++ b/swiftide-agents/Cargo.toml @@ -30,9 +30,6 @@ serde_json.workspace = true swiftide-core = { path = "../swiftide-core", version = "0.16", features = [ "test-utils", ] } -swiftide-integrations = { path = "../swiftide-integrations", version = "0.16", features = [ - "openai", -] } mockall.workspace = true test-log.workspace = true temp-dir.workspace = true diff --git a/swiftide-agents/src/agent.rs b/swiftide-agents/src/agent.rs index f4f40b20..3b6300c2 100644 --- a/swiftide-agents/src/agent.rs +++ b/swiftide-agents/src/agent.rs @@ -38,7 +38,10 @@ pub struct Agent { #[builder(default, setter(into))] pub(crate) hooks: Vec, /// The context in which the agent operates, by default this is the `DefaultContext`. - #[builder(setter(custom), default = Arc::new(DefaultContext::default()))] + #[builder( + setter(custom), + default = Arc::new(DefaultContext::default()) as Arc + )] pub(crate) context: Arc, /// Tools the agent can use #[builder(default = Agent::default_tools(), setter(custom))] @@ -107,7 +110,7 @@ impl AgentBuilder { where Self: Clone, { - self.context = Some(Arc::new(context)); + self.context = Some(Arc::new(context) as Arc); self } @@ -170,7 +173,7 @@ impl AgentBuilder { /// Set the LLM for the agent. An LLM must implement the `ChatCompletion` trait. pub fn llm(&mut self, llm: &LLM) -> &mut Self { - let boxed: Box = Box::new(llm.clone()); + let boxed: Box = Box::new(llm.clone()) as Box; self.llm = Some(boxed); self diff --git a/swiftide-agents/src/default_context.rs b/swiftide-agents/src/default_context.rs index e36ccea6..3049414c 100644 --- a/swiftide-agents/src/default_context.rs +++ b/swiftide-agents/src/default_context.rs @@ -42,7 +42,7 @@ impl Default for DefaultContext { completion_history: Arc::new(Mutex::new(Vec::new())), completions_ptr: Arc::new(AtomicUsize::new(0)), current_completions_ptr: Arc::new(AtomicUsize::new(0)), - tool_executor: Arc::new(LocalExecutor::default()), + tool_executor: Arc::new(LocalExecutor::default()) as Arc, stop_on_assistant: true, } }