AJXB Posted November 10 Share Posted November 10 (edited) Use AI in your MTA:SA resources. Powered by providers like OpenAI, Anthropic & Groq. You can now bake Artificial Intelligence into your resources, gamemodes and systems. This resource exports the below functions: init(config) generateText(prompt,system) generateObject(prompt, system) getProviders() getModels(provider) getConfig() Example usage: The below code initializes the AI agent (add your API key from the provider) and creates a ped and a marker. when the player hits the marker, the ped says something funny. addEventHandler("onResourceStart", resourceRoot, function() AI.init({ api_key = "", provider = "groq", model = "llama3-8b-8192", temperature = 0.7, max_tokens = 150 }) createPed(0, 0, 0, 5) local marker = createMarker(0, 0, 2, "cylinder", 5, 10, 244, 23, 10, root) local function handleMarkerHit(hitElement) local elementType = getElementType(hitElement) if elementType ~= "player" then return end local playerName = getPlayerName(hitElement) outputDebugString("Player "..playerName.." hit marker") AI.generateText(playerName.." got close to you, say something funny, and out of pocket. Limit is 255 characters. Your name is Pedro. Don't use quotes.", "You are a random pedestrian living in San Andreas, grand theft auto.")( function(result, error) if error then outputDebugString("Error: " .. error) return end if (result:len() >= 254) then result = result:sub(1, 254) .. "..." return end outputChatBox("[Pedro]: "..result, hitElement, 255, 255, 255) end ) end addEventHandler("onMarkerHit", marker, handleMarkerHit) end ) Download: https://community.multitheftauto.com/index.php?p=resources&s=details&id=18946 Roadmap: - Support conversation history - Support streaming - Contributing: Contributions are welcome on Github: https://github.com/MrgSub/mtasa-ai Edited November 10 by AJXB added github link 1 Link to comment
FernandoMTA Posted November 10 Share Posted November 10 oooo interesting Is the project available for contribution on GitHub or something? Link to comment
TMTMTL Posted November 10 Share Posted November 10 Nice work! As Nando said it would be cool if this was a Git repo so it could be contributed to, it couldbe used in many instances I would think Link to comment
AJXB Posted November 10 Author Share Posted November 10 7 hours ago, FernandoMTA said: oooo interesting Is the project available for contribution on GitHub or something? 7 hours ago, TMTMTL said: Nice work! As Nando said it would be cool if this was a Git repo so it could be contributed to, it couldbe used in many instances I would think Thank you! Yes, I just added the Github link: https://github.com/MrgSub/mtasa-ai 1 Link to comment
FernandoMTA Posted November 11 Share Posted November 11 awesome! I'm new to using these APIs i'll be digging into the project Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now