behest_core/capabilities.rs
1//! Capability flags advertised by provider implementations.
2//!
3//! Used by the runtime for feature negotiation and routing decisions.
4
5use serde::{Deserialize, Serialize};
6
7/// Static capability advertisement returned by provider implementations.
8#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]
9pub struct ProviderCapabilities {
10 /// Provider can return a complete chat response.
11 pub chat: bool,
12 /// Provider can stream chat events.
13 pub chat_stream: bool,
14 /// Provider accepts tool definitions in chat requests.
15 pub tool_calling: bool,
16 /// Provider can execute or request multiple tool calls concurrently.
17 pub parallel_tool_calls: bool,
18 /// Provider can constrain output with a JSON schema.
19 pub json_schema_output: bool,
20 /// Provider can consume image content.
21 pub vision: bool,
22 /// Provider can produce embeddings.
23 pub embeddings: bool,
24 /// Maximum supported input tokens, when known.
25 pub max_input_tokens: Option<u32>,
26 /// Maximum supported output tokens, when known.
27 pub max_output_tokens: Option<u32>,
28}
29
30impl ProviderCapabilities {
31 /// Returns a capability set for a basic non-streaming chat provider.
32 #[must_use]
33 pub const fn chat() -> Self {
34 Self {
35 chat: true,
36 ..Self::empty()
37 }
38 }
39
40 /// Returns a capability set for an embedding-only provider.
41 #[must_use]
42 pub const fn embeddings() -> Self {
43 Self {
44 embeddings: true,
45 ..Self::empty()
46 }
47 }
48
49 /// Returns an empty capability set.
50 #[must_use]
51 pub const fn empty() -> Self {
52 Self {
53 chat: false,
54 chat_stream: false,
55 tool_calling: false,
56 parallel_tool_calls: false,
57 json_schema_output: false,
58 vision: false,
59 embeddings: false,
60 max_input_tokens: None,
61 max_output_tokens: None,
62 }
63 }
64}