Motivation

This is a summary of what I have done with chatGPT in the past few months. I myself have toyed with some language models for some years and being bilingual, language is of course an issues that comes up often in the various stages of my life.
​
The first work I ever published in the States was in high school almost 35 years ago. It was a poem about a famous poet of ancient China . It was selected and published by our high school English teacher in our school literature magazine. It was this poem that gave me the idea of the fact that being authentically yourself in the United States is a viable approach to interacting with society. But looking back it was really my German language teacher that gave me the confidence.
​
So I thought it was fitting that my first chatPT project was trying to re-create the lost work with new twist and angle that I have learned since then.

chatGPT and Chinese Poetry

The pome I published in our high school magazine was a bit depressing. So I decided that this time I want something more upbeat. After a few try with the chat bot at the openAI website, I came across the early version of OpenAILink paclet created by Christopher Wolfram. I hope to demonstrate to my students how they can use this tool creatively inside Mathematica.
PacletInstall["ChristopherWolfram/OpenAILink"]
openaikey=(*enteryourkey*);​​Needs["ChristopherWolfram`OpenAILink`"]
SystemCredential["OPENAI_API_KEY"]=openaikey​​$OpenAIKey
OpenAICreateImage
["Chinese poet sitting by a lake",ImageSize->Medium]
Out[]=
I have watched a few videos of how people try to generate image with other artificial intelligence tools. It became apparent that you still need to know what to ask or else what do you get will be as good. It seems like from the above result, that my years of learning Asian art, and art appreciation is paying off.
​
In my next prompt, I added some details to the description. For something that is free this is pretty good stuff
OpenAICreateImage
["Chinese poet sitting by a garden of flowers and butterflies",ImageSize->Medium]
Out[]=
So far so good. So I try some text with style.
In[]:=
Style
OpenAICompletion
["Write a 7 words 5 line poem about a butterfly.\n\n",OpenAITokenLimit->500],24,FontFamily->"Palatino"
Out[]=
Fluttering wings of grace,Bright colours on its face,Gently in the breeze,Bringing joy and ease,A beauty to behold,Butterfly of gold.
In[]:=
OpenAICompletion
["Write a 7 word 5 line poem about a butterfly.\n\n",OpenAITokenLimit->500,OpenAIModel->"gpt-3.5-turbo"]
OpenAICompletion
::openAIResponseFailureMessage
:Request to the OpenAI API failed with message: This is a chat model and not supported in the v1/completions endpoint. Did you mean to use v1/chat/completions?.
​
Out[]=
Failure

Message: Request to the OpenAI API failed with message:
This is a chat model and not supported in the v1/completions endpoint. Did you mean to use v1/chat/completions?
.
Tag: OpenAIResponseFailure
HTTPResponse: HTTPResponse
Status: Not Found
Content type: application/json


In the old version the response did not follow exactly the request of seven words and five lines . This is a particular specifications of Chinese poetry. In the updated version it worked as specified.
In[]:=
Style
OpenAICompletion
["Write a 7 words 5 line poem about a garden of flowers and butterflies,reading a book and thinking about galactic nebulae.\n\n",OpenAITokenLimit->500],24,FontFamily->"Palatino"
Out[]=
Roses and daisies, so pretty and brightButterflies flit, a dazzling sightReading a book, lost in thoughtGalactic nebulae seen in my thoughtsSoft fragrant breeze, in the garden of peaceFloat away to a life beyond reach
Here' s more images of the Chinese poet with prompts that spells out more details about the background.
In[]:=
OpenAICreateImage
["a young Chinese poet sitting by lake with red mountain in the background blossoming with pink flowers and butterflies",ImageSize->Medium]
Out[]=
In[]:=
OpenAICreateImage
["in chinese painting style paint a young Chinese poet sitting by lake with red mountain in the background blossoming with pink flowers and butterflies ",ImageSize->Medium]
Out[]=
In[]:=
OpenAICreateImage
["in chinese Qi Bai Shi painting style paint a young Chinese poet sitting by lake with red mountain in the background blossoming with pink flowers and butterflies ",ImageSize->Medium]
Out[]=
The nice thing about having OpenAI within Mathematica is that you can save the work, mix text and graphics, process the graphics, create a matrix of graphics from the same prompt, generate visualizations from the data given by chatGPT, etc. Below are 2 arrays of a poet with one having happy background and the other with bleak background. As you notice OpenAI isn’t particularly good at drawing mosquitoes.
In[]:=
Table[OpenAIGenerateImage["Chinese poet sitting by a garden of flowers and butterflies,reading a book and thinking about star nebulae",ImageSize->Medium],{i,5}]
Out[]=

