/AWS1/IF_BDZ=>AGENTICRETRIEVESTREAM()¶
About AgenticRetrieveStream¶
Retrieves information from one or more knowledge bases using an agentic approach. Agentic retrieval uses a foundation model to intelligently decompose complex queries into sub-queries and iteratively retrieve relevant information from your knowledge bases. This approach improves retrieval accuracy for complex, multi-step questions that a single retrieval pass might not fully address.
The operation returns results through a stream that includes retrieval results, trace events for visibility into the process, and a generated response synthesized from the results by default, which can be turned off.
Method Signature¶
METHODS /AWS1/IF_BDZ~AGENTICRETRIEVESTREAM
IMPORTING
!IT_MESSAGES TYPE /AWS1/CL_BDZAGNTCRETRVMESSAGE=>TT_AGENTICRETRIEVEMESSAGES OPTIONAL
!IT_RETRIEVERS TYPE /AWS1/CL_BDZAGENTICRETRIEVER=>TT_AGENTICRETRIEVERS OPTIONAL
!IO_AGENTICRETRIEVECONF TYPE REF TO /AWS1/CL_BDZAGENTICRETRVCONF OPTIONAL
!IO_POLICYCONFIGURATION TYPE REF TO /AWS1/CL_BDZAGNTCRETRVPLYCONF OPTIONAL
!IV_NEXTTOKEN TYPE /AWS1/BDZNEXTTOKEN OPTIONAL
!IO_USERCONTEXT TYPE REF TO /AWS1/CL_BDZUSERCONTEXT OPTIONAL
!IV_GENERATERESPONSE TYPE /AWS1/BDZBOOLEAN OPTIONAL
RETURNING
VALUE(OO_OUTPUT) TYPE REF TO /aws1/cl_bdzagntcretrvstrmrsp
RAISING
/AWS1/CX_BDZACCESSDENIEDEX
/AWS1/CX_BDZBADGATEWAYEX
/AWS1/CX_BDZCONFLICTEXCEPTION
/AWS1/CX_BDZDEPENDENCYFAILEDEX
/AWS1/CX_BDZINTERNALSERVEREX
/AWS1/CX_BDZRESOURCENOTFOUNDEX
/AWS1/CX_BDZSERVICEQUOTAEXCDEX
/AWS1/CX_BDZTHROTTLINGEX
/AWS1/CX_BDZVALIDATIONEX
/AWS1/CX_BDZCLIENTEXC
/AWS1/CX_BDZSERVEREXC
/AWS1/CX_RT_TECHNICAL_GENERIC
/AWS1/CX_RT_SERVICE_GENERIC.
IMPORTING¶
Required arguments:¶
it_messages TYPE /AWS1/CL_BDZAGNTCRETRVMESSAGE=>TT_AGENTICRETRIEVEMESSAGES TT_AGENTICRETRIEVEMESSAGES¶
The list of messages for the agentic retrieval conversation.
it_retrievers TYPE /AWS1/CL_BDZAGENTICRETRIEVER=>TT_AGENTICRETRIEVERS TT_AGENTICRETRIEVERS¶
The list of retrievers to use for agentic retrieval.
io_agenticretrieveconf TYPE REF TO /AWS1/CL_BDZAGENTICRETRVCONF /AWS1/CL_BDZAGENTICRETRVCONF¶
Configuration settings for the agentic retrieval operation.
Optional arguments:¶
io_policyconfiguration TYPE REF TO /AWS1/CL_BDZAGNTCRETRVPLYCONF /AWS1/CL_BDZAGNTCRETRVPLYCONF¶
Policy configuration for guardrails and content filtering.
iv_nexttoken TYPE /AWS1/BDZNEXTTOKEN /AWS1/BDZNEXTTOKEN¶
Opaque continuation token for paginated results.
io_usercontext TYPE REF TO /AWS1/CL_BDZUSERCONTEXT /AWS1/CL_BDZUSERCONTEXT¶
Contains information about the user making the request. This is used for access control filtering to ensure that retrieval results only include documents the user is authorized to access.
iv_generateresponse TYPE /AWS1/BDZBOOLEAN /AWS1/BDZBOOLEAN¶
Whether to generate a response based on the retrieved results.
RETURNING¶
oo_output TYPE REF TO /aws1/cl_bdzagntcretrvstrmrsp /AWS1/CL_BDZAGNTCRETRVSTRMRSP¶
Examples¶
Syntax Example¶
This is an example of the syntax for calling the method. It includes every possible argument and initializes every possible value. The data provided is not necessarily semantically accurate (for example the value "string" may be provided for something that is intended to be an instance ID, or in some cases two arguments may be mutually exclusive). The syntax shows the ABAP syntax for creating the various data structures.
DATA(lo_result) = lo_client->agenticretrievestream(
io_agenticretrieveconf = new /aws1/cl_bdzagenticretrvconf(
io_foundationmodelconf = new /aws1/cl_bdzfndtnmodelconf(
io_bedrockfndtnmodelconf = new /aws1/cl_bdzbdrkfndtnmodelconf( new /aws1/cl_bdzbdrfndnmodmodconf( |string| ) )
iv_type = |string|
)
io_rerankingconfiguration = new /aws1/cl_bdzagtcretrernkconf(
io_bedrockrerankingconf = new /aws1/cl_bdzagrtvbdrrernkconf( new /aws1/cl_bdzagrtvbdrrernkmod00( |string| ) )
iv_type = |string|
)
iv_foundationmodeltype = |string|
iv_maxagentiteration = 123
iv_rerankingmodeltype = |string|
)
io_policyconfiguration = new /aws1/cl_bdzagntcretrvplyconf(
io_bedrockguardrailconf = new /aws1/cl_bdzagtcrtvbdrgdrlconf(
iv_guardrailid = |string|
iv_guardrailversion = |string|
)
)
io_usercontext = new /aws1/cl_bdzusercontext( |string| )
it_messages = VALUE /aws1/cl_bdzagntcretrvmessage=>tt_agenticretrievemessages(
(
new /aws1/cl_bdzagntcretrvmessage(
io_content = new /aws1/cl_bdzagntcretrvmsgcont( |string| )
iv_role = |string|
)
)
)
it_retrievers = VALUE /aws1/cl_bdzagenticretriever=>tt_agenticretrievers(
(
new /aws1/cl_bdzagenticretriever(
io_configuration = new /aws1/cl_bdzretrieverconf(
io_knowledgebase = new /aws1/cl_bdzknowbaseretrconf(
io_retrievaloverrides = new /aws1/cl_bdzretrievaloverrides(
io_filter = new /aws1/cl_bdzretrievalfilter(
io_equals = new /aws1/cl_bdzfilterattribute(
io_value = /AWS1/CL_RT_DOCUMENT=>FROM_JSON_STR( |\{"foo":"this is a JSON object..."\}| )
iv_key = |string|
)
io_greaterthan = new /aws1/cl_bdzfilterattribute(
io_value = /AWS1/CL_RT_DOCUMENT=>FROM_JSON_STR( |\{"foo":"this is a JSON object..."\}| )
iv_key = |string|
)
io_greaterthanorequals = new /aws1/cl_bdzfilterattribute(
io_value = /AWS1/CL_RT_DOCUMENT=>FROM_JSON_STR( |\{"foo":"this is a JSON object..."\}| )
iv_key = |string|
)
io_in = new /aws1/cl_bdzfilterattribute(
io_value = /AWS1/CL_RT_DOCUMENT=>FROM_JSON_STR( |\{"foo":"this is a JSON object..."\}| )
iv_key = |string|
)
io_lessthan = new /aws1/cl_bdzfilterattribute(
io_value = /AWS1/CL_RT_DOCUMENT=>FROM_JSON_STR( |\{"foo":"this is a JSON object..."\}| )
iv_key = |string|
)
io_lessthanorequals = new /aws1/cl_bdzfilterattribute(
io_value = /AWS1/CL_RT_DOCUMENT=>FROM_JSON_STR( |\{"foo":"this is a JSON object..."\}| )
iv_key = |string|
)
io_listcontains = new /aws1/cl_bdzfilterattribute(
io_value = /AWS1/CL_RT_DOCUMENT=>FROM_JSON_STR( |\{"foo":"this is a JSON object..."\}| )
iv_key = |string|
)
io_notequals = new /aws1/cl_bdzfilterattribute(
io_value = /AWS1/CL_RT_DOCUMENT=>FROM_JSON_STR( |\{"foo":"this is a JSON object..."\}| )
iv_key = |string|
)
io_notin = new /aws1/cl_bdzfilterattribute(
io_value = /AWS1/CL_RT_DOCUMENT=>FROM_JSON_STR( |\{"foo":"this is a JSON object..."\}| )
iv_key = |string|
)
io_startswith = new /aws1/cl_bdzfilterattribute(
io_value = /AWS1/CL_RT_DOCUMENT=>FROM_JSON_STR( |\{"foo":"this is a JSON object..."\}| )
iv_key = |string|
)
io_stringcontains = new /aws1/cl_bdzfilterattribute(
io_value = /AWS1/CL_RT_DOCUMENT=>FROM_JSON_STR( |\{"foo":"this is a JSON object..."\}| )
iv_key = |string|
)
it_andall = VALUE /aws1/cl_bdzretrievalfilter=>tt_retrievalfilterlist(
(
new /aws1/cl_bdzretrievalfilter(
io_equals = new /aws1/cl_bdzfilterattribute(
io_value = /AWS1/CL_RT_DOCUMENT=>FROM_JSON_STR( |\{"foo":"this is a JSON object..."\}| )
iv_key = |string|
)
io_greaterthan = new /aws1/cl_bdzfilterattribute(
io_value = /AWS1/CL_RT_DOCUMENT=>FROM_JSON_STR( |\{"foo":"this is a JSON object..."\}| )
iv_key = |string|
)
io_greaterthanorequals = new /aws1/cl_bdzfilterattribute(
io_value = /AWS1/CL_RT_DOCUMENT=>FROM_JSON_STR( |\{"foo":"this is a JSON object..."\}| )
iv_key = |string|
)
io_in = new /aws1/cl_bdzfilterattribute(
io_value = /AWS1/CL_RT_DOCUMENT=>FROM_JSON_STR( |\{"foo":"this is a JSON object..."\}| )
iv_key = |string|
)
io_lessthan = new /aws1/cl_bdzfilterattribute(
io_value = /AWS1/CL_RT_DOCUMENT=>FROM_JSON_STR( |\{"foo":"this is a JSON object..."\}| )
iv_key = |string|
)
io_lessthanorequals = new /aws1/cl_bdzfilterattribute(
io_value = /AWS1/CL_RT_DOCUMENT=>FROM_JSON_STR( |\{"foo":"this is a JSON object..."\}| )
iv_key = |string|
)
io_listcontains = new /aws1/cl_bdzfilterattribute(
io_value = /AWS1/CL_RT_DOCUMENT=>FROM_JSON_STR( |\{"foo":"this is a JSON object..."\}| )
iv_key = |string|
)
io_notequals = new /aws1/cl_bdzfilterattribute(
io_value = /AWS1/CL_RT_DOCUMENT=>FROM_JSON_STR( |\{"foo":"this is a JSON object..."\}| )
iv_key = |string|
)
io_notin = new /aws1/cl_bdzfilterattribute(
io_value = /AWS1/CL_RT_DOCUMENT=>FROM_JSON_STR( |\{"foo":"this is a JSON object..."\}| )
iv_key = |string|
)
io_startswith = new /aws1/cl_bdzfilterattribute(
io_value = /AWS1/CL_RT_DOCUMENT=>FROM_JSON_STR( |\{"foo":"this is a JSON object..."\}| )
iv_key = |string|
)
io_stringcontains = new /aws1/cl_bdzfilterattribute(
io_value = /AWS1/CL_RT_DOCUMENT=>FROM_JSON_STR( |\{"foo":"this is a JSON object..."\}| )
iv_key = |string|
)
it_orall = VALUE /aws1/cl_bdzretrievalfilter=>tt_retrievalfilterlist(
)
)
)
)
it_orall = VALUE /aws1/cl_bdzretrievalfilter=>tt_retrievalfilterlist(
(
new /aws1/cl_bdzretrievalfilter(
io_equals = new /aws1/cl_bdzfilterattribute(
io_value = /AWS1/CL_RT_DOCUMENT=>FROM_JSON_STR( |\{"foo":"this is a JSON object..."\}| )
iv_key = |string|
)
io_greaterthan = new /aws1/cl_bdzfilterattribute(
io_value = /AWS1/CL_RT_DOCUMENT=>FROM_JSON_STR( |\{"foo":"this is a JSON object..."\}| )
iv_key = |string|
)
io_greaterthanorequals = new /aws1/cl_bdzfilterattribute(
io_value = /AWS1/CL_RT_DOCUMENT=>FROM_JSON_STR( |\{"foo":"this is a JSON object..."\}| )
iv_key = |string|
)
io_in = new /aws1/cl_bdzfilterattribute(
io_value = /AWS1/CL_RT_DOCUMENT=>FROM_JSON_STR( |\{"foo":"this is a JSON object..."\}| )
iv_key = |string|
)
io_lessthan = new /aws1/cl_bdzfilterattribute(
io_value = /AWS1/CL_RT_DOCUMENT=>FROM_JSON_STR( |\{"foo":"this is a JSON object..."\}| )
iv_key = |string|
)
io_lessthanorequals = new /aws1/cl_bdzfilterattribute(
io_value = /AWS1/CL_RT_DOCUMENT=>FROM_JSON_STR( |\{"foo":"this is a JSON object..."\}| )
iv_key = |string|
)
io_listcontains = new /aws1/cl_bdzfilterattribute(
io_value = /AWS1/CL_RT_DOCUMENT=>FROM_JSON_STR( |\{"foo":"this is a JSON object..."\}| )
iv_key = |string|
)
io_notequals = new /aws1/cl_bdzfilterattribute(
io_value = /AWS1/CL_RT_DOCUMENT=>FROM_JSON_STR( |\{"foo":"this is a JSON object..."\}| )
iv_key = |string|
)
io_notin = new /aws1/cl_bdzfilterattribute(
io_value = /AWS1/CL_RT_DOCUMENT=>FROM_JSON_STR( |\{"foo":"this is a JSON object..."\}| )
iv_key = |string|
)
io_startswith = new /aws1/cl_bdzfilterattribute(
io_value = /AWS1/CL_RT_DOCUMENT=>FROM_JSON_STR( |\{"foo":"this is a JSON object..."\}| )
iv_key = |string|
)
io_stringcontains = new /aws1/cl_bdzfilterattribute(
io_value = /AWS1/CL_RT_DOCUMENT=>FROM_JSON_STR( |\{"foo":"this is a JSON object..."\}| )
iv_key = |string|
)
it_andall = VALUE /aws1/cl_bdzretrievalfilter=>tt_retrievalfilterlist(
)
)
)
)
)
iv_maxnumberofresults = 123
)
iv_knowledgebaseid = |string|
)
)
iv_description = |string|
)
)
)
iv_generateresponse = ABAP_TRUE
iv_nexttoken = |string|
).
This is an example of reading all possible response values
lo_result = lo_result.
IF lo_result IS NOT INITIAL.
TRY.
WHILE lo_result->get_stream( )->/aws1/if_rt_stream_reader~data_available( ) = ABAP_TRUE.
lo_event = lo_result->get_stream( )->READ( ).
IF lo_event->get_result( ) IS NOT INITIAL.
" process this kind of event
ELSEIF lo_event->get_traceevent( ) IS NOT INITIAL.
" process this kind of event
ELSEIF lo_event->get_responseevent( ) IS NOT INITIAL.
" process this kind of event
ENDIF.
ENDWHILE.
CATCH /aws1/cx_bdzaccessdeniedex.
" handle error in stream
CATCH /aws1/cx_bdzinternalserverex.
" handle error in stream
CATCH /aws1/cx_bdzvalidationex.
" handle error in stream
CATCH /aws1/cx_bdzthrottlingex.
" handle error in stream
CATCH /aws1/cx_bdzdependencyfailedex.
" handle error in stream
CATCH /aws1/cx_bdzbadgatewayex.
" handle error in stream
CATCH /aws1/cx_bdzresourcenotfoundex.
" handle error in stream
CATCH /aws1/cx_bdzservicequotaexcdex.
" handle error in stream
CATCH /aws1/cx_bdzconflictexception.
" handle error in stream
ENDTRY.
ENDIF.