Skip to main content

vtcode_core/prompts/system/
tokens.rs

1//! Minimal/lightweight/specialized instruction entry points and token estimation.
2
3use crate::llm::providers::gemini::wire::Content;
4use crate::prompts::static_prompts::{
5    lightweight_instruction_text, minimal_instruction_text, specialized_instruction_text,
6};
7use vtcode_commons::estimate_tokens;
8
9/// Generate a minimal system instruction (pi-inspired, <1K tokens)
10pub fn generate_minimal_instruction() -> Content {
11    Content::system_text(minimal_instruction_text())
12}
13
14/// Generate a lightweight system instruction for simple operations
15pub fn generate_lightweight_instruction() -> Content {
16    Content::system_text(lightweight_instruction_text())
17}
18
19/// Generate a specialized system instruction for advanced operations
20pub fn generate_specialized_instruction() -> Content {
21    Content::system_text(specialized_instruction_text())
22}
23
24// ─── Token Estimation ────────────────────────────────────────────────────────
25
26/// Estimate prompt tokens through the shared workspace tokenizer.
27///
28/// Keeping prompt budgeting on the common estimator makes prompt reports and
29/// the other runtime token budgets use the same tokenization semantics.
30#[must_use]
31pub fn estimate_token_count(text: &str) -> u64 {
32    estimate_tokens(text) as u64
33}