Download codex-rs/backend-client/src/client/profile.rs from SaylorTwift/codex: direct link, hf CLI and curl.
- Browser
- Download file 2.34 kB
-
https://huggingface.co/SaylorTwift/codex/resolve/main/codex-rs/backend-client/src/client/profile.rs
- Command line
-
hf download hf://SaylorTwift/codex/codex-rs/backend-client/src/client/profile.rs
-
curl -L -o profile.rs https://huggingface.co/SaylorTwift/codex/resolve/main/codex-rs/backend-client/src/client/profile.rs
2.34 kB
| //! Read-only profile statistics shared with the desktop account summary. | |
| //! Optional fields retain absence; unknown invocation kinds do not invalidate other statistics. | |
| use super::Client; | |
| use super::RequestError; | |
| use crate::TokenUsageProfileStats; | |
| use http::Method; | |
| use serde::Deserialize; | |
| pub struct AccountProfile { | |
| pub profile: Option<ProfileIdentity>, | |
| pub metadata: Option<ProfileMetadata>, | |
| pub stats: ProfileStats, | |
| } | |
| pub struct ProfileIdentity { | |
| pub display_name: Option<String>, | |
| pub username: Option<String>, | |
| } | |
| pub struct ProfileMetadata { | |
| pub stats_as_of: Option<String>, | |
| pub stats_error: Option<String>, | |
| } | |
| pub struct ProfileStats { | |
| pub tokens: TokenUsageProfileStats, | |
| pub fast_mode_usage_percentage: Option<serde_json::Number>, | |
| pub most_used_reasoning_effort: Option<String>, | |
| pub most_used_reasoning_effort_percentage: Option<serde_json::Number>, | |
| pub unique_skills_used: Option<u64>, | |
| pub total_skills_used: Option<u64>, | |
| pub total_threads: Option<u64>, | |
| pub top_invocations: Option<Vec<ProfileInvocation>>, | |
| } | |
| pub struct ProfileInvocation { | |
| pub kind: ProfileInvocationKind, | |
| pub plugin_name: Option<String>, | |
| pub skill_name: Option<String>, | |
| pub usage_count: Option<u64>, | |
| } | |
| pub enum ProfileInvocationKind { | |
| Plugin, | |
| Skill, | |
| Unknown, | |
| } | |
| impl Client { | |
| /// Read the full profile using the same route as account token usage. | |
| pub async fn get_account_profile(&self) -> Result<AccountProfile, RequestError> { | |
| let url = self.token_usage_profile_url(); | |
| let request = self.request(Method::GET, &url).headers(self.headers()); | |
| let (body, _) = self.exec_request_detailed(request, "GET", &url).await?; | |
| serde_json::from_str(&body) | |
| .map_err(|_| RequestError::Other(anyhow::anyhow!("Invalid account profile response."))) | |
| } | |
| } | |
| mod tests; | |