Skip to content

Commit bd3ed8e

Browse files
committed
remove get_usage_status
1 parent b0ba988 commit bd3ed8e

File tree

3 files changed

+6
-101
lines changed

3 files changed

+6
-101
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
### 0.10.0
22

3-
* Removed deprecated features `create_edit` and `get_usage_statistics`
3+
* Removed deprecated features `create_edit` and `get_usage_status`
44

55
### 0.9.1
66

src/OpenAI.jl

Lines changed: 5 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -398,10 +398,10 @@ Create embeddings
398398
To get embeddings for multiple inputs in a single request, pass an array of strings
399399
or array of token arrays. Each input must not exceed 8192 tokens in length.
400400
- `model_id::String`: Model id. Defaults to $DEFAULT_EMBEDDING_MODEL_ID.
401-
401+
402402
# Keyword Arguments:
403403
- `http_kwargs::NamedTuple`: Optional. Keyword arguments to pass to HTTP.request.
404-
404+
405405
For additional details about the endpoint, visit <https://platform.openai.com/docs/api-reference/embeddings>
406406
"""
407407
function create_embeddings(api_key::String,
@@ -421,7 +421,7 @@ end
421421
"""
422422
Create images
423423
424-
# Arguments:
424+
# Arguments:
425425
- `api_key::String`: OpenAI API key
426426
- `prompt`: The input text to generate the image(s) for, as String or array of tokens.
427427
- `n::Integer`: Optional. The number of images to generate. Must be between 1 and 10.
@@ -433,8 +433,8 @@ Create images
433433
434434
For additional details about the endpoint, visit <https://platform.openai.com/docs/api-reference/images/create>
435435
436-
# once the request is made,
437-
download like this:
436+
# once the request is made,
437+
download like this:
438438
`download(r.response["data"][begin]["url"], "image.png")`
439439
"""
440440
function create_images(api_key::String,
@@ -451,83 +451,6 @@ function create_images(api_key::String,
451451
kwargs...)
452452
end
453453

454-
"""
455-
get_usage_status(provider::OpenAIProvider; numofdays::Int=99)
456-
457-
NOTE: currently this endpoint can only be used from the browser. See https://github.com/JuliaML/OpenAI.jl/issues/46
458-
459-
Get usage status for the last `numofdays` days.
460-
461-
# Arguments:
462-
- `provider::OpenAIProvider`: OpenAI provider object.
463-
- `numofdays::Int`: Optional. Defaults to 99. The number of days to get usage status for.
464-
Note that the maximum `numofdays` is 99.
465-
466-
# Returns:
467-
- `quota`: The total quota for the subscription.(unit: USD)
468-
- `usage`: The total usage for the subscription.(unit: USD)
469-
- `daily_costs`: The daily costs for the subscription.
470-
471-
Each element of `daily_costs` looks like this:
472-
```
473-
{
474-
"timestamp": 1681171200,
475-
"line_items": [
476-
{
477-
"name": "Instruct models",
478-
"cost": 0
479-
},
480-
{
481-
"name": "Chat models",
482-
"cost": 0
483-
},
484-
{
485-
"name": "GPT-4",
486-
"cost": 0
487-
},
488-
{
489-
"name": "Fine-tuned models",
490-
"cost": 0
491-
},
492-
{
493-
"name": "Embedding models",
494-
"cost": 0
495-
},
496-
{
497-
"name": "Image models",
498-
"cost": 0
499-
},
500-
{
501-
"name": "Audio models",
502-
"cost": 0
503-
}
504-
]
505-
}
506-
```
507-
"""
508-
function get_usage_status(provider::OpenAIProvider; numofdays::Int = 99)
509-
(; base_url, api_key) = provider
510-
isempty(api_key) && throw(ArgumentError("api_key cannot be empty"))
511-
numofdays > 99 && throw(ArgumentError("numofdays cannot be greater than 99"))
512-
513-
# Get total quota from subscription_url
514-
subscription_url = "$base_url/dashboard/billing/subscription"
515-
subscrip = HTTP.get(subscription_url, headers = auth_header(provider))
516-
resp = OpenAIResponse(subscrip.status, JSON3.read(subscrip.body))
517-
# TODO: catch error
518-
quota = resp.response.hard_limit_usd
519-
520-
# Get usage status from billing_url
521-
start_date = today()
522-
end_date = today() + Day(numofdays)
523-
billing_url = "$base_url/dashboard/billing/usage?start_date=$(start_date)&end_date=$(end_date)"
524-
billing = HTTP.get(billing_url, headers = auth_header(provider))
525-
resp = OpenAIResponse(billing.status, JSON3.read(billing.body))
526-
usage = resp.response.total_usage / 100
527-
daily_costs = resp.response.daily_costs
528-
return (; quota, usage, daily_costs)
529-
end
530-
531454
include("assistants.jl")
532455

533456
export OpenAIResponse
@@ -537,7 +460,6 @@ export create_chat
537460
export create_completion
538461
export create_embeddings
539462
export create_images
540-
export get_usage_status
541463

542464
# Assistant exports
543465
export list_assistants

test/usage.jl

Lines changed: 0 additions & 17 deletions
This file was deleted.

0 commit comments

Comments
 (0)