Skip to main content

ProviderService

Struct ProviderService 

Source
pub struct ProviderService;
Expand description

供应商相关业务逻辑

Implementations§

Source§

impl ProviderService

Source

pub fn import_codex_providers_from_live( state: &AppState, ) -> Result<CodexImportReport, AppError>

Source§

impl ProviderService

Source

pub fn get_custom_endpoints( state: &AppState, app_type: AppType, provider_id: &str, ) -> Result<Vec<CustomEndpoint>, AppError>

获取自定义端点列表

Source

pub fn add_custom_endpoint( state: &AppState, app_type: AppType, provider_id: &str, url: String, ) -> Result<(), AppError>

新增自定义端点

Source

pub fn remove_custom_endpoint( state: &AppState, app_type: AppType, provider_id: &str, url: String, ) -> Result<(), AppError>

删除自定义端点

Source

pub fn update_endpoint_last_used( state: &AppState, app_type: AppType, provider_id: &str, url: String, ) -> Result<(), AppError>

更新端点最后使用时间

Source§

impl ProviderService

Source

pub async fn fetch_provider_models( base_url: &str, api_key: Option<&str>, ) -> Result<Vec<String>, AppError>

尝试从远端拉取模型列表

Source§

impl ProviderService

Source

pub async fn query_usage( state: &AppState, app_type: AppType, provider_id: &str, ) -> Result<UsageResult, AppError>

查询供应商用量(使用已保存的脚本配置)

Source

pub async fn test_usage_script( _state: &AppState, _app_type: AppType, _provider_id: &str, script_code: &str, timeout: u64, api_key: Option<&str>, base_url: Option<&str>, access_token: Option<&str>, user_id: Option<&str>, template_type: Option<&str>, ) -> Result<UsageResult, AppError>

测试用量脚本(使用临时脚本内容,不保存)

Source§

impl ProviderService

Source

pub fn sync_openclaw_to_live(state: &AppState) -> Result<(), AppError>

Source

pub fn set_common_config_snippet( state: &AppState, app_type: AppType, snippet: Option<String>, ) -> Result<(), AppError>

Source

pub fn clear_common_config_snippet( state: &AppState, app_type: AppType, ) -> Result<(), AppError>

Source

pub fn list( state: &AppState, app_type: AppType, ) -> Result<IndexMap<String, Provider>, AppError>

列出指定应用下的所有供应商

Source

pub fn current(state: &AppState, app_type: AppType) -> Result<String, AppError>

获取当前供应商 ID

Source

pub fn add( state: &AppState, app_type: AppType, provider: Provider, ) -> Result<bool, AppError>

新增供应商

Source

pub fn update( state: &AppState, app_type: AppType, provider: Provider, ) -> Result<bool, AppError>

更新供应商

Source

pub fn import_default_config( state: &AppState, app_type: AppType, ) -> Result<bool, AppError>

导入当前 live 配置为默认供应商。

返回 Ok(true) 表示实际导入,Ok(false) 表示该 app 已有非官方 seed provider 而跳过。

Source

pub fn read_live_settings(app_type: AppType) -> Result<Value, AppError>

读取当前 live 配置

Source

pub fn update_sort_order( state: &AppState, app_type: AppType, updates: Vec<ProviderSortUpdate>, ) -> Result<bool, AppError>

更新供应商排序

Source

pub fn remove_from_live_config( state: &AppState, app_type: AppType, provider_id: &str, ) -> Result<(), AppError>

Source

pub fn sync_current_to_live(state: &AppState) -> Result<(), AppError>

将所有应用的当前供应商配置同步到 live 文件。

用于 WebDAV 下载、备份恢复等场景:数据库已更新,但 live 配置文件 (~/.codex/config.toml、Claude settings.json 等)尚未同步。 对齐上游 sync_current_to_live 行为。

Source

pub fn switch( state: &AppState, app_type: AppType, provider_id: &str, ) -> Result<(), AppError>

切换指定应用的供应商

Source

pub fn delete( state: &AppState, app_type: AppType, provider_id: &str, ) -> Result<(), AppError>

Source

pub fn import_openclaw_providers_from_live( state: &AppState, ) -> Result<usize, AppError>

Source

pub fn import_opencode_providers_from_live( state: &AppState, ) -> Result<usize, AppError>

Source

pub fn import_hermes_providers_from_live( state: &AppState, ) -> Result<usize, AppError>

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> ParallelSend for T

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ThreadSafetyMarker for T

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more