From 90bf325367c0fa5848b82bd4503f64b959173177 Mon Sep 17 00:00:00 2001 From: afterexam <108462554+afterexam@users.noreply.github.com> Date: Thu, 17 Sep 2026 21:04:05 +0800 Subject: [PATCH 1/2] fix: wrap reqwest client in rig ReqwestClient for HttpClientExt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit rig 0.40 的 ClientBuilder::http_client 要求参数实现 HttpClientExt, 原生 reqwest::Client 不满足该约束导致 15 个 E0599 编译错误。 用官方 rig::http_client::ReqwestClient 包一层,底层仍是同一个 client,insecure 开关的 TLS 行为不变。 --- src-tauri/src/command/llm_provider.rs | 7 +++++-- src-tauri/src/llm/service.rs | 13 ++++++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src-tauri/src/command/llm_provider.rs b/src-tauri/src/command/llm_provider.rs index fbb64b4..d723a01 100644 --- a/src-tauri/src/command/llm_provider.rs +++ b/src-tauri/src/command/llm_provider.rs @@ -2,7 +2,10 @@ use crate::command::base::CommandResult; use crate::config::{LlmChainLink, LlmProviderPreset, PRIMARY_LLM_ENTRY_ID}; use crate::credential::{self, CredentialStatus, EffectiveCredentialSource, ResolvedCredential}; use crate::error::AppError; -use crate::llm::service::{http_client_for, normalize_provider_base_url, provider_requires_key, LlmService}; +use crate::llm::service::{ + http_client_for, normalize_provider_base_url, provider_requires_key, rig_http_client_for, + LlmService, +}; use crate::llm::types::ConnectionReport; use rig::client::ModelListingClient; use rig::model::{Model, ModelList, ModelListingError}; @@ -264,7 +267,7 @@ async fn fetch_model_list_with_credential( "noop" }); let base_url = normalize_provider_base_url(&provider, base_url); - let http_client = http_client_for(insecure)?; + let http_client = rig_http_client_for(insecure)?; let models = match provider { LlmProviderPreset::Anthropic => { diff --git a/src-tauri/src/llm/service.rs b/src-tauri/src/llm/service.rs index 1e2ceff..de2055f 100644 --- a/src-tauri/src/llm/service.rs +++ b/src-tauri/src/llm/service.rs @@ -80,7 +80,7 @@ impl LlmService { }); // 自签证书场景下跳过 TLS 校验的开关:默认关闭,仅对 insecure=true 的服务生效 - let http_client = http_client_for(link.insecure)?; + let http_client = rig_http_client_for(link.insecure)?; let backend = match provider { LlmProviderPreset::Anthropic => LlmBackend::Anthropic( @@ -853,6 +853,17 @@ pub(crate) fn http_client_for(insecure: bool) -> Result Result { + http_client_for(insecure).map(rig::http_client::ReqwestClient::new) +} + pub(crate) fn normalize_provider_base_url(provider: &LlmProviderPreset, base_url: &str) -> String { let base_url = base_url.trim().trim_end_matches('/'); if matches!(provider, LlmProviderPreset::Ollama) { From efbd149b87cfcdd88685bd4e82058a30037ab016 Mon Sep 17 00:00:00 2001 From: afterexam <108462554+afterexam@users.noreply.github.com> Date: Thu, 17 Sep 2026 21:12:27 +0800 Subject: [PATCH 2/2] fix: build rig http client from rig's own reqwest 0.13 re-export rig-core 0.40 depends on reqwest 0.13 while the app uses reqwest 0.12; HttpClientExt is only implemented for rig's 0.13 Client, so construct the client via rig::http_client::ReqwestClient::builder() instead of wrapping the app's 0.12 client (ReqwestClient is a type alias, not a wrapper). --- src-tauri/src/llm/service.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src-tauri/src/llm/service.rs b/src-tauri/src/llm/service.rs index de2055f..b74627f 100644 --- a/src-tauri/src/llm/service.rs +++ b/src-tauri/src/llm/service.rs @@ -853,15 +853,22 @@ pub(crate) fn http_client_for(insecure: bool) -> Result Result { - http_client_for(insecure).map(rig::http_client::ReqwestClient::new) + rig::http_client::ReqwestClient::builder() + .tls_danger_accept_invalid_certs(insecure) + .build() + .map_err(|error| { + AppError::configuration("无法创建 HTTP 客户端").with_detail(error.to_string()) + }) } pub(crate) fn normalize_provider_base_url(provider: &LlmProviderPreset, base_url: &str) -> String {