Cool AI-powered application ideas for your next project
Tags: webdev, machinelearning, openai
Published: 2023-03-25 06:23:46

This post would be aimed at people having limited knowledge of AI and how they can still leverage AI features in their applications using the API provided by OpenAI, the organization behind ChatGPT.

A good place to start would be to register on their website at https://platform.openai.com/ and get your API key. Explore the examples page they have and you’d find 50+ cool ideas to try for your next AI-powered application. I’d list down my favourites from the list they have which I explored:-

- Language conversion from English to Spanish
- Keyword extractor from paragraphs of text
- Item classifier based on categories
- Grammar correction
- Movie to emojis
- Ad from the product description
- Tweet classifier
- Javascript to Python
- Questions and Answers
- Explain code
- Interview Questions

They have a quick start guide where they illustrate how to build a ‘pet name generator‘ in Node JS here -
 https://platform.openai.com/docs/quickstart/closing.

I actually used this **‘Interview Questions‘** model they had on the examples page. This would generate a list of questions for you based on the topic you provide in the text box. For instance, if you type something like “15 Most popular interview questions in Python“, it would reply back with 15 most popular interview questions in Python, exactly what you asked it for. You can try playing around with this here -

https://platform.openai.com/playground/p/default-interview-questions?model=text-davinci-003

As of now, they have examples in **Python** and **Javascript**. They have packages available which you can use for testing. Mine was a simple app using React with just a payload being passed to the API in JSON format. Below is the excerpt I took from the application I built. This contains the payload I passed to the openAI end-point.

`const jsonData = {
    "model": "text-davinci-003",
    "prompt": "Python interview questions",
    "temperature": 0.5,
    "max_tokens": 150,
    "top_p": 1.0,
    "frequency_penalty": 0.0,
    "presence_penalty": 0.0
}`

The **‘Model‘** key specifies which model to be used from the openAI API. “Prompt“ is the input sequence you pass into the model. The model then breaks down this sequence into granular pieces called ‘tokens‘ which are fed into the model to process.

**‘Temperature‘** parameter in Layman's terms simply means it controls the degree of randomness and creativity of the response generated by the model. A high-temperature value triggers more unpredictable outcomes from the model while a low value injects more confidence the model has in the most probable generated outcomes.

**‘Top_P‘** parameter is used for sampling the model outcomes based on cumulative probability distribution. For instance, a top_p of 0.3 means that only the tokens comprising the top 30% probability mass are considered.

**‘Frequency Penalty‘** limits the text from occurring further in the response based on the frequency of its presence till now in the response text.

**‘Presence Penalty‘** has a similar purpose to the ‘frequency penalty‘ except that it does not take the frequency of words into account while diminishing the relevance of keywords generated in the response text.

This was just a basic explanation of the options you pass in the payload. To get more comfortable with it, the best way inevitably would be to just play around with the options and see the difference in the produced response. It definitely helps if you know statistics and machine learning concepts. Here’s the link for the project I implemented in Vue JS using this API for the folks who are interested:- 

https://github.com/Apfirebolt/ask-interview-questions-ai-in-vue

You don't need a lot of AI knowledge to use this. This brings this post to the conclusion 🙂. If you like this post, please consider a reaction in form of a like or comment. Until then, see you in the next post 👋