Repository navigation
Add package 10 - AI / LLM: chat and table summary against a language model - #89
Merged
Merged
Conversation
…model Three samples that call a large language model from an abap2UI5 app, in a new package src/10 (branch 10-ai-llm, Cloud + Standard >= 7.40 SP08): - Z2UI5_CL_SMPS_APP_013 - settings and connection test: provider, destination, model, token limit, request path, API key (write-only) - Z2UI5_CL_SMPS_APP_014 - chat with FeedInput / FeedListItem, the conversation sent with every question, the answer in a second roundtrip - Z2UI5_CL_SMPS_APP_015 - a table of sales figures summarized with AI, with prompt hygiene (row cap, needed columns only, data fenced off) Provider-neutral: the apps know Z2UI5_IF_SMPS_LLM only, the factory picks Z2UI5_CL_SMPS_LLM_CLAUDE (Anthropic Messages API), Z2UI5_CL_SMPS_LLM_OPENAI (OpenAI-compatible Chat Completions) or Z2UI5_CL_SMPS_LLM_ISLM (SAP ABAP AI SDK) from the configuration table Z2UI5_T_SMPS_LLM. No endpoint, model or key is in the code. The HTTP transport exists once per stack and is created by name: Z2UI5_CL_SMPS_LLM_SM59 (cl_http_client on an SM59 destination, Standard) and Z2UI5_CL_SMPS_LLM_CLOUD (cl_web_http_client_manager on a BTP destination, ABAP Cloud). The branch is linted at v751 because the cloud transport's released enums need it; everything else parses at 7.40 SP08. Overview app, README tables, packages.json, SAMPLES.md, catalogue.json and catalogue-derived.json updated; package counts nine -> ten. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Dx9qDRBfuVKdBr8EXrKNXf
…dy pointer Z2UI5_CL_SMPS_APP_014 already named Z2UI5_CL_SMP_APP_540 as the screen it puts a real model behind; it now links its source too. Z2UI5_CL_SMPS_APP_015 names Z2UI5_CL_SMP_APP_541 (explain this data, with a local deterministic provider) as its counterpart, in the class header and in the package README. The README gets the AI-ready badge and paragraph samples-controls carries: the AI page of the documentation, the MCP one-liner and the two Claude Code plugin commands. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Dx9qDRBfuVKdBr8EXrKNXf
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No sample showed an abap2UI5 app calling a large language model. This repository is the right home: the samples need something beyond abap2UI5, namely an LLM endpoint the system can reach. This PR adds a new package,
src/10, branch10-ai-llm, runs on Cloud + Standard ≥ 7.40 SP08.The samples
Z2UI5_CL_SMPS_APP_013Z2UI5_CL_SMPS_APP_014Z2UI5_CL_SMP_APP_540in abap2UI5/samples refers to.Z2UI5_CL_SMPS_APP_015When no provider is configured, 014 and 015 still start. They show a warning MessageStrip saying what is missing, keep their buttons disabled and send nothing.
Design
Z2UI5_IF_SMPS_LLM(chat( system, messages )).Z2UI5_CL_SMPS_LLM_FACTORYreads the configuration and creates one of:Z2UI5_CL_SMPS_LLM_CLAUDE: Anthropic Messages API.POST /v1/messageswith headersx-api-keyandanthropic-version: 2023-06-01, body{model, max_tokens, system, messages}. The answer is read as the firsttextkey undercontent, not ascontent[0], because current models can return a thinking block first. I checked this against platform.claude.com/docs (messages and errors pages).Z2UI5_CL_SMPS_LLM_OPENAI: OpenAI-compatible Chat Completions.POST /v1/chat/completionswithAuthorization: Bearer, answer fromchoices[0].message.content. The token limit is sent asmax_completion_tokens, because current OpenAI models rejectmax_tokens. The field name is a constant in the class.Z2UI5_CL_SMPS_LLM_ISLM: SAP ABAP AI SDK (see below).Z2UI5_T_SMPS_LLM, maintained withZ2UI5_CL_SMPS_APP_013.Z2UI5_IF_SMPS_LLM_HTTP:src/10/01Z2UI5_CL_SMPS_LLM_SM59:cl_http_client=>create_by_destinationwith an SM59 destination. For Standard.src/10/02Z2UI5_CL_SMPS_LLM_CLOUD:cl_web_http_client_manageroncl_http_destination_provider=>create_by_cloud_destination, which uses the BTP destination service and communication arrangementSAP_COM_0276. For ABAP Cloud.Z2UI5_CL_SMPS_LLM_JSON), as the abap2UI5 building-apps guide asks./ui2/cl_jsonis not released for ABAP Cloud, andxco_cp_jsondoes not exist on 7.40. The reader reads each string token whole and resolves escapes, the same idea asZ2UI5_CL_SMPS_APP_489.\uXXXXescapes are decoded only in the ASCII range, because decoding beyond it needs a codepage API that differs between the two stacks. This is documented in the class.Z2UI5_CX_SMPS_LLM. Its text is written for the person fixing the setup. The package raises it through=>raise( ): at the 7.40 floor,RAISE EXCEPTION NEWdoes not parse, while the shared rule set asks for NEW overRAISE EXCEPTION TYPE. Raising an object created withNEWsatisfies both without changing the shared rule block.SAP ABAP AI SDK (ISLM)
Z2UI5_CL_SMPS_LLM_ISLM(src/10/03) uses these calls:cl_aic_islm_compl_api_factory=>get( )->create_instance( scenario )create_message_container( ), thenset_system_role,add_user_messageandadd_assistant_messageget_parameter_setter( )->set_maximum_tokens( )execute_for_messages( )->get_completion( )cx_aic_api_factoryandcx_aic_completion_apiI checked the class and method names against SAP's own published samples: SAP-samples/abap-cheat-sheets
30_Generative_AI.mdand SAP-samples/abap-partner-reference-application tutorial 42, which agree with each other. help.sap.com and developers.sap.com were not reachable from the build environment, so the exact release that first ships the SDK is not verified. Because of that, the class header says "where the ABAP AI SDK is installed" and gives no release number. The factory creates the class by name and says so when it is missing.Follow-up: check
Z2UI5_CL_SMPS_LLM_ISLMon a system with the SDK, including the parameter type ofcreate_instance(passed withCONV #( )), and add the release floor to the package README.Release floor and lint version
.github/packages.jsondeclaresrunsOn"Cloud + Standard ≥ 7.40 SP08" butsyntaxv751:src/10/02parses cleanly (I checked this locally).if_web_http_client=>post,if_a4c_cp_service=>service_specific), which need 7.51 syntax.notefield explains this, and it is printed into the generated branch README.Other changes
build-package-branch.mjsnow derives the package count frompackages.json.SAMPLES.md,catalogue.jsonandcatalogue-derived.jsonregenerated.@keywordsline includesai llm chat.Gates run locally
npm ci, thennpm run check. All passed:I also simulated the branch build:
build-package-branch.mjs 10-ai-llmplus abaplint at v751 plus check-overview, and the same for09-launchpad. Both passed.Not verified on a real system
create_by_cloud_destinationwith a NoAuthentication destinationCross-links and AI-ready pointer
Z2UI5_CL_SMPS_APP_014already namedZ2UI5_CL_SMP_APP_540in its header. It now links that class's source on samplesmainas well.Z2UI5_CL_SMPS_APP_015now namesZ2UI5_CL_SMP_APP_541(explain this data, with a local deterministic provider) as its counterpart, in the header and in thesrc/10README table. The links go live when Add two AI samples: chat assistant and explain-this-data panel samples#871 is merged. The root prose that check-prose-names reads names neither class, so CI does not depend on the order the two pull requests are merged in.npm run samples:md,npm run catalogueandnpm run derived, no files changed.npm run checkpassed (exit 0).🤖 Generated with Claude Code
https://claude.ai/code/session_01Dx9qDRBfuVKdBr8EXrKNXf
Generated by Claude Code