providers: map native tool support from capabilities
This commit is contained in:
parent
b5869d424e
commit
e9e45acd6d
1 changed files with 28 additions and 1 deletions
|
|
@ -278,7 +278,7 @@ pub trait Provider: Send + Sync {
|
|||
|
||||
/// Whether provider supports native tool calls over API.
|
||||
fn supports_native_tools(&self) -> bool {
|
||||
false
|
||||
self.capabilities().native_tool_calling
|
||||
}
|
||||
|
||||
/// Warm up the HTTP connection pool (TLS handshake, DNS, HTTP/2 setup).
|
||||
|
|
@ -358,6 +358,27 @@ pub trait Provider: Send + Sync {
|
|||
mod tests {
|
||||
use super::*;
|
||||
|
||||
struct CapabilityMockProvider;
|
||||
|
||||
#[async_trait]
|
||||
impl Provider for CapabilityMockProvider {
|
||||
fn capabilities(&self) -> ProviderCapabilities {
|
||||
ProviderCapabilities {
|
||||
native_tool_calling: true,
|
||||
}
|
||||
}
|
||||
|
||||
async fn chat_with_system(
|
||||
&self,
|
||||
_system_prompt: Option<&str>,
|
||||
_message: &str,
|
||||
_model: &str,
|
||||
_temperature: f64,
|
||||
) -> anyhow::Result<String> {
|
||||
Ok("ok".into())
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn chat_message_constructors() {
|
||||
let sys = ChatMessage::system("Be helpful");
|
||||
|
|
@ -442,4 +463,10 @@ mod tests {
|
|||
assert_eq!(caps1, caps2);
|
||||
assert_ne!(caps1, caps3);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn supports_native_tools_reflects_capabilities_default_mapping() {
|
||||
let provider = CapabilityMockProvider;
|
||||
assert!(provider.supports_native_tools());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue