Spark AI - GPT Dialogue & Tools

Discover Spark AI - ChatGPT Dialogue System & Tools - the ultimate suite of tools that harnesses the power of AI revolutionizing your Unity Editor experience and boosting your productivity by x10!

Getting Started

Welcome to the Spark AI - ChatGPT Dialogue System & Tools documentation! In this section, we’ll walk you through the initial steps to start using the tools.

This includes setting up your OpenAI API key, configuring the AI settings, and introducing you to the different tools available in the suite. With these steps, you’ll be able to unlock the full potential of GPT tools and take your Unity development to the next level. Let’s get started!

AI Settings

With the AI Settings window, you can easily configure the AI API settings, including the model selection, API key input, maximum token count, and temperature settings for the model. You can open the AI Settings window by going to the supertool in “Window > Spark AI > Spark”

Generating an OpenAI API Key

To get an API key for using OpenAI’s API, you can follow these steps:

  1. Create an OpenAI account: Go to the OpenAI website and create an account by clicking the “Get started for free” button in the top right corner. Follow the prompts to sign up and verify your email address.

  2. Go to the platform.openai.com/account/api-keys and generate a new API key.

  3. Enable your free trial (enabling billing might be required for this)

Using the API Key in the Editor tools
  1. Copy the key and paste it into the API Key field in the AI Settings window. Now you can use it in your API requests for the editor tools.
Using the API key at runtime in the game

In order to use the API at runtime see the next ChatEngine section.

Demos

The asset contains 3 demos, one for each example use case:

  • Interactive dialogues using the OpenAI Chat API
  • Live audio transcription from the player’s microphone using the OpenAI Whisper API
  • Non-interactive but extremely diverse dialogues from NPCs using the OpenAI Chat API

Dialogue System

ChatEngine

This script loads all the API settings into the game, allowing you to interact with ChatGPT during runtime.

ChatEngine.cs Script Reference

Property Type Description Default Value
Auth File Json File File to use for connecting to ChatGPT at runtime null
Auth file format

In order for the ChatEngine.cs to be able to load the settings at runtime a json file with the correct credentials needs to be defined. Check out the sample file at GPTDialogueAndTools/Demo/creds.json. It should look like this

{
  "api_key": "<YOUR_API_KEY_HERE>",
  "temperature": 0.2
}

Replace <YOUR_API_KEY_HERE> with your OpenAI API key.

InteractiveAIDialogue

This script is in charge of simulating a dialog using ChatGPT as a backend. It allows the player to talk freely to the NPCs and characters while still following certain guidelines for the conversations.

InteractiveAIDialogue.cs Script Reference

Property Type Description Default Value
Name string The name of this character. Leave null for no name/unknown. null
Act as string Brief description of the character the AI should act as. null
Things to mention string[] Anything the AI should try mention (e.g. ‘the dragon nest is 2km south’, ‘the king wants to meet you’) null
Write speed float A float that represents the writing speed of the dialogue 0.04f

BarkAIDialogue

This script is in charge of simulating an NPC that always provides a default response or talks about specific topics, without interaction from the player. Useful for games where the NPC interaction is just talking to them but when you want players to have an infinite variety of dialogs.

BarkAIDialogue.cs

Property Type Description Default Value
Name string The name of this character. Leave null for no name/unknown. null
Act as string Brief description of the character the AI should act as. null
Things to mention string[] Anything the AI should try mention (e.g. ‘the dragon nest is 2km south’, ‘the king wants to meet you’) null
Word count int Average word count the response should have 100
Write speed float A float that represents the writing speed of the dialogue 0.04f

TranscribeAudio

This script is in charge of interacting with the Whisper API to transcribe audio in realtime. Records an audio clip from the microphone and shows its transcription on the screen using Whisper.

TranscribeAudio.cs Script Reference

Property Type Description Default Value
Record Button Button Button to use for recording null
Transcription Text TMP_Text Where to put the transcription text null
Language string The language to use for the transcription. Leave null for auto detecting the language. null
Max Recording Length float Max length we should record with the microphone. In seconds. 10

Editor Tools

Spark AI contains several tools to help you increase your productivity while writing games. The supertool contains everything you need to improve your productivity. You can access it from Window > Spark AI > Spark

AI Conversation (ChatGPT like)

The AI Conversation tool is an editor extension that allows you to have a complete ChatGPT like UI inside your Unity Editor. It saves and loads existing conversations, lets you set the AI to act as a predefined actor like (unity developer, gamer, game critique, etc) or on a custom prompt. It also lets you manage conversations and see all of your previous messages and questions.

Iterative AI Coder

The Iterative AI Coder is a unique tool that allows you to create scripts using AI, by iteratively rejecting or asking modifications on changes proposed by the AI. You will only need words to refine and code your scripts.

Shader Coder

The Shader coder works in a similar fashion as the Iterative AI Coder. This tool allows you to write and preview shaders with the help of AI.

AI Artist

The AI Engineer tool is a powerful feature that allows you to describe an idea and receive a script that implements that idea. With the help of ChatGPT, you can write code faster and more efficiently.

AI Debugger

The AI Debugger tool allows you to debug your code with ease using the intelligence of ChatGPT. Simply select a Unity C# script, explain the issues you are having, and the AI will help you find and debug the issue. This can save you a lot of time and frustration when trying to locate and fix bugs in your code.

AI Helper

The AI Helper tool is designed to answer any Unity questions you may have. Simply ask the AI Helper a question, and it will provide you with a helpful answer. This can be especially useful if you’re new to Unity and need some guidance.

AI Writer

The AI writes includes 3 subtools:

  • The AI Name Generator tool allows you to quickly generate unique and interesting names for characters, locations, and more with the power of ChatGPT. Simply describe the attributes of the name you’re looking for, and the AI will generate multiple ideas for different names. This can be a great tool for game developers who need to come up with a lot of names.

  • The AI Lore Writer tool is designed to help you effortlessly create immersive lore for your game with the help of ChatGPT. Simply describe a character, and the AI will generate a background story. This can be a great tool for game developers who want to create a rich, immersive world for their players.

  • The AI Lore Writer tool is designed to help you develop engaging descriptions for items and objects in your game directly from your editor!

Troubleshooting

Too many requests

You probably need to enable billing on your OpenAI API account

Error 429: You exceeded your current quota, please check your plan and billing details. Apply for a quota increase.

You probably need to enable billing on your OpenAI API account

GPT-4 model returns 404 or fails

As of March 19th the GPT-4 model API is still in closed access. Therefore you need to whitelist your API key/account before being able to use the model. You can ask for access here

Other

For any questions, issues or feature requests don’t hesitate to email us at help@leastsquares.io or ask in the discord. LeastSquares Discord



About us

We are a small company focused on building tools for game developers. Send us an email to careers@leastsquares.io if interested in working with us. For any other inquiries, feel free to contact us at hello@leastsquares.io or contact us on the discord





Sign up to our newsletter.

Want to receive news about discounts, new products and updates?