# shellcheck shell=dash
# https://platform.openai.com/docs/guides/embeddings

___x_cmd_openai_embedding(){
    local X_help_cmd='___x_cmd help -m openai embedding';   help:arg-null:parse
    param:scope     ___x_cmd_openai
    param:subcmd    ___x_cmd_openai_embedding                       \
        create            "Creates an embedding vector representing the input text"

    param:subcmd:try
    param:run

    ___x_cmd_openai_embedding _param_help_doc
    return 1
}

# text-embedding-ada-002
# x openai embedding create --input "x-cmd" --model "text-embedding-ada-002"
___x_cmd_openai_embedding_create(){
    local X_help_cmd='___x_cmd help -m openai embedding create';   help:arg-null:parse
    param:scope     ___x_cmd_openai
    param:dsl       '
options:
    --input              "Input text to embed, encoded as a string or array of tokens"          <>:String
    --model              "ID of the model to use"                                               <>:String
    --encoding_format    "The format to return the embeddings in"                               <>=""        = float base64
    --user               "A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse"     <>=""
'
    param:run

    local gen_openai_json="";   gen_openai_json="$(param:option2json)"
    openai:debug  --data "$gen_openai_json"
    ___x_cmd_openai_curl post "/embeddings" gen_openai_json
}

