Skyrat-tg icon indicating copy to clipboard operation
Skyrat-tg copied to clipboard

GPT API Integration + Use cases

Open Gandalf2k15 opened this issue 1 year ago • 20 comments

About The Pull Request

This PR aims to add GPT API integration into our wonderful little game, and it has done it!

You can now use your API key to access the GPT API and submit automatically formatted requests and receive requests. You can choose the model you use, you can also get a list of models that are currently active on GPT.

There are many many use cases for this that I have yet to implement. But this adds the basic foundation for GPT API interfacing while also providing decent instructions on how to do so, which is all in the code.

Here are specific descriptions of what has been added: GPT Subsystem This subsystem is responsible for sending API calls to OpenAI and then awaiting their response. It is responsible for creating instances of conversations and sending singleton messages. It can also retrieve the currently available list of OpenAI GPT Models. This is the primary and best way to interact with GPT within BYOND. It ensures proper use and formatting to prevent errors.

It stores conversations via refs that can be retrieved at any time.

GPT Conversations These are basic datums that hold information regarding a GPT conversation. They are able to be preconditioned to make the responses you get to be exactly how you want them. It is responsible for formatting the message payload, but not sending it.

GPT Endpoints Endpoints are the core API interface for OpenAI, they store and format all HTTP requests and also define how the GPT response should be formatted using things like temperature, max tokens, response count, etc. It also deals with HTTP errors and formatting of the requests. Requests are submitted by the GPT subsystem. All instances of these are also stored in the subsystem. They also define what OpenAI ENDPOINT to refer to.

Conversation Component This is just a tech demo of how you can use the system to interact with the game world. It takes given responses and does all the fancy stuff to make it look like the thing is responding. Can be expanded massively.

Sentient Announcer I couldn't not do this.

Adds a station announcer that uses GPT to interpret any standard given priority announcement into something unique. It does this for all priority announcements.

to-do(maybe): Convert AI configs to toml convert endpoints to toml

How This Contributes To The Skyrat Roleplay Experience

This enables us to have somewhat unique implementations of certain aspects of the game. Something that once had to be "randomised" by a human using preset values can now be fully generated by GPT-4 or whatever model you choose.

The prospects for this integration are near enough endless, I'll be looking to integrate fully autonomous human-level intelligence monkeys soon.

Proof of Testing

AI Engineer Helper:

https://user-images.githubusercontent.com/9026500/236548557-31026361-176f-451b-bbe6-d7b941274469.mp4

Sentient Announcer: Discord_mOHTKW0Uib dreamseeker_eHNAyvBhWF

Changelog

:cl: add: Added GPT API integration support. add: Added a new station trait: Sentient announcer. /:cl:

Gandalf2k15 avatar May 05 '23 19:05 Gandalf2k15