Skip to content

Commit 38d6c93

Browse files
authored
Fix query parameter (#64)
* Fix query parameter * update changelog
1 parent 762daad commit 38d6c93

File tree

5 files changed

+40
-22
lines changed

5 files changed

+40
-22
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
### 0.9.1
2+
3+
* Fixed a bug in `request_body` that prevented `query` argument from being passed to `HTTP.jl`.
4+
* Updated completion model in the unit tests suite (`ada` series has been deprecated).
5+
* 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.
6+
7+
### 0.9.0
8+
9+
* Added OpenAI Assistants API
10+
111
### 0.8.7
212

313
* disable `test/usage.jl` in `test/runtests.jl` to close issue: https://github.com/JuliaML/OpenAI.jl/issues/46

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "OpenAI"
22
uuid = "e9f21f70-7185-4079-aca2-91159181367c"
33
authors = ["Rory Linehan @rory-linehan", "Marius Fersigan @algunion", "RexWzh @RexWzh", "Thatcher Chamberlin @ThatcherC", "Nicu Stiurca @nstiurca", "Peter @chengchingwen", "Stefan Wojcik @stefanjwojcik", "J S @svilupp", "Logan Kilpatrick @logankilpatrick", "Jerry Ling @Moelf"]
4-
version = "0.9.0"
4+
version = "0.9.1"
55

66
[deps]
77
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"

src/OpenAI.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ end
7777

7878
function request_body(url, method; input, headers, query, kwargs...)
7979
input = isnothing(input) ? [] : input
80-
query = isnothing(query) ? [] : query
8180

8281
resp = HTTP.request(method,
8382
url;
@@ -393,6 +392,8 @@ end
393392
"""
394393
Create edit
395394
395+
Note: This functionality is not accessible via API anymore -- see https://platform.openai.com/docs/deprecations
396+
396397
# Arguments:
397398
- `api_key::String`: OpenAI API key
398399
- `model_id::String`: Model id (e.g. "text-davinci-edit-001")
@@ -410,6 +411,7 @@ function create_edit(api_key::String,
410411
instruction::String;
411412
http_kwargs::NamedTuple = NamedTuple(),
412413
kwargs...)
414+
@warn "This functionality is not accessible via API anymore -- see https://platform.openai.com/docs/deprecations"
413415
return openai_request("edits",
414416
api_key;
415417
method = "POST",

test/completion.jl

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,24 @@
44
@test false
55
end
66
r = create_completion(ENV["OPENAI_API_KEY"],
7-
"text-ada-001";
7+
"gpt-3.5-turbo-instruct";
88
prompt = "Say \"this is a test\"")
99
println(r.response["choices"][begin]["text"])
1010
if !=(r.status, 200)
1111
@test false
1212
end
1313
end
1414

15-
@testset "create edit" begin
16-
r = create_edit(ENV["OPENAI_API_KEY"],
17-
"text-davinci-edit-001",
18-
"Fix this piece of text for grammatical errors",
19-
input = "I hav ben riting sence i wuz 5")
20-
println(r.response["choices"][begin]["text"])
21-
if !=(r.status, 200)
22-
@test false
15+
# This functionality is not accessible via API anymore -- see https://platform.openai.com/docs/deprecations
16+
@test_skip begin
17+
@testset "create edit" begin
18+
r = create_edit(ENV["OPENAI_API_KEY"],
19+
"gpt-3.5-turbo-instruct",
20+
"Fix this piece of text for grammatical errors",
21+
input = "I hav ben riting sence i wuz 5")
22+
println(r.response["choices"][begin]["text"])
23+
if !=(r.status, 200)
24+
@test false
25+
end
2326
end
2427
end

test/usage.jl

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
# Get usage status of an api
22

33
# See https://github.com/JuliaML/OpenAI.jl/issues/46
4-
@testset "usage information" begin
5-
provider = OpenAI.OpenAIProvider(ENV["OPENAI_API_KEY"], "https://api.openai.com/v1", "")
6-
(; quota, usage, daily_costs) = get_usage_status(provider, numofdays = 5)
7-
@test quota > 0
8-
@test usage >= 0
9-
@test length(daily_costs) == 5
10-
println("Total quota: $quota")
11-
println("Total usage: $usage")
12-
costs = [sum(item["cost"] for item in day.line_items) for day in daily_costs]
13-
println("Recent costs(5 days): $costs")
14-
end
4+
# This functionality is not accessible via API anymore -- see https://platform.openai.com/docs/api-reference/administration
5+
@test_skip begin
6+
@testset "usage information" begin
7+
provider = OpenAI.OpenAIProvider(ENV["OPENAI_API_KEY"], "https://api.openai.com/v1", "")
8+
(; quota, usage, daily_costs) = get_usage_status(provider, numofdays = 5)
9+
@test quota > 0
10+
@test usage >= 0
11+
@test length(daily_costs) == 5
12+
println("Total quota: $quota")
13+
println("Total usage: $usage")
14+
costs = [sum(item["cost"] for item in day.line_items) for day in daily_costs]
15+
println("Recent costs(5 days): $costs")
16+
end
17+
end

0 commit comments

Comments
 (0)