Skip to content

Commit

Permalink
fix: Fixed GetPercent after update.
Browse files Browse the repository at this point in the history
  • Loading branch information
HavenDV committed Sep 17, 2024
1 parent ed1b5d2 commit 9ce89ae
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/libs/Ollama/PullModelResponseExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,14 @@ public static class PullModelResponseExtensions
public static double GetPercent(this PullModelResponse response)
{
response = response ?? throw new ArgumentNullException(nameof(response));

if (response.Total == null || response.Completed == null)
{
return 0;
}

return response.Total == 0
return response.Total.Value == 0
? 100.0
: response.Completed * 100.0 / response.Total;
: response.Completed.Value * 100.0 / response.Total.Value;
}
}
2 changes: 2 additions & 0 deletions src/tests/Ollama.SnapshotTests/TestHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,12 @@ public static async Task CheckSourceAsync(
await Task.WhenAll(
verifier
.Verify(diagnostics)
//.AutoVerify()
.UseDirectory("Snapshots")
.UseTextForParameters("Diagnostics"),
verifier
.Verify(driver)
//.AutoVerify()
.UseDirectory("Snapshots"));
}
}

0 comments on commit 9ce89ae

Please sign in to comment.