DEV Community

SamyMe
SamyMe

Posted on • Edited on • Originally published at Medium

OpenAI (GPT-3 API) for WebDevs - Concrete applications

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, 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 showcasing that pretty well.

Code generation gpt3

Make your app understand texts : GPT3 is great at understanding natural language. In a previous article 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

Summarization example :


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'])

Enter fullscreen mode Exit fullscreen mode

Semantic Search : one of the (limited but evolving) use cases is searching for information (Google vs ChatGPT3). 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)

Semantic search

You can easily do this with Eden AI's API.

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'])

Enter fullscreen mode Exit fullscreen mode

Automated customer service and support : ChatGPT3 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

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 their generative image model as well as the 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, china’s huge Wu Dao or GPT-Neo 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.

Top comments (2)

Collapse
 
samyme profile image
SamyMe

I'm moving all my writing to medium : medium.com/@samy_89073/

Collapse
 
samyme profile image
SamyMe

My previous article on AI in general : dev.to/samyme/ai-for-web-devs-conc...