Special

Introducing the “Welcome to Xojo” Bundle!

New to Xojo and looking for guidance? We've put together a terrific bundle to welcome you! Xojo Bundle

This bundle includes six back issues of the magazine -- all of year 21 in printed book and digital formats -- plus a one-year subscription (beginning with 22.1) so you'll be learning all about Xojo for the next year. It's the perfect way to get started programming with Xojo. And you save as much as $35 over the non-bundle price!

This offer is only available for a limited time as supplies are limited, so hurry today and order this special bundle before the offer goes away!

Article Preview


Buy Now

Issue 22.3

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):

Download Icon 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 and ChatGPTConnection.

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 between 0 (no hallucination) to 2 (it's allowed to make stuff up). The default is 0.5.

Set Up an OpenAI Account

...End of Excerpt. Please purchase the magazine to read the full article.