Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
quovadis
Product and Topic Expert
Product and Topic Expert

Mistral gagnant. Mistral AI and SAP Kyma serverless (nodejs) story.

Let me tell you my story.

I have come across Mistral AI as an alternative to OpenAI/SAP AI core.

And, very naturally, I wanted to be able to consume the Mistral Javascript Client from a backend service running on SAP BTP, Kyma runtime (which is the SAP's managed and business-friendly kubernetes offering) as a serverless function.

And here is how the story unfolded...

 

Table of Contents
  1. Tackling SAP Kyma serverless nodejs functions CommonJS (cjs) vs. ECMAScript (esm) conundrum
  2. The making of.
    1. SyntaxError: Cannot use import statement outside a module .
    2. ERR_REQUIRE_ESM error when trying to require('@mistralai/mistralai').
    3. Dynamic import..
  3. Mistral gagnant.
    1. mistral.mjs.
    2. handler.js.
    3. tadam.
  4. Integration into SAP APIM
  5. Integration into SAP Build Apps with the BTP destinations

Voila. C'est le mistral gagnant:)

PS.

Prompts examples:

 

MistralAI prompt: what is the best French dish?
The "best" French dish can depend on personal taste, but some of the most popular and renowned French dishes include:

1. Coq au Vin: This is a classic French dish where chicken is slow-cooked with wine, lardons (small strips or cubes of pork fat), mushrooms, and possibly garlic.

2. Bouillabaisse: Originating from the port city of Marseille, this is a traditional Provençal fish stew.

3. Escargots: Snails cooked in a garlic, butter, and parsley sauce, often served as an appetizer.

4. Ratatouille: A vegetable stew from Nice, usually made with eggplant, zucchini, bell peppers, tomatoes, and sometimes potatoes and onions.

5. Crème Brûlée: A rich custard base topped with a contrasting layer of hard caramel.

6. Tarte Tatin: A caramelized apple tart where the apples are cooked first in butter and sugar before the tart is baked.

7. French Onion Soup: Made with onions, beef broth, and usually topped with croutons and cheese.

8. Quiche Lorraine: An open pie with a filling consisting of a savoury custard with smoked lardons or bacon.

9. Steak Frites: A simple yet classic dish of a grilled or fried steak served with French fries.

10. Croissants: A buttery, flaky, crescent-shaped pastry that originated in Austria but became very popular in France.

 

 

MistralAI prompt: How to implement mTLS with SAP Kyma
Mutual Transport Layer Security (mTLS) is a method of authentication that uses digital certificates to verify the identity of both the client and server during a communication session. Implementing mTLS with SAP Kyma involves several steps, including creating a certificate authority (CA), generating and distributing certificates, and configuring your applications to use mTLS.

Here are the general steps to implement mTLS with SAP Kyma:

1. Set up a certificate authority (CA) to issue and sign the certificates. You can use a public CA, or set up your own private CA using tools such as OpenSSL or Certbot.
2. Generate a private key and certificate signing request (CSR) for each service or application that will use mTLS. You can use OpenSSL or Certbot to generate the private key and CSR.
3. Submit the CSR to the CA to obtain a signed certificate. The CA will verify the identity of the requestor and issue a signed certificate.
4. Configure your application or service to use the private key and signed certificate. This typically involves setting environment variables or configuration files in your application to point to the location of the private key and certificate.
5. Configure SAP Kyma to use mTLS. This involves setting up a custom domain for your application, configuring the Istio service mesh to enforce mTLS, and configuring any ingress gateways to require client authentication.
6. Test your mTLS implementation to ensure that it is working correctly. You can use tools such as curl or OpenSSL to test the connection between your client and server, and verify that the certificates are being exchanged and validated correctly.

SAP Kyma provides a built-in certificate authority called the Kyma Certificate Service (KCS) which can be used for generating and managing certificates for mTLS. You can find more information on how to use KCS in the SAP Kyma documentation.

 

Additional reading:

Piet Mondrian's artwork powered with AI with little or no code.