Skip to content

Commit

Permalink
fix: model stats fallback (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
louisgv committed Jun 22, 2023
1 parent 850dfb7 commit 6b8087b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion apps/desktop/src-tauri/src/model/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ pub struct ModelStats {
crate::macros::bucket_state::make!(ModelStats, "model_stats", "v1");
impl State {
pub fn increment_load_count(&self, path: &str) -> Result<(), String> {
let current_value = self.get(path)?;
let current_value = self.get(path).unwrap_or_default();
let bucket = self.0.lock();
let file_path = String::from(path);

Expand Down
7 changes: 3 additions & 4 deletions apps/desktop/src/features/inference-server/model-config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ export const ModelConfig = () => {
const {
model,
modelLoadState,
launchCount,
incrementLaunchCount,
modelStats,
loadModel,
downloadState,
modelConfig
Expand Down Expand Up @@ -137,7 +136,7 @@ export const ModelConfig = () => {
"text-xs rounded-lg bg-gray-6 py-2 px-3",
className
)}>
{launchCount}
{modelStats.launchCount}
</code>
)}
isSpinning={modelLoadState === ModelLoadState.Loading}
Expand All @@ -147,7 +146,7 @@ export const ModelConfig = () => {
downloadState !== DownloadState.Completed)
}
onClick={() => {
incrementLaunchCount()
modelStats.incrementLaunchCount()
loadModel()
}}>
{modelLoadState === ModelLoadState.Loaded ? "Loaded" : "Load Model"}
Expand Down
5 changes: 2 additions & 3 deletions apps/desktop/src/providers/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const useModelProvider = ({ model }: { model: ModelMetadata }) => {
const { downloadState, pauseDownload, progress, resumeDownload, modelSize } =
useModelDownload(model)

const { launchCount, incrementLaunchCount } = useModelStats(model)
const modelStats = useModelStats(model)

const knownModelInfo = useMemo(
() => modelMap?.[integrity?.blake3],
Expand Down Expand Up @@ -137,8 +137,7 @@ const useModelProvider = ({ model }: { model: ModelMetadata }) => {
progress,
pauseDownload,
resumeDownload,
launchCount,
incrementLaunchCount
modelStats
}
}

Expand Down

1 comment on commit 6b8087b

@vercel
Copy link

@vercel vercel bot commented on 6b8087b Jun 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.