SampleSampletypeA worked example you read or clone. Evidence: it demonstrates, it never provides.See every one →What this type is →independently maintainedindependently maintainedoriginPublished by one person or a small company outside SAP. Says nothing about quality; the readings say that.See every one →

cap-ui5-gpt-chat

A working chat application on CAP and SAPUI5 against the OpenAI API — selectable models, per-user chat history in the database, maintainable chatbot personalities, and streaming responses as an option per chat.

A whole application rather than a call: the CAP service holds messages and personalities as entities, the completion stream is an event emitter the UI consumes as it arrives, and the UI5 side adds a custom list item control with code highlighting. Both halves are TypeScript, the backend using decorators and dependency injection. Personalities are seeded from a CSV, so changing the assistant's character is a data change and a redeploy rather than a code change.

Facts

Last pushLicenceApache-2.0

Where it sits

Lives in
Demonstrates
LLM integrationCAPUI5LLM integrationcapabilityCalling a language model from application code with the tenant, destination and credential handling already solved instead using an SDK call with a hand-rolled key.Reference appsCAPReference appscapabilityA whole application to read rather than a snippet to copy — somewhere to see how the pieces sit together once there are more than three of them.TypeScript patternsCAPTypeScript patternscapabilityHow an application is arranged once it is written in TypeScript — where handlers live, what registers them, and how business logic is kept apart from persistence. Distinct from typing, which is about the model being visible to the compiler; this is about the shape of the code around it.
Serves
Runs
Cloud Foundry

Who is behind it

Mike ZaschkaMike ZaschkaPersonMaintains this
In the atlas: maintains 6, contributes to 9, wrote 12
@mikezaschka
maintainer

Before choosing this

Conditions

PracticalFunctional boundary

It calls the OpenAI API directly with a key in the environment. It was written in early 2023 and last touched in May 2023, which is before SAP AI Core and the CAP LLM plugins existed — so read it for the shape of the application, not for how a CAP service should reach a model today.

What it declares

Every artifact

Type
Sample
Origin
Independently maintained
Runtime
Node.js
Runs on
Cloud Foundry

As a sample

Type declarations
declared
Form
A reference application

Connections3

Learn more3

Readings
  1. A ChatGPT-like chat app built with modern SAP technologies (CAP, SAPUI5) – Part 3/3Mike Zaschka, SAP Community
  2. A ChatGPT-like chat app built with modern SAP technologies (CAP, SAPUI5) – Part 2/3Mike Zaschka, SAP Community
  3. A ChatGPT-like chat app built with modern SAP technologies (CAP, SAPUI5) – Part 1/3Mike Zaschka, SAP Community

ArchitectureBetaRead from the sample's deployment descriptor. Some of the connections it states are not drawn yet.

as mta.yaml states it at 8b89dcc, read
SAP BTP, Cloud Foundry Runtimecapui5gptchatmta.yaml, module capui5gptchat-router, requires capui5gptchat-html5-repo-runtimebinding, outboundmta.yaml, module capui5gptchat-router, requires capui5gptchat-destinationbinding, outboundmta.yaml, module capui5gptchat-router, requires capui5gptchat-uaabindingOAuth 2.0, outboundmta.yaml, module capui5gptchat-router, requires srv-apisrv-apiSAP Authorization and Trust Management service, xsuaa, applicationSAP Authorizationand TrustManagement serviceSAP Destination service, destination, liteSAP DestinationserviceSAP HTML5 Application Repository service for SAP BTP, html5-apps-repo, app-runtimeSAP HTML5ApplicationRepository servicefor SAP BTPcapui5gptchat-router, approuter.nodejscapui5gptchat-routercapui5gptchat-srv, nodejscapui5gptchat-srvcapui5gptchat-db-deployer, hdbcapui5gptchat-db-dep…capui5gptchat-ui-content, com.sap.application.contentcapui5gptchat-ui-con…capui5gptchat-ui, html5capui5gptchat-uicapui5gptchat-destination-content, com.sap.application.contentcapui5gptchat-destin…hana, hana, hdi-sharedhanaSAP HTML5 Application Repository service for SAP BTP, html5-apps-repo, app-hostSAP HTML5ApplicationRepository servicefor SAP BTP
SAPnot SAP's, or the project's ownauthenticationstated in the document

Bound, and not drawn

Documented, with no instance in the document

Bound in the descriptor, not joined to an entry

hana

README

quoted from mikezaschka/cap-ui5-gpt-chat under Apache-2.0, read
mikezaschka/cap-ui5-gpt-chat/README.mdOn GitHub

A ChatGPT-like chat app built with SAP CAP and SAPUI5

This is a full working chat application built with the SAP Cloud Application Programming Model and SAPUI5. It uses a selectable OpenAI model (including the latest ChatGPT model) of the OpenAI API to generate responses to the user's prompts. More details can be found in the related blog posts in the SAP Community:

Features

  • Chat with a selectable OpenAI model including the GPT-4 and GPT-3.5 models powering ChatGPT
  • Multi-user support for individual chats
  • Selectable and maintainable personalities for the AI chatbot
  • Chat history for each user (everything is stored in the database)
  • Per chat option to enable streaming responses from the OpenAI API
  • Code-Highlighting for code snippets in the chat messages
  • Ready to be deployed to SAP BTP Cloud Foundry
