Accessing ChatGPT from the desktop or the Linux command line

Smart Assistant

Article from Issue 276/2023
Author(s):

Do you think ChatGPT only works in your web browser? You can also access the global chat phenomenon from your desktop – or even from the Linux command line.

ChatGPT [1] is a chatbot developed by OpenAI [2] based on a large language model (LLM). You can have conversations with it, get answers to your questions, or let it write texts or code. With some guidance, the answers are quite useful. However, always keep in mind that ChatGPT lacks understanding: it is purely based on statistical patterns. Therefore, it's essential to critically evaluate the answers.

To begin using ChatGPT on the web, you need to create an OpenAI account. You can sign up by entering your email address and creating a password, or you can log in with a Google, Microsoft, or Apple account. Additionally, you will need to provide your name and mobile phone number, and you will need to answer questions about your intended use of OpenAI's services.

It's important to note that ChatGPT is still a prototype and access to the free version is not guaranteed. The website (Figure 1) often experiences high traffic, resulting in occasional messages asking that you try again later. Furthermore, the free version does not offer the latest version of the language model.

Figure 1: Using ChatGPT on the web is easy, but the web version comes with some limitations.

If you upgrade to ChatGPT Plus (for US$20 a month), you will always have access to the service, experience faster response times, and get earlier access to new features and versions of the language model. For example, ChatGPT Plus gives you access to GPT-4, a language model that is much more powerful than the GPT-3.5 model available in the free version.

API Access

In addition to the web interface, OpenAI provides an API that allows external applications to interact with ChatGPT. To access this API, you need to create an API key. Log in to the OpenAI platform site [3] with your OpenAI account, click on your username in the top-right corner, and then click on View API keys in the menu that appears. Next, click Create new secret key, give the key a name, and select Create secret key. Make sure to save this key immediately on your computer – you won't be able to retrieve it again after clicking on Done (Figure 2). You can create multiple keys, and it is a good idea to create a separate key for each application, as you can revoke individual keys if needed.

Figure 2: Create a new secret key for every application using the OpenAI API.

As a new user, you receive an initial credit in your OpenAI account, which is valid for three months. This credit allows you to experiment and evaluate the ChatGPT API. Afterwards, you need to provide credit card details. In many cases, using the API is cheaper than a ChatGPT Plus subscription. With the API, you pay based on the number of tokens used (1,000 tokens correspond to approximately 750 words). See the "Pricing and Models" box for more information.

Pricing and Models

OpenAI provides several language models, each with its own capabilities. The default model is GPT-3.5 Turbo with a context size of 4,000 tokens. This means that the length of your input (the prompt) and the model's response (its completion) can't exceed 4,000 tokens. There's also a GPT-3.5 Turbo model with a 16,000-token context. OpenAI's latest model, GPT-4, comes in versions with 8,000 and 32,000-token contexts. The OpenAI pricing [4] page lists detailed costs associated with using the API for these models. For example, using GPT-3.5 Turbo 4K incurs a cost of $0.0015 per 1,000 tokens for the input and $0.002 per 1,000 tokens for the model's response. In comparison, GPT-4 8K costs $0.03 per 1,000 tokens for the input and $0.06 per 1,000 tokens for the response. This makes GPT-4 roughly 20 times more expensive than GPT-3.5 Turbo. It is better to use GPT-4 only when you require its broader general knowledge and advanced reasoning capabilities. Previously, access to GPT-4 through the API required joining a waiting list. However, OpenAI has made the model generally available for paying API users as of July 2023.

Installing ChatWizard

After setting up your OpenAI account and obtaining an API key, you no longer need to use the website to access ChatGPT. An excellent desktop application for ChatGPT is ChatWizard [5], which works on Linux, Windows, and macOS. Although the developer primarily tests the application on macOS, he does make an effort to resolve any issues on other platforms as well. I have successfully tested ChatWizard on Ubuntu 22.04 LTS by downloading the AppImage of version 0.5.0.

To begin, download chat-wizard_0.5.0_amd64.AppImage (or the latest version available) from the ChatWizard releases [6] and make it executable:

chmod +x chat-wizard_0.5.0_amd64.AppImage

You can then launch the application:

./chat-wizard_0.3.0_amd64.AppImage

Chatting on the Desktop

First click on the icon at the bottom-left to access ChatWizard's settings. The only field you need to fill in is the Api Key (Figure 3). Generate a new API key in your OpenAI account, as described earlier, and paste it here. After you click on the light bulb icon in the top-left corner, ChatWizard opens a Casual Chat. To start a conversation, simply type your question in the text field at the bottom (in any language you like), and ChatGPT's response will appear at the top (Figure 4).

Figure 3: Paste your OpenAI API key in ChatWizard's settings to use the desktop application.
Figure 4: A casual chat with GPT-4 in ChatWizard.

If you find that ChatGPT's response is excessively lengthy, and you've gathered enough information, you can interrupt it by clicking Stop replying. Upon completing a response, you will see the cost of the API calls for that conversation displayed at the bottom-left. Additionally, you can click on Export at the bottom-right to select specific questions and answers for export, generating a PNG file with the result. By mousing over a question or answer, you can access icons to delete, edit, or copy the text to the clipboard. Resending a question is also possible (by clicking on the paper plane icon) to explore different responses to the same query.

Clicking on the three dots at the top-right corner allows you to adjust various settings for ChatGPT in this conversation, such as the language model (GPT-3.5 Turbo by default, but you can switch to GPT-4), "temperature," presence penalty, and frequency penalty. Only adjust the latter three parameters if you have a thorough understanding of their impact (see the box entitled "Adjusting Language Model Parameters" for more information). In most cases, the default values are sufficient. When selecting the GPT-4 model, keep an eye on the cost displayed at the bottom-left.

Adjusting Language Model Parameters

ChatGPT's models have three important parameters that you can adjust to modify the model's behavior. Using ChatWizard, you can experiment with different values for these parameters. Temperature ranges from 0 to 2, where 0 means that the answer is the same every time, and higher values introduce more randomness. If left unset, the default value is 1, resulting in moderate variation. Presence penalty and frequency penalty both range from -2 to 2 and have a default value of 0. A positive presence penalty reduces the likelihood of previously used tokens reappearing in the response, favoring discussions on new topics. With a positive frequency penalty, the model is less likely to reuse tokens that have already been used multiple times. This reduces the chances of the model repeating a sentence verbatim. Adjusting these parameters is rarely necessary; however, they can be useful if you notice the model providing repetitive answers to specific questions. In such cases, assigning both parameters a value between 0.1 and 1 can help reduce repetition.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Machine Language

    The electronic brain behind ChatGPT from OpenAI is amazingly capable when it comes to chatting with human partners. Mike Schilli picked up an API token and has set about coding some small practical applications.

  • LLMs at Home with Ollama

    Ollama and Open WebUI let you join the AI revolution without relying on the cloud.

  • New Release of Br OS Includes ChatGPT Integration

    Br OS 23.04 is now available and is geared specifically toward web content creation.

  • Shell Genie

    Shell Genie uses artificial intelligence to convert your questions into commands in the terminal.

  • Bash PaLM Shell

    The PaLMShell.bash script lets you connect to the Google Pathways API Large Language Model (PaLM) from the command line.

comments powered by Disqus
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters

Support Our Work

Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

Learn More

News