CITE THIS NOTEBOOK: OpenAIMode: paclet for interaction w/ OpenAI's GPT & DALL-E via OpenAILink by Anton Antonov. Wolfram Community April 3 2023.
In this presentation we demonstrate creation and evaluation of OpenAI interaction cells in Mathematica notebooks. (Via a special notebook style.)
Video recording

Setup

Short

◼
  • It is assumed that the paclet OpenAILink is installed
  • ◼
  • ... and the required setup steps are completed.
  • ◼
  • Install the paclet OpenAIMode
  • In[]:=
    PacletInstall["AntonAntonov/OpenAIMode"]
    Out[]=
    PacletObject
    Name: AntonAntonov/OpenAIMode
    Version: 1.0.3
    
    In[]:=
    Needs["AntonAntonov`OpenAIMode`"]
    In[]:=
    OpenAIMode[]

    Complete

    In[]:=
    PacletInstall["ChristopherWolfram/OpenAILink"]​​​​Needs["ChristopherWolfram`OpenAILink`"]​​​​PacletSymbol["ChristopherWolfram/OpenAILink","ChristopherWolfram`OpenAILink`$OpenAIKey"]="<YOUR API KEY>";​​​​SystemCredential["OpenAIAPI"]="<YOUR API KEY>";​​​​PacletInstall["AntonAntonov/OpenAIMode"]​​​​Needs["AntonAntonov`OpenAIMode`"]
    Out[]=
    PacletObject
    Name: ChristopherWolfram/OpenAILink
    Version: 2.0.2
    
    Out[]=
    PacletObject
    Name: AntonAntonov/OpenAIMode
    Version: 1.0.3
    
    In[]:=
    OpenAIMode[]

    Demo

    Let us show how the notebook style works:
    ◼
  • Needs
  • ◼
  • OpenAIMode
  • ◼
  • Text completion cell (shortcut: "Shift-|")
  • ◼
  • Tweak invocation parameters with SetOptions
  • ◼
  • Image generation cell (shortcuts: "Tab")
  • In[]:=
    What is total number of cows in the world?
    Out[]=
    ​It is impossible to accurately estimate the total number of cows in the world because most cows are domesticated and kept on various farms and ranches. A third-party report estimated the global bovine population to be approximately 1.5 billion as of 2018.
    Pressing Tab while in text completion cell (light green) converts it to an image generation cell (light purple)
    In[]:=
    What is total number of cows in the world?
    Out[]=
    In[]:=
    Where is the gold of the Incas
    Out[]=
    ?​The gold of the Incas is believed to have been taken away by the Spanish conquistadors during the Conquest in the 16th century, so its exact whereabouts are unknown. It is possible some remains in Peru or other parts of South America, as well as in museums or private collections around the world.
    In[]:=
    SetOptions[OpenAIInputExecuteToText,OpenAITokenLimit->120];
    In[]:=
    Where is the gold of the Incas?
    Out[]=
    ​The location of the Inca gold is unknown as much of it is believed to have been looted by the Spanish during the conquest of Peru in the 16th Century. Much of what remains is believed to be located in museums, private collections, and buried beneath the ruins of ancient Inca sites in Peru and surrounding countries.
    In[]:=
    SetOptions[OpenAIInputExecuteToImage,ImageSize->Small];
    In[]:=
    Inca’s gold in the style of hieronymus Bosch
    Out[]=
    In[]:=
    Where is the most populous city in the world?
    Out[]=
    ​The most populous city in the world is Tokyo, Japan, with a population of over 37 million people.
    In[]:=
    pencil drawing of wasps fighting
    Out[]=
    SetOptions[OpenAIInputExecuteToImage,ImageSize->Small];
    In[]:=
    Where is the most populous city in the world?
    Out[]=

    Political

    In[]:=
    What are the indicators of declining empire
    In[]:=
    what is the damage from nuclear bomb
    In[]:=
    what is the damage from nuclear bomb

    How does it work?

    Consider the following flowchart:

    Concluding remarks

    Similar work

    ◼
  • DSLMode and RakuMode
  • ◼
  • DarkMode and DraculaTheme
  • Future plans (...maybe)

    More documentation
    Should this notebook style functions be part of OpenAILink?
    Based on feedback:
    ◼
  • Better default options
  • ◼
  • Additional OpenAI cells