LLM支持优化
This commit is contained in:
@@ -12,15 +12,43 @@ pub struct ContentGenerator {
|
||||
impl ContentGenerator {
|
||||
/// Create new content generator
|
||||
pub async fn new(manager: &ConfigManager) -> Result<Self> {
|
||||
let llm_client = LlmClient::from_config(manager).await?;
|
||||
|
||||
Self::new_with_think(manager, false).await
|
||||
}
|
||||
|
||||
/// Create new content generator with thinking override
|
||||
pub async fn new_with_think(manager: &ConfigManager, think_override: bool) -> Result<Self> {
|
||||
let mut thinking_enabled = if think_override {
|
||||
true
|
||||
} else {
|
||||
manager.config().llm.thinking_enabled
|
||||
};
|
||||
|
||||
// Validate thinking support per provider
|
||||
if thinking_enabled {
|
||||
let provider = manager.llm_provider();
|
||||
if !Self::supports_thinking(provider) {
|
||||
eprintln!(
|
||||
"Warning: Provider '{}' does not support thinking mode. \
|
||||
Disabling thinking for this invocation.",
|
||||
provider
|
||||
);
|
||||
thinking_enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
let llm_client = LlmClient::from_config_with_think(manager, thinking_enabled).await?;
|
||||
|
||||
if !llm_client.is_available().await {
|
||||
anyhow::bail!("LLM provider '{}' is not available", manager.llm_provider());
|
||||
}
|
||||
|
||||
|
||||
Ok(Self { llm_client })
|
||||
}
|
||||
|
||||
fn supports_thinking(provider: &str) -> bool {
|
||||
matches!(provider, "deepseek" | "kimi" | "anthropic" | "openai")
|
||||
}
|
||||
|
||||
/// Generate commit message from diff
|
||||
pub async fn generate_commit_message(
|
||||
&self,
|
||||
|
||||
Reference in New Issue
Block a user