Esempi di utilizzo di Select AI Agent
Esplora esempi che mostrano come creare, configurare e interagire con Select AI Agent per attività comuni come l'analisi di filmati, l'analisi dei log e l'assistenza clienti.
- Esempio: creazione di un agente
Creare un agente per eseguire un task definito. - Esempio: creazione di strumenti integrati
creazione di strumenti integrati quali SQL, RAG, Websearch, Email e Slack. Questi strumenti consentono ad agenti e task di eseguire query sui dati, recuperare informazioni, eseguire ricerche nel Web e inviare notifiche. - Esempio: creazione di un task
Creare un task che un agente può eseguire. - Esempio: creazione di un team agente
Creare team agente per eseguire i task. - Esempio: creazione di un agente di analisi filmati con strumenti integrati
In questo esempio viene illustrato come creare un agente di analisi filmati utilizzando Seleziona agente AI. In questo esempio, è possibile impostare un agente di analisi filmati che recupera dati, risponde a domande, esegue ricerche sul Web e invia notifiche Slack tramite e-mail. - Esempio: creazione di un agente restituzione prodotto
In questo esempio viene illustrato come creare un agente conversazionale a più turni utilizzando Seleziona agente AI. In questo esempio, è possibile impostare un agente del servizio clienti che gestisce i resi dei prodotti e aggiorna lo stato di restituzione nel database. - Esempio: recupero e analisi dei report di log
In questo esempio viene illustrato come creare un team agente utilizzando due coppie agente-task per recuperare i log e analizzarli. - Esempio: creazione di uno strumento HTTP personalizzato
In questo esempio viene definita una funzione PL/SQL che invia una richiestaHTTP GETe restituisce il testo della risposta. La funzione viene quindi aggiunta nello strumento Seleziona agente AI. - Esempio: visualizzazione dei prompt e delle risposte dell'agente dall'ultima esecuzione del team
In questo esempio è possibile eseguire il debug dell'attività Seleziona agente AI recente visualizzando prompt, risposte e pensieri dell'agente dall'esecuzione più recente del team dell'agente utilizzando viste cronologiche e dati di conversazione. - Esempio: ripresa dell'esecuzione di un team agente dallo stato WAITING_FOR_HUMAN
In questo esempio viene illustrato come riprendere l'esecuzione di un team agente quando lo stato della cronologia dei task èWAITING_FOR_HUMAN. Quando un team agente entra nello statoWAITING_FOR_HUMAN, viene sospeso fino a quando un utente non fornisce l'input o la conferma successiva. È possibile riprendere l'esecuzione a seconda di come si utilizza il team agente: nella riga di comando SQL o tramiteDBMS_CLOUD_AI_AGENT.RUN_TEAM.
Argomento padre: Seleziona agente AI
Esempio: creazione di un agente
In questo esempio viene creato un agente denominato Customer_Return_Agent responsabile della gestione delle conversazioni correlate alla restituzione del prodotto.
Questo esempio illustra l'utilizzo di Google come provider AI specificato nel profilo AI denominato GOOGLE. Il profilo AI identifica l'LLM utilizzato dall'agente per il ragionamento e le risposte. L'attributo role fornisce istruzioni per guidare l'agente.
BEGIN
DBMS_CLOUD_AI_AGENT.CREATE_AGENT(
agent_name => 'CustomerAgent',
attributes =>'{
"profile_name": "GOOGLE",
"role": "You are an experienced customer agent who deals with customers return request."
}'
);
END;
/ Ogni agente in un team multi-agente può avere un profilo AI distinto e ogni profilo può utilizzare un provider AI e/o un LLM diverso.
Argomento padre: Esempi di utilizzo di Seleziona agente AI
Esempio: creazione di strumenti integrati
Select AI Agent accetta i seguenti tipi di strumenti:
-
SQL -
RAG -
WEBSEARCH -
NOTIFICATIONEMAILSLACK
Gli strumenti integrati (ad esempio SQL e RAG) includono istruzioni interne. Facoltativamente, è possibile aggiungere istruzioni fornite dall'utente per adattare il comportamento al proprio caso d'uso. L'aggiunta di un'istruzione può aggiungere un contesto specifico del task (ad esempio, query di ambito a uno schema specifico o aiutare ad applicare un formato di risposta). Ciò può migliorare la pertinenza per gli scenari specializzati. Istruzioni scritte in modo errato o eccessivamente prescrittive possono compromettere le prestazioni degli strumenti. Mantenere le istruzioni brevi, specifiche e coerenti con lo scopo dello strumento.
In questo esempio viene creato uno strumento SQL che converte le query in linguaggio naturale in istruzioni SQL. Lo strumento SQL consente agli agenti di rispondere alle domande correlate ai dati mappando i prompt nelle query SQL.
Questo esempio mostra l'uso di OCI come provider AI specificato nel profilo AI denominato nl2sql_profile. Il profilo AI identifica l'LLM utilizzato dall'agente per il ragionamento e le risposte. In questo esempio, il profilo AI nl2sql_profile definisce il set di tabelle di schema SH su cui l'agente può eseguire query, consentendo l'accesso in linguaggio naturale AI dati della cronologia delle vendite comunemente utilizzati, ad esempio clienti, prodotti, promozioni e paesi. Lo strumento SQL utilizza gli oggetti di database specificati nel profilo AI, garantendo che le istruzioni SQL generate rimangano accurate e pertinenti per il data set SH.
BEGIN
DBMS_CLOUD_AI.CREATE_PROFILE(
profile_name => 'nl2sql_profile',
attributes => '{"provider": "oci",
"credential_name": "GEN1_CRED",
"oci_compartment_id": "ocid1.compartment.oc1..aaaa...",
object_list": [{"owner": "SH", "name": "customers"},
{"owner": "SH", "name": "countries"},
{"owner": "SH", "name": "supplementary_demographics"},
{"owner": "SH", "name": "profits"},
{"owner": "SH", "name": "promotions"},
{"owner": "SH", "name": "products"}]
}');
end;
/
EXEC DBMS_CLOUD_AI_AGENT.DROP_TOOL('SQL');
BEGIN
DBMS_CLOUD_AI_AGENT.CREATE_TOOL(
tool_name => 'SQL',
attributes => '{"tool_type": "SQL",
"tool_params": {"profile_name": "nl2sql_profile"}}'
);
END;
/In questo esempio viene creato uno strumento RAG (Retrieval Augmented Generation). Lo strumento RAG consente agli agenti di recuperare e mettere a terra le risposte nei documenti aziendali, migliorando l'accuratezza per le risposte basate sulla conoscenza.
In questo esempio viene illustrata la definizione di un RAG_PROFILE con credenziali, un indice vettoriale e la specifica dei parametri del profilo. Quindi, creare un indice vettoriale RAG_INDEX nello storage degli oggetti per le integrazioni dei documenti e creare il collegamento RAG_TOOL al profilo.
BEGIN
DBMS_CLOUD_AI.CREATE_PROFILE(
profile_name =>'RAG_PROFILE',
attributes =>'{"provider": "oci",
"credential_name": "GENAI_CRED",
"vector_index_name": "RAG_INDEX",
"oci_compartment_id": "ocid1.compartment.oc1..aaaa..",
"temperature": 0.2,
"max_tokens": 3000
}');
END;
/
BEGIN
DBMS_CLOUD_AI.CREATE_VECTOR_INDEX(
index_name => 'RAG_INDEX',
attributes => '{"vector_db_provider": "oracle",
"location": "https://swiftobjectstorage.us-phoenix-1.oraclecloud.com/v1/my_namespace/my_bucket/my_data_folder",
"object_storage_credential_name": "OCI_CRED",
"profile_name": "RAG_PROFILE",
"chunk_overlap":128,
"chunk_size":1024
}');
END;
/
EXEC DBMS_CLOUD_AI_AGENT.DROP_TOOL('RAG_TOOL');
BEGIN
DBMS_CLOUD_AI_AGENT.CREATE_TOOL(
tool_name => 'RAG_TOOL',
attributes => '{"tool_type": "RAG",
"tool_params": {"profile_name": "RAG_PROFILE"}}'
);
END;
/
In questo esempio viene creato uno strumento di ricerca Web per il recupero dei dettagli da Internet. Lo strumento di ricerca Web consente agli agenti di cercare informazioni dal Web, ad esempio i prezzi o le descrizioni dei prodotti.
OPENAI_CRED con la chiave API e creazione dello strumento di ricerca Web, descrivendone lo scopo, collegandolo alle credenziali.
OpenAI è l'unico provider AI di ricerca Web supportato.
BEGIN
DBMS_NETWORK_ACL_ADMIN.APPEND_HOST_ACE(
host => 'api.openai.com',
ace => xs$ace_type(privilege_list => xs$name_list('http'),
principal_name => 'ADB_USER',
principal_type => xs_acl.ptype_db)
);
END;
/
BEGIN
DBMS_CLOUD.CREATE_CREDENTIAL(
credential_name => 'OPENAI_CRED',
username => 'OPENAI',
password => '<OPENAI_API_KEY>'
);
END;
/
EXEC DBMS_CLOUD_AI_AGENT.DROP_TOOL('Websearch');
BEGIN
DBMS_CLOUD_AI_AGENT.create_tool(
tool_name => 'Websearch',
attributes => '{"instruction": "This tool can be used for searching the details about topics mentioned in notes and prepare a summary about prices, details on web",
"tool_type": "WEBSEARCH",
"tool_params": {"credential_name": "OPENAI_CRED"}}'
);
END;
/
In questo esempio viene creato uno strumento di notifica e-mail. Lo strumento E-mail consente agli agenti di inviare e-mail di notifica come parte del flusso di lavoro.
Questo esempio illustra la creazione delle credenziali EMAIL_CRED con la password, consentendo l'accesso SMTP per l'utente del database e la creazione di uno strumento di notifica di tipo EMAIL, inclusi i dettagli SMTP, il mittente e gli indirizzi dei destinatari.
BEGIN
DBMS_CLOUD.CREATE_CREDENTIAL(
credential_name => 'EMAIL_CRED',
username => '<username>',
password => '<password>');
END;
/
-- Allow SMTP access for user
BEGIN
DBMS_NETWORK_ACL_ADMIN.APPEND_HOST_ACE(
host => 'smtp.email.us-ashburn-1.oci.oraclecloud.com',
lower_port => 587,
upper_port => 587,
ace => xs$ace_type(privilege_list => xs$name_list('SMTP'),
principal_name => 'ADB_USER',
principal_type => xs_acl.ptype_db));
END;
/
EXEC DBMS_CLOUD_AI_AGENT.DROP_TOOL('Email');
BEGIN
DBMS_CLOUD_AI_AGENT.CREATE_TOOL(
tool_name => 'EMAIL',
attributes => '{"tool_type": "NOTIFICATION",
"tool_params": {"notification_type" : "EMAIL",
"credential_name": "EMAIL_CRED",
"recipient": "example_recipient@oracle.com",
"smtp_host": "smtp.email.us-ashburn-1.oci.oraclecloud.com",
"sender": "example_sender@oracle.com"}}'
);
END;
/
In questo esempio viene creato uno strumento di notifica Slack. Lo strumento Slack consente agli agenti di consegnare le notifiche direttamente a un canale dell'area di lavoro Slack.
Questo esempio illustra l'aggiunta di una voce ACL per Slack e la creazione di uno strumento di notifica con tipo SLACK che lo collega a SLACK_CRED e al canale di destinazione.
BEGIN
DBMS_NETWORK_ACL_ADMIN.APPEND_HOST_ACE (
host => 'slack.com',
lower_port => 443,
upper_port => 443,
ace => xs$ace_type(
privilege_list => xs$name_list('http'),
principal_name => 'ADB_USER',
principal_type => xs_acl.ptype_db));
END;
/
BEGIN
DBMS_CLOUD_AI_AGENT.create_tool(
tool_name => 'slack',
attributes => '{"tool_type": "SLACK",
"tool_params": {"credential_name": "SLACK_CRED",
"channel": "<channel_number>"}}'
);
END;
/Argomento padre: Esempi di utilizzo di Seleziona agente AI
Esempio: creazione di un task
Solo un DBA può concedere i privilegi EXECUTE e la procedura ACL di rete.
In questo esempio viene creato Generate_Email_Task che indica all'LLM di produrre un'e-mail di conferma standard utilizzando dati strutturati.
Nell'esempio seguente viene illustrato l'utilizzo dell'attributo instruction e vengono fornite istruzioni su ciò che l'e-mail deve includere.
BEGIN DBMS_CLOUD_AI_AGENT.DROP_TASK('Generate_Email_Task');
EXCEPTION WHEN OTHERS THEN NULL; END;
/
BEGIN
DBMS_CLOUD_AI_AGENT.CREATE_TASK(
task_name => 'Generate_Email_Task',
attributes => '{"instruction": "Use the customer information and product details to generate an email in a professional format. The email should:' ||
'1. Include a greeting to the customer by name' ||
'2. Specify the item being returned, the order number, and the reason for the return' ||
'3. If it is a refund, state the refund will be issued to the credit card on record.' ||
'4. If it is a replacement, state that the replacement will be shipped in 3-5 business days."}'
);
END;In questo esempio viene creato un FETCH_LOGS_TASK che recupera i log in base alla richiesta.
Questo esempio illustra la creazione di un task che utilizza lo strumento log_fetcher per recuperare i log. Questo strumento personalizzato specifica la procedura PL/SQL fetch_logs. L'istruzione task specifica ciò che il task deve eseguire. L'attributo enable_human_tool è impostato su true in modo che una persona possa intervenire per guidare o approvare il flusso di task, se necessario. Per un esempio completo, vedere Esempio: recupero e analisi dei report di log.
BEGIN
DBMS_CLOUD_AI_AGENT.CREATE_TASK(
task_name =>'FETCH_LOGS_TASK',
attributes =>'{
"instruction": "Fetch the log entries from the database based on user request: {query}",
"tools": ["log_fetcher"],
"enable_human_tool" : "true"
}'
);
END;
/In questo esempio viene creato un ANALYZE_LOG_TASK che analizza i log recuperati.
Nell'esempio seguente viene illustrato l'uso di FETCH_LOGS_TASK come attributo input. Il task denominato ANALYZE_LOG_TASK viene avviato dopo che sono stati raccolti i log per avere come input l'output FETCH_LOGS_TASK. L'istruzione task specifica ciò che il task deve eseguire. L'attributo enable_human_tool è impostato su false per indicare l'assenza di revisione human-in-the-loop.
BEGIN
DBMS_CLOUD_AI_AGENT.CREATE_TASK(
task_name =>'ANALYZE_LOG_TASK',
attributes =>'{"instruction": "Analyze the fetched log entries retrieved based on user request: {query} ' ||
'Generate a detailed report include issue analysis and possible solution.",
"input" : "FETCH_LOGS_TASK",
"enable_human_tool" : "false"
}'
);
END;
/Argomento padre: Esempi di utilizzo di Seleziona agente AI
Esempio: creazione di un team agente
In questo esempio viene creato il team ReturnAgency e viene incluso un singolo agente Customer_Return_Agent. Il task Return_And_Price_Match è assegnato all'agente. Questo task gestisce le richieste di reso chiedendo il motivo e aggiornando lo stato dell'ordine nel database. Il valore process è impostato su sequential per eseguire le attività in un ordine definito.
BEGIN
DBMS_CLOUD_AI_AGENT.CREATE_TEAM(
team_name => 'ReturnAgency',
attributes => '{"agents": [{"name":"Customer_Return_Agent","task" : "Return_And_Price_Match"}],
"process": "sequential"}');
END;
/Per un esempio completo, vedere Esempio: creazione di un agente restituzione prodotto.
In questo esempio viene creato il team Ops_Issues_Solution_Team e sono inclusi due agenti per gestire l'analisi dei log e la risoluzione dei problemi: Data_Engineer e Ops_Manager. L'agente Data_Engineer esegue il task fetch_logs_task e l'agente Ops_Manager esegue il task analyze_log_task. Il valore process è impostato su sequential per eseguire le attività in un ordine definito.
BEGIN
DBMS_CLOUD_AI_AGENT.create_team(
team_name => 'Ops_Issues_Solution_Team',
attributes => '{"agents": [{"name":"Data_Engineer","task" : "fetch_logs_task"},
{"name":"Ops_Manager","task" : "analyze_log_task"}],
"process": "sequential"
}');
END;
/Per un esempio completo, vedere Esempio: recupero e analisi dei report di log.
Argomento padre: Esempi di utilizzo di Seleziona agente AI
Esempio: creazione di un agente di analisi filmato con strumenti integrati
Nell'esempio seguente si presume che i dati siano disponibili.
In questo esempio viene creato un agente MOVIE_ANALYST e vengono utilizzati più strumenti incorporati, ad esempio SQL, RAG, WEBSEARCH e NOTIFICATION, di tipo EMAIL e SLACK. L'agente risponde alle domande relative ai film utilizzando prompt in linguaggio naturale.
In questo esempio, dopo che il DBA concede privilegi EXECUTE per: i pacchetti DBMS_CLOUD_AI_AGENT, DBMS_CLOUD_AI, DBMS_CLOUD_PIPELINE, l'accesso ACL per il provider AI, l'accesso SMTP e l'accesso Slack, si inizia creando l'agente MOVIE_ANALYST.
Crea agente
Si crea un agente denominato MOVIE_ANALYST con un profilo (GROK) e il ruolo di rispondere alle domande su film, attori e generi.
Crea attività
È possibile creare un task denominato ANALYZE_MOVIE_TASK con istruzioni per rispondere a query correlate ai filmati.
Crea team
Si crea un team MOVIE_AGENT_TEAM con MOVIE_ANALYST come agente e il task come ANALYZE_MOVIE_TASK e lo si imposta come team attivo.
È possibile collegare in un secondo momento strumenti quali SQL, RAG, Websearch o Notification per estenderne le funzionalità.
Esegui il team Seleziona agente AI
Ora si esegue il team agente utilizzando select ai agent come prefisso per i prompt.
Crea strumenti
SQL: utilizza un profilo NL2SQL per tradurre le domande in query SQL e in altre azioni Select AI supportate.RAG: recupera il contesto basato sulla conoscenza dai documenti memorizzati.WEBSEARCH: Raccogli i dettagli del film o i prezzi online.NOTIFICATION:EMAIL: invia le risposte ai prompt utente, ai report filmati o alle recensioni a un destinatario.SLACK: invia risposte a prompt utente, riepiloghi o aggiornamenti direttamente a Slack.
L'esempio completo è il seguente:
--Grants EXECUTE privilege to ADB_USER
--
GRANT EXECUTE on DBMS_CLOUD_AI_AGENT to ADB_USER;
GRANT EXECUTE on DBMS_CLOUD_AI to ADB_USER;
GRANT EXECUTE on DBMS_CLOUD_PIPELINE to ADB_USER;
-- Websearch tool accesses OPENAI endpoint, allow ACL access
BEGIN
DBMS_NETWORK_ACL_ADMIN.APPEND_HOST_ACE(
host => 'api.openai.com',
ace => xs$ace_type(privilege_list => xs$name_list('http'),
principal_name => 'ADB_USER',
principal_type => xs_acl.ptype_db)
);
END;
/
-- To allow Email tool in Autonomous Database, allow SMTP access
BEGIN
DBMS_NETWORK_ACL_ADMIN.APPEND_HOST_ACE(
host => 'smtp.email.us-ashburn-1.oci.oraclecloud.com',
lower_port => 587,
upper_port => 587,
ace => xs$ace_type(privilege_list => xs$name_list('SMTP'),
principal_name => 'ADB_USER,
principal_type => xs_acl.ptype_db));
END;
/
-- Allow ACL access to Slack
BEGIN
DBMS_NETWORK_ACL_ADMIN.APPEND_HOST_ACE (
host => 'slack.com',
lower_port => 443,
upper_port => 443,
ace => xs$ace_type(
privilege_list => xs$name_list('http'),
principal_name => 'ADB_USER',
principal_type => xs_acl.ptype_db));
END;
/
PL/SQL procedure successfully completed.
--Create an agent
BEGIN
DBMS_CLOUD_AI_AGENT.CREATE_AGENT(
agent_name => 'MOVIE_ANALYST',
attributes => '{"profile_name": "GROK",
"role": "You are an AI Movie Analyst. Your can help answer a variety of questions related to movies. "
}'
);
END;
/
PL/SQL procedure successfully completed.
BEGIN
DBMS_CLOUD_AI_AGENT.CREATE_TASK(
task_name => 'ANALYZE_MOVIE_TASK',
attributes => '{"instruction": "Help the user with their request about movies. User question: {query}",
"enable_human_tool" : "true"
}'
);
END;
/
PL/SQL procedure successfully completed.
BEGIN
DBMS_CLOUD_AI_AGENT.CREATE_TEAM(
team_name => 'MOVIE_AGENT_TEAM',
attributes => '{"agents": [{"name":"MOVIE_ANALYST","task" : "ANALYZE_MOVIE_TASK"}],
"process": "sequential"
}');
END;
/
PL/SQL procedure successfully completed.
EXEC DBMS_CLOUD_AI_AGENT.SET_TEAM('MOVIE_AGENT_TEAM');
PL/SQL procedure successfully completed.
select ai agent who are you?;
RESPONSE
--------------------------------------------------------------------------------
I'm MOVIE_ANALYST, an AI Movie Analyst here to assist with any questions or topi
cs related to movies. Whether you need information on films, actors, directors,
genres, or recommendations, I'm ready to help. What can I assist you with regard
ing movies?
-- SQL TOOL
BEGIN
DBMS_CLOUD_AI.CREATE_PROFILE(
profile_name =>'nl2sql_profile',
attributes => '{"provider": "oci",
"credential_name": "GENAI_CRED",
"oci_compartment_id" : "ocid1.compartment.oc1..aaaaa...",
"object_list": [{"owner": "ADB_USER", "name": "GENRE"},
{"owner": "ADB_USER", "name": "CUSTOMER"},
{"owner": "ADB_USER", "name": "WATCH_HISTORY"},
{"owner": "ADB_USER", "name": "STREAMS"},
{"owner": "ADB_USER", "name": "MOVIES"},
{"owner": "ADB_USER", "name": "ACTORS"}]
}');
END;
/
PL/SQL procedure successfully completed.
BEGIN
DBMS_CLOUD_AI_AGENT.CREATE_TOOL(
tool_name => 'SQL',
attributes => '{"tool_type": "SQL",
"tool_params": {"profile_name": "nl2sql_profile"}}'
);
END;
/
PL/SQL procedure successfully completed.
EXEC DBMS_CLOUD_AI_AGENT.drop_task('ANALYZE_MOVIE_TASK');
PL/SQL procedure successfully completed.
BEGIN
DBMS_CLOUD_AI_AGENT.CREATE_TASK(
task_name => 'ANALYZE_MOVIE_TASK',
attributes =>'{"instruction": "Help the user with their request about movies. User question: {query}. ' ||
'You can use SQL tool to search the data from database",
"tools": ["SQL"],
"enable_human_tool" : "true"
}'
);
END;
/
PL/SQL procedure successfully completed.
EXEC DBMS_CLOUD_AI_AGENT.CLEAR_TEAM;
PL/SQL procedure successfully completed.
EXEC DBMS_CLOUD_AI_AGENT.SET_TEAM('MOVIE_AGENT_TEAM');
PL/SQL procedure successfully completed.
-- SQL tool retrieves the movie with the highest popularity view count from the watch_history table
select ai agent what is the most popular movie?;
RESPONSE
----------------------------------------------------------------
The most popular movie is "Laugh Out Loud" released in 2008.
-- RAG TOOL
BEGIN
DBMS_CLOUD_AI.CREATE_PROFILE(
profile_name => 'RAG_PROFILE',
attributes =>'{"provider": "oci",
"credential_name": "GENAI_CRED",
"vector_index_name": "RAG_INDEX",
"oci_compartment_id": "ocid1.compartment.oc1..aaaaa...",
"temperature": 0.2,
"max_tokens": 3000
}');
END;
/
PL/SQL procedure successfully completed.
BEGIN
DBMS_CLOUD_AI.CREATE_VECTOR_INDEX(
index_name => 'RAG_INDEX',
attributes => '{"vector_db_provider": "oracle",
"location": "https://swiftobjectstorage.us-phoenix-1.oraclecloud.com/v1/my_namespace/my_bucket/my_data_folder",
"object_storage_credential_name": "MY_OCI_CRED",
"profile_name": "RAG_PROFILE",
"vector_dimension": 1024,
"vector_distance_metric": "cosine",
"chunk_overlap":128,
"chunk_size":1024
}');
END;
/
PL/SQL procedure successfully completed.
BEGIN
DBMS_CLOUD_AI_AGENT.CREATE_TOOL(
tool_name => 'RAG_TOOL',
attributes => '{"tool_type": "RAG",
"tool_params": {"profile_name": "RAG_PROFILE"}}'
);
END;
/
PL/SQL procedure successfully completed.
BEGIN
DBMS_CLOUD_AI_AGENT.CREATE_TASK(
task_name =>'ANALYZE_MOVIE_TASK',
attributes => '{"instruction": "Help the user with their request about movies. User question: {query}. ' ||
'You can use RAG tool to search the information from the knowledge base user give.",
"tools": ["RAG_TOOL"],
"enable_human_tool" : "true"
}'
);
END;
/
PL/SQL procedure successfully completed.
EXEC DBMS_CLOUD_AI_AGENT.CLEAR_TEAM;
PL/SQL procedure successfully completed.
EXEC DBMS_CLOUD_AI_AGENT.SET_TEAM('MOVIE_AGENT_TEAM');
PL/SQL procedure successfully completed.
-- Rag seach the object store to find review or comments of Movie Laugh out Loud
select ai agent Please find the comments of Movie Laugh out Loud;
RESPONSE
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
The comments for the movie "Laugh Out Loud" (2008) are as follows:
1. A lighthearted comedy that delivers plenty of laughs, though the plot is fairly predictable.
2. The performances are fun, especially from the lead actor who keeps the energy high.
3. Some jokes feel a bit outdated, but overall it is an enjoyable watch for a casual movie night.
4. Good chemistry between the cast members, which makes the humor more natural.
5. Not a groundbreaking comedy, but it does what it promises makes you laugh out loud.
-- WEBSEARCH TOOL
BEGIN
DBMS_CLOUD.CREATE_CREDENTIAL(
credential_name => 'OPENAI_CRED',
username => 'OPENAI',
password => '<API_KEY>'
);
END;
/
PL/SQL procedure successfully completed.
BEGIN
DBMS_CLOUD_AI_AGENT.CREATE_TOOL(
tool_name => 'WEBSEARCH_TOOL',
attributes => '{"instruction": "This tool can be used for searching the details about topics mentioned in notes and prepare a summary about prices, details on web",
"tool_type": "WEBSEARCH",
"tool_params": {"credential_name": "OPENAI_CRED"}}'
);
END;
/
PL/SQL procedure successfully completed.
BEGIN
DBMS_CLOUD_AI_AGENT.CREATE_TASK(
task_name => 'ANALYZE_MOVIE_TASK',
attributes => '{"instruction": "Help the user with their request about movies. User question: {query}. ' ||
'You can use WEBSEARCH_TOOL tool to search the information from internet.",
"tools": ["WEBSEARCH_TOOL"],
"enable_human_tool" : "true"
}'
);
END;
/
PL/SQL procedure successfully completed.
EXEC DBMS_CLOUD_AI_AGENT.CLEAR_TEAM;
PL/SQL procedure successfully completed.
EXEC DBMS_CLOUD_AI_AGENT.SET_TEAM('MOVIE_AGENT_TEAM');
PL/SQL procedure successfully completed.
select ai agent What is the most popular movie of 2023?;
RESPONSE
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Determining the most popular movie of 2023 can depend on various metrics such as box office earnings, streaming viewership, critical acclaim, or audience reception. Based on global box office data, which is often a strong indicator of popularity, the most successful movie of 2023 is "Barbie," directed by Greta Gerwig. Released in July 2023, it grossed over $1.4 billion worldwide, making it the highest-grossing film of the year and one of the biggest cultural phenomena, often discussed alongside "Oppenheimer" due to the "Barbenheimer" trend. Its widespread appeal, marketing, and social media buzz further solidify its status as the most popular movie of 2023. However, if you are looking for popularity based on a different metric (like streaming numbers or awards), please let me know, and I can adjust the analysis accordingly.
-- NOTIFICATION TOOL WITH EMAIL TYPE
BEGIN
DBMS_CLOUD_AI_AGENT.CREATE_TOOL(
tool_name => 'EMAIL',
attributes => q'[{"tool_type": "Notification",
"tool_params": {"notification_type" : "EMAIL",
"credential_name": "EMAIL_CRED",
"recipient": "example@oracle.com",
"smtp_host": "smtp.email.us-ashburn-1.oci.oraclecloud.com",
"sender": "example@oracle.com"}}]'
);
END;
/
PL/SQL procedure successfully completed.
BEGIN
DBMS_CLOUD_AI_AGENT.CREATE_TASK(
task_name => 'ANALYZE_MOVIE_TASK',
attributes =>'{"instruction": "Help the user with their request about movies. User question: {query}. ' ||
'You can use EMAIL TOOL tool to send email to the user.",
"tools": ["EMAIL"],
"enable_human_tool" : "true"
}'
);
END;
/
PL/SQL procedure successfully completed.
EXEC DBMS_CLOUD_AI_AGENT.CLEAR_TEAM;
PL/SQL procedure successfully completed.
EXEC DBMS_CLOUD_AI_AGENT.SET_TEAM('MOVIE_AGENT_TEAM');
PL/SQL procedure successfully completed.
select ai agent Please help me write a review of Movie "Barbie" and send the review to my email;
RESPONSE
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
I have written a review for the movie "Barbie" (2023) and sent it to your email. Please check your inbox for the detailed review. If you have any additional feedback or would like me to revise the review, let me know!
-- NOTIFICATION TOOL WITH SLACK TYPE
DBMS_CLOUD_AI_AGENT.CREATE_TOOL(
tool_name => 'SLACK_TOOL',
attributes => '{"tool_type": "SLACK",
"tool_params": {"credential_name": "SLACK_CRED",
"channel": "<channel_number>"}}'
);
END;
/
PL/SQL procedure successfully completed.
BEGIN
DBMS_CLOUD_AI_AGENT.CREATE_TASK(
task_name => 'ANALYZE_MOVIE_TASK',
attributes => '{"instruction": "Help the user with their request about movies. User question: {query}. ' ||
'You can use SLACK TOOL to send the notification to the user.",
"tools": ["SLACK_TOOL"],
"enable_human_tool" : "true"
}'
);
END;
/
PL/SQL procedure successfully completed.
select ai agent Please help me find the top 3 most-watched movies of 2023 and send them to me on slack;
RESPONSE
------------------------------------------------------------------------------------------------------------------------------------
I have sent the list of the top 3 most-watched movies of 2023 to you via Slack. Please check your Slack notifications for the details.
Argomento padre: Esempi di utilizzo di Seleziona agente AI
Esempio: creazione di un agente restituzione prodotto
In questo esempio viene creato un agente denominato Customer_Return_Agent e uno strumento denominato Update_Order_Status_Tool, quindi viene definito un task e un team per gestire la restituzione del prodotto.
In questo esempio, dopo che il DBA concede privilegi EXECUTE per: DBMS_CLOUD_AI_AGENT e DBMS_CLOUD_AI, si inizia creando un esempio di dati relativi ai clienti, allo stato degli ordini dei clienti e una funzione per aggiornare lo stato degli ordini dei clienti. quindi creare un agente denominato Customer_Return_Agent.
Crea agente
È possibile creare un agente denominato Customer_Return_Agent con un profilo (OCI_GENAI_GROK) e un ruolo per gestire le richieste di restituzione.
Crea strumenti
Quindi, creerete uno strumento agente denominato Update_Order_Status_Tool per aggiornare lo stato dell'ordine nel Vostro database.
Crea attività
Si crea un task chiamato Handle_Product_Return_Task per guidare il flusso: chiedere il motivo (non più necessario, arrivato troppo tardi, scatola rotta o difettoso). Procedere con un flusso di ritorno difettoso.
Crea team
Si crea un team agente denominato Return_Agency_Team con Customer_Return_Agent come agente e lo si imposta come team attivo.
Esegui il team Seleziona agente AI
Ora si esegue il team agente utilizzando select ai agent come prefisso per i prompt.
L'esempio completo è il seguente:
--Grants EXECUTE privilege to ADB_USER
--
GRANT EXECUTE on DBMS_CLOUD_AI_AGENT to ADB_USER;
GRANT EXECUTE on DBMS_CLOUD_AI to ADB_USER;
BEGIN
DBMS_CLOUD_AI_AGENT.CREATE_AGENT(
agent_name => 'Customer_Return_Agent',
attributes => '{"profile_name": "OCI_GENAI_GROK",
"role": "You are an experienced customer return agent who deals with customers return requests."}');
END;
/
PL/SQL procedure successfully completed.
--Sample customer data
CREATE TABLE CUSTOMERS (
customer_id NUMBER(10) PRIMARY KEY,
name VARCHAR2(100),
email VARCHAR2(100),
phone VARCHAR2(20),
state VARCHAR2(2),
zip VARCHAR2(10)
);
INSERT INTO CUSTOMERS (customer_id, name, email, phone, state, zip) VALUES
(1, 'Alice Thompson', 'alice.thompson@example.com', '555-1234', 'NY', '10001'),
(2, 'Bob Martinez', 'bob.martinez@example.com', '555-2345', 'CA', '94105'),
(3, 'Carol Chen', 'carol.chen@example.com', '555-3456', 'TX', '73301'),
(4, 'David Johnson', 'david.johnson@example.com', '555-4567', 'IL', '60601'),
(5, 'Eva Green', 'eva.green@example.com', '555-5678', 'FL', '33101');
--create customer order status
CREATE TABLE CUSTOMER_ORDER_STATUS (
customer_id NUMBER(10),
order_number VARCHAR2(20),
status VARCHAR2(30),
product_name VARCHAR2(100)
);
INSERT INTO CUSTOMER_ORDER_STATUS (customer_id, order_number, status, product_name) VALUES
(2, '7734', 'delivered', 'smartphone charging cord'),
(1, '4381', 'pending_delivery', 'smartphone protective case'),
(2, '7820', 'delivered', 'smartphone charging cord'),
(3, '1293', 'pending_return', 'smartphone stand (metal)'),
(4, '9842', 'returned', 'smartphone backup storage'),
(5, '5019', 'delivered', 'smartphone protective case'),
(2, '6674', 'pending_delivery', 'smartphone charging cord'),
(1, '3087', 'returned', 'smartphone stand (metal)'),
(3, '7635', 'pending_return', 'smartphone backup storage'),
(4, '3928', 'delivered', 'smartphone protective case'),
(5, '8421', 'pending_delivery', 'smartphone charging cord'),
(1, '2204', 'returned', 'smartphone stand (metal)'),
(2, '7031', 'pending_delivery', 'smartphone backup storage'),
(3, '1649', 'delivered', 'smartphone protective case'),
(4, '9732', 'pending_return', 'smartphone charging cord'),
(5, '4550', 'delivered', 'smartphone stand (metal)'),
(1, '6468', 'pending_delivery', 'smartphone backup storage'),
(2, '3910', 'returned', 'smartphone protective case'),
(3, '2187', 'delivered', 'smartphone charging cord'),
(4, '8023', 'pending_return', 'smartphone stand (metal)'),
(5, '5176', 'delivered', 'smartphone backup storage');
--Create a update customer order status function
CREATE OR REPLACE FUNCTION UPDATE_CUSTOMER_ORDER_STATUS (
p_customer_name IN VARCHAR2,
p_order_number IN VARCHAR2,
p_status IN VARCHAR2
) RETURN CLOB IS
v_customer_id customers.customer_id%TYPE;
v_row_count NUMBER;
BEGIN
-- Find customer_id from customer_name
SELECT customer_id
INTO v_customer_id
FROM customers
WHERE name = p_customer_name;
UPDATE customer_order_status
SET status = p_status
WHERE customer_id = v_customer_id
AND order_number = p_order_number;
v_row_count := SQL%ROWCOUNT;
IF v_row_count = 0 THEN
RETURN 'No matching record found to update.';
ELSE
RETURN 'Update successful.';
END IF;
EXCEPTION
WHEN OTHERS THEN
RETURN 'Error: ' || SQLERRM;
END;
--Create Tool
BEGIN
DBMS_CLOUD_AI_AGENT.CREATE_TOOL(
tool_name => 'Update_Order_Status_Tool',
attributes => '{"instruction": "This tool updates the database to reflect return status change. Always confirm user name and order number with user before update status",
"function" : "update_customer_order_status"}',
description => 'Tool for updating customer order status in database table.'
);
END;
/
--Create Task
BEGIN
DBMS_CLOUD_AI_AGENT.CREATE_TASK(
task_name => 'Handle_Product_Return_Task',
attributes => '{"instruction": "Process a product return request from a customer:{query}' ||
'1. Ask customer the order reason for return (no longer needed, arrived too late, box broken, or defective)' ||
'2. If no longer needed:' ||
' a. Inform customer to ship the product at their expense back to us.' ||
' b. Update the order status to return_shipment_pending using Update_Order_Status_Tool.' ||
'3. If it arrived too late:' ||
' a. Ask customer if they want a refund.' ||
' b. If the customer wants a refund, then confirm refund processed and update the order status to refund_completed' ||
'4. If the product was defective or the box broken:' ||
' a. Ask customer if they want a replacement or a refund' ||
' b. If a replacement, inform customer replacement is on its way and they will receive a return shipping label for the defective product, then update the order status to replaced' ||
' c. If a refund, inform customer to print out the return shipping label for the defective product, return the product, and update the order status to refund' ||
'5. After the completion of a return or refund, ask if you can help with anything else.' ||
' End the task if user does not need help on anything else",
"tools": ["Update_Order_Status_Tool"]}'
);
END;
/
SQL> BEGIN
DBMS_CLOUD_AI_AGENT.CREATE_TEAM(
team_name => 'Return_Agency_Team',
attributes => '{"agents": [{"name":"Customer_Return_Agent","task" : "Handle_Product_Return_Task"}],
"process": "sequential"}');
END;
/
PL/SQL procedure successfully completed.
SQL> EXEC DBMS_CLOUD_AI_AGENT.SET_TEAM('Return_Agency_Team');
PL/SQL procedure successfully completed.
--Validate that the agent team is set in the current session with get_team
SQL> SELECT DBMS_CLOUD_AI_AGENT.GET_TEAM from DUAL;
--Interact with the agent
SQL> select ai agent I want to return a smartphone case;
RESPONSE
Could you please tell me the reason for returning the smartphone case? Is it no longer needed, arrived too late, box broken, or defective?
SQL> select ai agent the item is defective
RESPONSE
I'm sorry to hear that the smartphone case is defective. Would you like a replacement or a refund?
SQL> select ai agent I will need a replacement
RESPONSE
Can you please confirm your name and order number so I can update the status and process the replacement?
SQL> select ai agent I''m Bob Martinez and my order number is 7820
RESPONSE
Is there anything else I can help you with?
SQL> select ai agent No, I''m all set. Thanks
RESPONSE
Thank you for reaching out, Bob. I'm glad I could assist with the return of your smartphone case and stand. If you have any further questions or need assistance in the future, feel free to contact us. Have a great day!
Se si utilizzano client Web SQL quali Azioni del database, eseguire il team agente utilizzando la funzione DBMS_CLOUD_AI_AGENT.RUN_TEAM e fornire il prompt all'interno della funzione.
Non utilizzare DBMS_CLOUD_AI_AGENT.SET_TEAM in Database Actions o APEX Service. Specificare invece il team dell'agente utilizzando l'argomento team_name di DBMS_CLOUD_AI_AGENT.RUN_TEAM.
Nell'esempio seguente viene creato un ID conversazione per tenere traccia della cronologia delle conversazioni dei clienti e quindi viene utilizzata la funzione DBMS_CLOUD_AI_AGENT.RUN_TEAM per interagire con l'agente di restituzione del prodotto.
Per ulteriori informazioni, vedere RUN_TEAM Function.
CREATE OR REPLACE PACKAGE my_globals IS
l_team_cov_id varchar2(4000);
END my_globals;
/
-- Create conversation
DECLARE
l_team_cov_id varchar2(4000);
BEGIN
l_team_cov_id := DBMS_CLOUD_AI.create_conversation();
my_globals.l_team_cov_id := l_team_cov_id;
DBMS_OUTPUT.PUT_LINE('Created conversation with ID: ' || my_globals.l_team_cov_id);
END;
--Interact with the agent
DECLARE
v_response VARCHAR2(4000);
BEGIN
v_response := DBMS_CLOUD_AI_AGENT.RUN_TEAM(
team_name => 'Return_Agency_Team',
user_prompt => 'I want to return a smartphone case',
params => '{"conversation_id": "' || my_globals.l_team_cov_id || '"}'
);
DBMS_OUTPUT.PUT_LINE(v_response);
END;
Argomento padre: Esempi di utilizzo di Seleziona agente AI
Esempio: recupero e analisi dei report di log
-
Esegui prerequisiti per selezione AI
- Crea un profilo AI con Google come provider. Vedere Esempio: selezione di AI con Google.
- Creare un profilo AI con OpenAI come provider. Vedere Esempio: selezione di AI con OpenAI.
- workflow con due agenti per la risoluzione dei problemi: Data_Engineer e Ops_Manager
- uno strumento:
log-fetcher
Solo un DBA può eseguire i privilegi EXECUTE e la procedura ACL di rete.
In questo esempio, dopo che il DBA concede privilegi EXECUTE per: il pacchetto DBMS_CLOUD_AI_AGENT, il pacchetto DBMS_CLOUD_AI e l'accesso ACL per i provider AI, è possibile iniziare creando gli agenti Data_Engineer e Ops_Manager.
Crea agente
Si crea l'agente denominato Data_Engineer con un profilo (GOOGLE) che utilizza Google come provider e ruolo AI per recuperare ed elaborare dati complessi.
Creare l'agente denominato Ops_Manager con un profilo (OPENAI) che utilizza OpenAI come provider AI e ruolo per analizzare i dati.
Crea uno strumento
Creare quindi uno strumento agente:log_fetcher: restituisce le voci di log dopo una determinata data. In questo modo viene utilizzata una procedura personalizzata fetch_logs.
Crea i task
Per guidare il flusso, definire due task fetch_logs_task e analyze_log_task. fetch_logs_task chiama log_fetcher per recuperare i log in base alla richiesta. analyze_log_task analizza i log recuperati.
Crea team
Si crea un team Ops_Issues_Solution_Team con Data_Engineer e Ops_Manager per l'esecuzione sequenziale.
Esegui selezione agente AI
È ora possibile impostare il team attivo ed eseguire il team agente con select ai agent come prefisso per i prompt.
L'esempio completo è il seguente:
--Grants EXECUTE privilege to ADB_USER
--
GRANT EXECUTE on DBMS_CLOUD_AI_AGENT to ADB_USER;
GRANT EXECUTE on DBMS_CLOUD_AI to ADB_USER;
-- Grant Network ACL for OpenAI endpoint
BEGIN
DBMS_NETWORK_ACL_ADMIN.APPEND_HOST_ACE(
host => 'api.openai.com',
ace => xs$ace_type(privilege_list => xs$name_list('http'),
principal_name => 'ADB_USER',
principal_type => xs_acl.ptype_db)
);
END;
/
--Grant Network ACL for Google endpoint
BEGIN
DBMS_NETWORK_ACL_ADB_USER.APPEND_HOST_ACE(
host => 'generativelanguage.googleapis.com',
ace => xs$ace_type(privilege_list => xs$name_list('http'),
principal_name => 'ADB_USER',
principal_type => xs_acl.ptype_db)
);
END;
/
PL/SQL procedure successfully completed.
--Create a table with Database logs and insert sample data
SQL> CREATE TABLE app_logs (
log_id NUMBER GENERATED BY DEFAULT AS IDENTITY,
log_timestamp DATE,
log_message VARCHAR2(4000)
);
Table created.
SQL> INSERT INTO app_logs (log_timestamp, log_message) VALUES (
TO_DATE('2025-03-22 03:15:45', 'YYYY-MM-DD HH24:MI:SS'),
'INFO: Database Cluster: Failover completed successfully. Standby promoted to primary. Downtime duration: 33 seconds. Correlation ID: dbfailover102.'
);
1 row created.
SQL> INSERT INTO app_logs (log_timestamp, log_message) VALUES (
TO_DATE('2025-03-23 08:44:10', 'YYYY-MM-DD HH24:MI:SS'),
'INFO: Switchover Process: Synchronization restored. Performing scheduled switchover. Correlation ID: dbswitchover215.'
);
1 row created.
SQL> INSERT INTO app_logs (log_timestamp, log_message) VALUES (
TO_DATE('2025-03-24 03:15:12', 'YYYY-MM-DD HH24:MI:SS'),
'ERROR: Database Cluster: Primary database unreachable, initiating failover to standby. Correlation ID: dbfailover102.'
);
1 row created.
SQL> COMMIT;
Commit complete.
-- create data engineer agent
SQL> BEGIN
DBMS_CLOUD_AI_AGENT.CREATE_AGENT(
agent_name => 'Data_Engineer',
attributes => '{"profile_name": "GOOGLE",
"role": "You are a specialized data ingestion engineer with expertise in ' ||
'retrieving and processing data from complex database systems."
}'
);
END;
/
PL/SQL procedure successfully completed.
-- create ops manager agent
SQL> BEGIN
DBMS_CLOUD_AI_AGENT.CREATE_AGENT(
agent_name => 'Ops_Manager',
attributes => '{"profile_name": "OPENAI",
"role": "You are an experienced Ops manager who excels at analyzing ' ||
'complex log data, diagnosing the issues."
}'
);
END;
/
PL/SQL procedure successfully completed.
-- create log_fetcher tool
-- fetch_logs is a customized procedure.
-- Please make sure you have created your own procedure before use it in the tool
--Create a customized fetch_logs procedure
SQL> CREATE OR REPLACE FUNCTION fetch_logs(since_date IN DATE) RETURN CLOB IS
l_logs CLOB;
BEGIN
SELECT JSON_ARRAYAGG(log_message RETURNING CLOB)
INTO l_logs
FROM app_logs
WHERE log_timestamp >= since_date
ORDER BY log_timestamp;
RETURN l_logs;
EXCEPTION
WHEN OTHERS THEN
RETURN 'Error fetching logs: ' || SQLERRM;
END fetch_logs;
/
Function created.
SQL> BEGIN
DBMS_CLOUD_AI_AGENT.CREATE_TOOL(
tool_name => 'log_fetcher',
attributes => '{"instruction": "retrieves and returns all log messages with a LOG_TIMESTAMP greater than or equal to the input date.",
"function": "fetch_logs"}'
);
END;
/
PL/SQL procedure successfully completed.
-- create task with log fetcher tool
SQL> BEGIN
DBMS_CLOUD_AI_AGENT.CREATE_TASK(
task_name => 'fetch_logs_task',
attributes => '{"instruction": "Fetch the log entries from the database based on user request: {query}}.",
"tools": ["log_fetcher"]}'
);
END;
/
PL/SQL procedure successfully completed.
-- create task with predefined rag and slack tool
SQL> BEGIN
DBMS_CLOUD_AI_AGENT.create_task(
task_name => 'analyze_log_task',
attributes => '{"instruction": "Analyze the fetched log entries retrieved based on user request: {query} ' ||
'Generate a detailed report include issue analysis and possible solution.",
"input" : "fetch_logs_task"
}'
);
END;
/
PL/SQL procedure successfully completed.
-- create team and set agent team
SQL> BEGIN
DBMS_CLOUD_AI_AGENT.create_team(
team_name => 'Ops_Issues_Solution_Team',
attributes => '{"agents": [{"name":"Data_Engineer","task" : "fetch_logs_task"},
{"name":"Ops_Manager","task" : "analyze_log_task"}],
"process": "sequential"
}');
END;
/
PL/SQL procedure successfully completed.
SQL> EXEC DBMS_CLOUD_AI_AGENT.SET_TEAM('Ops_Issues_Solution_Team');
PL/SQL procedure successfully completed.
SQL> select ai agent fetch and analyze the logs after 03/15 2025;
RESPONSE
-----------------------------------------------------------------------------------------------------------------------------------------------
1. Issue: High volume of 500 Internal Server Errors between 03/22 and 03/24.
Solution: Review server application logs to identify failing components; add better exception handling and fallback mechanisms to prevent service crashes.
2. Issue: Increased response time on /api/v1/user and /checkout, peaking on 03/25.
Solution: Profile backend queries and services, apply caching where applicable, and offload static content to a CDN.
3. Issue: Detected brute-force login attack with over 500 failed POST attempts from a single IP.
Solution: Add rate-limiting, temporary IP bans, and CAPTCHA on the /login endpoint to prevent credential stuffing.
4. Issue: Suspicious User-Agent headers such as curl/7.58.0 or empty headers mimicking mobile devices.
Solution: Block malformed or uncommon User-Agent strings and log them for threat intelligence analysis.
5. Issue: DDoS-like traffic spike from distributed IPs observed on 03/20.
Solution: Enable DDoS protection at the CDN or cloud provider level, and configure autoscaling to absorb burst traffic.
Argomento padre: Esempi di utilizzo di Seleziona agente AI
Esempio: creazione di uno strumento HTTP personalizzato
HTTP GET e restituisce il testo della risposta. La funzione viene quindi aggiunta nello strumento Seleziona agente AI.
È possibile creare uno strumento personalizzato che invia una richiesta REST utilizzando la procedura DBMS_CLOUD.SEND_REQUEST e restituisce la risposta come testo. Questo esempio mostra come scrivere la funzione PL/SQL e aggiungerla come strumento da utilizzare nei task dell'agente.
La funzione get_url_content invia una richiesta GET all'URL di destinazione e restituisce la risposta come CLOB. DBMS_CLOUD_AI_AGENT.CREATE_TOOL utilizza la funzione get_url_content e crea uno strumento denominato HTTP_TOOL che l'agente Select AI può chiamare quando un task richiede il recupero di contenuto da un URL.
CREATE OR REPLACE FUNCTION get_url_content (
url IN CLOB
) RETURN CLOB
AS
l_resp DBMS_CLOUD_TYPES.RESP;
l_result CLOB;
BEGIN
l_resp := DBMS_CLOUD.SEND_REQUEST(
credential_name => NULL,
method => 'GET',
uri => url
);
l_result := DBMS_VECTOR_CHAIN.UTL_TO_TEXT(DBMS_CLOUD.GET_RESPONSE_RAW(l_resp);
RETURN l_result;
END get_url_content;
/
BEGIN
DBMS_CLOUD_AI_AGENT.create_tool(
tool_name => 'HTTP_TOOL',
attributes => '{
"instruction": "This tool fetches and returns the plain text content from the specified URL. ",
"function": "get_url_content"
}'
);
END;
/
Argomento padre: Esempi di utilizzo di Seleziona agente AI
Esempio: visualizzazione dei prompt e delle risposte dell'agente dall'ultima esecuzione del team
In questo esempio vengono recuperati e visualizzati i log dettagliati dall'esecuzione più recente del team Select AI Agent. Nell'esempio vengono utilizzate le viste USER_AI_AGENT_TEAM_HISTORY, USER_AI_AGENT_TASK_HISTORY e USER_CLOUD_AI_CONVERSATION_PROMPTS per mostrare il nome del team, il task, i prompt associati e le risposte di ciascun agente. Utilizzare questa query per risolvere i problemi esaminando sia il prompt di input che le risposte generate dall'ultima esecuzione del team.
WITH latest_team AS (
SELECT team_exec_id, team_name, start_date
FROM user_ai_agent_team_history
ORDER BY start_date DESC
FETCH FIRST 1 ROW ONLY
),
latest_task AS (
SELECT team_exec_id, task_name, agent_name, conversation_params, start_date,
ROW_NUMBER() OVER (PARTITION BY team_exec_id, task_name, agent_name
ORDER BY start_date DESC) as rn
FROM user_ai_agent_task_history
)
SELECT
team.team_name,
task.task_name,
task.agent_name,
p.prompt,
p.prompt_response
FROM latest_team team
JOIN latest_task task
ON team.team_exec_id = task.team_exec_id
AND task.rn = 1
LEFT JOIN user_cloud_ai_conversation_prompts p
ON p.conversation_id = JSON_VALUE(task.conversation_params, '$.conversation_id')
ORDER BY task.start_date DESC NULLS LAST,
p.created DESC NULLS LAST;
Argomento padre: Esempi di utilizzo di Seleziona agente AI
Esempio: ripresa dell'esecuzione di un team agente dallo stato WAITING_FOR_HUMAN
WAITING_FOR_HUMAN. Quando un team agente entra nello stato WAITING_FOR_HUMAN, viene sospeso fino a quando un utente non fornisce l'input o la conferma successiva. È possibile riprendere l'esecuzione a seconda di come si utilizza il team agente: nella riga di comando SQL o tramite DBMS_CLOUD_AI_AGENT.RUN_TEAM.
Se si utilizza SELECT AI AGENT <prompt> nella riga di comando SQL, Select AI Agent riprende automaticamente l'esecuzione del team in pausa. Il contesto della conversazione, inclusi i prompt e il ragionamento precedenti, viene mantenuto senza richiedere parametri aggiuntivi.
Se si utilizza la procedura DBMS_CLOUD_AI_AGENT.RUN_TEAM, è possibile riprendere un team agente in pausa passando lo stesso conversation_id utilizzato nell'esecuzione iniziale. Lo stato di esecuzione del team agente, incluse le azioni in sospeso e il contesto, viene mantenuto e il team agente continua esattamente da dove si è interrotto.
Per un esempio, vedere Esempio: creazione di un agente restituzione prodotto utilizzando la funzione DBMS_CLOUD_AI_AGENT.RUN_TEAM.
--Interact with the agent
DECLARE
v_response VARCHAR2(4000);
BEGIN
v_response := DBMS_CLOUD_AI_AGENT.RUN_TEAM(
team_name => '<same initial team name>',
user_prompt => 'response to request',
params => '{"conversation_id": "<same initial conversation_id>"}'
);
DBMS_OUTPUT.PUT_LINE(v_response);
END;Argomento padre: Esempi di utilizzo di Seleziona agente AI