-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
29 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,17 @@ | ||
# Get usage status of an api | ||
|
||
# See https://github.com/JuliaML/OpenAI.jl/issues/46 | ||
@testset "usage information" begin | ||
provider = OpenAI.OpenAIProvider(ENV["OPENAI_API_KEY"], "https://api.openai.com/v1", "") | ||
(; quota, usage, daily_costs) = get_usage_status(provider, numofdays = 5) | ||
@test quota > 0 | ||
@test usage >= 0 | ||
@test length(daily_costs) == 5 | ||
println("Total quota: $quota") | ||
println("Total usage: $usage") | ||
costs = [sum(item["cost"] for item in day.line_items) for day in daily_costs] | ||
println("Recent costs(5 days): $costs") | ||
end | ||
# This functionality is not accessible via API anymore -- see https://platform.openai.com/docs/api-reference/administration | ||
@test_skip begin | ||
@testset "usage information" begin | ||
provider = OpenAI.OpenAIProvider(ENV["OPENAI_API_KEY"], "https://api.openai.com/v1", "") | ||
(; quota, usage, daily_costs) = get_usage_status(provider, numofdays = 5) | ||
@test quota > 0 | ||
@test usage >= 0 | ||
@test length(daily_costs) == 5 | ||
println("Total quota: $quota") | ||
println("Total usage: $usage") | ||
costs = [sum(item["cost"] for item in day.line_items) for day in daily_costs] | ||
println("Recent costs(5 days): $costs") | ||
end | ||
end |