If You Can’t Beat AI, Then Adopt It

Integrating OpenAI into Applications

--

I strongly believe we are going through one of the most dramic changes in technology in the history of human kind. And it is AI that is driving this. To me, you can either bury your head in the sand and hope it goes away. But, I think it will only snowball, so if you can’t beat them, join them.

And, so I’ve gone through many major updates on my Web site, and the rise of AI is one which I must adopt. So, I’m starting to translate much of my work towards the integration of OpenAI. The basic code that we using is:


from openai import OpenAI
import sys

client = OpenAI(api_key='API KEY HERE')

msg="."

if (len(sys.argv)>1):
msg=str(sys.argv[1])



try:

completion = client.chat.completions.create(messages=[{ "role": "user", "content": msg, } ],model="gpt-3.5-turbo",)
str = completion.choices[0].message.content
print(str)



except Exception as e:
print("An error occurred:", str(e))

</pre>

And, so, I use this API to grab text for some basic terms [here]:

And for hashing [here]:

--

--

Prof Bill Buchanan OBE FRSE
ASecuritySite: When Bob Met Alice

Professor of Cryptography. Serial innovator. Believer in fairness, justice & freedom. Based in Edinburgh. Old World Breaker. New World Creator. Building trust.