@@ -398,10 +398,10 @@ Create embeddings
398
398
To get embeddings for multiple inputs in a single request, pass an array of strings
399
399
or array of token arrays. Each input must not exceed 8192 tokens in length.
400
400
- `model_id::String`: Model id. Defaults to $DEFAULT_EMBEDDING_MODEL_ID .
401
-
401
+
402
402
# Keyword Arguments:
403
403
- `http_kwargs::NamedTuple`: Optional. Keyword arguments to pass to HTTP.request.
404
-
404
+
405
405
For additional details about the endpoint, visit <https://platform.openai.com/docs/api-reference/embeddings>
406
406
"""
407
407
function create_embeddings (api_key:: String ,
421
421
"""
422
422
Create images
423
423
424
- # Arguments:
424
+ # Arguments:
425
425
- `api_key::String`: OpenAI API key
426
426
- `prompt`: The input text to generate the image(s) for, as String or array of tokens.
427
427
- `n::Integer`: Optional. The number of images to generate. Must be between 1 and 10.
@@ -433,8 +433,8 @@ Create images
433
433
434
434
For additional details about the endpoint, visit <https://platform.openai.com/docs/api-reference/images/create>
435
435
436
- # once the request is made,
437
- download like this:
436
+ # once the request is made,
437
+ download like this:
438
438
`download(r.response["data"][begin]["url"], "image.png")`
439
439
"""
440
440
function create_images (api_key:: String ,
@@ -451,83 +451,6 @@ function create_images(api_key::String,
451
451
kwargs... )
452
452
end
453
453
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
-
531
454
include (" assistants.jl" )
532
455
533
456
export OpenAIResponse
@@ -537,7 +460,6 @@ export create_chat
537
460
export create_completion
538
461
export create_embeddings
539
462
export create_images
540
- export get_usage_status
541
463
542
464
# Assistant exports
543
465
export list_assistants
0 commit comments