Quomodo integrare ChatGPT in SUFFODIO UI5

Praefatio - Post haec pars est UI5 Integration Programs series.

Introduction

Non potest directe integrare ChatGPT utens CDN (Content Delivery Network) sicut exemplar GPT-3 nullo publico CDN hosted. GPT-3 exemplar proprietatis est ab OpenAI possessum, et accessus ad id providetur per OpenAI API, quod clavis API utendi requirit.

OpenAI API uti potes in applicatione JavaScript, petitiones HTTP ad API finem faciens et clavis API utens. Quod OpenAI API praebet a prompt endpoint that sino vos promptum ad GPT-III mittere et responsionem accipere.

Hic est exemplum quomodo uti possis fetch API in JavaScript promptum mittere ad GPT-3 et responsionem log:

const API_KEY = 'YOUR_API_KEY'; const promptum = 'What is the meaning of vita?'; arcesse(`https://api.openai.com/v1/engines/davinci/completions`, { method: 'POST', capitis: { 'Content-Type': 'application/json', 'LICENTIA': `portator ${API_KEY}` }, corpus: JSON.stringify({ promptum, max_tokens: 20 }) }).tunc(responsum => responsio.json()) .then(data => { console.log(data.choices[ 0].text);

Quomodo integrare ChatGPT in SUFFODIO UI5

Ut infra imaginem ostenditur, tres gradus simplices sequemur ut APIs ChatGPT integrandi intra SAP UI5 App.

Quomodo integrare ChatGPT in SUFFODIO UI5

1. Get API ex Open AI

Iam de omnibus gradibus quae circa API creationem in dictum.

2. crea UI5 Project

Utere Web IDE vel SUFFODIO BAS et generare simplex UI5 Application usus generantis.

3. Integrate ChatGPT Call

Sententiam simplicissimam cum capsa input , conjunctionem et aream textilem creamus ut outputum ostendemus ut infra visum ostendemus:


Et in prelo Sutton, codicem datum in controller.js . scripsimus

sap.ui.define(["sap/ui/core/mvc/Controller" ], function (Controller) { "utere stricte"; return Controller.extend("Test.controller.Main", {onInit: function ( ) { }, onPressGPT: function () { var id = hoc; const API_KEY = ''; var promptum = this.byId("idInput").getValue(); v1/engines/davinci/completions`, { method: 'POST', capitis: { 'Content-Type': 'application/json', 'LICENTIA': `Bartor ${API_KEY}` }, corpus: JSON.stringify( { promptum, max_signa: 2000 }) }).tunc(responsum => responsio.json()).then(data => { that.byId("idText").setText(data.choices[0].text); });

Output

Output sine premente puga similis est:

UI5 ChatGPT output view

auctor

  • Barry allen

    A Full Developer Stack with 10+ years experience in different domain including SAP, Blockchain, AI and Web Development.

    Omnes stipes

Comments

Leave a Reply

Curabitur sit amet nisl. Inquisita agros sunt praenotati *

Et hoc site utitur ad redigendum Akismet spamma annotatum est. Disce quomodo data est processionaliter vestri comment.