mirror of
https://wget.la/https://github.com/leookun/cursor-byok
synced 2026-12-01 01:05:10 +08:00
feat: plugin system
This commit is contained in:
1 parent
1609b57433
commit
e6130e01a7
78 files changed
+9010
-643
No files matched your search
@@ -18,6 +18,9 @@ pub enum ProviderType {
|
||||
OpenAiResponses,
|
||||
#[serde(rename = "anthropic")]
|
||||
Anthropic,
|
||||
/// 插件执行的调用;协议细节在插件内部,核心只按统一事件流记录。
|
||||
#[serde(rename = "plugin")]
|
||||
Plugin,
|
||||
}
|
||||
|
||||
impl ProviderType {
|
||||
@@ -26,6 +29,7 @@ impl ProviderType {
|
||||
Self::OpenAiChat => "openai-chat",
|
||||
Self::OpenAiResponses => "openai-responses",
|
||||
Self::Anthropic => "anthropic",
|
||||
Self::Plugin => "plugin",
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -44,6 +48,7 @@ impl FromStr for ProviderType {
|
||||
"openai-chat" => Ok(Self::OpenAiChat),
|
||||
"openai-responses" => Ok(Self::OpenAiResponses),
|
||||
"anthropic" => Ok(Self::Anthropic),
|
||||
"plugin" => Ok(Self::Plugin),
|
||||
_ => Err(Error::Config(format!("unsupported provider type: {value}"))),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,9 @@ mod usage {
|
||||
pub(crate) fn context_input_tokens(self, provider: ProviderType) -> Option<u64> {
|
||||
let input = self.input_tokens?;
|
||||
match provider {
|
||||
ProviderType::OpenAiChat | ProviderType::OpenAiResponses => Some(input),
|
||||
ProviderType::OpenAiChat | ProviderType::OpenAiResponses | ProviderType::Plugin => {
|
||||
Some(input)
|
||||
}
|
||||
ProviderType::Anthropic => input
|
||||
.checked_add(self.cache_read_tokens.unwrap_or_default())?
|
||||
.checked_add(self.cache_write_tokens.unwrap_or_default()),
|
||||
|
||||
Reference in new issue
Block a user