,
,
,
,

In[]:=
Table[OpenAIGenerateImage["Chinese poet sitting by a garden of flour and butter and flies,reading a book and thinking about star nebulae",ImageSize->Medium],{i,5}]
Out[]=

,
,
,
,


Ports of East Asia: Geographics and chatGPT

Because chatPT is train on Internet data, it is essentially a way to access the Internet up to the cut off date of the dataset. When you were chatting with it keep in mind that you’re really playing make-believe and that it is really a computer algorithm to fetch text it deems stochastically meaningful from internet data to complete the prompt that you entered.
​
My first intuitive guess is that since the data is from the Internet and since it is stochastic, whatever the Internet has the most are the answers that they will respond best. And world trade would be one such case.

ChatGPT and map: Using chatGPT as a internet librarian

To do some thing interesting I asked chatGPT to list all of the major ports of east asia . We all know that there is billions and billions of dollars of goods that flow between Asia and America but nobody ever bothered asking how these things get around from here to there and vice versa.
In[]:=
eastasia=OpenAIChatComplete[OpenAIChatMessageObject["user"," List the top 15 Ports in East Asia by volume"],OpenAITokenLimit->500]
Out[]=
OpenAIChatMessageObject
role: assistant
text: 1. Shanghai, China2. Singapore3. Ningbo-Zhoushan, China4. Tianjin, China5. Busan, South Korea6. Guangzhou, China7. Qingdao, China8. Shenzhen, China9. Hong Kong, China10. Kaohsiung, Taiwan11. Yokohama, Japan12. Dalian, China13. Xiamen, China14. Bangkok, Thailand15. Kobe, Japan

In[]:=
eastasia["Text"]
Out[]=
1. Shanghai, China2. Singapore3. Ningbo-Zhoushan, China4. Tianjin, China5. Busan, South Korea6. Guangzhou, China7. Qingdao, China8. Shenzhen, China9. Hong Kong, China10. Kaohsiung, Taiwan11. Yokohama, Japan12. Dalian, China13. Xiamen, China14. Bangkok, Thailand15. Kobe, Japan
After getting the list of major port, I thought it would be interesting to visualize their location using TextCases and GeoListPlot
In[]:=
porttowns=TextCases[eastasia["Text"],"City"->"Interpretation"]
Out[]=

Shanghai
,
Singapore
,
Tianjin
,
Busan
,
Guangzhou
,
Qingdao
,
Shenzhen
,
Kong
,
Kaohsiung
,
Yokohama
,
Dalian
,
China
,
Xiamen
,
Bangkok
,
Kobe

In[]:=
porttowns=
Shanghai
CITY
,
Singapore
CITY
,
Ningbo
CITY
,
Tianjin
CITY
,
Busan
CITY
,
Guangzhou
CITY
,
Qingdao
CITY
,
Shenzhen
CITY
,
,
Kaohsiung
CITY
,
Yokohama
CITY
,
Dalian
CITY
,
Xiamen
CITY
,
Bangkok
CITY
,
Kobe
CITY

Out[]=

Shanghai
,
Singapore
,
Ningbo
,
Tianjin
,
Busan
,
Guangzhou
,
Qingdao
,
Shenzhen
,
Hong Kong
,
Kaohsiung
,
Yokohama
,
Dalian
,
Xiamen
,
Bangkok
,
Kobe

In[]:=
Partition[porttowns,UpTo@5]
Out[]=

Shanghai
,
Singapore
,
Ningbo
,
Tianjin
,
Busan
,
Guangzhou
,
Qingdao
,
Shenzhen
,
Hong Kong
,
Kaohsiung
,
Yokohama
,
Dalian
,
Xiamen
,
Bangkok
,
Kobe

