harbour-openai/README.md

6.6 KiB

SeaAiNetic, An OpenAI client, generated by OpenAI

SeaAiNetic is a quick december development project built on the hype of OpenAI and AI generated content altogether. The goal was to "fully" develop a Sailfish OS app using only OpenAI. I failed to do so and had to make some adjustments, this can also be due to the instructions I gave to OpenAI, which might not be the best ones.

Something I learned from doing this was "how to explain in details what I wanted" . If I were to do that again I would put more time in designing the pseudo code of the app before asking the AI about it.

You can read the instructions bellow. I hope this code migth be usefull for new developpers, this is why I asked OpenAI to explain the code. I left the comments from OpenAI on purpose. It's also important to note that the AI uses data from 2021 which influences the code output, for example, the API url in 2021 was different than the one in 2022, that's why I had to specify it.

You are limited to three requests with my API key. Although you can remove this limit in the code, if you have the knowledge to do so, please consider instead setting your API key it in the app. It's shorter to create an account with OpenAI than recompiling the app (and others can use it too).

A name for the new app

find a name for a sailfish OS application that uses openai API. The name should have something to do with the sea world and artificial intelligence. Explain the name

SeaAiNetic: The name SeaAiNetic is derived from the words "sea" and "A.I." combined with the word "kinetic," which means having to do with motion. This name reflects the use of the OpenAI API to create a sailfish OS application that explores the connection between the sea world and artificial intelligence.

App Icon

Created using DALL-E : sailfish os app icon for openai artificial intelligence sailfish

First instruction, create the API client

Write a Sailfish OS client in QML, QtQuick 2.6, LocalStorage and SailfishSilica for the openai.com API. Use SilicaFlickable for building the application. The width and the height of the SilicaFlickable should be the same size as the current screen. It's a page. In the SilicaFlickable, write a PageHeader. The PageHeader title is "Open AI API", placed on the upper right of the page. The TextArea should be placed bellow the PageHeader. Write the API request inside a button. The API token must be a global variable that can be changed from an other page. Use the button to send the question. Show an error message if the API cannot be reached. Write in a database the question asked and the answer received. If there are more than 3 questions in the database do not send the API request and display the error message "you sent more than 3 questions". The button should be placed bellow the input area. Display the text response from openai.com in a text area. Only send question if the string is bigger than one. Follow the Sailfish OS definition of done principles. Explain the code. Write a console log for each operation. The token API is sk-8aFzWbcLXXXXXXXXXXXXXXXXXXXXXXXXXXX. The URL https://api.openai.com/v1/completions.

Second instruction, create a settings page

Write a Sailfish OS client in QML, QtQuick 2.6, LocalStorage and SailfishSilica for the openai.com API. Use SilicaFlickable for building the application. The width and the height of the SilicaFlickable should be the same size as the current screen. It's a page. In the SilicaFlickable, write a PageHeader. The PageHeader title is "Open AI API", placed on the upper right of the page. The TextArea should be placed bellow the PageHeader. Write the API request inside a button. The API token must be a global variable that can be changed from an other page. Use the button to send the question. Show an error message if the API cannot be reached. Write in a database the question asked and the answer received. If there are more than 3 questions in the database do not send the API request and display the error message "you sent more than 3 questions". The button should be placed bellow the input area. Display the text response from openai.com in a text area. Only send question if the string is bigger than one. Follow the Sailfish OS definition of done principles. Explain the code. Write a console log for each operation. The token API is sk-8aFzWbcLXXXXXXXXXXXXXXXXXXXXXXXXXXX. The URL https://api.openai.com/v1/completions.

Third instruction, create a history page

Write a Sailfish OS Page in QML, QtQuick 2.6, QtQuick.LocalStorage 2.0 and SailfishSilica. Use Page and SilicaFlickable for building the application. The PageHeader inside the SilicaFlickable should have the title "History". Use LocalStorage.openDatabaseSync to open the database. List all the entries of the database called "openai_db16" with the table "openai_table" version "1.0" and the columns "question" and "answer". For every question and every answer in the database List each question and each answer, one bellow the other. Explain the code.

Bonus - The first request I made and the answer from OpenAI

Question: create a Sailfish OS application that can request the openai API

Answer: The first step to creating a Sailfish OS application that can request the OpenAI API is to install the necessary software development tools. This includes the Sailfish OS SDK and the Sailfish OS IDE. Once the tools are installed, the next step is to create a project and begin coding the application.

The application should make use of the OpenAI API by making requests for specific data or information. The application should also include a UI for the user to interact with and configure the API requests. The application should also include a way for the user to view the data or information returned by the API requests. Finally, the application should include a way for the user to save the data or information returned by the API requests.

Once the application is complete, the user should be able to make requests to the OpenAI API and view the data or information returned. The user should also be able to save the data or information returned for later review.

Creating a Sailfish OS application that can request the OpenAI API requires knowledge of programming in Sailfish OS and the OpenAI API. It also requires the user to have access to the necessary development tools. With the right knowledge and tools, creating such an application should be a relatively straightforward process.