Technical Aspects
  • Full TypeScript implementation in backend (SAP CAP) and frontend (SAPUI5)
  • Usage of advanced TypeScript features like decorators and dependency injection in the backend
  • Chat UI built with SAPUI5 including a custom list item control and with the integration of external modules

Demo

Ask the AI for help with SAPUI5:

alt text

Ask the AI about SAP BTP:

alt text

Customize the app

Since the app is Open Source, you can simply fork the repository and customize it to your needs.

Without a technical deep dive, there are two ways to easily customize the app:

Add a new personality

There is currently no UI to administrate personalities, but they can easily be changed in a csv file. Open the file packages/server/db/data/p36.capui5gpt.chat-Personalities.csv and simply add a new line with the following format:

<name>;<instruction>

After changing the file you need to redeploy the entities to the database. In the local enviroment you can do this with the following command (please note that this will delete all data in the local database):

pnpm -r deploy:local

In the Cloud Foundry environment you can simply re-deploy the app (no data will be lost).

Modify the AI model parameters

It is possible to tweak the OpenAI API parameters for the completion request. For more details, see the OpenAI API documentation. Simply add the following in the default-env.json file in the packages/server folder and change the parameters to your needs:

{
  "app_openai": {
    "apiKey": "YOUR-API-KEY",
    "completionAttributes": {
      "max_tokens": 1200,
      "temperature": 0.8,
      "top_p": 1,
      "frequency_penalty": 0,
      "presence_penalty": 0.6
    }
  }
}

When being deployed to the Cloud Foundry environment, you can also change the parameters by changing the values in the dev.mtaext file.

Run the app locally in development mode

Prerequisites
Install pnpm

If you haven't pnpm already installed, you can globally install it via the following command:

npm i -g pnpm
Install dependencies

Install all dependencies using the following command:

pnpm i
Deploy the cds entities from the CAP backend to the SQLite database
pnpm -r deploy:local
Add your OpenAI API key

Put a new file in the folder packages/server called default-env.json with the following content and add your OpenAI API key:

{
  "app_openai": {
    "apiKey": "YOUR-API-KEY"
  },
  "VCAP_SERVICES": {}
}
Start the app in development mode

The following command will start the app in development mode. Server and UI will be started in parallel.

pnpm --parallel start:dev
Open the app in the browser

Open the following URL in your browser and start chatting: http://localhost:8080/local.html

You need to login with one of the following credentials:

usernamepassword
developerhelloworld
pirateahoy

There a no specific roles attached to either user, so feel free to choose.

Deploy the app to the SAP BTP Cloud Foundry environment

The project is already prepared to be deployed to the SAP BTP Cloud Foundry environment. The following diagram shows the architecture of the app:

alt text

The full application can be deployed to SAP BTP without any cost, using a Trial or Free Tier acccount.

Prerequisites
Add your OpenAI API key

Edit the file dev.mtaext and add your OpenAI API key to the app_openai property:

modules:
  - name: capui5gptchat-srv
    properties:
      app_openai: >
        {
          "apiKey": "YOUR-API-KEY",
          "completionAttributes": {
            "max_tokens": 1200,
            "temperature": 0.8,
            "top_p": 1,
            "frequency_penalty": 0,
            "presence_penalty": 0.6
          }
        }
Login to the SAP BTP Cloud Foundry environment
cf login
Deploy the MTA

All parts of the application can be deployed with a single command:

pnpm deploy:dev

The mta.yaml file contains all relevant services and modules:

  • The capui5gptchat-router module for a standalone approuter
  • The capui5gptchat-server module including the CAP backend
  • The capui5gptchat-ui module including the SAPUI5 frontend

The app will be accessible via managed approuter as well as via the standalone approuter.

Assign the required role to your user

The deployment will create a Role Collection ChatGPT-like App Human in your Cloud Foundry environment. You need to assign the role to your user in order to be able to login to the app.

How to obtain Support

This content is provided "as-is" without warranties or conditions of any kind.

License

Copyright (c) 2023 p36 GmbH. All rights reserved. This project is licensed under the Apache Software License, version 2.0 except as noted otherwise in the LICENSE file.

Apache-2.0, read

Details

Sources3
GitHub APIdiscovered here, mikezaschkachecked
github.com/mikezaschka/cap-ui5-gpt-chattree, pushes, contributors, CIchecked
README.mdquoted, and what the entry declareschecked

Sources are graph entities: the same page may back several entries, and an unreachable source flags every row that rests on it.

Compatibility and provenance
runtimesnode
deploymentCloud Foundry
discovered viaGitHub API · mikezaschka
first seen in the atlas
ecosystem and domaincap, ai-and-agents
Flavors1
UI5 / Freestyle
“Chat UI built with SAPUI5 including a custom list item control and with the integration of external modules” — mikezaschka/cap-ui5-gpt-chat — READMEchecked
History in the atlas1
  1. First seen.
For your agent
Ref
artifact:mikezaschka-cap-ui5-gpt-chat
JSON
/artifacts/mikezaschka-cap-ui5-gpt-chat.json
MCP
Connecting an agent