refactor(core): remove provider module, migrate to LLMProvider, add client mode handling, improve serialization error handling, update workspace edition, and clean up conditionals and imports
This commit is contained in:
@@ -3,8 +3,8 @@
|
||||
//! This module provides the core agent orchestration logic that allows an LLM
|
||||
//! to reason about tasks, execute tools, and observe results in an iterative loop.
|
||||
|
||||
use crate::Provider;
|
||||
use crate::mcp::{McpClient, McpToolCall, McpToolDescriptor, McpToolResponse};
|
||||
use crate::provider::Provider;
|
||||
use crate::types::{ChatParameters, ChatRequest, Message};
|
||||
use crate::{Error, Result};
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -189,7 +189,7 @@ impl AgentExecutor {
|
||||
fn build_system_prompt(&self, tools: &[McpToolDescriptor]) -> String {
|
||||
let mut prompt = String::from(
|
||||
"You are an AI assistant that uses the ReAct (Reasoning and Acting) pattern to solve tasks.\n\n\
|
||||
You have access to the following tools:\n\n"
|
||||
You have access to the following tools:\n\n",
|
||||
);
|
||||
|
||||
for tool in tools {
|
||||
@@ -230,7 +230,7 @@ impl AgentExecutor {
|
||||
tools: None,
|
||||
};
|
||||
|
||||
let response = self.llm_client.chat(request).await?;
|
||||
let response = self.llm_client.send_prompt(request).await?;
|
||||
Ok(response.message.content)
|
||||
}
|
||||
|
||||
@@ -364,13 +364,13 @@ impl AgentExecutor {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::llm::test_utils::MockProvider;
|
||||
use crate::mcp::test_utils::MockMcpClient;
|
||||
use crate::provider::test_utils::MockProvider;
|
||||
|
||||
#[test]
|
||||
fn test_parse_tool_call() {
|
||||
let executor = AgentExecutor {
|
||||
llm_client: Arc::new(MockProvider),
|
||||
llm_client: Arc::new(MockProvider::default()),
|
||||
tool_client: Arc::new(MockMcpClient),
|
||||
config: AgentConfig::default(),
|
||||
};
|
||||
@@ -399,7 +399,7 @@ ACTION_INPUT: {"query": "Rust programming language"}
|
||||
#[test]
|
||||
fn test_parse_final_answer() {
|
||||
let executor = AgentExecutor {
|
||||
llm_client: Arc::new(MockProvider),
|
||||
llm_client: Arc::new(MockProvider::default()),
|
||||
tool_client: Arc::new(MockMcpClient),
|
||||
config: AgentConfig::default(),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user