Implementing Prompt Templates in ABAP AI SDK via ISL Scenario Model
PorAinvest
viernes, 11 de julio de 2025, 1:22 pm ET2 min de lectura
SAP--
Understanding Prompt Templates
Prompt templates serve as the foundation for generating prompts for language models. They allow for the inclusion of dynamic variables, making the generated text more personalized and relevant. The ABAP AI SDK provides robust tools to manage and utilize these templates efficiently.
Implementing Prompt Templates in ABAP AI SDK
To integrate prompt templates within the ABAP AI SDK, developers need to follow a specific process. First, they must add the prompt templates to the Intelligent Scenario Model (ISLM) artifact in Eclipse (ADT). This can be achieved by defining the parameters using a specific format, such as `{ISLM_name of the variable}`.
Code Example
The following code snippet demonstrates how to add prompt templates and generate descriptions using the ABAP AI SDK classes:
```abap
METHOD generate_description.
TRY.
FINAL(api) = cl_aic_islm_compl_api_factory=get( )-create_instance( islm_scenario = 'Z_ISLM_SCEN_SB1' ).
CATCH cx_aic_api_factory INTO DATA(lx_api).
rv_description = ''.
ENDTRY.
TRY.
FINAL(prompt_template_instance) = cl_aic_islm_prompt_tpl_factory=get( )-create_instance( islm_scenario = 'Z_ISLM_SCEN_SB1' template_id = 'CITY_DESC' ).
FINAL(prompt_template_instance2) = cl_aic_islm_prompt_tpl_factory=get( )-create_instance( islm_scenario = 'Z_ISLM_SCEN_SB1' template_id = 'SYS_ROLE' ).
CATCH cx_aic_api_factory INTO DATA(lx_api1).
rv_description = ''.
ENDTRY.
IF ( prompt_template_instance IS BOUND ).
TRY.
FINAL(prompt) = prompt_template_instance-get_prompt( parameters = VALUE #( ( name = 'ISLM_city' value = iv_city ) ) ).
FINAL(sys_role_prompt) = prompt_template_instance2-get_prompt( ).
CATCH cx_aic_prompt_template INTO DATA(lx_prompt_templ).
"handle exception
ENDTRY.
ENDIF.
IF ( api IS BOUND ).
TRY.
DATA(messages) = api-create_message_container( ).
messages-set_system_role( sys_role_prompt ).
messages-add_user_message( prompt ).
rv_description = api-execute_for_messages( messages )-get_completion( ).
CATCH cx_aic_completion_api INTO DATA(lx_completion).
rv_description = ''.
ENDTRY.
ENDIF.
ENDMETHOD.
```
Conclusion
By integrating prompt templates into the ABAP AI SDK via ISLM using Eclipse (ADT), financial professionals can significantly enhance the capabilities of their AI models. This approach allows for the generation of more accurate and contextually relevant descriptions, which can be crucial for decision-making processes in the financial sector. The provided code example offers a practical guide on how to implement this functionality, ensuring that AI models can be effectively utilized to meet the specific needs of financial professionals.
References
[1] SAP Community. "How to Use Prompt Templates in ABAP AI SDK via ISLM Scenario." Retrieved from https://community.sap.com/t5/technology-blog-posts-by-sap/how-to-use-prompt-templates-in-abap-ai-sdk-via-islm-scenario/ba-p/14150585
[2] LangChain. "PromptTemplate." Retrieved from https://python.langchain.com/api_reference/core/prompts/langchain_core.prompts.prompt.PromptTemplate.html
The article explains how to use Prompt Templates in ABAP AI SDK via ISL using Eclipse (ADT). It provides a code example of how to add Prompt Templates in the Intelligent Scenario Model artefact and access them using the ABAP AI SDK classes. The code example demonstrates how to retrieve prompt templates and generate descriptions using the SDK classes.
In the rapidly evolving landscape of artificial intelligence, leveraging prompt templates has become a crucial aspect of enhancing the capabilities of AI models. This article explores how to effectively utilize prompt templates in the ABAP AI SDK via the Intelligent Scenario Model (ISLM) using Eclipse (ADT). By following a structured approach, financial professionals can harness the power of AI to generate more accurate and contextually relevant descriptions.Understanding Prompt Templates
Prompt templates serve as the foundation for generating prompts for language models. They allow for the inclusion of dynamic variables, making the generated text more personalized and relevant. The ABAP AI SDK provides robust tools to manage and utilize these templates efficiently.
Implementing Prompt Templates in ABAP AI SDK
To integrate prompt templates within the ABAP AI SDK, developers need to follow a specific process. First, they must add the prompt templates to the Intelligent Scenario Model (ISLM) artifact in Eclipse (ADT). This can be achieved by defining the parameters using a specific format, such as `{ISLM_name of the variable}`.
Code Example
The following code snippet demonstrates how to add prompt templates and generate descriptions using the ABAP AI SDK classes:
```abap
METHOD generate_description.
TRY.
FINAL(api) = cl_aic_islm_compl_api_factory=get( )-create_instance( islm_scenario = 'Z_ISLM_SCEN_SB1' ).
CATCH cx_aic_api_factory INTO DATA(lx_api).
rv_description = ''.
ENDTRY.
TRY.
FINAL(prompt_template_instance) = cl_aic_islm_prompt_tpl_factory=get( )-create_instance( islm_scenario = 'Z_ISLM_SCEN_SB1' template_id = 'CITY_DESC' ).
FINAL(prompt_template_instance2) = cl_aic_islm_prompt_tpl_factory=get( )-create_instance( islm_scenario = 'Z_ISLM_SCEN_SB1' template_id = 'SYS_ROLE' ).
CATCH cx_aic_api_factory INTO DATA(lx_api1).
rv_description = ''.
ENDTRY.
IF ( prompt_template_instance IS BOUND ).
TRY.
FINAL(prompt) = prompt_template_instance-get_prompt( parameters = VALUE #( ( name = 'ISLM_city' value = iv_city ) ) ).
FINAL(sys_role_prompt) = prompt_template_instance2-get_prompt( ).
CATCH cx_aic_prompt_template INTO DATA(lx_prompt_templ).
"handle exception
ENDTRY.
ENDIF.
IF ( api IS BOUND ).
TRY.
DATA(messages) = api-create_message_container( ).
messages-set_system_role( sys_role_prompt ).
messages-add_user_message( prompt ).
rv_description = api-execute_for_messages( messages )-get_completion( ).
CATCH cx_aic_completion_api INTO DATA(lx_completion).
rv_description = ''.
ENDTRY.
ENDIF.
ENDMETHOD.
```
Conclusion
By integrating prompt templates into the ABAP AI SDK via ISLM using Eclipse (ADT), financial professionals can significantly enhance the capabilities of their AI models. This approach allows for the generation of more accurate and contextually relevant descriptions, which can be crucial for decision-making processes in the financial sector. The provided code example offers a practical guide on how to implement this functionality, ensuring that AI models can be effectively utilized to meet the specific needs of financial professionals.
References
[1] SAP Community. "How to Use Prompt Templates in ABAP AI SDK via ISLM Scenario." Retrieved from https://community.sap.com/t5/technology-blog-posts-by-sap/how-to-use-prompt-templates-in-abap-ai-sdk-via-islm-scenario/ba-p/14150585
[2] LangChain. "PromptTemplate." Retrieved from https://python.langchain.com/api_reference/core/prompts/langchain_core.prompts.prompt.PromptTemplate.html

Divulgación editorial y transparencia de la IA: Ainvest News utiliza tecnología avanzada de Modelos de Lenguaje Largo (LLM) para sintetizar y analizar datos de mercado en tiempo real. Para garantizar los más altos estándares de integridad, cada artículo se somete a un riguroso proceso de verificación con participación humana.
Mientras la IA asiste en el procesamiento de datos y la redacción inicial, un miembro editorial profesional de Ainvest revisa, verifica y aprueba de forma independiente todo el contenido para garantizar su precisión y cumplimiento con los estándares editoriales de Ainvest Fintech Inc. Esta supervisión humana está diseñada para mitigar las alucinaciones de la IA y garantizar el contexto financiero.
Advertencia sobre inversiones: Este contenido se proporciona únicamente con fines informativos y no constituye asesoramiento profesional de inversión, legal o financiero. Los mercados conllevan riesgos inherentes. Se recomienda a los usuarios que realicen una investigación independiente o consulten a un asesor financiero certificado antes de tomar cualquier decisión. Ainvest Fintech Inc. se exime de toda responsabilidad por las acciones tomadas con base en esta información. ¿Encontró un error? Reportar un problema

Comentarios
Aún no hay comentarios