Skip to content

Commit

Permalink
update changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
svilupp committed Sep 25, 2024
1 parent 2fb06b0 commit 1c30c44
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 19 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

* Fixed a bug in `request_body` that prevented `query` argument from being passed to `HTTP.jl`.
* Updated completion model in the unit tests suite (`ada` series has been deprecated).
* Added warnings to `create_edit` that it's deprecated by OpenAI. Disabled tests for `get_usage_status` and `create_edit` functions, as they cannot be tested via API.

### 0.9.0

Expand Down
3 changes: 3 additions & 0 deletions src/OpenAI.jl
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,8 @@ end
"""
Create edit
Note: This functionality is not accessible via API anymore -- see https://platform.openai.com/docs/deprecations
# Arguments:
- `api_key::String`: OpenAI API key
- `model_id::String`: Model id (e.g. "text-davinci-edit-001")
Expand All @@ -409,6 +411,7 @@ function create_edit(api_key::String,
instruction::String;
http_kwargs::NamedTuple = NamedTuple(),
kwargs...)
@warn "This functionality is not accessible via API anymore -- see https://platform.openai.com/docs/deprecations"
return openai_request("edits",
api_key;
method = "POST",
Expand Down
19 changes: 11 additions & 8 deletions test/completion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,16 @@
end
end

@testset "create edit" begin
r = create_edit(ENV["OPENAI_API_KEY"],
"gpt-3.5-turbo-instruct",
"Fix this piece of text for grammatical errors",
input = "I hav ben riting sence i wuz 5")
println(r.response["choices"][begin]["text"])
if !=(r.status, 200)
@test false
# This functionality is not accessible via API anymore -- see https://platform.openai.com/docs/deprecations
@test_skip begin
@testset "create edit" begin
r = create_edit(ENV["OPENAI_API_KEY"],
"gpt-3.5-turbo-instruct",
"Fix this piece of text for grammatical errors",
input = "I hav ben riting sence i wuz 5")
println(r.response["choices"][begin]["text"])
if !=(r.status, 200)
@test false
end
end
end
25 changes: 14 additions & 11 deletions test/usage.jl
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

0 comments on commit 1c30c44

Please sign in to comment.