Implement planning mode

This commit is contained in:
Jochen
2025-12-09 09:59:28 +11:00
parent 4aa84e2144
commit ff8b3e7c7b
24 changed files with 3817 additions and 346 deletions

View File

@@ -120,6 +120,7 @@ const ANTHROPIC_VERSION: &str = "2023-06-01";
#[derive(Debug, Clone)]
pub struct AnthropicProvider {
client: Client,
name: String,
api_key: String,
model: String,
max_tokens: u32,
@@ -150,6 +151,40 @@ impl AnthropicProvider {
Ok(Self {
client,
name: "anthropic".to_string(),
api_key,
model,
max_tokens: max_tokens.unwrap_or(4096),
temperature: temperature.unwrap_or(0.1),
cache_config,
enable_1m_context: enable_1m_context.unwrap_or(false),
thinking_budget_tokens,
})
}
/// Create a new AnthropicProvider with a custom name (e.g., "anthropic.default")
pub fn new_with_name(
name: String,
api_key: String,
model: Option<String>,
max_tokens: Option<u32>,
temperature: Option<f32>,
cache_config: Option<String>,
enable_1m_context: Option<bool>,
thinking_budget_tokens: Option<u32>,
) -> Result<Self> {
let client = Client::builder()
.timeout(Duration::from_secs(300))
.build()
.map_err(|e| anyhow!("Failed to create HTTP client: {}", e))?;
let model = model.unwrap_or_else(|| "claude-3-5-sonnet-20241022".to_string());
debug!("Initialized Anthropic provider '{}' with model: {}", name, model);
Ok(Self {
client,
name,
api_key,
model,
max_tokens: max_tokens.unwrap_or(4096),
@@ -787,7 +822,7 @@ impl LLMProvider for AnthropicProvider {
}
fn name(&self) -> &str {
"anthropic"
&self.name
}
fn model(&self) -> &str {

View File

@@ -145,6 +145,7 @@ impl DatabricksAuth {
#[derive(Debug, Clone)]
pub struct DatabricksProvider {
client: Client,
name: String,
host: String,
auth: DatabricksAuth,
model: String,
@@ -172,6 +173,34 @@ impl DatabricksProvider {
Ok(Self {
client,
name: "databricks".to_string(),
host: host.trim_end_matches('/').to_string(),
auth: DatabricksAuth::token(token),
model,
max_tokens: max_tokens.unwrap_or(50000),
temperature: temperature.unwrap_or(0.1),
})
}
/// Create a DatabricksProvider with token auth and a custom name (e.g., "databricks.default")
pub fn from_token_with_name(
name: String,
host: String,
token: String,
model: String,
max_tokens: Option<u32>,
temperature: Option<f32>,
) -> Result<Self> {
let client = Client::builder()
.timeout(Duration::from_secs(DEFAULT_TIMEOUT_SECS))
.build()
.map_err(|e| anyhow!("Failed to create HTTP client: {}", e))?;
info!("Initialized Databricks provider '{}' with model: {} on host: {}", name, model, host);
Ok(Self {
client,
name,
host: host.trim_end_matches('/').to_string(),
auth: DatabricksAuth::token(token),
model,
@@ -198,6 +227,33 @@ impl DatabricksProvider {
Ok(Self {
client,
name: "databricks".to_string(),
host: host.trim_end_matches('/').to_string(),
auth: DatabricksAuth::oauth(host.clone()),
model,
max_tokens: max_tokens.unwrap_or(50000),
temperature: temperature.unwrap_or(0.1),
})
}
/// Create a DatabricksProvider with OAuth auth and a custom name (e.g., "databricks.default")
pub async fn from_oauth_with_name(
name: String,
host: String,
model: String,
max_tokens: Option<u32>,
temperature: Option<f32>,
) -> Result<Self> {
let client = Client::builder()
.timeout(Duration::from_secs(DEFAULT_TIMEOUT_SECS))
.build()
.map_err(|e| anyhow!("Failed to create HTTP client: {}", e))?;
info!("Initialized Databricks provider '{}' with OAuth for model: {} on host: {}", name, model, host);
Ok(Self {
client,
name,
host: host.trim_end_matches('/').to_string(),
auth: DatabricksAuth::oauth(host.clone()),
model,
@@ -1045,7 +1101,7 @@ impl LLMProvider for DatabricksProvider {
}
fn name(&self) -> &str {
"databricks"
&self.name
}
fn model(&self) -> &str {