create or replace package pkg_26ai_auto_load
as

/*

-- Teste

    -- gerar arquivos a serem vetorizados
    begin
    PKG_26AI_AUTO_LOAD.prc_refresh_files(p_mimetype => 'PDF',p_embedding_name=>'COHERE');
    PKG_26AI_AUTO_LOAD.prc_refresh_files(p_mimetype => 'JPG',p_embedding_name=>'COHERE');
    PKG_26AI_AUTO_LOAD.prc_refresh_files(p_mimetype => 'CLOB',p_embedding_name=>'COHERE');
    end; 

    -- liste de dados a serem vetorizados. Status incial: NULL
    select * from tb_26ai_auto_load

    -- reserva de dados para associar aos jobs que executarao, marcado status como R
    -- CUIDADO: nao preciso executar manulamnete opois faz parte da rotina de embedding AUTOMATICAMENTE
    declare
      v_name SYS.ODCIVARCHAR2LIST;
    begin
    PKG_26AI_AUTO_LOAD.prc_reserve_files (
    	  p_limit    => 10,	                           
          p_worker_id => 1 ,
          p_oci_cred  => 'OCI_CRED',
          p_bucket  => '',
          p_docs  =>v_name
    	)  ;
    end; 

    -- liste de dados a serem vetorizados. Status reservado por worker id em R
    select * from tb_26ai_auto_load

    -- Embedding 
    -- CUIDADO: ja faz o reserve de acordo com p_worker_id e p_limit
    declare
      v_name SYS.ODCIVARCHAR2LIST;
    begin
    PKG_26AI_AUTO_LOAD.proc_embed_files (
    	  p_limit    => 10,	                           
          p_worker_id => 1 ,
          p_stop_process_list  => 'N'
    	)  ;
    end; 

    -- liste status
    select * from tb_26ai_auto_load  

    -- erro
    select * from tb_26ai_auto_load_debug

    -- vector
    select * from tb_26ai_auto_load_vector

    -- em caso de erro nos TESTES
    begin
    update tb_26ai_auto_load set ERROR_MSG= null, status = NULL, WORKER_ID = null where status is not null ;
    delete tb_26ai_auto_load_debug;
    delete tb_26ai_auto_load_vector;
    end;


*/
   c_embedding_name CONSTANT VARCHAR2(10) := 'ONNX-E5'; -- requer ajuste do JSON usado nas rotinas de embedding no BODY

   PROCEDURE  prc_refresh_files(p_oci_cred  IN VARCHAR2 default 'OCI_CRED',
                                p_bucket in varchar2 default null,
                                p_mimetype in varchar2 default 'PDF',
                                 p_embedding_name  in varchar2 default 'COHERE');
									 
   PROCEDURE  prc_reserve_files (
	  p_limit     IN NUMBER,	                           
      p_worker_id IN VARCHAR2,
      p_oci_cred  IN VARCHAR2 default 'OCI_CRED',
      p_bucket in varchar2 ,
      p_docs  OUT SYS.ODCIVARCHAR2LIST,
      p_mimetype in varchar2 default 'PDF',
      p_embedding_name  in varchar2 default 'COHERE'	) ;
	  
	PROCEDURE proc_embed_files(p_limit in number default 10,
	                           p_worker_id in number,
							   p_stop_process_list in varchar2 default 'N',
                               p_mimetype in varchar2 default 'PDF',
                               p_embedding_name  in varchar2 default 'COHERE');

	PROCEDURE proc_remove_jobs;

	PROCEDURE proc_add_jobs(p_limit in number, 
                            p_total_jobs in number,
                            p_mimetype in varchar2 default 'PDF',
                            p_embedding_name  in varchar2 default 'COHERE');
  
end;
/