feat(usage): track cloud quotas and expose :limits
Acceptance Criteria:\n- header shows hourly/weekly usage with colored thresholds\n- :limits command prints persisted usage data and quotas\n- token usage survives restarts and emits 80%/95% toasts Test Notes:\n- cargo test -p owlen-core usage
This commit is contained in:
@@ -32,6 +32,10 @@ pub const OLLAMA_API_KEY_ENV: &str = "OLLAMA_API_KEY";
|
||||
pub const LEGACY_OLLAMA_CLOUD_API_KEY_ENV: &str = "OLLAMA_CLOUD_API_KEY";
|
||||
/// Legacy environment variable used by earlier Owlen releases.
|
||||
pub const LEGACY_OWLEN_OLLAMA_CLOUD_API_KEY_ENV: &str = "OWLEN_OLLAMA_CLOUD_API_KEY";
|
||||
/// Default hourly soft quota for Ollama Cloud usage visualization (tokens).
|
||||
pub const DEFAULT_OLLAMA_CLOUD_HOURLY_QUOTA: u64 = 50_000;
|
||||
/// Default weekly soft quota for Ollama Cloud usage visualization (tokens).
|
||||
pub const DEFAULT_OLLAMA_CLOUD_WEEKLY_QUOTA: u64 = 250_000;
|
||||
/// Default base URL for local Ollama daemons.
|
||||
pub const OLLAMA_LOCAL_BASE_URL: &str = "http://localhost:11434";
|
||||
/// Default OpenAI API base URL.
|
||||
@@ -880,6 +884,14 @@ fn default_ollama_cloud_config() -> ProviderConfig {
|
||||
OLLAMA_CLOUD_ENDPOINT_KEY.to_string(),
|
||||
serde_json::Value::String(OLLAMA_CLOUD_BASE_URL.to_string()),
|
||||
);
|
||||
extra.insert(
|
||||
"hourly_quota_tokens".to_string(),
|
||||
serde_json::Value::Number(serde_json::Number::from(DEFAULT_OLLAMA_CLOUD_HOURLY_QUOTA)),
|
||||
);
|
||||
extra.insert(
|
||||
"weekly_quota_tokens".to_string(),
|
||||
serde_json::Value::Number(serde_json::Number::from(DEFAULT_OLLAMA_CLOUD_WEEKLY_QUOTA)),
|
||||
);
|
||||
|
||||
ProviderConfig {
|
||||
enabled: false,
|
||||
|
||||
Reference in New Issue
Block a user