UBOS Community

Vika
Vika

Posted on • Updated on

Using Templates on UBOS: Instructions and Examples, Powered by OpenAI

1. Introduction
2. Template Overview
3. Using a Template on UBOS: Step-by-Step Guide
4. Examples of Using a Template on UBOS

1.Introduction

In this article, we will talk about what a template is and how to use it on UBOS. We will provide a detailed instruction on using the template and give examples of how it can be used to create a website. With this article, you will be able to quickly and effectively start your project and add the necessary functionality by using the template.

2.Template Overview

To get started, you will need a UBOS account where you can deploy any template you choose. Each template consists of both a user interface and a backend.

UI part
Image description

Backend part
Image description

3.Using a Template on UBOS

UI
The UI includes an input field to enter prompts, a submit button to send requests, and another input field to display the OpenAI's response. The "settings" tab allows you to view the specific configurations used for sending requests.
Image description
In this input you have to insert your api key OpenAI, the instruction is at the link ⇥

Image description
We send the data from this input to Http in in Node-red, and receive them in msg.payload
Image descriptionOn the Onclick event, send a POST request to the backend.

Image descriptionIn this input, we see the result of the query.

Image description
This button open the modal window "settings"
Image descriptionSettings data is also the result of the query.

Backend
IMPORTANT!!!
To run the flow on the backend, you need to add
OpenAI key

1._HTTP In node_

This node is the starting point of the flow and waits for an incoming HTTP POST request on the "/createSQLtranslate" URL. When it receives a request, it passes the payload to the next node.

_Function node "OpenAI API properties"_

This node is responsible for setting up the necessary properties and headers for making a request to the OpenAI API. It takes the incoming text payload and creates an object with the OpenAI API properties and headers required for making a request. It then returns the modified message object to the next node.

_HTTP Request node "OpenAI API"_

This node sends a POST request to the OpenAI API using the properties and headers that were set up in the previous node. It waits for the response from the API and passes it to the next node.

_Function node "Response"_

This node is responsible for processing the response from the OpenAI API. It converts the payload from the API response to an object format, extracts the translated text, and returns a modified message object that contains the text and the translation settings or response the error info.

_HTTP Response node_

This node sends a response back to the client who made the initial request, with the translated text as the payload. It sends the HTTP response back to the client with the translated text.
Image description

4.Examples of Using a Template on UBOS

Template "SQL translate." The product designed to provide a translation service for SQL queries, allowing users to convert SQL queries from one dialect to another.
Image description

Discussion (0)