Skip to content

Commit

Permalink
fix(agents): Remove circular dev dependency breaking build
Browse files Browse the repository at this point in the history
  • Loading branch information
timonv committed Jan 4, 2025
1 parent e14b094 commit a5f1d30
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions swiftide-agents/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions swiftide-agents/src/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ pub struct Agent {
#[builder(default, setter(into))]
pub(crate) hooks: Vec<Hook>,
/// 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<dyn AgentContext>
)]
pub(crate) context: Arc<dyn AgentContext>,
/// Tools the agent can use
#[builder(default = Agent::default_tools(), setter(custom))]
Expand Down Expand Up @@ -107,7 +110,7 @@ impl AgentBuilder {
where
Self: Clone,
{
self.context = Some(Arc::new(context));
self.context = Some(Arc::new(context) as Arc<dyn AgentContext>);
self
}

Expand Down Expand Up @@ -170,7 +173,7 @@ impl AgentBuilder {

/// Set the LLM for the agent. An LLM must implement the `ChatCompletion` trait.
pub fn llm<LLM: ChatCompletion + Clone + 'static>(&mut self, llm: &LLM) -> &mut Self {
let boxed: Box<dyn ChatCompletion> = Box::new(llm.clone());
let boxed: Box<dyn ChatCompletion> = Box::new(llm.clone()) as Box<dyn ChatCompletion>;

self.llm = Some(boxed);
self
Expand Down
2 changes: 1 addition & 1 deletion swiftide-agents/src/default_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<dyn ToolExecutor>,
stop_on_assistant: true,
}
}
Expand Down

0 comments on commit a5f1d30

Please sign in to comment.