Article Preview
Buy Now
COLUMN
Using ChatGPT
Add ChatGPT to Your Xojo App
Issue: 22.3 (May/June 2024)
Author: Marc Zeedar
Author Bio: Marc taught himself programming in high school when he bought his first computer but had no money for software. He's had fun learning ever since.
Article Description: No description available.
Article Length (in bytes): 10,488
Starting Page Number: 82
Article Number: 22307
Resource File(s):
project22307.zip Updated: 2024-05-03 11:27:10
Related Link(s): None
Excerpt of article text...
With Xojo 2024 Release 1, we now have the ability to easily add ChatGPT usage within our Xojo projects. While this isn't the same thing as using the AI to help generate our Xojo code (hopefully AI assistance is forthcoming), it can be a useful way of enhancing your own apps.
To test this, I wrote a little Xojo app that includes some text and I have ChatGPT summarize the text (see Figure 1). It's surprisingly effective and would be a great addition to many apps that contain data. For instance, a word processor could offer to summarize the contents file for the user.
To get started, we first open the ChatGPT example project included with Xojo 2024R1 (see Figure 1). You'll then want to copy the
ChatGPT
folder into your own project. This folder contains two classes,ChatGPTException
andChatGPTConnection
.The latter class contains additional methods and properties over the base class that makes it easier to use. For example, there's a
model
property that lets you set which ChatGPT engine to use (gpt-3.5-turbo is the default). This is useful as some models are more expensive and if you don't need those additional capabilities, there's no point in using a more powerful engine.Another important property is the
temperature
. This controls how "creative" ChatGPT will be with its answers. It requires a numeric value between0
(no hallucination) to2
(it's allowed to make stuff up). The default is0.5
.Set Up an OpenAI Account
...End of Excerpt. Please purchase the magazine to read the full article.