In[]:=
GeoListPlot[Partition[porttowns,UpTo@5],GeoLabels->True,PlotMarkersNone]
Out[]=
Shanghai
,
Singapore
,
Ningbo
,
Tianjin
,
Busan
Guangzhou
,
Qingdao
,
Shenzhen
,
Hong Kong
,
Kaohsiung
Yokohama
,
Dalian
,
Xiamen
,
Bangkok
,
Kobe
Next I ask it to generate a poem
In[]:=
eastasiaportpoem=OpenAIChatComplete[OpenAIChatMessageObject["user"," List the top 15 Ports in East Asia by volume and write a 7 word 10 line poem about the ports"],OpenAITokenLimit->500]
Out[]=
OpenAIChatMessageObject
role: assistant
text: 1. Shanghai, China2. Ningbo-Zhoushan, China3. Shenzhen, China4. Guangzhou Harbor, China5. Hong Kong, China6. Qingdao, China7. Dalian, China8. Tianjin, China9. Busan, South Korea10. Yokohama, Japan11. Port Klang, Malaysia12. Manila, Philippines13. Kaohsiung, Taiwan14. Singapore15. Jakarta, Indonesia​A sea of ships, a land of trade,East Asia's ports, a global parade,Navigating waves, amidst a storm,Busy harbours, a constant swarm.​From Shanghai's towering cranes,To Hong Kong's neon-lit lanes,Goods flow freely, through each gate,A world connected, a global fate.​In Singapore's bustling bay,And Manila's shores far away,A sea of commerce, a trading spree,Each port a gateway, to destiny.

In[]:=
eastasiaportpoem["Text"]
Out[]=
1. Shanghai, China2. Ningbo-Zhoushan, China3. Shenzhen, China4. Guangzhou Harbor, China5. Hong Kong, China6. Qingdao, China7. Dalian, China8. Tianjin, China9. Busan, South Korea10. Yokohama, Japan11. Port Klang, Malaysia12. Manila, Philippines13. Kaohsiung, Taiwan14. Singapore15. Jakarta, Indonesia​A sea of ships, a land of trade,East Asia's ports, a global parade,Navigating waves, amidst a storm,Busy harbours, a constant swarm.​From Shanghai's towering cranes,To Hong Kong's neon-lit lanes,Goods flow freely, through each gate,A world connected, a global fate.​In Singapore's bustling bay,And Manila's shores far away,A sea of commerce, a trading spree,Each port a gateway, to destiny.
Poetry need stylings
In[]:=
portpoem=Style["A sea of ships, a land of trade,\nEast Asia's ports, a global parade,\nNavigating waves, amidst a storm,\nBusy harbours, a constant swarm.\n\nFrom Shanghai's towering cranes,\nTo Hong Kong's neon-lit lanes,\nGoods flow freely, through each gate,\nA world connected, a global fate.\n\nIn Singapore's bustling bay,\nAnd Manila's shores far away,\nA sea of commerce, a trading spree,\nEach port a gateway, to destiny.",24,FontFamily->"Palatino"]
Out[]=
A sea of ships, a land of trade,East Asia's ports, a global parade,Navigating waves, amidst a storm,Busy harbours, a constant swarm.​From Shanghai's towering cranes,To Hong Kong's neon-lit lanes,Goods flow freely, through each gate,A world connected, a global fate.​In Singapore's bustling bay,And Manila's shores far away,A sea of commerce, a trading spree,Each port a gateway, to destiny.
And also image
In[]:=
Table[OpenAIGenerateImage["Port of Kaohsiung with Sky 85 building in the background and large cranes and container frieght in the foreground in style of water color painitng"],{i,5}]
Out[]=

,
,
,
,

In[]:=
OpenAIGenerateImage["Port of Kaohsiung with Sky 85 building in the background and large cranes and container frieght in the foreground in style of water color painitng"]
In[]:=
portimg=
;
​
Putting the poem and image together using GraphicsGrid. Now it’s ready to be printed and sent to a friend as a gift.
In[]:=
GraphicsGrid[{{portpoem,portimg}},ImageSize->Full]
Out[]=
​
As of this writing, the US copyright office has decided that any art work generator by artificial intelligence without any post processing would by default be in the public domain and not copyrightable. Below are some fun I had generating pictures of poor technocrats. Can you guess who they might be?
In[]:=
Table[OpenAIGenerateImage["A picture of a poor computer technocrat in worn out suit"],5]
Out[]=

,
,
,
,

In[]:=
Table[OpenAIGenerateImage["A picture of a homeless computer technocrat in worn out turtleneck"],5]
Out[]=

,
,
,
,

In[]:=
Table[OpenAIGenerateImage["A picture of a homeless social media technocrat in worn out t-shirt"],5]
Out[]=

,
,
,
,


Future work

It seems like this is a good way to generate usable data from the Internet and then using the data as a basis of some Geographic visualization.
This seems like a good way to do some historical data scrapping
But the data presented need to be verified with other sources as well

CITE THIS NOTEBOOK

Traditional Chinese Style Poetry, GeoListPlot with OpenAILink and chatGPT​
by Jack I Houng​
Wolfram Community, STAFF PICKS, April 20 2023
​https://community.wolfram.com/groups/-/m/t/2902033