Anyone Can Create A Chatbot With Codex

Leveraging OpenAI API, GPT-3 API & Codex


The GPT-3 based OpenAI Language API is a text-in-text out API. It is not a chatbot development framework.

A chatbot development development framework demands the existence of seven elements which constitutes fine-tuning (there can be more).

  1. Forms & Slots
  2. Intents
  3. Entities
  4. Natural Language Generation (NLG)
  5. Dialog Management
  6. Digression
  7. Disambiguation

The OpenAI API allows for basic training with a few lines of example utterances, giving the API a basic gist of your application.

Fine tuning is available, but again this is a way of influencing the text-out portion. And not comprehensive fine-tuning per se.

Fine-tuning in OpenAI Language API based on GPT-3 is currently in beta and might change considerably in the near future.

The OpenAI API is impressive none the less; but implementation scenarios currently is limited. Some implementation scenarios:

  1. A standalone general chatbot for general conversation. Or a question-and-answer Wikipedia-like chatbot.
  2. The second implementation is a Support API for a conventional Chatbot implementation. These can cover:
  • Grammar Correction
  • Text Summarization
  • Keywords
  • Parse Unstructured Data
  • Classification
  • Extract Contact Information
  • Summarize For A Second Grader

However, this is not the case with Codex…

Codex Use-Cases

There are a few definite use-cases for Codex as an API, ready for implementation.

Some of these use scenarios can include:

  • As a general AI Assistant for general code questions by a company’s development team/s.
  • A real use-case is having Codex as a bot within a Slack or Teams environment and coders can pose general questions to the Codex interface.
  • As a code QA bot. This process can be automated where code is run against the Codex API and reports are generated on vulnerabilities or errors.
  • Solving coding challenge and problems in certain routines.
  • Establishing best practice.
  • Explaining code
  • Interactive Learning
  • Crafting code based on Natural Language Input for developers to try out.
  • Converting code from one language to another.

A Practical Example: JavaScript Chatbot

This is an implementation of a JavaScript chatbot. Users can ask the chatbot any question regarding JavaScript. A user can ask the chatbot a practical question and the chatbot responds in natural language actually explaining the implementation in natural language.

As with the other offerings from OpenAI, the natural language generation is smooth, coherent and truly natural. Should you ask for a practical implementation, the Codex JavaScript chatbot will return working code.

Below is a practical example of a simplistic Python implementation of the JavaScript chatbot with the prompt input.

pip install openai
import openai
openai.api_key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"response = openai.Completion.create(
prompt="JavaScript chatbot\n\n\nYou: How do I combine arrays?\nJavaScript chatbot: You can use the concat() method.\nYou: How do make an alert appear after 10 seconds?\nJavaScript chatbot: You can use the setTimeout() method.\nYou: Show me a practical implementiton of concat();",
print (response)

You can see the typos in the user input, but it does not cause any fallback proliferation.

Below is the JSON response…

"choices": [
"finish_reason": "length",
"index": 0,
"logprobs": null,
"text": "\nJavaScript chatbot: You can use the following code:\n\n

var arr1 = [1, 2, 3];\n
var arr2 = [4, 5, 6];\n
var arr3 = arr1.concat(arr2);\n
"created": 1630678929,
"id": "cmpl-3e4Mz3L6Tfk0vc5",
"model": "davinci-codex:2021-08-03",
"object": "text_completion"

The JavaScript chatbot is diverse in responses understanding if a user wants code or an explanation. This a complete API ready for use.


Codex is exceptionally good at explaining code and debugging code. Creating an application using natural language input demands that the user to break down their requirement for larger application, into smaller modules or segments.

This approach does take some time to build the application layer by layer, but allows for neat and predictable outputs.

Something small I found interesting I each segment of code is very well described with comments. The Natural Language Generation (NLG) of these comments is extremely well formed, cohered and natural sounding.

This is testament to the astute NLG capabilities of OpenAI Language API.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store