feat: AI integration - #132
Open
jack5github wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request adds the ability for Elementipelago to generate element names and icons (other than the starting elements) via a local AI model from Ollama using a queue system, and saves the generated names and icons to the multiworld storage so they don't need to be re-generated when reconnecting. The generated names and icons are different depending on where an item is coming from, where it is going to and what its item name is, and there is a small amount of randomness that goes into each prompt as well.
Note that as it is currently implemented, items sent to other players that are not ingredients (useless to the Elementipelago player) are spoiled since the AI does not change their names, and for all elements, the AI is allowed to choose from both normal element icons and substitute icons (which are both normally reversed for specific types of elements). I like these things about it.
The benefit of this new feature is that it makes element combinations and recipes more discernible, as well as more personalised to each multiworld, traits that Elementipelago currently lacks with its entirely random names and icons.
The AI integration should be disabled by default and is enabled from a new checkbox in the Settings menu. It uses the Ollama model 'gemma4:e2b' by default (the latest most-performant Google model available), but can be changed to any other model of the user's choice. Importantly, no means of changing the endpoint is provided, meaning that all generation requests will only ever be responded to locally, and there is no threat of multiworld data being sent to third parties.
Disclaimer: The code I have written was produced with the assistance of an AI agent, but know that I rewrote much of its output myself and have thoroughly tested it in multiple multiworlds, hosted both locally and online. All the comments are my own and are there for a reason. Regardless, I wouldn't mind a review of my contribution to ensure it is ready for the public. I'm also kind of sick of prompt engineering for a few days straight.
On a side note, if AI integration is enabled, the notification toast will display the item name, not the element name, as the element name takes time to generate. This was mainly just me doing the bare minimum to keep the notification looking nice. I haven't tested what happens when AI integration is off and the notification appears, so I wouldn't mind somebody check that out.