OpenAI (GPT-3 API) for WebDevs - Concrete applications
Tags: gpt3, ai, webdev, machinelearning
Published: 2022-12-20 13:16:45



## What is OpenAI’s GPT3 and how is it different from other AI models? 

Open AI is a (well funded) research and development company that focuses on Artificial Intelligence. They’re developing a [large language model](https://medium.com/@aousabdo/what-are-ai-language-models-and-how-are-they-being-used-f1bf06f8ae80), a type of AI model that is trained on a very large datasets of textual data including web pages, books, articles, and more. 

## How can you use OpenAI’s GPT as a WebDev.

**Content generation** : Apart from generating code and threatening developers' jobs, a lot of companies are finding a use in GPT3 to create software around automating content creation. It can be blog articles, social media posts or personalized email campaigns. Notion has just published their [AI assistant](https://www.youtube.com/watch?v=FElBbgnNtVA) showcasing that pretty well.


![Code generation gpt3](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9j7k2xbu9gk2n85c9eug.png)


**Make your app understand texts** : GPT3 is great at understanding natural language. In a [previous article](https://dev.to/samyme/ai-for-web-devs-concretely-5140) I talked about AI use cases in web dev and it can do a lot of that. Like : sentiment analysis, text classification and keywords extraction. But you can also do more advanced things like summarizing a text.

![natural language understanding](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ho2f6tt11pwe1t3dsnyi.png)

Summarization example :

```python

import json
import requests

headers = {"Authorization": "Bearer 🔑 Your_API_Key"}

url ="https://api.edenai.run/v2/text/summarize"
payload={"providers": "openai", 
         "language": "en", 
         "text": "Linux is a family of open-source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically packaged in a Linux distribution..."}

response = requests.post(url, json=payload, headers=headers)

result = json.loads(response.text)
print(result['openai']['result'])

```


**Semantic Search** : one of the (limited but evolving) use cases is searching for information ([Google vs ChatGPT3](https://www.cnbc.com/2022/12/15/google-vs-chatgpt-what-happened-when-i-swapped-services-for-a-day.html)). This could also be used to search content inside an app. It could be used as an internal search engine where your users can search for information in your documentation or your app. ([Illustration ref](https://www.seobility.net/en/wiki/Semantic_Search))


![Semantic search](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qkx93d1nu0vpny2cda5s.png)

You can easily do this with [Eden AI's API](https://edenai.co). 

```python
import json
import requests

headers = {"Authorization": "Bearer 🔑 Your_API_Key"}

url ="https://api.edenai.run/v2/text/search"
payload={
    "providers":"openai",
    "texts":["In Roman mythology, Romulus and Remus (Latin: [ˈroːmʊlʊs], [ˈrɛmʊs]) are twin brothers whose story tells of the events that led to the founding of the city of Rome and the Roman Kingdom by Romulus.","In ancient Roman religion and myth, Mars (Latin: Mārs, pronounced [maːrs]) was the god of war and also an agricultural guardian, a combination characteristic of early Rome.",
        "Proto-Indo-European mythology is the body of myths and deities associated with the Proto-Indo-Europeans, the hypothetical speakers of the reconstructed Proto-Indo-European language","The Ashvamedha (Sanskrit: अश्वमेध, romanized: aśvamedha) was a horse sacrifice ritual followed by the Śrauta tradition of Vedic religion.",
        "Purusha (puruṣa or Sanskrit: पुरुष) is a complex concept whose meaning evolved in Vedic and Upanishadic times. Depending on source and historical timeline, it means the cosmic being or self, consciousness, and universal principle."],
    "query":"Rome"}

response = requests.post(url, json=payload, headers=headers)

result = json.loads(response.text)
print(result['openai']['items'])

```


**Automated customer service and support** : [ChatGPT3](https://openai.com/blog/chatgpt/) is GPT optimized for dialog and it’s leading the Chatbots renaissance. After all the attention chatbots got a few years ago, we saw their limitations very rapidly. But now, with the stunning power ChatGPT showed these bots are going to be upgraded into a new level.


![chatbots](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ap1ufehat22mufez3v4l.png)


**Find the right prompt** : All of these applications are simple examples of what a LLM can do. Now it’s up to you to find new applications by finding the right input prompt. 

## Conclusion : 

In addition to gpt, OpenAI have [DALLE-E](https://openai.com/dall-e-2/) their generative image model as well as the [whisper](https://openai.com/blog/whisper/) speech recognition model. They are working on unifying their different models to be able to process text, images and audio at the same time which will lead to incredible new use cases !

Other alternatives to OpenAI exist, either retraining and fine-tuning gpt3 or creating new models like [Google’s PaLM](https://ai.googleblog.com/2022/04/pathways-language-model-palm-scaling-to.html), [china’s huge Wu Dao](https://reason.com/2021/06/11/amazing-new-chinese-a-i-powered-language-model-wu-dao-2-0-unveiled/) or [GPT-Neo](https://huggingface.co/EleutherAI/gpt-neo-1.3B) open source alternative. 
At Eden AI, we’re working on bringing the capabilities of all these different models to your application using one simple unified APIs with a very intuitive [developer portal](https://app.edenai.run/).