Upload files to "/"
This commit is contained in:
56
fnc_26ai_rag_vllm.sql
Normal file
56
fnc_26ai_rag_vllm.sql
Normal file
@@ -0,0 +1,56 @@
|
||||
create or replace FUNCTION "FNC_26AI_RAG_VLLM" (p_ai_prompt IN clob)
|
||||
RETURN CLOB AS
|
||||
v_gen_ai_model varchar2(500) :='openai/gpt-oss-120b';
|
||||
resp dbms_cloud_types.RESP;
|
||||
BEGIN
|
||||
/*
|
||||
|
||||
Criado por: fernando.leal@oracle.com
|
||||
Data: Mar/2026
|
||||
Objetivo: RAG via PL/SQL usando um vLLM em arquitetura LOCAL
|
||||
|
||||
v1 - funcao de RAG usando openai/gpt-oss-120b - fleal
|
||||
|
||||
Set host to local to disable credential
|
||||
The provider value must specify openai
|
||||
https://docs.oracle.com/en/database/oracle/oracle-database/26/vecse/utl_to_embedding-and-utl_to_embeddings-dbms_vector_chain.html
|
||||
|
||||
*/
|
||||
|
||||
resp := dbms_cloud.send_request(
|
||||
credential_name => NULL,
|
||||
uri => 'https://hub-gpus.DOMINIO.com.br/gpt120/v1/chat/completions',
|
||||
method => DBMS_CLOUD.METHOD_POST,
|
||||
headers => JSON_OBJECT('Content-Type' VALUE 'application/json'),
|
||||
body => UTL_RAW.CAST_TO_RAW('{"model": "' || v_gen_ai_model || '",
|
||||
"messages": [{"role": "user",
|
||||
"content": "' || p_ai_prompt || '"
|
||||
}]}')
|
||||
);
|
||||
|
||||
|
||||
--RETURN json_value( dbms_cloud.get_response_text(resp) , '$.chatResponse.choices[0].message.content[0].text') ;
|
||||
--
|
||||
RETURN DBMS_CLOUD.GET_RESPONSE_TEXT(resp) ;
|
||||
|
||||
/* opcao 2:
|
||||
declare
|
||||
params clob;
|
||||
input clob;
|
||||
response clob;
|
||||
begin
|
||||
input := '[{"role": "user","content": "Fale sobre a Oracle"}]';
|
||||
params := '{
|
||||
"provider": "openai",
|
||||
"url": "https://hub-gpus.DOMINIO.com.br/gpt120/v1/chat/completions",
|
||||
"host": "local",
|
||||
"model": "openai/gpt-oss-120b"}';
|
||||
response := dbms_vector_chain.utl_to_generate_text( input , json(params)) ;
|
||||
DBMS_OUTPUT.PUT_LINE(response);
|
||||
end; */
|
||||
|
||||
EXCEPTION
|
||||
WHEN OTHERS THEN
|
||||
RETURN sqlerrm;
|
||||
END;
|
||||
/
|
||||
Reference in New Issue
Block a user