create or replace procedure prc_26AI_rerank_VLLM( p_text in varchar2, p_string_options in varchar2)
as
  l_resp        DBMS_CLOUD_TYPES.resp;
  l_text        CLOB;
  l_body_clob   CLOB;
  l_body        BLOB;
  l_query       VARCHAR2(500) := 'qual o melhor meio de transporte para ir ate o trabalho em SP'; -- := p_text;
BEGIN
  -- montar o JSON do body corretamente
  l_body_clob := '{'
    || '"model": "Qwen/Qwen3-Reranker-8B",'
    || '"topN": 1,'   
    || '"query": "' || l_query || '",'
    || '"documents": ["foguete", "planeta", "carro"]'
    || '}';

    -- "documents": [ p_string_options ]

  l_body := UTL_I18N.STRING_TO_RAW(l_body_clob, 'AL32UTF8');

  l_resp := DBMS_CLOUD.SEND_REQUEST(
    credential_name => NULL,
    uri             => 'https://hub-gpus.DOMINIO.com.br/rerank/v1/rerank',
    method          => DBMS_CLOUD.METHOD_POST,
    headers         => JSON_OBJECT('Content-Type' VALUE 'application/json'),
    body            => l_body
  );

  l_text := DBMS_CLOUD.GET_RESPONSE_TEXT(l_resp);

  DBMS_OUTPUT.PUT_LINE('Status: ' || DBMS_CLOUD.GET_RESPONSE_STATUS_CODE(l_resp));
  DBMS_OUTPUT.PUT_LINE(SUBSTR(l_text, 1, 5000));
END;
/